summaryrefslogtreecommitdiff
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2009-02-26 02:29:24 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2009-02-26 02:29:24 +0000
commit59c6178a54c414fd19e064f0077d00b82a1eb812 (patch)
tree69bc8f09fc89959005fa8527d6822cc2eeea96c0 /libavformat/matroskaenc.c
parentcaee91f7d038f80893b3c1ccdcd1bc44a9a19351 (diff)
Use a shared function to validate FLAC extradata.
Originally committed as revision 17602 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 44787be2d2..0b0adef1ba 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -28,6 +28,7 @@
#include "libavutil/md5.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
+#include "libavcodec/flac.h"
typedef struct ebml_master {
int64_t pos; ///< absolute offset in the file where the master's elements start
@@ -420,23 +421,20 @@ static int put_xiph_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecCont
return 0;
}
-#define FLAC_STREAMINFO_SIZE 34
-
static int put_flac_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec)
{
- // if the extradata_size is greater than FLAC_STREAMINFO_SIZE,
- // assume that it's in Matroska format already
- if (codec->extradata_size < FLAC_STREAMINFO_SIZE) {
+ uint8_t *streaminfo;
+ enum FLACExtradataFormat format;
+
+ if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo)) {
av_log(s, AV_LOG_ERROR, "Invalid FLAC extradata\n");
return -1;
- } else if (codec->extradata_size == FLAC_STREAMINFO_SIZE) {
+ }
+ if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) {
// only the streaminfo packet
put_buffer(pb, "fLaC", 4);
put_byte(pb, 0x80);
put_be24(pb, FLAC_STREAMINFO_SIZE);
- } else if(memcmp("fLaC", codec->extradata, 4)) {
- av_log(s, AV_LOG_ERROR, "Invalid FLAC extradata\n");
- return -1;
}
put_buffer(pb, codec->extradata, codec->extradata_size);
return 0;