mbox series

[FFmpeg-devel,000/279] New channel layout API

Message ID 20211208010649.381-1-jamrial@gmail.com
Headers show
Series New channel layout API | expand

Message

James Almer Dec. 8, 2021, 1:06 a.m. UTC
This is an updated and rebased version of the API that was sent to this mailing
list about two years ago. It expands it with some new helpers, implements some
changes that allows further extensibility for new features down the line, and
finishes porting all missing modules and those introduced since 2019.

I'm sending a reduced amount of patches to not spam the ML too much. In total
it's 279 patches, the bulk being one per module ported, which it's what i'm
skipping.
This reduced set will obviously not apply as is, so you can find the entire set
in https://github.com/jamrial/FFmpeg/commits/channel_layout

Anton Khirnov (136):
  Add a new channel layout API
  lavu: support AVChannelLayout AVOptions
  lavc: deprecate channel count/layout changing side data
  avframe: switch to the new channel layout API
  lavf: add a temporary compat layer for the channel layout API change
  lavf: convert the generic layer to the new channel layout
  3dostr: convert to new channel layout API
  aa: convert to new channel layout API
  acm: convert to new channel layout API
  act: convert to new channel layout API
  adp: convert to new channel layout API
  ads: convert to new channel layout API
  afc: convert to new channel layout API
  aixdec: convert to new channel layout API
  aptxdec: convert to new channel layout API
  argo: convert to new channel layout API
  ast: convert to new channel layout API
  avr: convert to new channel layout API
  bit: convert to new channel layout API
  boa: convert to new channel layout API
  brstm: convert to new channel layout API
  codec2: convert to new channel layout API
  dcstr: convert to new channel layout API
  dhav: convert to new channel layout API
  dtshddec: convert to new channel layout API
  dsfdec: convert to new channel layout API
  epafdec: convert to new channel layout API
  framehash: convert to new channel layout API
  fsb: convert to new channel layout API
  g726: convert to new channel layout API
  gdv: convert to new channel layout API
  genh: convert to new channel layout API
  hcom: convert to new channel layout API
  ifv: convert to new channel layout API
  ircam: convert to new channel layout API
  jack: port to new channel layout API
  libcdio: port to new channel layout API
  lvf: convert to new channel layout API
  mpeg: convert to new channel layout API
  mpegtsenc: convert to new channel layout API
  msf: convert to new channel layout API
  mtaf: convert to new channel layout API
  musx: convert to new channel layout API
  nistspheredec: convert to new channel layout API
  nspdec: convert to new channel layout API
  oss: port to new channel layout API
  pvf: convert to new channel layout API
  rawenc: convert to new channel layout API
  redspark: convert to new channel layout API
  rsd: convert to new channel layout API
  sbg: convert to new channel layout API
  sdr2: convert to new channel layout API
  sds: convert to new channel layout API
  sdx: convert to new channel layout API
  svag: convert to new channel layout API
  vag: convert to new channel layout API
  vividas: convert to new channel layout API
  vivo: convert to new channel layout API
  vpk: convert to new channel layout API
  lavf: drop the channel layout compat layer for old-style (de)muxers
  8svx: convert to new channel layout API
  aac: convert to new channel layout API
  adpcm: convert to new channel layout API
  alac: convert to new channel layout API
  amr: convert to new channel layout API
  aptx: convert to new channel layout API
  atrac9: convert to new channel layout API
  apedec: convert to new channel layout API
  audiotoolbox: convert to new channel layout API
  binkaudio: convert to new channel layout API
  bmvaudio: convert to new channel layout API
  cng: convert to new channel layout API
  cook: convert to new channel layout API
  dca: convert to new channel layout API
  dolby_e: convert to new channel layout API
  dsd: convert to new channel layout API
  dsicinav: convert to new channel layout API
  dst: convert to new channel layout API
  dvaudio: convert to new channel layout API
  evrc: convert to new channel layout API
  ffwavesynth: convert to new channel layout API
  flac: convert to new channel layout API
  g722: convert to new channel layout API
  g723_1: convert to new channel layout API
  g726: convert to new channel layout API
  g729: convert to new channel layout API
  gsmdec: convert to new channel layout API
  hcom: convert to new channel layout API
  ilbc: convert to new channel layout API
  imc: convert to new channel layout API
  interplayacm: convert to new channel layout API
  libcelt: convert to new channel layout API
  libcodec2: convert to new channel layout API
  libilbc: convert to new channel layout API
  libgsm: convert to new channel layout API
  libmp3lame: convert to new channel layout API
  libopencore-amr: convert to new channel layout API
  libopus: convert to new channel layout API
  libshine: convert to new channel layout API
  libspeexdec: convert to new channel layout API
  libtwolame: convert to new channel layout API
  libvo-amrwbenc: convert to new channel layout API
  libvorbis: convert to new channel layout API
  mace: convert to new channel layout API
  metasound: convert to new channel layout API
  mlp: convert to new channel layout API
  mpc7: convert to new channel layout API
  mpc8: convert to new channel layout API
  mpegaudio: convert to new channel layout API
  nellymoser: convert to new channel layout API
  on2avc: convert to new channel layout API
  opus: convert to new channel layout API
  pcm: convert to new channel layout API
  qcelpdec: convert to new channel layout API
  qdmc: convert to new channel layout API
  qdm2: convert to new channel layout API
  ra144: convert to new channel layout API
  ra288: convert to new channel layout API
  ralf: convert to new channel layout API
  roqaudioenc: convert to new channel layout API
  s302m: convert to new channel layout API
  sbc: convert to new channel layout API
  shorten: convert to new channel layout API
  sipr: convert to new channel layout API
  smacker: convert to new channel layout API
  sonic: convert to new channel layout API
  tak: convert to new channel layout API
  truespeech: convert to new channel layout API
  tta: convert to new channel layout API
  vmdaudio: convert to new channel layout API
  vorbis: convert to new channel layout API
  wavpack: convert to new channel layout API
  wma: convert to new channel layout API
  ws-snd1: convert to new channel layout API
  lavc: drop temporary compat wrappers for channel layout API change
  opus: export mapping family 2 (Ambisonic) as Ambisonic layout

James Almer (30):
  fate: add a channel_layout API test
  aax: convert to new channel layout API
  ace: convert to new channel layout API
  alsa: convert to new channel layout API
  alp: convert to new channel layout API
  amv: convert to new channel layout API
  apm: convert to new channel layout API
  derf: convert to new channel layout API
  dshow: convert to new channel layout API
  fwse: convert to new channel layout API
  hca: convert to new channel layout API
  hls_sample_encryption: convert to new channel layout API
  imx: convert to new channel layout API
  kvag: convert to new channel layout API
  avdevice/lavfi: convert to new channel layout API
  mca: convert to new channel layout API
  moflex: convert to new channel layout API
  pp_bnk: convert to new channel layout API
  scd: convert to new channel layout API
  sga: convert to new channel layout API
  svs: convert to new channel layout API
  fastaudio: convert to new channel layout API
  hca: convert to new channel layout API
  mf: convert to new channel layout API
  siren: convert to new channel layout API
  speex: convert to new channel layout API
  swresample: convert to new channel layout API
  avfilter: convert to new channel layout API
  ffmpeg: convert to new channel layout-API
  ffprobe: convert to new channel layout-API

