summaryrefslogtreecommitdiffstats
path: root/av_sub.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-07-11 09:40:46 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:14:43 +0200
commit1bcb3fc805e4d6577ac41ab797d38b8bacc8ef89 (patch)
treec24c8d48bbb47a18b341986b1b466c5af422fc93 /av_sub.c
parent4a466e95730e97e22c16688edfe19974fa9d7c90 (diff)
downloadmpv-1bcb3fc805e4d6577ac41ab797d38b8bacc8ef89.tar.bz2
mpv-1bcb3fc805e4d6577ac41ab797d38b8bacc8ef89.tar.xz
subs: improve scaling for avcodec subs
Try to get subtitle scaling somewhat right with libavcodec decoded bitmap subtitles. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31697 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'av_sub.c')
-rw-r--r--av_sub.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/av_sub.c b/av_sub.c
index d55a5674de..c1a1c7002f 100644
--- a/av_sub.c
+++ b/av_sub.c
@@ -38,11 +38,24 @@ void reset_avsub(struct sh_sub *sh)
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;
@@ -50,19 +63,10 @@ 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();
- 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");
@@ -83,7 +87,7 @@ int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size, double *pts, doub
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],