#include <stdlib.h>
#include "libavutil/avstring.h"
#include "libavutil/bswap.h"
+#include "libavutil/dict.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
+#include "internal.h"
#include "oggdec.h"
#include "vorbiscomment.h"
if (sscanf(val, "%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4)
return 0;
- ff_new_chapter(as, cnum, (AVRational){1,1000},
+ avpriv_new_chapter(as, cnum, (AVRational){1,1000},
ms + 1000*(s + 60*(m + 60*h)),
AV_NOPTS_VALUE, NULL);
av_free(val);
if (!chapter)
return 0;
- av_metadata_set2(&chapter->metadata, "title", val,
- AV_METADATA_DONT_STRDUP_VAL);
+ av_dict_set(&chapter->metadata, "title", val,
+ AV_DICT_DONT_STRDUP_VAL);
} else
return 0;
}
int
-ff_vorbis_comment(AVFormatContext * as, AVMetadata **m, const uint8_t *buf, int size)
+ff_vorbis_comment(AVFormatContext * as, AVDictionary **m, const uint8_t *buf, int size)
{
const uint8_t *p = buf;
const uint8_t *end = buf + size;
ct[vl] = 0;
if (!ogm_chapter(as, tt, ct))
- av_metadata_set2(m, tt, ct,
- AV_METADATA_DONT_STRDUP_KEY |
- AV_METADATA_DONT_STRDUP_VAL);
+ av_dict_set(m, tt, ct,
+ AV_DICT_DONT_STRDUP_KEY |
+ AV_DICT_DONT_STRDUP_VAL);
}
}
if (srate > 0) {
st->codec->sample_rate = srate;
- st->time_base.num = 1;
- st->time_base.den = srate;
+ av_set_pts_info(st, 64, 1, srate);
}
} else if (os->buf[os->pstart] == 3) {
- if (os->psize > 8)
- ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 7, os->psize - 8);
+ if (os->psize > 8 &&
+ ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7, os->psize - 8) >= 0) {
+ // drop all metadata we parsed and which is not required by libvorbis
+ unsigned new_len = 7 + 4 + AV_RL32(priv->packet[1] + 7) + 4 + 1;
+ if (new_len >= 16 && new_len < os->psize) {
+ AV_WL32(priv->packet[1] + new_len - 5, 0);
+ priv->packet[1][new_len - 1] = 1;
+ priv->len[1] = new_len;
+ }
+ }
} else {
st->codec->extradata_size =
fixup_vorbis_headers(s, priv, &st->codec->extradata);