Vittorio Giovara (113):
  avcodecpar: switch to the new channel layout API
  4xm: convert to new channel layout API
  adxdec: convert to new channel layout API
  aea: convert to new channel layout API
  aiff: convert to new channel layout API
  amr: convert to new channel layout API
  apc: convert to new channel layout API
  ape: convert to new channel layout API
  au: convert to new channel layout API
  bethsoftvid: convert to new channel layout API
  bfi: convert to new channel layout API
  bink: convert to new channel layout API
  bmv: convert to new channel layout API
  caf: convert to new channel layout API
  cdxl: convert to new channel layout API
  dash: convert to new channel layout API
  dsicin: convert to new channel layout API
  dss: convert to new channel layout API
  dv: convert to new channel layout API
  eac: convert to new channel layout API
  electronicarts: convert to new channel layout API
  flac: convert to new channel layout API
  flic: convert to new channel layout API
  flv: convert to new channel layout API
  g722: convert to new channel layout API
  g723_1: convert to new channel layout API
  g729: convert to new channel layout API
  gsm: convert to new channel layout API
  gxf: convert to new channel layout API
  idcin: convert to new channel layout API
  idroq: convert to new channel layout API
  iff: convert to new channel layout API
  ilbc: convert to new channel layout API
  ipmovie: convert to new channel layout API
  iss: convert to new channel layout API
  jvdec: convert to new channel layout API
  lxfdec: convert to new channel layout API
  matroska: convert to new channel layout API
  mm: convert to new channel layout API
  mmf: convert to new channel layout API
  mov: convert to new channel layout API
  movenc-test: convert to new channel layout API
  mp3: convert to new channel layout API
  mpc: convert to new channel layout API
  mpc8: convert to new channel layout API
  mpegenc: convert to new channel layout API
  mvdec: convert to new channel layout API
  mvi: convert to new channel layout API
  mxf: convert to new channel layout API
  mxg: convert to new channel layout API
  nsvdec: convert to new channel layout API
  nutdec: convert to new channel layout API
  nuv: convert to new channel layout API
  ogg: convert to new channel layout API
  oma: convert to new channel layout API
  paf: convert to new channel layout API
  pcm: convert to new channel layout API
  pmp: convert to new channel layout API
  psxstr: convert to new channel layout API
  qcp: convert to new channel layout API
  r3d: convert to new channel layout API
  riff: convert to new channel layout API
  rl2: convert to new channel layout API
  rm: convert to new channel layout API
  rpl: convert to new channel layout API
  rso: convert to new channel layout API
  rtp: convert to new channel layout API
  sdp: convert to new channel layout API
  segafilm: convert to new channel layout API
  sierravmd: convert to new channel layout API
  siff: convert to new channel layout API
  smacker: convert to new channel layout API
  smjpegenc: convert to new channel layout API
  smoothstreaming: convert to new channel layout API
  smush: convert to new channel layout API
  sol: convert to new channel layout API
  sox: convert to new channel layout API
  swf: convert to new channel layout API
  tak: convert to new channel layout API
  thp: convert to new channel layout API
  tiertexseq: convert to new channel layout API
  tmv: convert to new channel layout API
  tta: convert to new channel layout API
  voc: convert to new channel layout API
  vqf: convert to new channel layout API
  wav: convert to new channel layout API
  wc3movie: convert to new channel layout API
  westwood: convert to new channel layout API
  wtv: convert to new channel layout API
  wv: convert to new channel layout API
  xa: convert to new channel layout API
  xmv: convert to new channel layout API
  xwma: convert to new channel layout API
  yop: convert to new channel layout API
  wsd: convert to new channel layout API
  wve: convert to new channel layout API
  xvag: convert to new channel layout API
  lavc: switch to the new channel layout API
  ac3: convert to new channel layout API
  adx: convert to new channel layout API
  als: convert to new channel layout API
  atrac1: convert to new channel layout API
  atrac3: convert to new channel layout API
  atrac3plus: convert to new channel layout API
  dpcm: convert to new channel layout API
  dss_sp: convert to new channel layout API
  libfdk-aac: convert to new channel layout API
  pafaudio: convert to new channel layout API
  twinvq: convert to new channel layout API
  vima: convert to new channel layout API
  lavf: Add non diegetic stream disposition flag
  channel_layout: add support for Ambisonic
  mov: Implement spatial audio support

 fftools/cmdutils.c                            |  42 +-
 fftools/cmdutils.h                            |   8 -
 fftools/ffmpeg.c                              |  47 +-
 fftools/ffmpeg.h                              |   7 +-
 fftools/ffmpeg_filter.c                       |  43 +-
 fftools/ffmpeg_opt.c                          |  62 +-
 fftools/ffprobe.c                             |  19 +-
 libavcodec/8svx.c                             |  19 +-
 libavcodec/aac.h                              |  11 +-
 libavcodec/aac_ac3_parser.c                   |  13 +-
 libavcodec/aaccoder.c                         |  10 +-
 libavcodec/aaccoder_twoloop.h                 |   4 +-
 libavcodec/aacdec_template.c                  |  52 +-
 libavcodec/aacenc.c                           |  13 +-
 libavcodec/aacenc.h                           |  64 +-
 libavcodec/aacenctab.h                        |  16 +-
 libavcodec/aacpsy.c                           |   8 +-
 libavcodec/ac3dec.c                           |  57 +-
 libavcodec/ac3dec.h                           |   2 +
 libavcodec/ac3dec_fixed.c                     |   1 +
 libavcodec/ac3dec_float.c                     |   2 +
 libavcodec/ac3enc.c                           |  78 ++-
 libavcodec/ac3enc.h                           |   4 +-
 libavcodec/ac3enc_fixed.c                     |   5 +
 libavcodec/ac3enc_float.c                     |   5 +
 libavcodec/adpcm.c                            | 151 +++--
 libavcodec/adpcmenc.c                         | 122 ++--
 libavcodec/adx.c                              |  16 +-
 libavcodec/adxdec.c                           |   6 +-
 libavcodec/adxenc.c                           |  11 +-
 libavcodec/alac.c                             |  16 +-
 libavcodec/alac_data.c                        |  20 +-
 libavcodec/alac_data.h                        |   6 +
 libavcodec/alacenc.c                          |  37 +-
 libavcodec/alsdec.c                           |  90 +--
 libavcodec/amr_parser.c                       |  10 +-
 libavcodec/amrnbdec.c                         |  12 +-
 libavcodec/amrwbdec.c                         |  12 +-
 libavcodec/apedec.c                           |   9 +-
 libavcodec/aptx.c                             |   2 +-
 libavcodec/atrac1.c                           |  10 +-
 libavcodec/atrac3.c                           |  41 +-
 libavcodec/atrac3plusdec.c                    |  25 +-
 libavcodec/atrac9dec.c                        |   4 +-
 libavcodec/atrac9tab.h                        |  14 +-
 libavcodec/audiotoolboxdec.c                  |  27 +-
 libavcodec/audiotoolboxenc.c                  |  95 ++-
 libavcodec/avcodec.c                          |  51 +-
 libavcodec/avcodec.h                          |  23 +-
 libavcodec/binkaudio.c                        |  19 +-
 libavcodec/bmvaudio.c                         |   4 +-
 libavcodec/cngdec.c                           |   3 +-
 libavcodec/cngenc.c                           |   6 +-
 libavcodec/codec.h                            |  11 +
 libavcodec/codec_par.c                        |  65 +-
 libavcodec/codec_par.h                        |  12 +
 libavcodec/cook.c                             |  25 +-
 libavcodec/cook_parser.c                      |   4 +-
 libavcodec/dca_core.c                         |   6 +-
 libavcodec/dca_lbr.c                          |  13 +-
 libavcodec/dca_xll.c                          |   2 +-
 libavcodec/dcadec.c                           |  63 +-
 libavcodec/dcadec.h                           |   7 +
 libavcodec/dcaenc.c                           |  39 +-
 libavcodec/decode.c                           |  73 +-
 libavcodec/dolby_e.c                          |  52 +-
 libavcodec/dolby_e.h                          |   2 +
 libavcodec/dolby_e_parser.c                   |  11 +-
 libavcodec/dpcm.c                             |  16 +-
 libavcodec/dsddec.c                           |  14 +-
 libavcodec/dsicinaudio.c                      |   4 +-
 libavcodec/dss_sp.c                           |   4 +-
 libavcodec/dstdec.c                           |   8 +-
 libavcodec/dvaudiodec.c                       |   8 +-
 libavcodec/eac3enc.c                          |   5 +
 libavcodec/encode.c                           |  43 +-
 libavcodec/evrcdec.c                          |   4 +-
 libavcodec/fastaudio.c                        |   6 +-
 libavcodec/ffwavesynth.c                      |   6 +-
 libavcodec/flac.c                             |  39 +-
 libavcodec/flac.h                             |   2 +-
 libavcodec/flac_parser.c                      |   7 +-
 libavcodec/flacdec.c                          |   9 +-
 libavcodec/flacenc.c                          |  26 +-
 libavcodec/g722dec.c                          |   4 +-
 libavcodec/g722enc.c                          |   5 +
 libavcodec/g723_1_parser.c                    |   2 +-
 libavcodec/g723_1dec.c                        |  19 +-
 libavcodec/g723_1enc.c                        |   8 +-
 libavcodec/g726.c                             |   8 +-
 libavcodec/g729_parser.c                      |   2 +-
 libavcodec/g729dec.c                          |  20 +-
 libavcodec/gsmdec.c                           |   4 +-
 libavcodec/hcadec.c                           |  16 +-
 libavcodec/hcom.c                             |   2 +-
 libavcodec/ilbcdec.c                          |   4 +-
 libavcodec/imc.c                              |  22 +-
 libavcodec/interplayacm.c                     |  10 +-
 libavcodec/libcelt_dec.c                      |  10 +-
 libavcodec/libcodec2.c                        |   4 +-
 libavcodec/libfdk-aacdec.c                    |  34 +-
 libavcodec/libfdk-aacenc.c                    |  37 +-
 libavcodec/libgsmdec.c                        |   4 +-
 libavcodec/libgsmenc.c                        |   4 +-
 libavcodec/libilbc.c                          |   6 +-
 libavcodec/libmp3lame.c                       |   9 +-
 libavcodec/libopencore-amr.c                  |   8 +-
 libavcodec/libopusdec.c                       |  39 +-
 libavcodec/libopusenc.c                       |  65 +-
 libavcodec/libshine.c                         |   6 +-
 libavcodec/libspeexdec.c                      |  19 +-
 libavcodec/libspeexenc.c                      |  17 +-
 libavcodec/libtwolame.c                       |   2 +-
 libavcodec/libvo-amrwbenc.c                   |   2 +-
 libavcodec/libvorbisdec.c                     |   4 +-
 libavcodec/libvorbisenc.c                     |  42 +-
 libavcodec/mace.c                             |  15 +-
 libavcodec/metasound.c                        |  31 +-
 libavcodec/mfenc.c                            |   8 +-
 libavcodec/mlp_parser.c                       |  12 +-
 libavcodec/mlpdec.c                           | 112 ++-
 libavcodec/mlpenc.c                           |  98 ++-
 libavcodec/mp3_header_decompress_bsf.c        |   2 +-
 libavcodec/mpc7.c                             |   7 +-
 libavcodec/mpc8.c                             |   6 +-
 libavcodec/mpegaudio_parser.c                 |   4 +-
 libavcodec/mpegaudiodec_template.c            |  22 +-
 libavcodec/mpegaudioenc_template.c            |   2 +-
 libavcodec/nellymoserdec.c                    |   4 +-
 libavcodec/nellymoserenc.c                    |   6 +-
 libavcodec/on2avc.c                           |  20 +-
 libavcodec/options_table.h                    |   3 +
 libavcodec/opus.c                             |  73 +-
 libavcodec/opusdec.c                          |   4 +-
 libavcodec/opusenc.c                          |  11 +-
 libavcodec/opusenc_psy.c                      |  20 +-
 libavcodec/packet.h                           |   5 +
 libavcodec/pafaudio.c                         |   5 +-
 libavcodec/pcm-bluray.c                       |  36 +-
 libavcodec/pcm-dvd.c                          |  28 +-
 libavcodec/pcm-dvdenc.c                       |  20 +-
 libavcodec/pcm.c                              |  39 +-
 libavcodec/pcm_rechunk_bsf.c                  |   5 +-
 libavcodec/psymodel.c                         |   8 +-
 libavcodec/psymodel.h                         |   2 +-
 libavcodec/pthread_frame.c                    |  10 +-
 libavcodec/qcelpdec.c                         |   4 +-
 libavcodec/qdm2.c                             |   6 +-
 libavcodec/qdmc.c                             |   9 +-
 libavcodec/ra144dec.c                         |   4 +-
 libavcodec/ra144enc.c                         |   8 +-
 libavcodec/ra288.c                            |   4 +-
 libavcodec/ralf.c                             |  18 +-
 libavcodec/roqaudioenc.c                      |  20 +-
 libavcodec/s302m.c                            |  31 +-
 libavcodec/s302menc.c                         |  18 +-
 libavcodec/sbc_parser.c                       |   8 +-
 libavcodec/sbcdec.c                           |   4 +-
 libavcodec/sbcenc.c                           |  10 +-
 libavcodec/shorten.c                          |   6 +-
 libavcodec/sipr.c                             |   4 +-
 libavcodec/siren.c                            |   4 +-
 libavcodec/smacker.c                          |  12 +-
 libavcodec/sonic.c                            |  14 +-
 libavcodec/speexdec.c                         |   8 +-
 libavcodec/takdec.c                           |  41 +-
 libavcodec/truespeech.c                       |   7 +-
 libavcodec/tta.c                              |  18 +-
 libavcodec/ttaenc.c                           |  14 +-
 libavcodec/twinvq.c                           |  20 +-
 libavcodec/twinvqdec.c                        |  18 +-
 libavcodec/utils.c                            |  24 +-
 libavcodec/vima.c                             |   5 +-
 libavcodec/vmdaudio.c                         |  26 +-
 libavcodec/vorbisdec.c                        |  24 +-
 libavcodec/vorbisenc.c                        |   7 +-
 libavcodec/wavpack.c                          |  51 +-
 libavcodec/wavpackenc.c                       |  29 +-
 libavcodec/wma.c                              |  11 +-
 libavcodec/wmadec.c                           |  29 +-
 libavcodec/wmaenc.c                           |  27 +-
 libavcodec/wmalosslessdec.c                   |  13 +-
 libavcodec/wmaprodec.c                        |  28 +-
 libavcodec/wmavoice.c                         |   4 +-
 libavcodec/ws-snd1.c                          |   4 +-
 libavdevice/alsa.c                            |  19 +-
 libavdevice/alsa_dec.c                        |   3 +-
 libavdevice/alsa_enc.c                        |   2 +-
 libavdevice/dshow.c                           |   3 +-
 libavdevice/jack.c                            |   3 +-
 libavdevice/lavfi.c                           |   7 +-
 libavdevice/libcdio.c                         |   5 +-
 libavdevice/oss_dec.c                         |   3 +-
 libavdevice/oss_enc.c                         |   2 +-
 libavfilter/aeval.c                           |  19 +-
 libavfilter/af_afir.c                         |   9 +-
 libavfilter/af_aformat.c                      |  32 +-
 libavfilter/af_amerge.c                       |  38 +-
 libavfilter/af_amix.c                         |   2 +-
 libavfilter/af_apulsator.c                    |   2 +-
 libavfilter/af_aresample.c                    |  41 +-
 libavfilter/af_ashowinfo.c                    |  13 +-
 libavfilter/af_asr.c                          |   2 +-
 libavfilter/af_biquads.c                      |  42 +-
 libavfilter/af_bs2b.c                         |   2 +-
 libavfilter/af_channelmap.c                   |  86 ++-
 libavfilter/af_channelsplit.c                 |  42 +-
 libavfilter/af_compand.c                      |   6 +
 libavfilter/af_compensationdelay.c            |   7 +
 libavfilter/af_crossfeed.c                    |   2 +-
 libavfilter/af_earwax.c                       |   2 +-
 libavfilter/af_extrastereo.c                  |   2 +-
 libavfilter/af_firequalizer.c                 |   5 +-
 libavfilter/af_haas.c                         |   2 +-
 libavfilter/af_hdcd.c                         |   4 +-
 libavfilter/af_headphone.c                    |  22 +-
 libavfilter/af_join.c                         | 268 +++++---
 libavfilter/af_ladspa.c                       |  16 +-
 libavfilter/af_lv2.c                          |  17 +-
 libavfilter/af_pan.c                          |  62 +-
 libavfilter/af_replaygain.c                   |   2 +-
 libavfilter/af_sofalizer.c                    |  86 ++-
 libavfilter/af_speechnorm.c                   |  12 +-
 libavfilter/af_stereotools.c                  |   2 +-
 libavfilter/af_stereowiden.c                  |   2 +-
 libavfilter/af_surround.c                     |  72 +-
 libavfilter/asrc_afirsrc.c                    |   2 +-
 libavfilter/asrc_anoisesrc.c                  |   2 +-
 libavfilter/asrc_anullsrc.c                   |  13 +-
 libavfilter/asrc_flite.c                      |   6 +-
 libavfilter/asrc_hilbert.c                    |   2 +-
 libavfilter/asrc_sinc.c                       |   2 +-
 libavfilter/asrc_sine.c                       |   2 +-
 libavfilter/audio.c                           |  11 +-
 libavfilter/avf_aphasemeter.c                 |   2 +-
 libavfilter/avf_avectorscope.c                |   2 +-
 libavfilter/avf_showcqt.c                     |   3 +-
 libavfilter/avf_showspatial.c                 |   2 +-
 libavfilter/avf_showspectrum.c                |   3 +-
 libavfilter/avf_showvolume.c                  |   9 +-
 libavfilter/avfilter.c                        |  15 +-
 libavfilter/avfilter.h                        |  10 +-
 libavfilter/avfiltergraph.c                   |  84 ++-
 libavfilter/buffersink.c                      |  29 +-
 libavfilter/buffersink.h                      |   7 +-
 libavfilter/buffersrc.c                       |  92 ++-
 libavfilter/buffersrc.h                       |   9 +
 libavfilter/f_ebur128.c                       |  10 +-
 libavfilter/f_streamselect.c                  |   4 +
 libavfilter/formats.c                         | 131 ++--
 libavfilter/formats.h                         |  16 +-
 libavfilter/graphdump.c                       |   4 +-
 libavfilter/internal.h                        |   2 +-
 libavfilter/src_movie.c                       |  19 +-
 libavfilter/tests/filtfmts.c                  |   3 +-
 libavfilter/tests/formats.c                   |   8 +-
 libavfilter/vaf_spectrumsynth.c               |   2 +-
 libavformat/3dostr.c                          |  13 +-
 libavformat/4xm.c                             |   7 +-
 libavformat/aadec.c                           |   6 +-
 libavformat/aaxdec.c                          |   7 +-
 libavformat/acedec.c                          |   5 +-
 libavformat/acm.c                             |   7 +-
 libavformat/act.c                             |   3 +-
 libavformat/adp.c                             |   3 +-
 libavformat/ads.c                             |  11 +-
 libavformat/adxdec.c                          |  22 +-
 libavformat/aea.c                             |  11 +-
 libavformat/afc.c                             |   5 +-
 libavformat/aiffdec.c                         |  13 +-
 libavformat/aiffenc.c                         |   8 +-
 libavformat/aixdec.c                          |   3 +-
 libavformat/alp.c                             |  16 +-
 libavformat/amr.c                             |  20 +-
 libavformat/amvenc.c                          |   4 +-
 libavformat/apc.c                             |  12 +-
 libavformat/ape.c                             |   3 +-
 libavformat/apm.c                             |  22 +-
 libavformat/aptxdec.c                         |   3 +-
 libavformat/argo_asf.c                        |  18 +-
 libavformat/argo_cvg.c                        |   5 +-
 libavformat/astdec.c                          |  18 +-
 libavformat/astenc.c                          |   4 +-
 libavformat/au.c                              |   9 +-
 libavformat/avformat.h                        |   7 +
 libavformat/avr.c                             |   7 +-
 libavformat/bethsoftvid.c                     |   3 +-
 libavformat/bfi.c                             |   3 +-
 libavformat/bink.c                            |   8 +-
 libavformat/binka.c                           |   3 +-
 libavformat/bit.c                             |   7 +-
 libavformat/bmv.c                             |   3 +-
 libavformat/boadec.c                          |   8 +-
 libavformat/brstm.c                           |  44 +-
 libavformat/cafdec.c                          |   7 +-
 libavformat/cafenc.c                          |  12 +-
 libavformat/cdxl.c                            |   4 +-
 libavformat/codec2.c                          |   3 +-
 libavformat/dashenc.c                         |   2 +-
 libavformat/dauddec.c                         |   3 +-
 libavformat/daudenc.c                         |   2 +-
 libavformat/dcstr.c                           |  15 +-
 libavformat/demux.c                           |  18 +-
 libavformat/derf.c                            |  12 +-
 libavformat/dhav.c                            |   3 +-
 libavformat/dsfdec.c                          |  60 +-
 libavformat/dsicin.c                          |   7 +-
 libavformat/dss.c                             |   3 +-
 libavformat/dtshddec.c                        |   3 +-
 libavformat/dump.c                            |  11 +-
 libavformat/dv.c                              |   3 +-
 libavformat/dvenc.c                           |   2 +-
 libavformat/eacdata.c                         |  22 +-
 libavformat/electronicarts.c                  |   7 +-
 libavformat/epafdec.c                         |   6 +-
 libavformat/flacdec.c                         |   3 +-
 libavformat/flacenc.c                         |   7 +-
 libavformat/flic.c                            |   4 +-
 libavformat/flvdec.c                          |  15 +-
 libavformat/flvenc.c                          |  10 +-
 libavformat/framehash.c                       |   8 +-
 libavformat/fsb.c                             |  36 +-
 libavformat/fwse.c                            |  10 +-
 libavformat/g722.c                            |   2 +-
 libavformat/g723_1.c                          |   3 +-
 libavformat/g726.c                            |   3 +-
 libavformat/g729dec.c                         |   2 +-
 libavformat/gdv.c                             |   6 +-
 libavformat/genh.c                            |  38 +-
 libavformat/gsmdec.c                          |   3 +-
 libavformat/gxf.c                             |   9 +-
 libavformat/gxfenc.c                          |   2 +-
 libavformat/hca.c                             |   3 +-
 libavformat/hcom.c                            |   3 +-
 libavformat/hls_sample_encryption.c           |  12 +-
 libavformat/idcin.c                           |   4 +-
 libavformat/idroqdec.c                        |  12 +-
 libavformat/iff.c                             |  63 +-
 libavformat/ifv.c                             |   3 +-
 libavformat/ilbc.c                            |   2 +-
 libavformat/imx.c                             |   3 +-
 libavformat/ipmovie.c                         |   8 +-
 libavformat/ircamdec.c                        |   8 +-
 libavformat/ircamenc.c                        |   2 +-
 libavformat/isom.c                            |   5 +-
 libavformat/iss.c                             |  17 +-
 libavformat/jvdec.c                           |   3 +-
 libavformat/kvag.c                            |  19 +-
 libavformat/lvfdec.c                          |   3 +-
 libavformat/lxfdec.c                          |   3 +-
 libavformat/matroskadec.c                     |   8 +-
 libavformat/matroskaenc.c                     |  10 +-
 libavformat/mca.c                             |  25 +-
 libavformat/mm.c                              |   3 +-
 libavformat/mmf.c                             |   5 +-
 libavformat/moflex.c                          |   3 +-
 libavformat/mov.c                             | 172 ++++-
 libavformat/mov_chan.c                        |  21 +-
 libavformat/mov_chan.h                        |   3 +-
 libavformat/movenc.c                          |  25 +-
 libavformat/mp3enc.c                          |   2 +-
 libavformat/mpc.c                             |   3 +-
 libavformat/mpc8.c                            |   5 +-
 libavformat/mpeg.c                            |   3 +-
 libavformat/mpegenc.c                         |  10 +-
 libavformat/mpegtsenc.c                       |  30 +-
 libavformat/msf.c                             |  16 +-
 libavformat/mtaf.c                            |   5 +-
 libavformat/musx.c                            |  49 +-
 libavformat/mux.c                             |  19 +-
 libavformat/mvdec.c                           |  10 +-
 libavformat/mvi.c                             |   3 +-
 libavformat/mxfdec.c                          |  23 +-
 libavformat/mxfenc.c                          |  20 +-
 libavformat/mxg.c                             |   3 +-
 libavformat/nistspheredec.c                   |   8 +-
 libavformat/nspdec.c                          |   3 +-
 libavformat/nsvdec.c                          |   2 +-
 libavformat/nutdec.c                          |   3 +-
 libavformat/nutenc.c                          |   4 +-
 libavformat/nuv.c                             |  11 +-
 libavformat/oggparsecelt.c                    |   3 +-
 libavformat/oggparseogm.c                     |   6 +-
 libavformat/oggparseopus.c                    |   3 +-
 libavformat/oggparsespeex.c                   |   8 +-
 libavformat/oggparsevorbis.c                  |   6 +-
 libavformat/oma.h                             |   2 +
 libavformat/omadec.c                          |  35 +-
 libavformat/omaenc.c                          |   4 +-
 libavformat/paf.c                             |   3 +-
 libavformat/pcm.c                             |   2 +-
 libavformat/pcmdec.c                          |   7 +-
 libavformat/pmpdec.c                          |   3 +-
 libavformat/pp_bnk.c                          |  12 +-
 libavformat/psxstr.c                          |  10 +-
 libavformat/pvfdec.c                          |   5 +-
 libavformat/qcp.c                             |   3 +-
 libavformat/r3d.c                             |   3 +-
 libavformat/rawenc.c                          |   2 +-
 libavformat/redspark.c                        |  15 +-
 libavformat/riffdec.c                         |  20 +-
 libavformat/riffenc.c                         |  18 +-
 libavformat/rl2.c                             |   7 +-
 libavformat/rmdec.c                           |   6 +-
 libavformat/rmenc.c                           |   2 +-
 libavformat/rpl.c                             |   7 +-
 libavformat/rsd.c                             |  27 +-
 libavformat/rsodec.c                          |   3 +-
 libavformat/rsoenc.c                          |   2 +-
 libavformat/rtp.c                             |  10 +-
 libavformat/rtpdec.c                          |   4 +-
 libavformat/rtpdec_amr.c                      |   3 +-
 libavformat/rtpenc.c                          |  14 +-
 libavformat/rtsp.c                            |   6 +-
 libavformat/rtsp.h                            |   1 -
 libavformat/sbgdec.c                          |   3 +-
 libavformat/scd.c                             |   9 +-
 libavformat/sdp.c                             |  36 +-
 libavformat/sdr2.c                            |   3 +-
 libavformat/sdsdec.c                          |   3 +-
 libavformat/sdxdec.c                          |   3 +-
 libavformat/segafilm.c                        |   9 +-
 libavformat/segafilmenc.c                     |   2 +-
 libavformat/sga.c                             |   3 +-
 libavformat/sierravmd.c                       |  15 +-
 libavformat/siff.c                            |   3 +-
 libavformat/smacker.c                         |  11 +-
 libavformat/smjpegdec.c                       |   3 +-
 libavformat/smjpegenc.c                       |   2 +-
 libavformat/smoothstreamingenc.c              |   4 +-
 libavformat/smush.c                           |   4 +-
 libavformat/sol.c                             |   4 +-
 libavformat/soxdec.c                          |  14 +-
 libavformat/soxenc.c                          |   4 +-
 libavformat/svag.c                            |  12 +-
 libavformat/svs.c                             |   3 +-
 libavformat/swfdec.c                          |   8 +-
 libavformat/swfenc.c                          |   2 +-
 libavformat/takdec.c                          |   7 +-
 libavformat/tests/movenc.c                    |   2 +-
 libavformat/thp.c                             |   3 +-
 libavformat/tiertexseq.c                      |   7 +-
 libavformat/tmv.c                             |  10 +-
 libavformat/tta.c                             |   3 +-
 libavformat/ttaenc.c                          |   2 +-
 libavformat/utils.c                           |  13 +-
 libavformat/vag.c                             |  11 +-
 libavformat/vividas.c                         |   8 +-
 libavformat/vivo.c                            |   3 +-
 libavformat/voc_packet.c                      |   9 +-
 libavformat/vocenc.c                          |   9 +-
 libavformat/vpk.c                             |  15 +-
 libavformat/vqf.c                             |  13 +-
 libavformat/wavdec.c                          |  32 +-
 libavformat/wavenc.c                          |  14 +-
 libavformat/wc3movie.c                        |   8 +-
 libavformat/westwood_aud.c                    |  10 +-
 libavformat/westwood_audenc.c                 |   2 +-
 libavformat/westwood_vqa.c                    |   2 +-
 libavformat/wsddec.c                          |  12 +-
 libavformat/wtvdec.c                          |   6 +-
 libavformat/wvdec.c                           |   3 +-
 libavformat/wvedec.c                          |   6 +-
 libavformat/xa.c                              |   9 +-
 libavformat/xmv.c                             |   3 +-
 libavformat/xvag.c                            |  10 +-
 libavformat/xwma.c                            |  10 +-
 libavformat/yop.c                             |   3 +-
 libavutil/Makefile                            |   1 +
 libavutil/channel_layout.c                    | 641 ++++++++++++++++--
 libavutil/channel_layout.h                    | 559 ++++++++++++++-
 libavutil/frame.c                             | 112 ++-
 libavutil/frame.h                             |  12 +-
 libavutil/opt.c                               | 126 +++-
 libavutil/opt.h                               |  12 +
 libavutil/tests/channel_layout.c              | 231 +++++++
 libavutil/tests/opt.c                         |   8 +-
 libavutil/version.h                           |   1 +
 libswresample/options.c                       |  33 +-
 libswresample/rematrix.c                      | 227 ++++---
 libswresample/rematrix_template.c             |   7 +-
 libswresample/swresample.c                    | 158 ++++-
 libswresample/swresample.h                    |  63 ++
 libswresample/swresample_frame.c              |  65 +-
 libswresample/swresample_internal.h           |  10 +-
 tests/fate/aac.mak                            |   2 +-
 tests/fate/ac3.mak                            |  16 +-
 tests/fate/cover-art.mak                      |   2 +-
 tests/fate/lavf-container.mak                 |   2 +-
 tests/fate/libavutil.mak                      |   4 +
 tests/ref/fate/8bps                           |   1 -
 tests/ref/fate/aa-demux                       |   1 -
 tests/ref/fate/aac-autobsf-adtstoasc          |   1 -
 tests/ref/fate/adpcm-4xm                      |   1 -
 tests/ref/fate/adpcm-afc                      |   1 -
 tests/ref/fate/adpcm-dtk                      |   1 -
 tests/ref/fate/adpcm-ea-1                     |   1 -
 tests/ref/fate/adpcm-ea-2                     |   1 -
 tests/ref/fate/adpcm-ea-maxis-xa              |   1 -
 tests/ref/fate/adpcm-ea-r1                    |   1 -
 tests/ref/fate/adpcm-ima-amv                  |   1 -
 tests/ref/fate/adpcm-ima-ea-eacs              |   1 -
 tests/ref/fate/adpcm-ima-ea-sead              |   1 -
 tests/ref/fate/adpcm-ima-smjpeg               |   1 -
 tests/ref/fate/adpcm-ima-ws                   |   1 -
 tests/ref/fate/adpcm-ima-ws-vqa3              |   1 -
 tests/ref/fate/adpcm-ms-mono                  |   1 -
 tests/ref/fate/adpcm-thp                      |   1 -
 tests/ref/fate/adpcm-vima                     |   1 -
 tests/ref/fate/adpcm-xa                       |   1 -
 tests/ref/fate/adts-id3v1-demux               |   1 -
 tests/ref/fate/adts-id3v2-demux               |   1 -
 tests/ref/fate/adts-id3v2-two-tags-demux      |   1 -
 tests/ref/fate/adtstoasc_ticket3715           |   1 -
 tests/ref/fate/armovie-escape124              |   1 -
 tests/ref/fate/bethsoft-vid                   |   1 -
 tests/ref/fate/bfi                            |   1 -
 tests/ref/fate/bmv-audio                      |   1 -
 tests/ref/fate/caf-alac-remux                 |   1 -
 tests/ref/fate/caf-amr_nb-remux               |   1 -
 tests/ref/fate/caf-mace6-remux                |   1 -
 tests/ref/fate/caf-pcm_s24-remux              |   1 -
 tests/ref/fate/caf-pcm_s24le-remux            |   1 -
 tests/ref/fate/caf-qdm2-remux                 |   1 -
 tests/ref/fate/cdxl-demux                     |   1 -
 tests/ref/fate/channel_layout                 |  94 +++
 tests/ref/fate/copy-psp                       |   1 -
 tests/ref/fate/copy-shortest1                 |   1 -
 tests/ref/fate/copy-shortest2                 |   1 -
 tests/ref/fate/copy-trac236                   |   1 -
 tests/ref/fate/copy-trac3074                  |   1 -
 tests/ref/fate/copy-trac4914                  |   1 -
 tests/ref/fate/copy-trac4914-avi              |   1 -
 tests/ref/fate/corepng                        |   1 -
 tests/ref/fate/cover-art-aiff-id3v2-remux     |   1 -
 tests/ref/fate/cover-art-flac-remux           |   6 +-
 tests/ref/fate/cover-art-mp3-id3v2-remux      |   1 -
 tests/ref/fate/creatureshock-avs              |   1 -
 tests/ref/fate/cyberia-c93                    |   1 -
 tests/ref/fate/d-cinema-demux                 |   1 -
 tests/ref/fate/dca-xll_51_16_192_768_0        |   1 -
 tests/ref/fate/dca-xll_51_16_192_768_0-dmix_2 |   1 -
 tests/ref/fate/dca-xll_51_16_192_768_0-dmix_6 |   1 -
 tests/ref/fate/dca-xll_51_16_192_768_1        |   1 -
 tests/ref/fate/dca-xll_51_16_192_768_1-dmix_2 |   1 -
 tests/ref/fate/dca-xll_51_16_192_768_1-dmix_6 |   1 -
 tests/ref/fate/dca-xll_51_24_48_768           |   1 -
 tests/ref/fate/dca-xll_51_24_48_768-dmix_2    |   1 -
 tests/ref/fate/dca-xll_51_24_48_768-dmix_6    |   1 -
 tests/ref/fate/dca-xll_51_24_48_none          |   1 -
 tests/ref/fate/dca-xll_51_24_48_none-dmix_2   |   1 -
 tests/ref/fate/dca-xll_51_24_48_none-dmix_6   |   1 -
 tests/ref/fate/dca-xll_71_24_48_768_0         |   1 -
 tests/ref/fate/dca-xll_71_24_48_768_0-dmix_2  |   1 -
 tests/ref/fate/dca-xll_71_24_48_768_0-dmix_6  |   1 -
 tests/ref/fate/dca-xll_71_24_48_768_1         |   1 -
 tests/ref/fate/dca-xll_71_24_48_768_1-dmix_2  |   1 -
 tests/ref/fate/dca-xll_71_24_48_768_1-dmix_6  |   1 -
 tests/ref/fate/dca-xll_71_24_96_768           |   1 -
 tests/ref/fate/dca-xll_71_24_96_768-dmix_2    |   1 -
 tests/ref/fate/dca-xll_71_24_96_768-dmix_6    |   1 -
 tests/ref/fate/dca-xll_x96_51_24_96_1509      |   1 -
 .../ref/fate/dca-xll_x96_51_24_96_1509-dmix_2 |   1 -
 .../ref/fate/dca-xll_x96_51_24_96_1509-dmix_6 |   1 -
 tests/ref/fate/dca-xll_xch_61_24_48_768       |   1 -
 .../ref/fate/dca-xll_xch_61_24_48_768-dmix_2  |   1 -
 .../ref/fate/dca-xll_xch_61_24_48_768-dmix_6  |   1 -
 tests/ref/fate/dcinema-encode                 |   1 -
 tests/ref/fate/delphine-cin-audio             |   1 -
 tests/ref/fate/dpcm-idroq                     |   1 -
 tests/ref/fate/dpcm-interplay                 |   1 -
 tests/ref/fate/dss-lp                         |   1 -
 tests/ref/fate/dss-sp                         |   1 -
 tests/ref/fate/ffmpeg-attached_pics           |   1 -
 tests/ref/fate/ffmpeg-filter_complex_audio    |   1 -
 tests/ref/fate/filter-acrossfade              |   1 -
 tests/ref/fate/filter-adelay                  |   1 -
 tests/ref/fate/filter-aecho                   |   1 -
 tests/ref/fate/filter-aemphasis               |   2 -
 tests/ref/fate/filter-aemphasis-50fm          |   1 -
 tests/ref/fate/filter-aemphasis-75kf          |   1 -
 tests/ref/fate/filter-afade-esin              |   1 -
 tests/ref/fate/filter-afade-exp               |   1 -
 tests/ref/fate/filter-afade-hsin              |   1 -
 tests/ref/fate/filter-afade-iqsin             |   1 -
 tests/ref/fate/filter-afade-log               |   1 -
 tests/ref/fate/filter-afade-qsin              |   1 -
 tests/ref/fate/filter-agate                   |   1 -
 tests/ref/fate/filter-alimiter                |   1 -
 tests/ref/fate/filter-amerge                  |   1 -
 tests/ref/fate/filter-anequalizer             |   1 -
 tests/ref/fate/filter-apad                    |   1 -
 tests/ref/fate/filter-asetnsamples-nopad      |   1 -
 tests/ref/fate/filter-asetnsamples-pad        |   1 -
 tests/ref/fate/filter-asetrate                |   1 -
 tests/ref/fate/filter-atrim-duration          |   1 -
 tests/ref/fate/filter-atrim-mixed             |   1 -
 tests/ref/fate/filter-atrim-samples           |   1 -
 tests/ref/fate/filter-atrim-time              |   1 -
 tests/ref/fate/filter-chorus                  |   1 -
 tests/ref/fate/filter-compand                 |   1 -
 tests/ref/fate/filter-concat                  |   1 -
 tests/ref/fate/filter-concat-vfr              |   1 -
 tests/ref/fate/filter-dcshift                 |   1 -
 tests/ref/fate/filter-earwax                  |   1 -
 tests/ref/fate/filter-extrastereo             |   1 -
 tests/ref/fate/filter-formats                 |  20 +-
 tests/ref/fate/filter-hls                     |   1 -
 tests/ref/fate/filter-hls-append              |   1 -
 tests/ref/fate/filter-meta-4560-rotate0       |   1 -
 tests/ref/fate/filter-overlay-dvdsub-2397     |   1 -
 tests/ref/fate/filter-pan-downmix1            |   1 -
 tests/ref/fate/filter-pan-downmix2            |   1 -
 tests/ref/fate/filter-pan-mono1               |   1 -
 tests/ref/fate/filter-pan-mono2               |   1 -
 tests/ref/fate/filter-pan-stereo1             |   1 -
 tests/ref/fate/filter-pan-stereo2             |   1 -
 tests/ref/fate/filter-pan-stereo3             |   1 -
 tests/ref/fate/filter-pan-stereo4             |   1 -
 tests/ref/fate/filter-pan-upmix1              |   1 -
 tests/ref/fate/filter-pan-upmix2              |   1 -
 tests/ref/fate/filter-silenceremove           |   1 -
 tests/ref/fate/filter-stereotools             |   1 -
 tests/ref/fate/g722-encode                    |   1 -
 tests/ref/fate/g722dec-1                      |   1 -
 tests/ref/fate/g723_1-dec-1                   |   1 -
 tests/ref/fate/g723_1-dec-2                   |   1 -
 tests/ref/fate/g723_1-dec-3                   |   1 -
 tests/ref/fate/g723_1-dec-4                   |   1 -
 tests/ref/fate/g723_1-dec-5                   |   1 -
 tests/ref/fate/g723_1-dec-6                   |   1 -
 tests/ref/fate/g723_1-dec-7                   |   1 -
 tests/ref/fate/g723_1-dec-8                   |   1 -
 tests/ref/fate/g726-encode-2bit               |   1 -
 tests/ref/fate/g726-encode-3bit               |   1 -
 tests/ref/fate/g726-encode-4bit               |   1 -
 tests/ref/fate/g726-encode-5bit               |   1 -
 tests/ref/fate/gapless-mp3                    |   6 +-
 tests/ref/fate/gsm-ms                         |   1 -
 tests/ref/fate/gsm-toast                      |   1 -
 tests/ref/fate/h264-skip-nointra              |   1 -
 tests/ref/fate/h264-skip-nokey                |   1 -
 tests/ref/fate/h264-xavc-4389                 |   1 -
 tests/ref/fate/hls-fmp4                       |   1 -
 tests/ref/fate/hls-init-time                  |   1 -
 tests/ref/fate/hls-list-size                  |   1 -
 tests/ref/fate/hls-segment-single             |   1 -
 tests/ref/fate/hls-segment-size               |   1 -
 tests/ref/fate/id-cin-video                   |   1 -
 tests/ref/fate/id3v2-chapters                 |   1 -
 tests/ref/fate/id3v2-priv-remux               |   1 -
 tests/ref/fate/jv-demux                       |   1 -
 tests/ref/fate/lmlm4-demux                    |   1 -
 tests/ref/fate/matroska-flac-channel-mapping  |   2 -
 tests/ref/fate/matroska-flac-extradata-update |   3 -
 tests/ref/fate/matroska-lzo-decompression     |   1 -
 .../fate/matroska-mastering-display-metadata  |   2 -
 tests/ref/fate/matroska-mpegts-remux          |   2 -
 .../matroska-wavpack-missing-codecprivate     |   1 -
 tests/ref/fate/matroska-xiph-lacing           |   1 -
 tests/ref/fate/maxis-xa                       |   1 -
 tests/ref/fate/mkv                            |   1 -
 tests/ref/fate/mkv-1242                       |   1 -
 tests/ref/fate/mov-440hz-10ms                 |   1 -
 tests/ref/fate/mov-bbi-elst-starts-b          |   1 -
 tests/ref/fate/mov-cover-image                |   1 -
 tests/ref/fate/mov-mp3-demux                  |   1 -
 .../ref/fate/mov-mp4-disposition-mpegts-remux |   2 -
 tests/ref/fate/mpegps-remuxed-pcm-demux       |   1 -
 tests/ref/fate/mtv                            |   1 -
 tests/ref/fate/mxf-demux                      |   1 -
 tests/ref/fate/nsv-demux                      |   1 -
 tests/ref/fate/oma-atrac3-remux               |   1 -
 tests/ref/fate/oma-atrac3p-remux              |   1 -
 tests/ref/fate/on2avc                         |   1 -
 tests/ref/fate/opt                            |  16 +-
 tests/ref/fate/paf-audio                      |   1 -
 tests/ref/fate/paf-demux                      |   1 -
 tests/ref/fate/pcm-planar                     |   1 -
 tests/ref/fate/pcm_dvd                        |   1 -
 tests/ref/fate/pmp-demux                      |   1 -
 tests/ref/fate/prores-gray                    |   1 -
 tests/ref/fate/prores-transparency            |   1 -
 tests/ref/fate/prores-transparency_skip       |   1 -
 tests/ref/fate/psx-str-demux                  |   1 -
 tests/ref/fate/pva-demux                      |   1 -
 tests/ref/fate/ra3-144                        |   1 -
 tests/ref/fate/redcode-demux                  |   1 -
 tests/ref/fate/s337m-demux                    |   1 -
 tests/ref/fate/segment-adts-to-mkv-header-000 |   1 -
 tests/ref/fate/segment-adts-to-mkv-header-001 |   1 -
 tests/ref/fate/segment-adts-to-mkv-header-002 |   1 -
 tests/ref/fate/segment-adts-to-mkv-header-all |   1 -
 tests/ref/fate/shortest                       |   1 -
 tests/ref/fate/sierra-vmd-audio               |   1 -
 tests/ref/fate/siff-demux                     |   1 -
 tests/ref/fate/smacker-audio                  |   1 -
 tests/ref/fate/smjpeg-demux                   |   1 -
 tests/ref/fate/sp5x                           |   1 -
 tests/ref/fate/tiertex-seq                    |   1 -
 tests/ref/fate/tmv                            |   1 -
 tests/ref/fate/tscc-15bit                     |   1 -
 tests/ref/fate/vqf-demux                      |   2 +-
 tests/ref/fate/wav-ac3                        |   1 -
 tests/ref/fate/wc3movie-xan                   |   1 -
 tests/ref/fate/webm-dash-chapters             |   1 -
 tests/ref/fate/westwood-aud                   |   1 -
 tests/ref/fate/wmv3-drm-nodec                 |   1 -
 tests/ref/fate/wtv-demux                      |   1 -
 tests/ref/fate/xmv-demux                      |   1 -
 710 files changed, 6417 insertions(+), 3446 deletions(-)
 create mode 100644 libavutil/tests/channel_layout.c
 create mode 100644 tests/ref/fate/channel_layout

