[FFmpeg-devel] [PATCH] libavcodec/opus: Add channel mapping 2 to extradata parser

Michael Niedermayer michael at niedermayer.cc
Thu Sep 1 00:08:48 EEST 2016


On Tue, Aug 30, 2016 at 02:48:07PM -0700, Michael Graczyk wrote:
> This allows libavcodec/opus to demux ambisonics in an ogg/opus container.
> Channel mapping family 2 is being added in this standards track IETF draft:
> tools.ietf.org/html/draft-ietf-codec-ambisonics-00
> ---
>  libavcodec/opus.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/opus.c b/libavcodec/opus.c
> index 703d2e8..db758e9 100644
> --- a/libavcodec/opus.c
> +++ b/libavcodec/opus.c
> @@ -328,7 +328,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
>  
>      channels = avctx->extradata ? extradata[9] : (avctx->channels == 1) ? 1 : 2;
>      if (!channels) {
> -        av_log(avctx, AV_LOG_ERROR, "Zero channel count specified in the extadata\n");
> +        av_log(avctx, AV_LOG_ERROR, "Zero channel count specified in the extradata\n");
>          return AVERROR_INVALIDDATA;
>      }
>  

unrelated change, please put this in a separate patch


> @@ -347,7 +347,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
>          streams        = 1;
>          stereo_streams = channels - 1;
>          channel_map    = default_channel_map;
> -    } else if (map_type == 1 || map_type == 255) {
> +    } else if (map_type == 1 || map_type == 2 || map_type == 255) {
>          if (extradata_size < 21 + channels) {
>              av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n",
>                     extradata_size);
> @@ -371,6 +371,15 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
>              }
>              layout = ff_vorbis_channel_layouts[channels - 1];
>              channel_reorder = channel_reorder_vorbis;
> +        } else if (map_type == 2) {

> +            int ambisonic_order = ((int)sqrt(channels)) - 1;

ff_sqrt() to avoid float rounding

thx
[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160831/3d49b973/attachment.sig>


More information about the ffmpeg-devel mailing list