summaryrefslogtreecommitdiffstats
path: root/sub/dec_sub.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-28 23:23:30 +0100
committerwm4 <wm4@nowhere>2015-12-28 23:23:30 +0100
commit4c1deb680dacee555e7cdd5e247128d7416bac13 (patch)
tree2330f6d5581585a7d97714f4c1b1c97b8c5d20a5 /sub/dec_sub.c
parent97d50538cde30b42208f343720ee22ec431c40f1 (diff)
downloadmpv-4c1deb680dacee555e7cdd5e247128d7416bac13.tar.bz2
mpv-4c1deb680dacee555e7cdd5e247128d7416bac13.tar.xz
sub: do charset conversion in demux_lavf.c
Just so I can remove a few lines from dec_sub.c. This is slightly inelegant, as the whole subtitle file has to be read into memory, converted at once in memory, and then provided to libavformat in an awkward way by creating a memory stream instead of using demuxer->stream. It also won't be possible to force the charset on subtitles in binary container formats - but this wasn't exposed before, and we just hope this won't be ever needed. (One motivation was fixing broken files with non-UTF8 muxed.) It also won't be possible to change the charset on the fly, but this was not exposed either.
Diffstat (limited to 'sub/dec_sub.c')
-rw-r--r--sub/dec_sub.c36
1 files changed, 2 insertions, 34 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index 6733acfedc..c614b429ec 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -29,7 +29,6 @@
#include "options/options.h"
#include "common/global.h"
#include "common/msg.h"
-#include "misc/charset_conv.h"
#include "osdep/threads.h"
extern const struct sd_functions sd_ass;
@@ -123,48 +122,17 @@ struct dec_sub *sub_create(struct mpv_global *global, struct demuxer *demuxer,
return NULL;
}
-static struct demux_packet *recode_packet(struct mp_log *log,
- struct demux_packet *in,
- const char *charset)
-{
- struct demux_packet *pkt = NULL;
- bstr in_buf = {in->buffer, in->len};
- bstr conv = mp_iconv_to_utf8(log, in_buf, charset, MP_ICONV_VERBOSE);
- if (conv.start && conv.start != in_buf.start) {
- pkt = talloc_ptrtype(NULL, pkt);
- talloc_steal(pkt, conv.start);
- *pkt = (struct demux_packet) {
- .buffer = conv.start,
- .len = conv.len,
- .pts = in->pts,
- .pos = in->pos,
- .duration = in->duration,
- .avpacket = in->avpacket, // questionable, but gives us sidedata
- };
- }
- return pkt;
-}
-
-static void decode_chain_recode(struct dec_sub *sub, struct demux_packet *packet)
-{
- struct demux_packet *recoded = NULL;
- if (sub->sh->sub->charset)
- recoded = recode_packet(sub->log, packet, sub->sh->sub->charset);
- sub->sd->driver->decode(sub->sd, recoded ? recoded : packet);
- talloc_free(recoded);
-}
-
void sub_decode(struct dec_sub *sub, struct demux_packet *packet)
{
pthread_mutex_lock(&sub->lock);
- decode_chain_recode(sub, packet);
+ sub->sd->driver->decode(sub->sd, packet);
pthread_mutex_unlock(&sub->lock);
}
static void add_sub_list(struct dec_sub *sub, struct packet_list *subs)
{
for (int n = 0; n < subs->num_packets; n++)
- decode_chain_recode(sub, subs->packets[n]);
+ sub->sd->driver->decode(sub->sd, subs->packets[n]);
}
static void add_packet(struct packet_list *subs, struct demux_packet *pkt)