Comments

Paul B Mahol Dec. 8, 2021, 8:37 a.m. UTC | #1
On Wed, Dec 8, 2021 at 2:07 AM James Almer <jamrial@gmail.com> wrote:

> This is an updated and rebased version of the API that was sent to this
> mailing
> list about two years ago. It expands it with some new helpers, implements
> some
> changes that allows further extensibility for new features down the line,
> and
> finishes porting all missing modules and those introduced since 2019.
>
> I'm sending a reduced amount of patches to not spam the ML too much. In
> total
> it's 279 patches, the bulk being one per module ported, which it's what i'm
> skipping.
> This reduced set will obviously not apply as is, so you can find the
> entire set
> in https://github.com/jamrial/FFmpeg/commits/channel_layout


How are custom channel layouts defined?

I remember that if they are defined by '+', some other need to be used to
split multiple layouts when used at once.
Nicolas George Dec. 8, 2021, 10:55 a.m. UTC | #2
James Almer (12021-12-07):
> This is an updated and rebased version of the API that was sent to this mailing
> list about two years ago. It expands it with some new helpers, implements some
> changes that allows further extensibility for new features down the line, and
> finishes porting all missing modules and those introduced since 2019.

I see the concerns I raised last time have not been addressed:

(1) the ability to have a channel at a certain location several times;

