Merge commit '4efdadc8ec50332c812e8a95e8c67f5a260e7cb0'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 28 May 2014 10:49:28 +0000 (12:49 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 28 May 2014 10:49:28 +0000 (12:49 +0200)
* commit '4efdadc8ec50332c812e8a95e8c67f5a260e7cb0':
  matroskadec: export just the STREAMINFO block as FLAC extradata

Conflicts:
libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/matroskadec.c

@@@ -1559,24 -1439,30 +1560,42 @@@ static int matroska_aac_sri(int sampler
      return sri;
  }
  
 +static void matroska_metadata_creation_time(AVDictionary **metadata, int64_t date_utc)
 +{
 +    char buffer[32];
 +    /* Convert to seconds and adjust by number of seconds between 2001-01-01 and Epoch */
 +    time_t creation_time = date_utc / 1000000000 + 978307200;
 +    struct tm *ptm = gmtime(&creation_time);
 +    if (!ptm) return;
 +    strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm);
 +    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++) {
          MatroskaTrack *track = &tracks[i];
                  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);
          }
          track->codec_priv.size -= extradata_offset;