diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-05-28 12:49:28 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-28 12:49:28 +0200 |
commit | 1c0ce2d4e0e70fcc42aa73fb5284f621025bb6c4 (patch) | |
tree | 08d7d701df1802b6f72d84eb67e9962415ff8a13 | |
parent | 69de229bb8818e97c88ad34840c9bd4a6854b647 (diff) | |
parent | 4efdadc8ec50332c812e8a95e8c67f5a260e7cb0 (diff) | |
download | ffmpeg-1c0ce2d4e0e70fcc42aa73fb5284f621025bb6c4.tar.gz |
Merge commit '4efdadc8ec50332c812e8a95e8c67f5a260e7cb0'
* commit '4efdadc8ec50332c812e8a95e8c67f5a260e7cb0':
matroskadec: export just the STREAMINFO block as FLAC extradata
Conflicts:
libavformat/matroskadec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/matroskadec.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 956abbaa2a..77c4eb0f07 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -48,6 +48,7 @@ #include "libavutil/mathematics.h" #include "libavcodec/bytestream.h" +#include "libavcodec/flac.h" #include "libavcodec/mpeg4audio.h" #include "avformat.h" @@ -1570,12 +1571,30 @@ static void matroska_metadata_creation_time(AVDictionary **metadata, int64_t dat av_dict_set(metadata, "creation_time", buffer, 0); } +static int matroska_parse_flac(AVFormatContext *s, + MatroskaTrack *track, + int *offset) +{ + uint8_t *p = track->codec_priv.data; + int size = track->codec_priv.size; + + if (size < 8 + FLAC_STREAMINFO_SIZE || p[4] & 0x7f) { + av_log(s, AV_LOG_WARNING, "Invalid FLAC private data\n"); + track->codec_priv.size = 0; + return 0; + } + *offset = 8; + track->codec_priv.size = 8 + FLAC_STREAMINFO_SIZE; + + return 0; +} + static int matroska_parse_tracks(AVFormatContext *s) { MatroskaDemuxContext *matroska = s->priv_data; MatroskaTrack *tracks = matroska->tracks.elem; AVStream *st; - int i, j; + int i, j, ret; int k; for (i = 0; i < matroska->tracks.nb_elem; i++) { @@ -1854,6 +1873,10 @@ static int matroska_parse_tracks(AVFormatContext *s) st->codec->block_align = track->audio.sub_packet_size; extradata_offset = 78; } + } else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) { + ret = matroska_parse_flac(s, track, &extradata_offset); + if (ret < 0) + return ret; } else if (codec_id == AV_CODEC_ID_PRORES && track->codec_priv.size == 4) { fourcc = AV_RL32(track->codec_priv.data); } |