*/
#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);
put_ebml_num(pb, size-1, 0);
else
put_ebml_num(pb, size-9, 8);
- url_fseek(pb, currentpos + size, SEEK_SET);
+ while(url_ftell(pb) < currentpos + size)
+ put_byte(pb, 0);
}
static ebml_master start_ebml_master(ByteIOContext *pb, unsigned int elementid, uint64_t expectedsize)
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 if (codec->codec_id == CODEC_ID_FLAC)
ret = put_flac_codecpriv(s, dyn_cp, codec);
else if (codec->codec_id == CODEC_ID_H264)
- ret = isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size);
+ ret = ff_isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size);
else if (codec->extradata_size)
put_buffer(dyn_cp, codec->extradata, codec->extradata_size);
} else if (codec->codec_type == CODEC_TYPE_VIDEO) {
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++) {
codec->extradata_size > 0 && AV_RB32(codec->extradata) == 0x00000001) {
/* from x264 or from bytestream h264 */
/* nal reformating needed */
- int ret = avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size);
+ int ret = ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size);
if (ret < 0)
return ret;
assert(pkt->size);