]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/flacenc_header.c
mp3dec: read the initial/trailing padding from the LAME tag
[ffmpeg] / libavformat / flacenc_header.c
index ad8d55b380492b64ac36e690d1968bd3f2875cb6..4f9bb206e513869ef47620efea3ba4567c089eac 100644 (file)
  * 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;
 }