On 05/26/2014 07:56 AM, Anton Khirnov wrote:
> ---
>  libavformat/flacenc.c |   18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
> index 8a23163..dc75133 100644
> --- a/libavformat/flacenc.c
> +++ b/libavformat/flacenc.c
> @@ -19,6 +19,7 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
>   */
>  
> +#include "libavutil/channel_layout.h"
>  #include "libavutil/opt.h"
>  #include "libavcodec/flac.h"
>  #include "avformat.h"
> @@ -83,6 +84,23 @@ static int flac_write_header(struct AVFormatContext *s)
>      if (ret)
>          return ret;
>  
> +    /* add the channel layout tag */
> +    if (codec->channel_layout &&
> +        codec->channel_layout != AV_CH_LAYOUT_MONO &&
> +        codec->channel_layout != AV_CH_LAYOUT_STEREO) {
> +        AVDictionaryEntry *chmask = av_dict_get(s->metadata, 
> "WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
> +                                                NULL, 0);
> +
> +        if (chmask) {
> +            av_log(s, AV_LOG_WARNING, "A WAVEFORMATEXTENSIBLE_CHANNEL_MASK 
> is "
> +                   "already present, this muxer will not overwrite it.\n");
> +        } else {
> +            uint8_t buf[32];
> +            snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);
> +            av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", 
> buf, 0);
> +        }
> +    }
> +
>      ret = flac_write_block_comment(s->pb, &s->metadata, 0,
>                                     s->flags & AVFMT_FLAG_BITEXACT);
>      if (ret)

FLAC does have a pre-defined set of assumed layouts for a given channel
count. I would check the layout against those rather than just mono and
stereo.

-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to