sub: attempt to use video FPS for frame based subtitle formats

This only affects demux_subreader.c for now. Maybe there is some hope
this can be used for libavformat demuxers too, but I'm not sure yet.
This commit is contained in:
wm4 2013-06-23 22:14:43 +02:00
parent cfa45c40dc
commit feb64c2717
3 changed files with 6 additions and 0 deletions

View File

@ -1500,6 +1500,7 @@ static int d_check_file(struct demuxer *demuxer)
p->sh = new_sh_stream(demuxer, STREAM_SUB);
p->sh->codec = sd->codec;
p->sh->sub->frame_based = !sd->sub_uses_time;
add_sub_data(demuxer, sd);
subdata_free(sd);

View File

@ -163,6 +163,7 @@ typedef struct sh_sub {
SH_COMMON
unsigned char *extradata; // extra header data passed from demuxer
int extradata_len;
int frame_based; // timestamps are frame-based
struct ass_track *track; // loaded by libass
struct dec_sub *dec_sub; // decoder context
} sh_sub_t;

View File

@ -275,6 +275,10 @@ bool sub_read_all_packets(struct dec_sub *sub, struct sh_sub *sh)
MP_TARRAY_APPEND(tmp, subs.packets, subs.num_packets, pkt);
}
// 23.976 FPS is used as default timebase for frame based formats
if (sub->video_fps && sh->frame_based)
multiply_timings(&subs, sub->video_fps / 23.976);
if (opts->sub_fps && sub->video_fps)
multiply_timings(&subs, opts->sub_fps / sub->video_fps);