]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/matroskaenc.c
Remove useless intermediate variable
[ffmpeg] / libavformat / matroskaenc.c
index 2c1f542e1fd665257016e45d7a3200c6b9e97299..f799182c60c6d3efad005212929af107e9f515d2 100644 (file)
  */
 
 #include "avformat.h"
-#include "md5.h"
 #include "riff.h"
-#include "xiph.h"
 #include "matroska.h"
 #include "avc.h"
+#include "libavutil/md5.h"
+#include "libavcodec/xiph.h"
+#include "libavcodec/mpeg4audio.h"
 
 typedef struct ebml_master {
     offset_t        pos;                ///< absolute offset in the file where the master's elements start
@@ -149,7 +150,8 @@ static void put_ebml_num(ByteIOContext *pb, uint64_t num, int bytes)
 static void put_ebml_uint(ByteIOContext *pb, unsigned int elementid, uint64_t val)
 {
     int i, bytes = 1;
-    while (val >> bytes*8) bytes++;
+    uint64_t tmp = val;
+    while (tmp>>=8) bytes++;
 
     put_ebml_id(pb, elementid);
     put_ebml_num(pb, bytes, 0);
@@ -427,9 +429,12 @@ static int put_flac_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecCont
         return -1;
     } else if (codec->extradata_size == FLAC_STREAMINFO_SIZE) {
         // only the streaminfo packet
-        put_byte(pb, 0);
-        put_xiph_size(pb, codec->extradata_size);
-        av_log(s, AV_LOG_ERROR, "Only one packet\n");
+        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;
@@ -437,10 +442,6 @@ static int put_flac_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecCont
 
 static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int *sample_rate, int *output_sample_rate)
 {
-    static const int aac_sample_rates[] = {
-        96000, 88200, 64000, 48000, 44100, 32000,
-        24000, 22050, 16000, 12000, 11025,  8000,
-    };
     int sri;
 
     if (codec->extradata_size < 2) {
@@ -453,7 +454,7 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int
         av_log(s, AV_LOG_WARNING, "AAC samplerate index out of bounds\n");
         return;
     }
-    *sample_rate = aac_sample_rates[sri];
+    *sample_rate = ff_mpeg4audio_sample_rates[sri];
 
     // if sbr, get output sample rate as well
     if (codec->extradata_size == 5) {
@@ -462,7 +463,7 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int
             av_log(s, AV_LOG_WARNING, "AAC output samplerate index out of bounds\n");
             return;
         }
-        *output_sample_rate = aac_sample_rates[sri];
+        *output_sample_rate = ff_mpeg4audio_sample_rates[sri];
     }
 }
 
@@ -549,6 +550,8 @@ static int mkv_write_tracks(AVFormatContext *s)
         else
             put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, "und");
 
+        put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT));
+
         // look for a codec ID string specific to mkv to use,
         // if none are found, use AVI codes
         for (j = 0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++) {