2 * Copyright (C) 2007 Niels Martin Hansen
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
26 #include "..\..\..\subtitles\VobSubFile.h"
27 #include "..\..\..\subtitles\RTS.h"
28 #include "..\..\..\subtitles\SSF.h"
30 #define CSRIAPI extern "C" __declspec(dllexport)
31 #define CSRI_OWN_HANDLES
32 typedef const char *csri_rend
;
33 extern "C" struct csri_vsfilter_inst
{
34 CRenderedTextSubtitle
*rts
;
39 enum csri_pixfmt pixfmt
;
42 typedef struct csri_vsfilter_inst csri_inst
;
44 static csri_rend csri_vsfilter
= "vsfilter";
47 CSRIAPI csri_inst
*csri_open_file(csri_rend
*renderer
, const char *filename
, struct csri_openflag
*flags
)
49 AMTRACE((TEXT(__FUNCTION__
),0));
53 namesize
= MultiByteToWideChar(CP_UTF8
, 0, filename
, -1, NULL
, 0);
57 namebuf
= new wchar_t[namesize
];
58 MultiByteToWideChar(CP_UTF8
, 0, filename
, -1, namebuf
, namesize
);
60 csri_inst
*inst
= new csri_inst();
61 inst
->cs
= new CCritSec();
62 inst
->rts
= new CRenderedTextSubtitle(inst
->cs
);
63 if (inst
->rts
->Open(CString(namebuf
), DEFAULT_CHARSET
)) {
77 CSRIAPI csri_inst
*csri_open_mem(csri_rend
*renderer
, const void *data
, size_t length
, struct csri_openflag
*flags
)
79 AMTRACE((TEXT(__FUNCTION__
),0));
80 // This is actually less effecient than opening a file, since this first writes the memory data to a temp file,
81 // then opens that file and parses from that.
82 csri_inst
*inst
= new csri_inst();
83 inst
->cs
= new CCritSec();
84 inst
->rts
= new CRenderedTextSubtitle(inst
->cs
);
85 if (inst
->rts
->Open((BYTE
*)data
, (int)length
, DEFAULT_CHARSET
, _T("CSRI memory subtitles"))) {
97 CSRIAPI
void csri_close(csri_inst
*inst
)
107 CSRIAPI
int csri_request_fmt(csri_inst
*inst
, const struct csri_fmt
*fmt
)
109 if (!inst
) return -1;
111 if (!fmt
->width
|| !fmt
->height
)
114 // Check if pixel format is supported
115 switch (fmt
->pixfmt
) {
120 inst
->pixfmt
= fmt
->pixfmt
;
126 inst
->screen_res
= CSize(fmt
->width
, fmt
->height
);
127 inst
->video_rect
= CRect(0, 0, fmt
->width
, fmt
->height
);
132 CSRIAPI
void csri_render(csri_inst
*inst
, struct csri_frame
*frame
, double time
)
134 const double arbitrary_framerate
= 25.0;
136 spd
.w
= inst
->screen_res
.cx
;
137 spd
.h
= inst
->screen_res
.cy
;
138 switch (inst
->pixfmt
) {
140 spd
.type
= MSP_RGB32
;
142 spd
.bits
= frame
->planes
[0];
143 spd
.pitch
= frame
->strides
[0];
147 spd
.type
= MSP_RGB24
;
149 spd
.bits
= frame
->planes
[0];
150 spd
.pitch
= frame
->strides
[0];
156 spd
.bits
= frame
->planes
[0];
157 spd
.pitch
= frame
->strides
[0];
163 spd
.bits
= frame
->planes
[0];
164 spd
.bitsU
= frame
->planes
[1];
165 spd
.bitsV
= frame
->planes
[2];
166 spd
.pitch
= frame
->strides
[0];
167 spd
.pitchUV
= frame
->strides
[1];
174 spd
.vidrect
= inst
->video_rect
;
176 inst
->rts
->Render(spd
, (REFERENCE_TIME
)(time
*10000000), arbitrary_framerate
, inst
->video_rect
);
180 // No extensions supported
181 CSRIAPI
void *csri_query_ext(csri_rend
*rend
, csri_ext_id extname
)
186 // Get info for renderer
187 static struct csri_info csri_vsfilter_info
= {
189 "vsfilter_textsub_debug", // name
190 "2.39", // version (assumed version number, svn revision, patchlevel)
192 "vsfilter_textsub", // name
193 "2.39", // version (assumed version number, svn revision, patchlevel)
195 // 2.38-0611 is base svn 611
196 // 2.38-0611-1 is with clipfix and fax/fay patch
197 // 2.38-0611-2 adds CSRI
198 // 2.38-0611-3 fixes a bug in CSRI and adds fontcrash-fix and float-pos
199 // 2.38-0611-4 fixes be1-dots and ugly-fade bugs and adds xbord/ybord/xshad/yshad/blur tags and extends be
200 // 2.39 merges with guliverkli2 fork
201 "VSFilter/TextSub (guliverkli2)", // longname
203 "Copyright (c) 2003-2008 by Gabest and others" // copyright
205 CSRIAPI
struct csri_info
*csri_renderer_info(csri_rend
*rend
)
207 return &csri_vsfilter_info
;
209 // Only one supported, obviously
210 CSRIAPI csri_rend
*csri_renderer_byname(const char *name
, const char *specific
)
212 if (strcmp(name
, csri_vsfilter_info
.name
))
214 if (specific
&& strcmp(specific
, csri_vsfilter_info
.specific
))
216 return &csri_vsfilter
;
219 CSRIAPI csri_rend
*csri_renderer_default()
221 return &csri_vsfilter
;
224 CSRIAPI csri_rend
*csri_renderer_next(csri_rend
*prev
)