(2) the ability to attach an arbitrary label to a channel or to a group
    of channels;

(3) an API and syntax for the user to specify a particular channel.

(1) is necessary for the amerge filter: merge two stereo streams, you
get two FL and two FR.

(1) is also necessary for devices that can record several sources
simultaneously. IIRC, that is the case for the BlackMagick devices. If
your devices records a band from two stereo and three mono microphones,
we need two FL, two FR and three FC.

(2) and (3) are necessary consequences of (1).

I also have concerns with the signature of av_channel_description():
this is level 0 of string manipulation, we need to get past this. I
should post again about this in a separate thread.

Regards,
James Almer Dec. 8, 2021, 12:07 p.m. UTC | #3
On 12/8/2021 7:55 AM, Nicolas George wrote:
> James Almer (12021-12-07):
>> This is an updated and rebased version of the API that was sent to this mailing
>> list about two years ago. It expands it with some new helpers, implements some
>> changes that allows further extensibility for new features down the line, and
>> finishes porting all missing modules and those introduced since 2019.
> 
> I see the concerns I raised last time have not been addressed:
> 
> (1) the ability to have a channel at a certain location several times;
> 
> (2) the ability to attach an arbitrary label to a channel or to a group
>      of channels;
> 
> (3) an API and syntax for the user to specify a particular channel.
> 
> (1) is necessary for the amerge filter: merge two stereo streams, you
> get two FL and two FR.
> 
> (1) is also necessary for devices that can record several sources
> simultaneously. IIRC, that is the case for the BlackMagick devices. If
> your devices records a band from two stereo and three mono microphones,
> we need two FL, two FR and three FC.
> 
> (2) and (3) are necessary consequences of (1).
> 
> I also have concerns with the signature of av_channel_description():
> this is level 0 of string manipulation, we need to get past this. I
> should post again about this in a separate thread.

