Browse code

Put ff_flac_write_header() in a separate C file to allow it to be shared without duplicating code or adding a dependency on vorbiscomment.o.

Originally committed as revision 22652 to svn://svn.ffmpeg.org/ffmpeg/trunk

Justin Ruggles authored on 2010/03/24 08:58:45
Showing 3 changed files
... ...
@@ -71,7 +71,8 @@ OBJS-$(CONFIG_FILMSTRIP_MUXER)           += filmstripenc.o
71 71
 OBJS-$(CONFIG_FLAC_DEMUXER)              += flacdec.o raw.o id3v1.o \
72 72
                                             id3v2.o oggparsevorbis.o \
73 73
                                             vorbiscomment.o
74
-OBJS-$(CONFIG_FLAC_MUXER)                += flacenc.o vorbiscomment.o
74
+OBJS-$(CONFIG_FLAC_MUXER)                += flacenc.o flacenc_header.o \
75
+                                            vorbiscomment.o
75 76
 OBJS-$(CONFIG_FLIC_DEMUXER)              += flic.o
76 77
 OBJS-$(CONFIG_FLV_DEMUXER)               += flvdec.o
77 78
 OBJS-$(CONFIG_FLV_MUXER)                 += flvenc.o avc.o
... ...
@@ -103,7 +104,8 @@ OBJS-$(CONFIG_M4V_MUXER)                 += raw.o
103 103
 OBJS-$(CONFIG_MATROSKA_DEMUXER)          += matroskadec.o matroska.o \
104 104
                                             riff.o isom.o rmdec.o rm.o
105 105
 OBJS-$(CONFIG_MATROSKA_MUXER)            += matroskaenc.o matroska.o \
106
-                                            riff.o isom.o avc.o
106
+                                            riff.o isom.o avc.o \
107
+                                            flacenc_header.o
107 108
 OBJS-$(CONFIG_MJPEG_DEMUXER)             += raw.o
108 109
 OBJS-$(CONFIG_MJPEG_MUXER)               += raw.o
109 110
 OBJS-$(CONFIG_MLP_DEMUXER)               += raw.o id3v2.o
... ...
@@ -26,28 +26,7 @@
26 26
 #include "libavcodec/bytestream.h"
27 27
 #include "avformat.h"
28 28
 
29
-static int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec,
30
-                                int last_block)
31
-{
32
-    uint8_t header[8] = {
33
-        0x66, 0x4C, 0x61, 0x43, 0x00, 0x00, 0x00, 0x22
34
-    };
35
-    uint8_t *streaminfo;
36
-    enum FLACExtradataFormat format;
37
-
38
-    header[4] = last_block ? 0x80 : 0x00;
39
-    if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo))
40
-        return -1;
41
-
42
-    /* write "fLaC" stream marker and first metadata block header if needed */
43
-    if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) {
44
-        put_buffer(pb, header, 8);
45
-    }
46
-
47
-    /* write STREAMINFO or full header */
48
-    put_buffer(pb, codec->extradata, codec->extradata_size);
49
-
50
-    return 0;
51
-}
29
+int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec,
30
+                         int last_block);
52 31
 
53 32
 #endif /* AVFORMAT_FLACENC_H */
54 33
new file mode 100644
... ...
@@ -0,0 +1,49 @@
0
+/*
1
+ * raw FLAC muxer
2
+ * Copyright (C) 2009 Justin Ruggles
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+#include "libavcodec/flac.h"
22
+#include "libavcodec/bytestream.h"
23
+#include "avformat.h"
24
+#include "flacenc.h"
25
+
26
+int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec,
27
+                         int last_block)
28
+{
29
+    uint8_t header[8] = {
30
+        0x66, 0x4C, 0x61, 0x43, 0x00, 0x00, 0x00, 0x22
31
+    };
32
+    uint8_t *streaminfo;
33
+    enum FLACExtradataFormat format;
34
+
35
+    header[4] = last_block ? 0x80 : 0x00;
36
+    if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo))
37
+        return -1;
38
+
39
+    /* write "fLaC" stream marker and first metadata block header if needed */
40
+    if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) {
41
+        put_buffer(pb, header, 8);
42
+    }
43
+
44
+    /* write STREAMINFO or full header */
45
+    put_buffer(pb, codec->extradata, codec->extradata_size);
46
+
47
+    return 0;
48
+}