X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fflacenc_header.c;h=4f9bb206e513869ef47620efea3ba4567c089eac;hb=d60c2d5216930ef98c7d4d6837d6229b37e0dcb3;hp=ad8d55b380492b64ac36e690d1968bd3f2875cb6;hpb=d9cca9fc6a4796c0a4235b25f5f7fd7191813f3a;p=ffmpeg diff --git a/libavformat/flacenc_header.c b/libavformat/flacenc_header.c index ad8d55b3804..4f9bb206e51 100644 --- a/libavformat/flacenc_header.c +++ b/libavformat/flacenc_header.c @@ -19,31 +19,44 @@ * 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" #include "flacenc.h" -int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec, - int last_block) +int ff_flac_write_header(AVIOContext *pb, uint8_t *extradata, + int extradata_size, int last_block) { uint8_t header[8] = { 0x66, 0x4C, 0x61, 0x43, 0x00, 0x00, 0x00, 0x22 }; - uint8_t *streaminfo; - enum FLACExtradataFormat format; header[4] = last_block ? 0x80 : 0x00; - if (!avpriv_flac_is_extradata_valid(codec, &format, &streaminfo)) - return -1; - /* write "fLaC" stream marker and first metadata block header if needed */ - if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) { - avio_write(pb, header, 8); - } + if (extradata_size < FLAC_STREAMINFO_SIZE) + return AVERROR_INVALIDDATA; - /* write STREAMINFO or full header */ - avio_write(pb, codec->extradata, codec->extradata_size); + /* write "fLaC" stream marker and first metadata block header */ + avio_write(pb, header, 8); + /* write STREAMINFO */ + avio_write(pb, extradata, FLAC_STREAMINFO_SIZE); + + 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; }