mirror of
https://github.com/mpv-player/mpv
synced 2025-02-22 07:46:55 +00:00
subs: Add support for DVB and XSUB subtitles, not yet working properly
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31694 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
3b92d75481
commit
9e537d1f6e
11
av_sub.c
11
av_sub.c
@ -50,11 +50,20 @@ int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size, double *pts, doub
|
||||
if (*pts != MP_NOPTS_VALUE && *endpts != MP_NOPTS_VALUE)
|
||||
pkt.convergence_duration = (*endpts - *pts) * 1000;
|
||||
if (!ctx) {
|
||||
enum CodecID cid = CODEC_ID_NONE;
|
||||
AVCodec *sub_codec;
|
||||
avcodec_init();
|
||||
avcodec_register_all();
|
||||
ctx = avcodec_alloc_context();
|
||||
sub_codec = avcodec_find_decoder(CODEC_ID_HDMV_PGS_SUBTITLE);
|
||||
switch (sh->type) {
|
||||
case 'b':
|
||||
cid = CODEC_ID_DVB_SUBTITLE; break;
|
||||
case 'p':
|
||||
cid = CODEC_ID_HDMV_PGS_SUBTITLE; break;
|
||||
case 'x':
|
||||
cid = CODEC_ID_XSUB; break;
|
||||
}
|
||||
sub_codec = avcodec_find_decoder(cid);
|
||||
if (!ctx || !sub_codec || avcodec_open(ctx, sub_codec) < 0) {
|
||||
mp_msg(MSGT_SUBREADER, MSGL_FATAL, "Could not open subtitle decoder\n");
|
||||
av_freep(&ctx);
|
||||
|
@ -425,6 +425,10 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
||||
type = 'a';
|
||||
else if(codec->codec_id == CODEC_ID_DVD_SUBTITLE)
|
||||
type = 'v';
|
||||
else if(codec->codec_id == CODEC_ID_XSUB)
|
||||
type = 'x';
|
||||
else if(codec->codec_id == CODEC_ID_DVB_SUBTITLE)
|
||||
type = 'b';
|
||||
else if(codec->codec_id == CODEC_ID_DVB_TELETEXT)
|
||||
type = 'd';
|
||||
else if(codec->codec_id == CODEC_ID_HDMV_PGS_SUBTITLE)
|
||||
|
@ -94,7 +94,7 @@ static bool is_text_sub(int type)
|
||||
|
||||
static bool is_av_sub(int type)
|
||||
{
|
||||
return type == 'p';
|
||||
return type == 'b' || type == 'p' || type == 'x';
|
||||
}
|
||||
|
||||
void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
|
||||
|
Loading…
Reference in New Issue
Block a user