What is wrong with it? All the functions returning a string in this API 
use the same signature. You pass it a pre-allocated buffer and it's 
filled with the string, truncating it if there's not enough space and 
letting the user know about it.
I recall you were against dynamic allocation of the string, which the 
user then had to free, so this was the alternative.

I could make it use a user provided AVBprint buffer instead of using one 
internally, if you think that's better, but since you planned to replace 
that with AVWriter i figured using AVBprint in the signature would mean 
an eventual deprecation and removal.

> 
> Regards,
>
Anton Khirnov Dec. 8, 2021, 12:26 p.m. UTC | #4
Quoting Nicolas George (2021-12-08 11:55:40)
> James Almer (12021-12-07):
> > This is an updated and rebased version of the API that was sent to this mailing
> > list about two years ago. It expands it with some new helpers, implements some
> > changes that allows further extensibility for new features down the line, and
> > finishes porting all missing modules and those introduced since 2019.
> 
> I see the concerns I raised last time have not been addressed:
> 
> (1) the ability to have a channel at a certain location several times;

I have no idea what you mean, the CUSTOM order can have any channel at
any location. This was true in all versions of this API back to 2013.

> 
> (2) the ability to attach an arbitrary label to a channel or to a group
>     of channels;
> 
> (3) an API and syntax for the user to specify a particular channel.
> 
> (1) is necessary for the amerge filter: merge two stereo streams, you
> get two FL and two FR.
> 
> (1) is also necessary for devices that can record several sources
> simultaneously. IIRC, that is the case for the BlackMagick devices. If
> your devices records a band from two stereo and three mono microphones,
> we need two FL, two FR and three FC.

Multiplexing multiple streams into a single AVFrame is not a valid use
case. Just use multiple streams.
Nicolas George Dec. 8, 2021, 3 p.m. UTC | #5
James Almer (12021-12-08):
> What is wrong with it? All the functions returning a string in this API use
> the same signature. You pass it a pre-allocated buffer and it's filled with
> the string, truncating it if there's not enough space and letting the user
> know about it.
> I recall you were against dynamic allocation of the string, which the user
> then had to free, so this was the alternative.

There is nothing wrong with it, just as there is nothing wrong with
wearing pelts and a loincloth, but modern clothes are much more
comfortable.

In this case, there is a little usability issue: this description is
almost always very short but can be arbitrarily long, handling that
properly in the caller is very annoying: start with a small buffer on
the stack, try the conversion, if it fails start allocating a bigger
buffer on the heap, etc.

> I could make it use a user provided AVBprint buffer instead of using one
> internally, if you think that's better, but since you planned to replace
> that with AVWriter i figured using AVBprint in the signature would mean an
> eventual deprecation and removal.

We are on the same page on this.

A memory allocation would be a big no here, because it can happen once
every frame. We have implemented pools for frames and buffers, we do
consider once-per-frame to be frequent enough to warrant code to avoid
allocations.

My preferred outcome would be that we apply AVWriter before this series,
and using it here. The idea would be to start using AVWriter everywhere
we return some kind of string: AVWriter in one or two places is crap,
but the more we use it, the more its benefits outweigh the costs.

I will start a new discussion on string API soon, and
since we do not really disagree here but the rest will take
some time, we can continue discussing this later.

Regards,
Nicolas George Dec. 8, 2021, 3:08 p.m. UTC | #6
Anton Khirnov (12021-12-08):
> I have no idea what you mean, the CUSTOM order can have any channel at
> any location. This was true in all versions of this API back to 2013.

