summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2011-01-14 14:05:22 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2011-01-15 18:45:43 +0200
commitac79632ded16b62e0abf10f1cd319fba20bc0024 (patch)
treea671e3fe3971917f2dbf066395b90598320b3df1
parente9022ec470e9334a6d0f3cb044027964ac4f63f6 (diff)
downloadmpv-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.
-rw-r--r--av_sub.c42
-rw-r--r--av_sub.h4
-rw-r--r--mplayer.c7
3 files changed, 22 insertions, 31 deletions
diff --git a/av_sub.c b/av_sub.c
index e850e2ffa2..3f926c8fef 100644
--- a/av_sub.c
+++ b/av_sub.c
@@ -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;
}
diff --git a/av_sub.h b/av_sub.h
index 690ed6c1f1..af3edc4d34 100644
--- a/av_sub.h
+++ b/av_sub.h
@@ -24,7 +24,7 @@
struct sh_sub;
void reset_avsub(struct sh_sub *sh);
-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);
#endif /* MPLAYER_AV_SUB_H */
diff --git a/mplayer.c b/mplayer.c
index f36bb2788f..382fe2a6f5 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1901,10 +1901,8 @@ void update_subtitles(struct MPContext *mpctx, double refpts,
if (d_sub->non_interleaved)
ds_get_next_pts(d_sub);
- int orig_type = type;
while (d_sub->first) {
double subpts = ds_get_next_pts(d_sub) + sub_offset;
- type = orig_type;
if (subpts > curpts) {
// Libass handled subs can be fed to it in advance
if (!opts->ass_enabled || !is_text_sub(type))
@@ -1917,10 +1915,9 @@ void update_subtitles(struct MPContext *mpctx, double refpts,
len = ds_get_packet_sub(d_sub, &packet);
if (is_av_sub(type)) {
#ifdef CONFIG_FFMPEG
- type = decode_avsub(d_sub->sh, &packet, &len, &subpts, &endpts);
- if (type <= 0)
+ decode_avsub(d_sub->sh, packet, len, subpts, endpts);
#endif
- continue;
+ continue;
}
if (type == 'm') {
if (len < 2) continue;