*/
#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
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);
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;
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) {
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) {
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];
}
}
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++) {