diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2011-01-14 14:05:22 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2011-01-15 18:45:43 +0200 |
commit | ac79632ded16b62e0abf10f1cd319fba20bc0024 (patch) | |
tree | a671e3fe3971917f2dbf066395b90598320b3df1 /av_sub.c | |
parent | e9022ec470e9334a6d0f3cb044027964ac4f63f6 (diff) | |
download | mpv-ac79632ded16b62e0abf10f1cd319fba20bc0024.tar.bz2 mpv-ac79632ded16b62e0abf10f1cd319fba20bc0024.tar.xz |
subtitles: remove code trying to handle text subs with libavcodec
The avsub implementation tries to fall back to MPlayer's other text
subtitle decoding if libavcodec returns text as the 'decoded'
subtitle. The code implementing this is buggy, and as far as I can see
it should not be triggered normally (libavcodec decoding is only
used for xvid, pgs and dvb subtitles, and for those libavcodec should
return bitmaps). Remove the buggy code (don't try to support
non-bitmap results) and simplify things a bit.
Diffstat (limited to 'av_sub.c')
-rw-r--r-- | av_sub.c | 42 |
1 files changed, 18 insertions, 24 deletions
@@ -35,12 +35,11 @@ void reset_avsub(struct sh_sub *sh) * Decode a subtitle packet via libavcodec. * \return < 0 on error, > 0 if further processing is needed */ -int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size, - double *pts, double *endpts) +int decode_avsub(struct sh_sub *sh, uint8_t *data, int size, + double pts, double endpts) { AVCodecContext *ctx = sh->context; enum CodecID cid = CODEC_ID_NONE; - int new_type = 0; int res; int got_sub; AVSubtitle sub; @@ -56,11 +55,11 @@ int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size, } av_init_packet(&pkt); - pkt.data = *data; - pkt.size = *size; - pkt.pts = *pts * 1000; - if (*pts != MP_NOPTS_VALUE && *endpts != MP_NOPTS_VALUE) - pkt.convergence_duration = (*endpts - *pts) * 1000; + pkt.data = data; + pkt.size = size; + pkt.pts = pts * 1000; + if (pts != MP_NOPTS_VALUE && endpts != MP_NOPTS_VALUE) + pkt.convergence_duration = (endpts - pts) * 1000; if (!ctx) { AVCodec *sub_codec; avcodec_init(); @@ -78,13 +77,13 @@ int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size, res = avcodec_decode_subtitle2(ctx, &sub, &got_sub, &pkt); if (res < 0) return res; - if (*pts != MP_NOPTS_VALUE) { + if (pts != MP_NOPTS_VALUE) { if (sub.end_display_time > sub.start_display_time) - *endpts = *pts + sub.end_display_time / 1000.0; - *pts += sub.start_display_time / 1000.0; + endpts = pts + sub.end_display_time / 1000.0; + pts += sub.start_display_time / 1000.0; } if (got_sub && vo_spudec && sub.num_rects == 0) - spudec_set_paletted(vo_spudec, NULL, 0, NULL, 0, 0, 0, 0, *pts, *endpts); + spudec_set_paletted(vo_spudec, NULL, 0, NULL, 0, 0, 0, 0, pts, endpts); if (got_sub && sub.num_rects > 0) { switch (sub.rects[0]->type) { case SUBTITLE_BITMAP: @@ -98,19 +97,14 @@ int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size, sub.rects[0]->y, sub.rects[0]->w, sub.rects[0]->h, - *pts, - *endpts); + pts, + endpts); vo_osd_changed(OSDTYPE_SPU); break; - case SUBTITLE_TEXT: - *data = strdup(sub.rects[0]->text); - *size = strlen(*data); - new_type = 't'; - break; - case SUBTITLE_ASS: - *data = strdup(sub.rects[0]->ass); - *size = strlen(*data); - new_type = 'a'; + default: + mp_msg(MSGT_SUBREADER, MSGL_ERR, "sd_avsub: unsupported subtitle " + "type from libavcodec\n"); + res = -1; break; } } @@ -118,5 +112,5 @@ int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size, if (got_sub) avsubtitle_free(&sub); #endif - return new_type; + return res; } |