diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-05-28 12:28:23 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-28 12:28:23 +0200 |
commit | 61301ca7860fb044995c71a0cd432cb3d833eb3b (patch) | |
tree | ebe79c242179339032ea8528a3a5bb0b65457fff /libavformat | |
parent | 03ffaed3f0199f82ae32c28923f41f22123aea95 (diff) | |
parent | 54ed488b1af583df6c9d2a73b4a44f16b7e4f82c (diff) | |
download | ffmpeg-61301ca7860fb044995c71a0cd432cb3d833eb3b.tar.gz |
Merge commit '54ed488b1af583df6c9d2a73b4a44f16b7e4f82c'
* commit '54ed488b1af583df6c9d2a73b4a44f16b7e4f82c':
flac muxer: write WAVEFORMATEXTENSIBLE_CHANNEL_MASK tag for multichannel files
Conflicts:
libavformat/flacenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/flacenc.c | 18 | ||||
-rw-r--r-- | libavformat/flacenc.h | 2 | ||||
-rw-r--r-- | libavformat/flacenc_header.c | 16 |
3 files changed, 36 insertions, 0 deletions
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index d92801807e..f0b7d2956e 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" @@ -97,6 +98,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, !padding, s->flags & AVFMT_FLAG_BITEXACT); if (ret) diff --git a/libavformat/flacenc.h b/libavformat/flacenc.h index e83ee32aeb..2e9ee37766 100644 --- a/libavformat/flacenc.h +++ b/libavformat/flacenc.h @@ -29,4 +29,6 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec, int last_block); +int ff_flac_is_native_layout(uint64_t channel_layout); + #endif /* AVFORMAT_FLACENC_H */ diff --git a/libavformat/flacenc_header.c b/libavformat/flacenc_header.c index e16c14bf53..4dd89b1903 100644 --- a/libavformat/flacenc_header.c +++ b/libavformat/flacenc_header.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/channel_layout.h" + #include "libavcodec/flac.h" #include "libavcodec/bytestream.h" #include "avformat.h" @@ -45,3 +47,17 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec, return 0; } + +int ff_flac_is_native_layout(uint64_t channel_layout) +{ + if (channel_layout == AV_CH_LAYOUT_MONO || + channel_layout == AV_CH_LAYOUT_STEREO || + channel_layout == AV_CH_LAYOUT_SURROUND || + channel_layout == AV_CH_LAYOUT_QUAD || + channel_layout == AV_CH_LAYOUT_5POINT0 || + channel_layout == AV_CH_LAYOUT_5POINT1 || + channel_layout == AV_CH_LAYOUT_6POINT1 || + channel_layout == AV_CH_LAYOUT_7POINT1) + return 1; + return 0; +} |