mirror of
https://github.com/mpv-player/mpv
synced 2025-02-03 05:31:34 +00:00
dec_sub: change sublist memory allocation
This commit is contained in:
parent
5dcae2481d
commit
74c56309a3
@ -348,8 +348,7 @@ bool sub_read_all_packets(struct dec_sub *sub, struct sh_sub *sh)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const char *codec = sh->gsh->codec ? sh->gsh->codec : "";
|
const char *codec = sh->gsh->codec ? sh->gsh->codec : "";
|
||||||
void *tmp = talloc_new(NULL);
|
struct packet_list *subs = talloc_zero(NULL, struct packet_list);
|
||||||
struct packet_list subs = {0};
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ds_get_next_pts(sh->ds);
|
ds_get_next_pts(sh->ds);
|
||||||
@ -357,31 +356,31 @@ bool sub_read_all_packets(struct dec_sub *sub, struct sh_sub *sh)
|
|||||||
if (!pkt)
|
if (!pkt)
|
||||||
break;
|
break;
|
||||||
pkt = demux_copy_packet(pkt);
|
pkt = demux_copy_packet(pkt);
|
||||||
talloc_steal(tmp, pkt);
|
talloc_steal(subs, pkt);
|
||||||
MP_TARRAY_APPEND(tmp, subs.packets, subs.num_packets, pkt);
|
MP_TARRAY_APPEND(subs, subs->packets, subs->num_packets, pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't run auto-detection on movtext packets: it's the only codec that
|
// Can't run auto-detection on movtext packets: it's the only codec that
|
||||||
// even though it decodes to text has binary input data.
|
// even though it decodes to text has binary input data.
|
||||||
if (opts->sub_cp && !sh->is_utf8 && strcmp(codec, "movtext") != 0)
|
if (opts->sub_cp && !sh->is_utf8 && strcmp(codec, "movtext") != 0)
|
||||||
sub->charset = guess_sub_cp(&subs, opts->sub_cp);
|
sub->charset = guess_sub_cp(subs, opts->sub_cp);
|
||||||
|
|
||||||
if (sub->charset)
|
if (sub->charset)
|
||||||
mp_msg(MSGT_OSD, MSGL_INFO, "Using subtitle charset: %s\n", sub->charset);
|
mp_msg(MSGT_OSD, MSGL_INFO, "Using subtitle charset: %s\n", sub->charset);
|
||||||
|
|
||||||
// 23.976 FPS is used as default timebase for frame based formats
|
// 23.976 FPS is used as default timebase for frame based formats
|
||||||
if (sub->video_fps && sh->frame_based)
|
if (sub->video_fps && sh->frame_based)
|
||||||
multiply_timings(&subs, sub->video_fps / 23.976);
|
multiply_timings(subs, sub->video_fps / 23.976);
|
||||||
|
|
||||||
if (opts->sub_fps && sub->video_fps)
|
if (opts->sub_fps && sub->video_fps)
|
||||||
multiply_timings(&subs, opts->sub_fps / sub->video_fps);
|
multiply_timings(subs, opts->sub_fps / sub->video_fps);
|
||||||
|
|
||||||
if (!opts->suboverlap_enabled)
|
if (!opts->suboverlap_enabled)
|
||||||
fix_overlaps_and_gaps(&subs);
|
fix_overlaps_and_gaps(subs);
|
||||||
|
|
||||||
add_sub_list(sub, &subs);
|
add_sub_list(sub, subs);
|
||||||
|
|
||||||
talloc_free(tmp);
|
talloc_free(subs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user