Ok, my memories were muddy, now I remember better: it is possible, but
without (2) and (3) it is unusable: there is no point in having two LFE
channels if the user cannot specify "the second one" or know which one
is which.

> Multiplexing multiple streams into a single AVFrame is not a valid use
> case. Just use multiple streams.

We get to decide what is a valid use case and what is not. And in this
case, since the devices and filter I quoted already behave like that, I
posit that it IS a valid use case. Therefore, this new API must be
capable of handling them.

Regards,
Paul B Mahol Dec. 8, 2021, 6:42 p.m. UTC | #7
On Wed, Dec 8, 2021 at 4:09 PM Nicolas George <george@nsup.org> wrote:

> Anton Khirnov (12021-12-08):
> > I have no idea what you mean, the CUSTOM order can have any channel at
> > any location. This was true in all versions of this API back to 2013.
>
> Ok, my memories were muddy, now I remember better: it is possible, but
> without (2) and (3) it is unusable: there is no point in having two LFE
> channels if the user cannot specify "the second one" or know which one
> is which.
>
> > Multiplexing multiple streams into a single AVFrame is not a valid use
> > case. Just use multiple streams.
>
> We get to decide what is a valid use case and what is not. And in this
> case, since the devices and filter I quoted already behave like that, I
> posit that it IS a valid use case. Therefore, this new API must be
> capable of handling them.
>

Flawed logic.

>
> Regards,
>
> --
>   Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Anton Khirnov Dec. 9, 2021, 10:05 a.m. UTC | #8
Quoting Nicolas George (2021-12-08 16:08:54)
> Anton Khirnov (12021-12-08):
> We get to decide what is a valid use case and what is not. And in this
> case, since the devices and filter I quoted already behave like that,

It is not possible for them to behave "like that", because our current
channel layout API does not support duplicated channels at all.

> I posit that it IS a valid use case. Therefore, this new API must be
> capable of handling them.

I disagree. Technical limitations that were overcome 10 years ago should
not guide new API design.

If you insist then we can have a TC vote about this.
Nicolas George Dec. 9, 2021, 10:31 a.m. UTC | #9
Anton Khirnov (12021-12-09):
> It is not possible for them to behave "like that", because our current
> channel layout API does not support duplicated channels at all.

They behave like in the sense they output channels from several sources
in a single stream of AVFrame. They could not properly label it with a
layout. The new API should allow to enhance that, not break it utterly.

> I disagree. Technical limitations that were overcome 10 years ago should
> not guide new API design.

In the case of amerge, it was not a technical limitation, merging
several streams into one so that they can be handled by single-stream
filters is 100% part of the design. I suspect devices that capture
several independent channels are designed that way intentionally too,
possibly to reduce the risk of desynchronization.

> If you insist then we can have a TC vote about this.

Please, the TC is for when discussion has failed. Let us see what
arguments other developers bring to the discussion first.

I observe that about the ability to attach an arbitrary string label to
any channel, Lynne was with me for independent reasons.

And of course, if it comes to the TC, since you are a member yourself, I
expect you to recuse yourself from the proceedings on this question, as
you would be judge and party.

Regards,
Anton Khirnov Dec. 9, 2021, 1:47 p.m. UTC | #10
Quoting Nicolas George (2021-12-09 11:31:54)
> Anton Khirnov (12021-12-09):
> > I disagree. Technical limitations that were overcome 10 years ago should
> > not guide new API design.
> 
> In the case of amerge, it was not a technical limitation, merging
> several streams into one so that they can be handled by single-stream
> filters is 100% part of the design.

I fail to see how that is an advantage. You can just as well create
multiple instances of those single-stream filters instead of adding
hacks into core APIs.

> I suspect devices that capture several independent channels are
> designed that way intentionally too, possibly to reduce the risk of
> desynchronization.

"possibly" is not a strong enough argument. I'd like to hear at least
one clearly-defined use case that cannot just as well be handled by
using multiple streams.
Nicolas George Dec. 9, 2021, 1:52 p.m. UTC | #11
Anton Khirnov (12021-12-09):
> I fail to see how that is an advantage. You can just as well create
> multiple instances of those single-stream filters instead of adding
> hacks into core APIs.

Please think a little further: multiple instances of the single-stream
filters would not have access to all the channels.

> "possibly" is not a strong enough argument. I'd like to hear at least
> one clearly-defined use case that cannot just as well be handled by
> using multiple streams.

This was a discussion for when the device was implemented. Now, it works
that way, the new API has to accommodate it.

Anyway, these are just two example. I am sure we could find other
examples easily if we tried. It would be pretty stupid of us to add a
new API that is barely better than the current one and that we know is
too limited for likely use cases.

Regards,
Anton Khirnov Dec. 9, 2021, 2:19 p.m. UTC | #12
Quoting Nicolas George (2021-12-09 14:52:40)
> Anton Khirnov (12021-12-09):
> > I fail to see how that is an advantage. You can just as well create
> > multiple instances of those single-stream filters instead of adding
> > hacks into core APIs.
> 
> Please think a little further: multiple instances of the single-stream
> filters would not have access to all the channels.
> 
> > "possibly" is not a strong enough argument. I'd like to hear at least
> > one clearly-defined use case that cannot just as well be handled by
> > using multiple streams.
> 
> This was a discussion for when the device was implemented. Now, it works
> that way, the new API has to accommodate it.
> 
> Anyway, these are just two example. I am sure we could find other
> examples easily if we tried. It would be pretty stupid of us to add a
> new API that is barely better than the current one and that we know is
> too limited for likely use cases.

I see you repeating the same two arguments:
- it was implemented like this in the past and therefore must keep
  working exactly the same
- it might be useful under some vaguely specified conditions

Neither of these strikes me as a good enough reason to make major
changes to the API design. So again - can you describe a clearly-defined
use case that cannot just as well be handled by using multiple streams?
Empasis on "clearly defined", so not "I am sure we can find examples".
I would like to hear some of those examples. So far you have not
provided any.
Nicolas George Dec. 9, 2021, 2:24 p.m. UTC | #13
Anton Khirnov (12021-12-09):
> I see you repeating the same two arguments:
> - it was implemented like this in the past and therefore must keep
>   working exactly the same
> - it might be useful under some vaguely specified conditions
> 
> Neither of these strikes me as a good enough reason to make major
> changes to the API design.

I will turn this argument back on you: you have designed your API so
that it is too limited, it does not strike me as a good reason to make
major changes in existing filters and devices that have given
satisfaction to users for years.

Regards,
Lynne Dec. 9, 2021, 2:42 p.m. UTC | #14
9 Dec 2021, 15:24 by george@nsup.org:

> Anton Khirnov (12021-12-09):
>
>> I see you repeating the same two arguments:
>> - it was implemented like this in the past and therefore must keep
>>  working exactly the same
>> - it might be useful under some vaguely specified conditions
>>
>> Neither of these strikes me as a good enough reason to make major
>> changes to the API design.
>>
>
> I will turn this argument back on you: you have designed your API so
> that it is too limited, it does not strike me as a good reason to make
> major changes in existing filters and devices that have given
> satisfaction to users for years.
>

As a compromise, could we specify that while having multple
channels with the same ID in a single frame can happen and
can be generated by decoders, we would also specify that they
possibly won't be treated correctly by encoders and filters, and
could be outright dropped with a warning if unsupported.

I can see why having multiple channels with the
same ID can happen, an in fact, will, for custom user
layouts with more channels than there are IDs.
For example, an Opus stream containing a hundred or
so channels from multiple overlapping locations from a venue.
Each of those channels would have to have an ID of NONE,
because the codec mapping family doesn't carry such information
for such a configuration.
Hendrik Leppkes Dec. 9, 2021, 2:50 p.m. UTC | #15
On Thu, Dec 9, 2021 at 3:42 PM Lynne <dev@lynne.ee> wrote:
>
> 9 Dec 2021, 15:24 by george@nsup.org:
>
> > Anton Khirnov (12021-12-09):
> >
> >> I see you repeating the same two arguments:
> >> - it was implemented like this in the past and therefore must keep
> >>  working exactly the same
> >> - it might be useful under some vaguely specified conditions
> >>
> >> Neither of these strikes me as a good enough reason to make major
> >> changes to the API design.
> >>
> >
> > I will turn this argument back on you: you have designed your API so
> > that it is too limited, it does not strike me as a good reason to make
> > major changes in existing filters and devices that have given
> > satisfaction to users for years.
> >
>
> As a compromise, could we specify that while having multple
> channels with the same ID in a single frame can happen and
> can be generated by decoders, we would also specify that they
> possibly won't be treated correctly by encoders and filters, and
> could be outright dropped with a warning if unsupported.
>

Actually thats the worst part of it, and I would be happy to not have
to think about that, as an API user.
What kind of sense does a frame make that contains the same channel
twice? What am I ever supposed to do with that?

It sounds to me like some kind of theoretical design flaw is trying to
be solved at the wrong point, instead of clearly separating streams,
they are supposed to live together but somehow still be separate? That
just sounds like a hack to me. Two streams are two streams, not one
stream with somehow duplicated channels.

- Hendrik
Nicolas George Dec. 9, 2021, 2:57 p.m. UTC | #16
Hendrik Leppkes (12021-12-09):
> What kind of sense does a frame make that contains the same channel
> twice?

Imagine an orchestra recording:

Orchestra, front left
Orchestra, front center
Orchestra, front right
Orchestra, low freq
Orchestra, rear left
Orchestra, rear center
Winds, left
Winds, right
Percussions, left
Percussions, right
Strings, left
Strings, right

We cannot have enums for winds, percussions and strings, but we should
be able to label them properly left and right, and attach a string label
to each.

> What am I ever supposed to do with that?

Apply remixing matrices on channels from different parts of the
orchestra.

Let a very smart codec detect correlations, and therefore solutions for
better compression, between one section and another.

Regards,
Anton Khirnov Dec. 9, 2021, 2:57 p.m. UTC | #17
Quoting Lynne (2021-12-09 15:42:42)
> 9 Dec 2021, 15:24 by george@nsup.org:
> 
> > Anton Khirnov (12021-12-09):
> >
> >> I see you repeating the same two arguments:
> >> - it was implemented like this in the past and therefore must keep
> >>  working exactly the same
> >> - it might be useful under some vaguely specified conditions
> >>
> >> Neither of these strikes me as a good enough reason to make major
> >> changes to the API design.
> >>
> >
> > I will turn this argument back on you: you have designed your API so
> > that it is too limited, it does not strike me as a good reason to make
> > major changes in existing filters and devices that have given
> > satisfaction to users for years.
> >
> 
> As a compromise, could we specify that while having multple
> channels with the same ID in a single frame can happen and
> can be generated by decoders, we would also specify that they
> possibly won't be treated correctly by encoders and filters, and
> could be outright dropped with a warning if unsupported.

That is pretty much already the case. I know there are files in the wild
that have duplicated channels and the proposed API supports exporting
this information.

What I do _not_ want is treating such streams as first-class citizens
that have to be fully supported by everything. They are a pathology and
should be treated as such -- that is supported on input, but not output.

> 
> I can see why having multiple channels with the
> same ID can happen, an in fact, will, for custom user
> layouts with more channels than there are IDs.
> For example, an Opus stream containing a hundred or
> so channels from multiple overlapping locations from a venue.
> Each of those channels would have to have an ID of NONE,
> because the codec mapping family doesn't carry such information
> for such a configuration.

NONE is intended to be an invalid value, but we can add AV_CHAN_UNKNOWN
with a high id for such a case. Or we can reserve a range of ids for
application-specific usage.
Lynne Dec. 9, 2021, 3:47 p.m. UTC | #18
9 Dec 2021, 15:57 by anton@khirnov.net:

