return 0;
}
+static int mov_metadata_int8(MOVContext *c, AVIOContext *pb,
+ unsigned len, const char *key)
+{
+ char buf[16];
+
+ /* bypass padding bytes */
+ avio_r8(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+
+ snprintf(buf, sizeof(buf), "%hu", avio_r8(pb));
+ av_dict_set(&c->fc->metadata, key, buf, 0);
+
+ return 0;
+}
+
+static int mov_metadata_stik(MOVContext *c, AVIOContext *pb,
+ unsigned len, const char *key)
+{
+ char buf[16];
+
+ snprintf(buf, sizeof(buf), "%hu", avio_r8(pb));
+ av_dict_set(&c->fc->metadata, key, buf, 0);
+
+ return 0;
+}
+
static const uint32_t mac_to_unicode[128] = {
0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
parse = mov_metadata_track_or_disc_number; break;
case MKTAG( 'd','i','s','k'): key = "disc";
parse = mov_metadata_track_or_disc_number; break;
+ case MKTAG( 't','v','e','s'): key = "episode_sort";
+ parse = mov_metadata_int8; break;
+ case MKTAG( 't','v','s','n'): key = "season_number";
+ parse = mov_metadata_int8; break;
+ case MKTAG( 's','t','i','k'): key = "media_type";
+ parse = mov_metadata_stik; break;
}
if (c->itunes_metadata && atom.size > 8) {
sc->ctts_data[i].count = count;
sc->ctts_data[i].duration= duration;
- if (duration < 0 && i+1<entries)
+ if (duration < 0 && i+2<entries)
sc->dts_shift = FFMAX(sc->dts_shift, -duration);
}
// The samples could theoretically be in any encoding if there's an encd
// atom following, but in practice are only utf-8 or utf-16, distinguished
// instead by the presence of a BOM
- ch = avio_rb16(sc->pb);
- if (ch == 0xfeff)
- avio_get_str16be(sc->pb, len, title, title_len);
- else if (ch == 0xfffe)
- avio_get_str16le(sc->pb, len, title, title_len);
- else {
- AV_WB16(title, ch);
- get_strz(sc->pb, title + 2, len - 1);
+ if (!len) {
+ title[0] = 0;
+ } else {
+ ch = avio_rb16(sc->pb);
+ if (ch == 0xfeff)
+ avio_get_str16be(sc->pb, len, title, title_len);
+ else if (ch == 0xfffe)
+ avio_get_str16le(sc->pb, len, title, title_len);
+ else {
+ AV_WB16(title, ch);
+ if (len == 1 || len == 2)
+ title[len] = 0;
+ else
+ get_strz(sc->pb, title + 2, len - 1);
+ }
}
ff_new_chapter(s, i, st->time_base, sample->timestamp, end, title);