# HG changeset patch # User reimar # Date 1278841246 0 # Node ID 67f2fb3ff4c776e9f8cafe956594344c887c3b8c # Parent 78260a24639334b601a34ba85db4b1fbe857f761 Try to get subtitle scaling somewhat right with libavcodec decoded bitmap subtitles. diff -r 78260a246393 -r 67f2fb3ff4c7 av_sub.c --- a/av_sub.c Sun Jul 11 09:39:06 2010 +0000 +++ b/av_sub.c Sun Jul 11 09:40:46 2010 +0000 @@ -37,11 +37,24 @@ 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 srcw = 0, srch = 0; int new_type = 0; int res; int got_sub; AVSubtitle sub; AVPacket pkt; + + switch (sh->type) { + case 'b': + cid = CODEC_ID_DVB_SUBTITLE; break; + case 'p': + srcw = 1920; srch = 1080; + cid = CODEC_ID_HDMV_PGS_SUBTITLE; break; + case 'x': + cid = CODEC_ID_XSUB; break; + } + av_init_packet(&pkt); pkt.data = *data; pkt.size = *size; @@ -49,19 +62,10 @@ 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(); - 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"); @@ -82,7 +86,7 @@ switch (sub.rects[0]->type) { case SUBTITLE_BITMAP: if (!vo_spudec) - vo_spudec = spudec_new(NULL); + vo_spudec = spudec_new_scaled(NULL, srcw, srch, NULL, 0); spudec_set_paletted(vo_spudec, sub.rects[0]->pict.data[0], sub.rects[0]->pict.linesize[0], diff -r 78260a246393 -r 67f2fb3ff4c7 spudec.c --- a/spudec.c Sun Jul 11 09:39:06 2010 +0000 +++ b/spudec.c Sun Jul 11 09:40:46 2010 +0000 @@ -643,11 +643,9 @@ spu->start_col = packet->start_col; spu->start_row = packet->start_row; - // TODO use correct values + // reset scaled image spu->scaled_frame_width = 0; spu->scaled_frame_height = 0; - spu->orig_frame_width = 1920; - spu->orig_frame_height = 1080; } else { if (spu->auto_palette) compute_palette(spu, packet);