> Quoting Lynne (2021-12-09 15:42:42)
>
>> 9 Dec 2021, 15:24 by george@nsup.org:
>>
>> > Anton Khirnov (12021-12-09):
>> >
>> >> I see you repeating the same two arguments:
>> >> - it was implemented like this in the past and therefore must keep
>> >>  working exactly the same
>> >> - it might be useful under some vaguely specified conditions
>> >>
>> >> Neither of these strikes me as a good enough reason to make major
>> >> changes to the API design.
>> >>
>> >
>> > I will turn this argument back on you: you have designed your API so
>> > that it is too limited, it does not strike me as a good reason to make
>> > major changes in existing filters and devices that have given
>> > satisfaction to users for years.
>> >
>>
>> As a compromise, could we specify that while having multple
>> channels with the same ID in a single frame can happen and
>> can be generated by decoders, we would also specify that they
>> possibly won't be treated correctly by encoders and filters, and
>> could be outright dropped with a warning if unsupported.
>>
>
> That is pretty much already the case. I know there are files in the wild
> that have duplicated channels and the proposed API supports exporting
> this information.
>
> What I do _not_ want is treating such streams as first-class citizens
> that have to be fully supported by everything. They are a pathology and
> should be treated as such -- that is supported on input, but not output.
>
>>
>> I can see why having multiple channels with the
>> same ID can happen, an in fact, will, for custom user
>> layouts with more channels than there are IDs.
>> For example, an Opus stream containing a hundred or
>> so channels from multiple overlapping locations from a venue.
>> Each of those channels would have to have an ID of NONE,
>> because the codec mapping family doesn't carry such information
>> for such a configuration.
>>
>
> NONE is intended to be an invalid value, but we can add AV_CHAN_UNKNOWN
> with a high id for such a case. Or we can reserve a range of ids for
> application-specific usage.
>

I'm fine with this. I think an AV_CHAN_UNKNOWN ID is needed
pretty much anyway, and as for user IDs, maybe a single
AV_CHAN_CUSTOM or AV_CHAN_USER_DEFINED.
The user could then use the channel opaque field to store some
info, such as an index into their frame->opaque_ref data with
which they could store channel-specific offset.

So I'm fine with your proposal to have 16-bit enum for the channel
ID and a 16-bit opaque. Though I'd like the opaque to be an
uint16_t instead of int opaque : 16.
And 16-bits does sound like enough for many channels and quite a
few flags, though the silent flag should be moved to 1 << 15 instead
of 64, and any new flags could be added beneath so as to not conflict
with channels.
Nicolas George Dec. 9, 2021, 3:49 p.m. UTC | #19
Lynne (12021-12-09):
> So I'm fine with your proposal to have 16-bit enum for the channel
> ID and a 16-bit opaque. Though I'd like the opaque to be an
> uint16_t instead of int opaque : 16.
> And 16-bits does sound like enough for many channels and quite a
> few flags, though the silent flag should be moved to 1 << 15 instead
> of 64, and any new flags could be added beneath so as to not conflict
> with channels.

I insist: a tiny field like that is not enough, let us make it a whole
string.

Regards,
Hendrik Leppkes Dec. 9, 2021, 4:21 p.m. UTC | #20
On Thu, Dec 9, 2021 at 3:57 PM Nicolas George <george@nsup.org> wrote:
>
> Hendrik Leppkes (12021-12-09):
> > What kind of sense does a frame make that contains the same channel
> > twice?
>
> Imagine an orchestra recording:
>
> Orchestra, front left
> Orchestra, front center
> Orchestra, front right
> Orchestra, low freq
> Orchestra, rear left
> Orchestra, rear center
> Winds, left
> Winds, right
> Percussions, left
> Percussions, right
> Strings, left
> Strings, right
>
> We cannot have enums for winds, percussions and strings, but we should
> be able to label them properly left and right, and attach a string label
> to each.
>

It sounds like thats object audio, and should be driven separately,
and not by the legacy channel identifiers.

- Hendrik
Nicolas George Dec. 9, 2021, 4:26 p.m. UTC | #21
Hendrik Leppkes (12021-12-09):
> It sounds like thats object audio, and should be driven separately,
> and not by the legacy channel identifiers.

This is not exclusive. We have code that works with channel layouts
right now, and it is important that the extensions work gracefully.

For example, if I add a filter to just extract the pair of channels
related to the strings section, we want that its output is properly
marked as left and right.

Regards,
Paul B Mahol Dec. 9, 2021, 6:46 p.m. UTC | #22
On Thu, Dec 9, 2021 at 5:26 PM Nicolas George <george@nsup.org> wrote:

> Hendrik Leppkes (12021-12-09):
> > It sounds like thats object audio, and should be driven separately,
> > and not by the legacy channel identifiers.
>
> This is not exclusive. We have code that works with channel layouts
> right now, and it is important that the extensions work gracefully.
>
> For example, if I add a filter to just extract the pair of channels
> related to the strings section, we want that its output is properly
> marked as left and right.
>
> Why would it stop work with new API in place?


> Regards,
>
> --
>   Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Marton Balint Dec. 10, 2021, 12:04 a.m. UTC | #23
On Thu, 9 Dec 2021, Anton Khirnov wrote:

> Quoting Nicolas George (2021-12-09 11:31:54)
>> Anton Khirnov (12021-12-09):
>>> I disagree. Technical limitations that were overcome 10 years ago should
>>> not guide new API design.
>>
>> In the case of amerge, it was not a technical limitation, merging
>> several streams into one so that they can be handled by single-stream
>> filters is 100% part of the design.
>
> I fail to see how that is an advantage. You can just as well create
> multiple instances of those single-stream filters instead of adding
> hacks into core APIs.
>
>> I suspect devices that capture several independent channels are
>> designed that way intentionally too, possibly to reduce the risk of
>> desynchronization.
>
> "possibly" is not a strong enough argument. I'd like to hear at least
> one clearly-defined use case that cannot just as well be handled by
> using multiple streams.

I recently worked on the MXF demuxer to recognize channel designations in 
MXF files, and in MXF the designation and grouping of the channels is 
completely separate from the track those channels are muxed in.

So if you have e.g. english stereo sound, and german stereo sound you 
can mux it
- as a single 4 channel track
- as two 2 channel tracks
- as four 1 channel tracks.
Some MXF flavors use the multichannel single track approach, others the 
mono-track-only approach. So the user may not be able to choose the 
optimal muxed track assignment...

So ultimately, if you demux and decode a packet from a track, you will 
have an AVFrame, which might contain a single sound group on its own 
(optimal case), part of a sound group, or multiple sound groups.

To summerize, muxed tracks are not necessarily 1:1 mapping between sound 
groups. And when processing/filtering audio, you typically want sound 
groups, not tracks. And yes, it is very rare to have a soundgroup which 
has channels with the same designation, but for a muxed track, it depends 
on the format.

The goal of the end user is probably to be able to specify sound groups, 
not select muxed tracks. Preferably a demuxer should provide which channel 
is part of which sound group, and you should be able to use a filter or a 
combination of filters select a specific sound group. E.g. amerge all 
tracks, then keep only the channels from all the merged channels which are 
part of a specific sound group.

Regards,
Marton
Michael Niedermayer Dec. 10, 2021, 10:07 a.m. UTC | #24
On Thu, Dec 09, 2021 at 04:47:48PM +0100, Lynne wrote:
[...]
> So I'm fine with your proposal to have 16-bit enum for the channel
> ID and a 16-bit opaque. Though I'd like the opaque to be an
> uint16_t instead of int opaque : 16.
> And 16-bits does sound like enough for many channels and quite a
> few flags, though the silent flag should be moved to 1 << 15 instead
> of 64, and any new flags could be added beneath so as to not conflict
> with channels.

in how many cases where we use flags have 16 been enough ?

thx

[...]
Anton Khirnov Dec. 12, 2021, 7:34 p.m. UTC | #25
Quoting Marton Balint (2021-12-10 01:04:57)
> 
> 
> On Thu, 9 Dec 2021, Anton Khirnov wrote:
> 
> > Quoting Nicolas George (2021-12-09 11:31:54)
> >> Anton Khirnov (12021-12-09):
> >>> I disagree. Technical limitations that were overcome 10 years ago should
> >>> not guide new API design.
> >>
> >> In the case of amerge, it was not a technical limitation, merging
> >> several streams into one so that they can be handled by single-stream
> >> filters is 100% part of the design.
> >
> > I fail to see how that is an advantage. You can just as well create
> > multiple instances of those single-stream filters instead of adding
> > hacks into core APIs.
> >
> >> I suspect devices that capture several independent channels are
> >> designed that way intentionally too, possibly to reduce the risk of
> >> desynchronization.
> >
> > "possibly" is not a strong enough argument. I'd like to hear at least
> > one clearly-defined use case that cannot just as well be handled by
> > using multiple streams.
> 
> I recently worked on the MXF demuxer to recognize channel designations in 
> MXF files, and in MXF the designation and grouping of the channels is 
> completely separate from the track those channels are muxed in.
> 
> So if you have e.g. english stereo sound, and german stereo sound you 
> can mux it
> - as a single 4 channel track
> - as two 2 channel tracks
> - as four 1 channel tracks.
> Some MXF flavors use the multichannel single track approach, others the 
> mono-track-only approach. So the user may not be able to choose the 
> optimal muxed track assignment...
> 
> So ultimately, if you demux and decode a packet from a track, you will 
> have an AVFrame, which might contain a single sound group on its own 
> (optimal case), part of a sound group, or multiple sound groups.
> 
> To summerize, muxed tracks are not necessarily 1:1 mapping between sound 
> groups. And when processing/filtering audio, you typically want sound 
> groups, not tracks. And yes, it is very rare to have a soundgroup which 
> has channels with the same designation, but for a muxed track, it depends 
> on the format.
> 
> The goal of the end user is probably to be able to specify sound groups, 
> not select muxed tracks. Preferably a demuxer should provide which channel 
> is part of which sound group, and you should be able to use a filter or a 
> combination of filters select a specific sound group. E.g. amerge all 
> tracks, then keep only the channels from all the merged channels which are 
> part of a specific sound group.

So what are you proposing? In my view, such higher level information
should live at a higher level - e.g. in the side data. You can then
have a filter that reads this side data and gets you the group you want.
Nicolas George Dec. 12, 2021, 8 p.m. UTC | #26
Anton Khirnov (12021-12-12):
> So what are you proposing? In my view, such higher level information
> should live at a higher level - e.g. in the side data. You can then
> have a filter that reads this side data and gets you the group you want.

So, what is the point of this new API if anything of value needs to be
done with side data and yet another API?

It seems to me you are indulging in a sunken-costs fallacy: you wrote
this API and all the code but you neglected to poll your fellow
developers for needs that it should cover, and as a result got something
much too limited. But now, you are trying to force it anyway.

What I propose is:

(1) define the needs properly;

(2) redesign the API;

(3) see how much code can still be used.

The needs as far as I can see, please add to the list:

A. Allow the same channel to appear several time in the layout. Hendrik
agreed that it was useful for some kind of USER_SPECIFIED or UNKNOWN
channel specification, but allowing for any channel specification is
actually simpler.

It is not limited to just having the same channel in the list, it
requires API and user interface support: the API must be able to tell
the user "this USER_SPECIFIED channel is the oboe, this USER_SPECIFIED
is the piano", and the user must be able to tell the API "the second
USER_SPECIFIED channel" or "the USER_SPECIFIED channel relating to the
piano".

B. Possibly, I do not personally insist on it like A: groups of
channels.
Marton Balint Dec. 13, 2021, 10:47 p.m. UTC | #27
On Sun, 12 Dec 2021, Anton Khirnov wrote:

