diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-05-25 11:34:32 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-05-28 07:47:31 +0200 |
commit | 54ed488b1af583df6c9d2a73b4a44f16b7e4f82c (patch) | |
tree | 86ebb30c14f087e7050b2ee1612e48c0b4dd1876 /libavformat/flacenc.c | |
parent | d6b9ce99ea384fb676561461768b8316725a4ccd (diff) | |
download | ffmpeg-54ed488b1af583df6c9d2a73b4a44f16b7e4f82c.tar.gz |
flac muxer: write WAVEFORMATEXTENSIBLE_CHANNEL_MASK tag for multichannel files
Diffstat (limited to 'libavformat/flacenc.c')
-rw-r--r-- | libavformat/flacenc.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index 8a23163772..021891dbc3 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 & ~0x3ffffULL) && + !ff_flac_is_native_layout(codec->channel_layout)) { + 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) |