> Quoting Marton Balint (2021-12-10 01:04:57)
>>
>>
>> On Thu, 9 Dec 2021, Anton Khirnov wrote:
>>
>>> Quoting Nicolas George (2021-12-09 11:31:54)
>>>> Anton Khirnov (12021-12-09):
>>>>> I disagree. Technical limitations that were overcome 10 years ago should
>>>>> not guide new API design.
>>>>
>>>> In the case of amerge, it was not a technical limitation, merging
>>>> several streams into one so that they can be handled by single-stream
>>>> filters is 100% part of the design.
>>>
>>> I fail to see how that is an advantage. You can just as well create
>>> multiple instances of those single-stream filters instead of adding
>>> hacks into core APIs.
>>>
>>>> I suspect devices that capture several independent channels are
>>>> designed that way intentionally too, possibly to reduce the risk of
>>>> desynchronization.
>>>
>>> "possibly" is not a strong enough argument. I'd like to hear at least
>>> one clearly-defined use case that cannot just as well be handled by
>>> using multiple streams.
>>
>> I recently worked on the MXF demuxer to recognize channel designations in
>> MXF files, and in MXF the designation and grouping of the channels is
>> completely separate from the track those channels are muxed in.
>>
>> So if you have e.g. english stereo sound, and german stereo sound you
>> can mux it
>> - as a single 4 channel track
>> - as two 2 channel tracks
>> - as four 1 channel tracks.
>> Some MXF flavors use the multichannel single track approach, others the
>> mono-track-only approach. So the user may not be able to choose the
>> optimal muxed track assignment...
>>
>> So ultimately, if you demux and decode a packet from a track, you will
>> have an AVFrame, which might contain a single sound group on its own
>> (optimal case), part of a sound group, or multiple sound groups.
>>
>> To summerize, muxed tracks are not necessarily 1:1 mapping between sound
>> groups. And when processing/filtering audio, you typically want sound
>> groups, not tracks. And yes, it is very rare to have a soundgroup which
>> has channels with the same designation, but for a muxed track, it depends
>> on the format.
>>
>> The goal of the end user is probably to be able to specify sound groups,
>> not select muxed tracks. Preferably a demuxer should provide which channel
>> is part of which sound group, and you should be able to use a filter or a
>> combination of filters select a specific sound group. E.g. amerge all
>> tracks, then keep only the channels from all the merged channels which are
>> part of a specific sound group.
>
> So what are you proposing? In my view, such higher level information
> should live at a higher level - e.g. in the side data. You can then
> have a filter that reads this side data and gets you the group you want.

Does not look that simple to use side data for everything, because when 
you have a frame in a filter, you already should have configured the 
output channel layout... So unless you pass side data to filters somehow 
before initialization, it does not help you.

Regards,
Marton
James Almer Dec. 13, 2021, 11:10 p.m. UTC | #28
On 12/12/2021 5:00 PM, Nicolas George wrote:
> Anton Khirnov (12021-12-12):
>> So what are you proposing? In my view, such higher level information
>> should live at a higher level - e.g. in the side data. You can then
>> have a filter that reads this side data and gets you the group you want.
> 
> So, what is the point of this new API if anything of value needs to be
> done with side data and yet another API?
> 
> It seems to me you are indulging in a sunken-costs fallacy: you wrote
> this API and all the code but you neglected to poll your fellow
> developers for needs that it should cover, and as a result got something
> much too limited. But now, you are trying to force it anyway.
> 
> What I propose is:
> 
> (1) define the needs properly;
> 
> (2) redesign the API;
> 
> (3) see how much code can still be used.
> 
> The needs as far as I can see, please add to the list:
> 
> A. Allow the same channel to appear several time in the layout. Hendrik
> agreed that it was useful for some kind of USER_SPECIFIED or UNKNOWN
> channel specification, but allowing for any channel specification is
> actually simpler.
> 
> It is not limited to just having the same channel in the list, it
> requires API and user interface support: the API must be able to tell
> the user "this USER_SPECIFIED channel is the oboe, this USER_SPECIFIED
> is the piano", and the user must be able to tell the API "the second
> USER_SPECIFIED channel" or "the USER_SPECIFIED channel relating to the
> piano".

To achieve this you don't need the same AVChannel value to appear 
several times in the same layout. You have INT_MAX values available, so 
just assign one to each of these you mentioned. No need for an abstract 
value "user defined" that would then show up several times in a layout. 
Oboe can be 65, piano can be 66.
Also, each channel is meant to map to a speaker in a different physical 
location. If your idea is to have oboe and piano play through the same 
speaker, then you're thinking filtering, and that sounds beyond the 
scope of a channel layout API.

The user interface part to query and tell non standard AVChannel values 
apart in a human readable way is a different thing. That would probably 
require giving each channel a user defined name in some form.

> 
> B. Possibly, I do not personally insist on it like A: groups of
> channels.
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Nicolas George Dec. 13, 2021, 11:36 p.m. UTC | #29
James Almer (12021-12-13):
> To achieve this you don't need the same AVChannel value to appear several
> times in the same layout. You have INT_MAX values available, so just assign
> one to each of these you mentioned. No need for an abstract value "user
> defined" that would then show up several times in a layout. Oboe can be 65,
> piano can be 66.
> Also, each channel is meant to map to a speaker in a different physical
> location. If your idea is to have oboe and piano play through the same

The idea is that if some filters takes the oboe and piano from a single
stream and extracts them into two streams, then the left and right will
automatically be correctly marked left and right in the extracted
streams.

> speaker, then you're thinking filtering, and that sounds beyond the scope of
> a channel layout API.

Making sure existing filters and devices can flag the channel layout
they need, which they could not because of the limitation of the current
API, seems 100% in scope to me.

What is your definition of the scope of a channel layout API? I hope it
is not "we did it that way, anything it cannot do is beyond the scope".

Regards,
James Almer Dec. 14, 2021, 12:03 a.m. UTC | #30
On 12/13/2021 8:36 PM, Nicolas George wrote:
> James Almer (12021-12-13):
>> To achieve this you don't need the same AVChannel value to appear several
>> times in the same layout. You have INT_MAX values available, so just assign
>> one to each of these you mentioned. No need for an abstract value "user
>> defined" that would then show up several times in a layout. Oboe can be 65,
>> piano can be 66.
>> Also, each channel is meant to map to a speaker in a different physical
>> location. If your idea is to have oboe and piano play through the same
> 
> The idea is that if some filters takes the oboe and piano from a single
> stream and extracts them into two streams, then the left and right will
> automatically be correctly marked left and right in the extracted
> streams.

Can't user defined names let you do that without the need to reuse the 
same AVChannel value in a given layout? And for that matter, can you not 
set said names within the filter itself and not in the layout?

> 
>> speaker, then you're thinking filtering, and that sounds beyond the scope of
>> a channel layout API.
> 
> Making sure existing filters and devices can flag the channel layout
> they need, which they could not because of the limitation of the current
> API, seems 100% in scope to me.
> 
> What is your definition of the scope of a channel layout API? I hope it
> is not "we did it that way, anything it cannot do is beyond the scope".

Mapping a channel (each of the data pointers in a frame) to an specific 
output, like a speaker.

> 
> Regards,
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Anton Khirnov Dec. 14, 2021, 9:30 a.m. UTC | #31
Quoting Marton Balint (2021-12-13 23:47:22)
> On Sun, 12 Dec 2021, Anton Khirnov wrote:
> >
> > So what are you proposing? In my view, such higher level information
> > should live at a higher level - e.g. in the side data. You can then
> > have a filter that reads this side data and gets you the group you want.
> 
> Does not look that simple to use side data for everything, because when 
> you have a frame in a filter, you already should have configured the 
> output channel layout... So unless you pass side data to filters somehow 
> before initialization, it does not help you.

I don't see a big problem in adding stream (i.e. link-)-level side data
to avfilter. We already do this for hwcontexts (which btw need to be
better integrated into format negotiation).

It also seems to me that video properties like stereo3D or spherical
mapping are analogous to your MXF use case and they exist in side data.
Nicolas George Dec. 14, 2021, 1:03 p.m. UTC | #32
James Almer (12021-12-13):
> Can't user defined names let you do that without the need to reuse the same
> AVChannel value in a given layout? And for that matter, can you not set said
> names within the filter itself and not in the layout?

I do not see how they could. But as always, "I do not see how" is not an
argument, it only points to my limitations. So if you do know, please
let me know.

But I suspect we are talking at cross-purposes here. You say “the
filter”, singular, but the issue is not an isolated filter, the issue is
about several components working together in harmony. For example a
demuxer that knows about exotic layouts and labels such, but later a
filter that does not and only knows about standard channel identifiers.

> Mapping a channel (each of the data pointers in a frame) to an specific
> output, like a speaker.

I think this definition is too narrow. Currently, channel layouts are
also used to compute matrix coefficients for remixing, for example.

But even if we adopt this definition, mapping (oboe left, oboe right,
piano left, piano right) onto stereo is perfectly in scope.

Regards,
Nicolas George Dec. 14, 2021, 1:09 p.m. UTC | #33
Anton Khirnov (12021-12-14):
> I don't see a big problem in adding stream (i.e. link-)-level side data
> to avfilter.

It is not a problem. In fact, if we were to stay with “uint64_t
channel_layout”, that is probably what we would do. But we are
discussing a new API that could be very much exactly what we need here.

Again: if it does not help in these kind of cases, what is the point of
the proposed API?

Let us either keep “uint64_t channel_layout” or move to something really
significantly more powerful. But as it is, it is a waste of effort.

>		We already do this for hwcontexts (which btw need to be
> better integrated into format negotiation).

Interesting remark. I do not know hwcontexts in lavfi enough. Please
elaborate if you can.

But anyway, we are not currently discussing a rework of the whole
hwcontext API. And if we were, and somebody suggested we leave two
thirds of the uses cases for something else in side data, I would object
to.
James Almer Dec. 14, 2021, 9:26 p.m. UTC | #34
On 12/14/2021 10:03 AM, Nicolas George wrote:
> James Almer (12021-12-13):
>> Can't user defined names let you do that without the need to reuse the same
>> AVChannel value in a given layout? And for that matter, can you not set said
>> names within the filter itself and not in the layout?
> 
> I do not see how they could. But as always, "I do not see how" is not an
> argument, it only points to my limitations. So if you do know, please
> let me know.

You have a stream with four channels, you set up a custom order layout 
where you pick any four unused ids and call them OboeFL, OboeFR, 
PianoFL, PianoFR in u.map[], then split the streams (retaining strings 
and ids), pass them to channelmap using 
channelmap=map=OboeFL-FL|OboeFR-FR once support is added an so on. Or am 
i missing something?

> 
> But I suspect we are talking at cross-purposes here. You say “the
> filter”, singular, but the issue is not an isolated filter, the issue is
> about several components working together in harmony. For example a
> demuxer that knows about exotic layouts and labels such, but later a
> filter that does not and only knows about standard channel identifiers.
> 
>> Mapping a channel (each of the data pointers in a frame) to an specific
>> output, like a speaker.
> 
> I think this definition is too narrow. Currently, channel layouts are
> also used to compute matrix coefficients for remixing, for example.
> 
> But even if we adopt this definition, mapping (oboe left, oboe right,
> piano left, piano right) onto stereo is perfectly in scope.
> 
> Regards,
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Nicolas George Dec. 15, 2021, 10:53 a.m. UTC | #35
James Almer (12021-12-14):
> You have a stream with four channels, you set up a custom order layout where
> you pick any four unused ids and call them OboeFL, OboeFR, PianoFL, PianoFR
> in u.map[], then split the streams (retaining strings and ids), pass them to
> channelmap using channelmap=map=OboeFL-FL|OboeFR-FR once support is added an
> so on. Or am i missing something?

You are thinking too small. You are letting the users fend for
themselves, while we could make sure that everything is automatic. If we
can, then we should.

What I want is this: if the demuxer knows the label, then the user can
write:
	pan='stereo=0.3*.oboe+0.7*.piano'
and the system automatically pick the channels from the oboe and the
piano and figure out the matrix (if the oboe is recorded in mono for
example).

Regards,