mirror of https://github.com/mpv-player/mpv
commit
479f5e742f
|
@ -72,9 +72,7 @@ default as it offers better speed.
|
|||
The CVS version is usually stable enough to use, as most of the time it
|
||||
features fixes for bugs that exist in releases.
|
||||
Here is what to do to make <systemitem class="library">Xvid</systemitem>
|
||||
CVS work with <application>MEncoder</application> (you need at least
|
||||
<application>autoconf</application> 2.50,
|
||||
<application>automake</application> and <application>libtool</application>):
|
||||
CVS work with <application>MEncoder</application>:
|
||||
</para>
|
||||
<step><para>
|
||||
<screen>cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid login</screen>
|
||||
|
@ -86,21 +84,13 @@ default as it offers better speed.
|
|||
<screen>cd xvidcore/build/generic</screen>
|
||||
</para></step>
|
||||
<step><para>
|
||||
<screen>./bootstrap.sh</screen>
|
||||
</para></step>
|
||||
<step><para>
|
||||
<screen>./configure</screen>
|
||||
<screen>./bootstrap.sh && ./configure</screen>
|
||||
You may have to add some options (examine the output of
|
||||
<command>./configure --help</command>).
|
||||
</para></step>
|
||||
<step><para>
|
||||
<screen>make && make install</screen>
|
||||
</para></step>
|
||||
<step><para>
|
||||
If you specified <option>--enable-divxcompat</option>,
|
||||
copy <filename>../../src/divx4.h</filename> to
|
||||
<filename class="directory">/usr/local/include/</filename>.
|
||||
</para></step>
|
||||
<step><para>
|
||||
Recompile <application>MPlayer</application>.
|
||||
</para></step>
|
||||
|
|
|
@ -179,7 +179,6 @@ It can encode with various codecs, like
|
|||
&cd-dvd.xml;
|
||||
&faq.xml;
|
||||
|
||||
&containers.xml;
|
||||
&codecs.xml;
|
||||
&video.xml;
|
||||
&audio.xml;
|
||||
|
|
|
@ -1958,6 +1958,8 @@ static int mp_property_teletext_page(m_option_t *prop, int action, void *arg,
|
|||
tvi_handle_t *tvh = mpctx->demuxer->priv;
|
||||
int result;
|
||||
int val;
|
||||
if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
switch(action){
|
||||
case M_PROPERTY_STEP_UP:
|
||||
case M_PROPERTY_STEP_DOWN:
|
||||
|
|
|
@ -7984,12 +7984,12 @@ LIBPREF=lib
|
|||
LIBSUF=.a
|
||||
LIBNAME=\$(LIBPREF)\$(NAME)\$(LIBSUF)
|
||||
|
||||
CONFIG_ENCODERS=yes
|
||||
# Some FFmpeg codecs depend on these. Enable them unconditionally for now.
|
||||
CONFIG_FFT=yes
|
||||
CONFIG_MDCT=yes
|
||||
CONFIG_GOLOMB=yes
|
||||
CONFIG_MDCT=yes
|
||||
|
||||
CONFIG_ENCODERS=yes
|
||||
CONFIG_GPL=yes
|
||||
CONFIG_LIBAMR=$_libamr
|
||||
CONFIG_LIBAMR_NB=$_libamr_nb
|
||||
|
@ -8421,10 +8421,10 @@ $_def_threads
|
|||
/* Some FFmpeg codecs depend on these. Enable them unconditionally for now. */
|
||||
#define CONFIG_FFT 1
|
||||
#define ENABLE_FFT 1
|
||||
#define CONFIG_MDCT 1
|
||||
#define ENABLE_MDCT 1
|
||||
#define CONFIG_GOLOMB 1
|
||||
#define ENABLE_GOLOMB 1
|
||||
#define CONFIG_MDCT 1
|
||||
#define ENABLE_MDCT 1
|
||||
|
||||
/* Use these registers in FFmpeg x86 inline asm. No proper detection yet. */
|
||||
#define HAVE_EBX_AVAILABLE 1
|
||||
|
|
|
@ -93,7 +93,7 @@ static int allocStuff(FilterParam *f, int width, int height){
|
|||
swsF.lumH= swsF.lumV= vec;
|
||||
swsF.chrH= swsF.chrV= NULL;
|
||||
f->filterContext= sws_getContext(
|
||||
width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, get_sws_cpuflags(), &swsF, NULL, NULL);
|
||||
width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, SWS_BICUBIC | get_sws_cpuflags(), &swsF, NULL, NULL);
|
||||
|
||||
sws_freeVec(vec);
|
||||
|
||||
|
|
|
@ -252,123 +252,6 @@ aac_get_sample_rate_index (uint32_t sample_rate)
|
|||
return 11;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
vobsub_parse_size (sh_sub_t *sh, const char *start)
|
||||
{
|
||||
if (sscanf(&start[6], "%dx%d", &sh->width, &sh->height) == 2)
|
||||
{
|
||||
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub size: %ux%u\n",
|
||||
sh->width, sh->height);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_palette (sh_sub_t *sh, const char *start)
|
||||
{
|
||||
int i;
|
||||
|
||||
start += 8;
|
||||
while (isspace(*start))
|
||||
start++;
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
unsigned int tmp;
|
||||
if (sscanf(start, "%06x", &tmp) != 1)
|
||||
break;
|
||||
sh->palette[i] = vobsub_palette_to_yuv(tmp);
|
||||
start += 6;
|
||||
while ((*start == ',') || isspace(*start))
|
||||
start++;
|
||||
}
|
||||
if (i == 16)
|
||||
{
|
||||
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub palette: %06x,%06x,"
|
||||
"%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,"
|
||||
"%06x,%06x,%06x\n", sh->palette[0],
|
||||
sh->palette[1], sh->palette[2],
|
||||
sh->palette[3], sh->palette[4],
|
||||
sh->palette[5], sh->palette[6],
|
||||
sh->palette[7], sh->palette[8],
|
||||
sh->palette[9], sh->palette[10],
|
||||
sh->palette[11], sh->palette[12],
|
||||
sh->palette[13], sh->palette[14],
|
||||
sh->palette[15]);
|
||||
sh->has_palette = 1;
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_custom_colors (sh_sub_t *sh, const char *start)
|
||||
{
|
||||
int use_custom_colors, i;
|
||||
const char *p;
|
||||
unsigned int tridx = 0;
|
||||
|
||||
use_custom_colors = 0;
|
||||
start += 14;
|
||||
while (isspace(*start))
|
||||
start++;
|
||||
if (!strncasecmp(start, "ON", 2) || (*start == '1'))
|
||||
use_custom_colors = 1;
|
||||
else if (!strncasecmp(start, "OFF", 3) || (*start == '0'))
|
||||
use_custom_colors = 0;
|
||||
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub custom colors: %s\n",
|
||||
use_custom_colors ? "ON" : "OFF");
|
||||
if ((p = strstr(start, "tridx:")) != NULL)
|
||||
tridx = strtoul(p + 6, NULL, 2);
|
||||
if ((start = strstr(start, "colors:")) != NULL)
|
||||
{
|
||||
start += 7;
|
||||
while (isspace(*start))
|
||||
start++;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
unsigned int tmp;
|
||||
if (sscanf(start, "%06x", &tmp) != 1)
|
||||
break;
|
||||
sh->colors[i] = vobsub_rgb_to_yuv(tmp);
|
||||
if ((tridx << i) & 0x08)
|
||||
sh->colors[i] |= 1 << 31;
|
||||
start += 6;
|
||||
while ((*start == ',') || isspace(*start))
|
||||
start++;
|
||||
}
|
||||
if (i == 4)
|
||||
{
|
||||
sh->custom_colors = 4;
|
||||
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub colors: %08x,"
|
||||
"%08x,%08x,%08x\n", sh->colors[0],
|
||||
sh->colors[1], sh->colors[2],
|
||||
sh->colors[3]);
|
||||
}
|
||||
}
|
||||
if (!use_custom_colors)
|
||||
sh->custom_colors = 0;
|
||||
return 4;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_forced_subs (sh_sub_t *sh, const char *start)
|
||||
{
|
||||
start += 12;
|
||||
while (isspace(*start))
|
||||
start++;
|
||||
if (!strncasecmp(start, "on", 2) || (*start == '1'))
|
||||
sh->forced_subs_only = 1;
|
||||
else if (!strncasecmp(start, "off", 3) || (*start == '0'))
|
||||
sh->forced_subs_only = 0;
|
||||
else
|
||||
return 0;
|
||||
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub forced subs: %d\n",
|
||||
sh->forced_subs_only);
|
||||
return 8;
|
||||
}
|
||||
|
||||
/** \brief Free cached demux packets
|
||||
*
|
||||
* Reordering the timecodes requires caching of demux packets. This function
|
||||
|
@ -397,63 +280,6 @@ free_cached_dps (demuxer_t *demuxer)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
demux_mkv_parse_idx (mkv_track_t *t)
|
||||
{
|
||||
int things_found, last;
|
||||
char *buf, *pos, *start;
|
||||
|
||||
if ((t->private_data == NULL) || (t->private_size == 0))
|
||||
return 0;
|
||||
|
||||
things_found = 0;
|
||||
buf = malloc(t->private_size + 1);
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
memcpy(buf, t->private_data, t->private_size);
|
||||
buf[t->private_size] = 0;
|
||||
t->sh_sub->has_palette = 0;
|
||||
|
||||
pos = buf;
|
||||
start = buf;
|
||||
last = 0;
|
||||
do
|
||||
{
|
||||
if ((*pos == 0) || (*pos == '\r') || (*pos == '\n'))
|
||||
{
|
||||
if (*pos == 0)
|
||||
last = 1;
|
||||
*pos = 0;
|
||||
|
||||
if (!strncasecmp(start, "size: ", 6))
|
||||
things_found |= vobsub_parse_size(t->sh_sub, start);
|
||||
else if (!strncasecmp(start, "palette:", 8))
|
||||
things_found |= vobsub_parse_palette(t->sh_sub, start);
|
||||
else if (!strncasecmp(start, "custom colors:", 14))
|
||||
things_found |= vobsub_parse_custom_colors(t->sh_sub, start);
|
||||
else if (!strncasecmp(start, "forced subs:", 12))
|
||||
things_found |= vobsub_parse_forced_subs(t->sh_sub, start);
|
||||
|
||||
if (last)
|
||||
break;
|
||||
do
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
while ((*pos == '\r') || (*pos == '\n'));
|
||||
start = pos;
|
||||
}
|
||||
else
|
||||
pos++;
|
||||
}
|
||||
while (!last && (*start != 0));
|
||||
|
||||
free(buf);
|
||||
|
||||
return (things_found & 3) == 3;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
demux_mkv_decode (mkv_track_t *track, uint8_t *src, uint8_t **dest,
|
||||
uint32_t *size, uint32_t type)
|
||||
|
@ -2158,38 +1984,6 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** \brief Parse the private data for VobSub subtitle tracks.
|
||||
|
||||
This function tries to parse the private data for all VobSub tracks.
|
||||
The private data contains the normal text from the original .idx file.
|
||||
Things like the palette, subtitle dimensions and custom colors are
|
||||
stored here.
|
||||
|
||||
\param demuxer The generic demuxer.
|
||||
*/
|
||||
static void
|
||||
demux_mkv_parse_vobsub_data (demuxer_t *demuxer)
|
||||
{
|
||||
mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
|
||||
mkv_track_t *track;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mkv_d->num_tracks; i++)
|
||||
{
|
||||
track = mkv_d->tracks[i];
|
||||
if ((track->type != MATROSKA_TRACK_SUBTITLE) ||
|
||||
(track->subtitle_type != MATROSKA_SUBTYPE_VOBSUB))
|
||||
continue;
|
||||
|
||||
if (!demux_mkv_parse_idx (track))
|
||||
{
|
||||
free (track->private_data);
|
||||
track->private_data = NULL;
|
||||
track->private_size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid)
|
||||
{
|
||||
|
@ -2424,8 +2218,6 @@ demux_mkv_open (demuxer_t *demuxer)
|
|||
}
|
||||
}
|
||||
|
||||
demux_mkv_parse_vobsub_data (demuxer);
|
||||
|
||||
if (demuxer->chapters)
|
||||
{
|
||||
for (i=0; i < (int)demuxer->num_chapters; i++)
|
||||
|
|
|
@ -102,12 +102,6 @@ typedef struct sh_sub {
|
|||
struct MPOpts *opts;
|
||||
int sid;
|
||||
char type; // t = text, v = VobSub, a = SSA/ASS
|
||||
int has_palette; // If we have a valid palette
|
||||
unsigned int palette[16]; // for VobSubs
|
||||
int width, height; // for VobSubs
|
||||
int custom_colors;
|
||||
unsigned int colors[4];
|
||||
int forced_subs_only;
|
||||
unsigned char* extradata; // extra header data passed from demuxer
|
||||
int extradata_len;
|
||||
struct ass_track_s *ass_track; // for SSA/ASS streams (type == 'a')
|
||||
|
|
|
@ -13,7 +13,7 @@ OBJS-$(HAVE_VIS) += yuv2rgb_vis.o
|
|||
|
||||
ASM_OBJS-$(ARCH_BFIN) += internal_bfin.o
|
||||
|
||||
HEADERS = swscale.h rgb2rgb.h
|
||||
HEADERS = swscale.h
|
||||
|
||||
CLEANFILES = cs_test swscale-example
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "libavutil/avutil.h"
|
||||
#include "swscale.h"
|
||||
#include "swscale_internal.h"
|
||||
#include "rgb2rgb.h"
|
||||
|
||||
static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){
|
||||
int x,y;
|
||||
|
@ -207,11 +206,6 @@ int main(int argc, char **argv){
|
|||
rgb_data[ x + y*4*W]= random();
|
||||
}
|
||||
}
|
||||
#if defined(ARCH_X86)
|
||||
sws_rgb2rgb_init(SWS_CPU_CAPS_MMX*0);
|
||||
#else
|
||||
sws_rgb2rgb_init(0);
|
||||
#endif
|
||||
sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride);
|
||||
|
||||
#if defined(ARCH_X86)
|
||||
|
|
|
@ -1741,7 +1741,7 @@ static int pal2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
|
|||
|
||||
|
||||
for (i=0; i<srcSliceH; i++) {
|
||||
conv(srcPtr, dstPtr, c->srcW, c->pal_rgb);
|
||||
conv(srcPtr, dstPtr, c->srcW, (uint8_t *) c->pal_rgb);
|
||||
srcPtr+= srcStride[0];
|
||||
dstPtr+= dstStride[0];
|
||||
}
|
||||
|
@ -2734,7 +2734,8 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
|
|||
r= (i>>3 )*255;
|
||||
g= ((i>>1)&3)*85;
|
||||
b= (i&1 )*255;
|
||||
}else if(c->srcFormat == PIX_FMT_BGR4_BYTE){
|
||||
}else {
|
||||
assert(c->srcFormat == PIX_FMT_BGR4_BYTE);
|
||||
b= (i>>3 )*255;
|
||||
g= ((i>>1)&3)*85;
|
||||
r= (i&1 )*255;
|
||||
|
|
|
@ -739,19 +739,16 @@ else {
|
|||
if (spudec_ifo) {
|
||||
unsigned int palette[16], width, height;
|
||||
if (vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0)
|
||||
vo_spudec=spudec_new_scaled(palette, sh_video->disp_w, sh_video->disp_h);
|
||||
vo_spudec=spudec_new_scaled(palette, sh_video->disp_w, sh_video->disp_h, NULL, 0);
|
||||
}
|
||||
#ifdef CONFIG_DVDREAD
|
||||
if (vo_spudec==NULL) {
|
||||
vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL,
|
||||
sh_video->disp_w, sh_video->disp_h);
|
||||
sh_video->disp_w, sh_video->disp_h, NULL, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Apply current settings for forced subs
|
||||
spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
|
||||
|
||||
ostream = open_output_stream(out_filename, 0);
|
||||
if(!ostream) {
|
||||
mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CannotOpenOutputFile, out_filename);
|
||||
|
|
37
mplayer.c
37
mplayer.c
|
@ -1061,14 +1061,15 @@ void init_vo_spudec(struct MPContext *mpctx)
|
|||
unsigned int palette[16], width, height;
|
||||
current_module="spudec_init_vobsub";
|
||||
if (vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0)
|
||||
vo_spudec=spudec_new_scaled(palette, width, height);
|
||||
vo_spudec=spudec_new_scaled(palette, width, height, NULL, 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DVDREAD
|
||||
if (vo_spudec==NULL && mpctx->stream->type==STREAMTYPE_DVD) {
|
||||
current_module="spudec_init_dvdread";
|
||||
vo_spudec=spudec_new_scaled(((dvd_priv_t *)(mpctx->stream->priv))->cur_pgc->palette,
|
||||
mpctx->sh_video->disp_w, mpctx->sh_video->disp_h);
|
||||
mpctx->sh_video->disp_w, mpctx->sh_video->disp_h,
|
||||
NULL, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1076,34 +1077,14 @@ void init_vo_spudec(struct MPContext *mpctx)
|
|||
if (vo_spudec==NULL && mpctx->stream->type==STREAMTYPE_DVDNAV) {
|
||||
unsigned int *palette = mp_dvdnav_get_spu_clut(mpctx->stream);
|
||||
current_module="spudec_init_dvdnav";
|
||||
vo_spudec=spudec_new_scaled(palette, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h);
|
||||
vo_spudec=spudec_new_scaled(palette, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h, NULL, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((vo_spudec == NULL) && (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA) &&
|
||||
(mpctx->d_sub->sh != NULL) && (((sh_sub_t *)mpctx->d_sub->sh)->type == 'v')) {
|
||||
sh_sub_t *mkv_sh_sub = (sh_sub_t *)mpctx->d_sub->sh;
|
||||
current_module = "spudec_init_matroska";
|
||||
vo_spudec =
|
||||
spudec_new_scaled_vobsub(mkv_sh_sub->palette, mkv_sh_sub->colors,
|
||||
mkv_sh_sub->custom_colors, mkv_sh_sub->width,
|
||||
mkv_sh_sub->height);
|
||||
forced_subs_only = mkv_sh_sub->forced_subs_only;
|
||||
}
|
||||
|
||||
if (vo_spudec==NULL) {
|
||||
sh_sub_t *sh = (sh_sub_t *)mpctx->d_sub->sh;
|
||||
unsigned int *palette = NULL;
|
||||
if (sh && !sh->has_palette && sh->extradata_len == 16*4) {
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
sh->palette[i] = AV_RB32(sh->extradata + i*4);
|
||||
sh->has_palette = 1;
|
||||
}
|
||||
if (sh && sh->has_palette)
|
||||
palette = sh->palette;
|
||||
current_module="spudec_init_normal";
|
||||
vo_spudec=spudec_new_scaled(palette, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h);
|
||||
vo_spudec=spudec_new_scaled(NULL, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h, sh->extradata, sh->extradata_len);
|
||||
spudec_set_font_factor(vo_spudec,font_factor);
|
||||
}
|
||||
|
||||
|
@ -3133,8 +3114,6 @@ if (edl_output_filename) {
|
|||
if(vo_vobsub){
|
||||
mpctx->initialized_flags|=INITIALIZED_VOBSUB;
|
||||
vobsub_set_from_lang(vo_vobsub, dvdsub_lang);
|
||||
// check if vobsub requested only to display forced subtitles
|
||||
forced_subs_only=vobsub_get_forced_subs_flag(vo_vobsub);
|
||||
|
||||
// setup global sub numbering
|
||||
mpctx->global_sub_indices[SUB_SOURCE_VOBSUB] = mpctx->global_sub_size; // the global # of the first vobsub.
|
||||
|
@ -3462,14 +3441,10 @@ demux_info_print(mpctx->demuxer);
|
|||
|
||||
//================== Read SUBTITLES (DVD & TEXT) ==========================
|
||||
if(vo_spudec==NULL && mpctx->sh_video &&
|
||||
(mpctx->stream->type==STREAMTYPE_DVD || mpctx->stream->type == STREAMTYPE_DVDNAV || mpctx->d_sub->id >= 0)){
|
||||
(mpctx->stream->type==STREAMTYPE_DVD || mpctx->stream->type == STREAMTYPE_DVDNAV)){
|
||||
init_vo_spudec(mpctx);
|
||||
}
|
||||
|
||||
// Apply current settings for forced subs
|
||||
if (vo_spudec!=NULL)
|
||||
spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
|
||||
|
||||
if(mpctx->sh_video) {
|
||||
// after reading video params we should load subtitles because
|
||||
// we know fps so now we can adjust subtitle time to ~6 seconds AST
|
||||
|
|
86
spudec.c
86
spudec.c
|
@ -23,7 +23,9 @@
|
|||
#include <math.h>
|
||||
#include "libvo/video_out.h"
|
||||
#include "spudec.h"
|
||||
#include "vobsub.h"
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libswscale/swscale.h"
|
||||
|
||||
/* Valid values for spu_aamode:
|
||||
|
@ -1115,39 +1117,73 @@ void spudec_set_font_factor(void * this, double factor)
|
|||
spu->font_start_level = (int)(0xF0-(0xE0*factor));
|
||||
}
|
||||
|
||||
void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height)
|
||||
static void spudec_parse_extradata(spudec_handle_t *this,
|
||||
uint8_t *extradata, int extradata_len)
|
||||
{
|
||||
return spudec_new_scaled_vobsub(palette, NULL, 0, frame_width, frame_height);
|
||||
uint8_t *buffer, *ptr;
|
||||
unsigned int *pal = this->global_palette, *cuspal = this->cuspal;
|
||||
unsigned int tridx;
|
||||
int i;
|
||||
|
||||
if (extradata_len == 16*4) {
|
||||
for (i=0; i<16; i++)
|
||||
pal[i] = AV_RB32(extradata + i*4);
|
||||
this->auto_palette = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(ptr = buffer = malloc(extradata_len+1)))
|
||||
return;
|
||||
memcpy(buffer, extradata, extradata_len);
|
||||
buffer[extradata_len] = 0;
|
||||
|
||||
do {
|
||||
sscanf(ptr, "size: %dx%d", &this->orig_frame_width, &this->orig_frame_height);
|
||||
if (sscanf(ptr, "palette: %x, %x, %x, %x, %x, %x, %x, %x,"
|
||||
" %x, %x, %x, %x, %x, %x, %x, %x",
|
||||
&pal[ 0], &pal[ 1], &pal[ 2], &pal[ 3],
|
||||
&pal[ 4], &pal[ 5], &pal[ 6], &pal[ 7],
|
||||
&pal[ 8], &pal[ 9], &pal[10], &pal[11],
|
||||
&pal[12], &pal[13], &pal[14], &pal[15]) == 16) {
|
||||
for (i=0; i<16; i++)
|
||||
pal[i] = vobsub_palette_to_yuv(pal[i]);
|
||||
this->auto_palette = 0;
|
||||
}
|
||||
if (!strncasecmp(ptr, "forced subs: on", 15))
|
||||
this->forced_subs_only = 1;
|
||||
if (sscanf(ptr, "custom colors: ON, tridx: %x, colors: %x, %x, %x, %x",
|
||||
&tridx, cuspal+0, cuspal+1, cuspal+2, cuspal+3) == 5) {
|
||||
for (i=0; i<4; i++) {
|
||||
cuspal[i] = vobsub_rgb_to_yuv(cuspal[i]);
|
||||
if (tridx & (1 << (12-4*i)))
|
||||
cuspal[i] |= 1 << 31;
|
||||
}
|
||||
this->custom = 1;
|
||||
}
|
||||
} while ((ptr=strchr(ptr,'\n')) && *++ptr);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/* get palette custom color, width, height from .idx file */
|
||||
void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsigned int custom, unsigned int frame_width, unsigned int frame_height)
|
||||
void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len)
|
||||
{
|
||||
spudec_handle_t *this = calloc(1, sizeof(spudec_handle_t));
|
||||
if (this){
|
||||
//(fprintf(stderr,"VobSub Custom Palette: %d,%d,%d,%d", this->cuspal[0], this->cuspal[1], this->cuspal[2],this->cuspal[3]);
|
||||
this->packet = NULL;
|
||||
this->image = NULL;
|
||||
this->scaled_image = NULL;
|
||||
this->orig_frame_height = frame_height;
|
||||
// set up palette:
|
||||
if (palette)
|
||||
memcpy(this->global_palette, palette, sizeof(this->global_palette));
|
||||
else
|
||||
this->auto_palette = 1;
|
||||
if (extradata)
|
||||
spudec_parse_extradata(this, extradata, extradata_len);
|
||||
/* XXX Although the video frame is some size, the SPU frame is
|
||||
always maximum size i.e. 720 wide and 576 or 480 high */
|
||||
this->orig_frame_width = 720;
|
||||
this->orig_frame_height = (frame_height == 480 || frame_height == 240) ? 480 : 576;
|
||||
this->custom = custom;
|
||||
// set up palette:
|
||||
this->auto_palette = 1;
|
||||
if (palette){
|
||||
memcpy(this->global_palette, palette, sizeof(this->global_palette));
|
||||
this->auto_palette = 0;
|
||||
}
|
||||
this->custom = custom;
|
||||
if (custom && cuspal) {
|
||||
memcpy(this->cuspal, cuspal, sizeof(this->cuspal));
|
||||
this->auto_palette = 0;
|
||||
}
|
||||
// forced subtitles default: show all subtitles
|
||||
this->forced_subs_only=0;
|
||||
this->is_forced_sub=0;
|
||||
if (this->orig_frame_height == 480 || this->orig_frame_height == 240)
|
||||
this->orig_frame_height = 480;
|
||||
else
|
||||
this->orig_frame_height = 576;
|
||||
}
|
||||
else
|
||||
mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc");
|
||||
|
@ -1156,7 +1192,7 @@ void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsi
|
|||
|
||||
void *spudec_new(unsigned int *palette)
|
||||
{
|
||||
return spudec_new_scaled(palette, 0, 0);
|
||||
return spudec_new_scaled(palette, 0, 0, NULL, 0);
|
||||
}
|
||||
|
||||
void spudec_free(void *this)
|
||||
|
|
3
spudec.h
3
spudec.h
|
@ -8,8 +8,7 @@ void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pt
|
|||
void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
void spudec_draw_scaled(void *this, unsigned int dxs, unsigned int dys, void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx);
|
||||
void spudec_update_palette(void *this, unsigned int *palette);
|
||||
void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height);
|
||||
void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsigned int custom, unsigned int frame_width, unsigned int frame_height);
|
||||
void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len);
|
||||
void *spudec_new(unsigned int *palette);
|
||||
void spudec_free(void *this);
|
||||
void spudec_reset(void *this); // called after seek
|
||||
|
|
155
vobsub.c
155
vobsub.c
|
@ -595,14 +595,13 @@ packet_queue_insert(packet_queue_t *queue)
|
|||
**********************************************************************/
|
||||
|
||||
typedef struct {
|
||||
unsigned char *extradata;
|
||||
unsigned int extradata_len;
|
||||
unsigned int palette[16];
|
||||
unsigned int cuspal[4];
|
||||
int delay;
|
||||
unsigned int custom;
|
||||
unsigned int have_palette;
|
||||
unsigned int orig_frame_width, orig_frame_height;
|
||||
unsigned int origin_x, origin_y;
|
||||
unsigned int forced_subs;
|
||||
/* index */
|
||||
packet_queue_t *spu_streams;
|
||||
unsigned int spu_streams_size;
|
||||
|
@ -766,23 +765,6 @@ vobsub_parse_timestamp(vobsub_t *vob, const char *line)
|
|||
return vobsub_add_timestamp(vob, filepos, vob->delay + ms + 1000 * (s + 60 * (m + 60 * h)));
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_size(vobsub_t *vob, const char *line)
|
||||
{
|
||||
// size: WWWxHHH
|
||||
char *p;
|
||||
while (isspace(*line))
|
||||
++line;
|
||||
if (!isdigit(*line))
|
||||
return -1;
|
||||
vob->orig_frame_width = strtoul(line, &p, 10);
|
||||
if (*p != 'x')
|
||||
return -1;
|
||||
++p;
|
||||
vob->orig_frame_height = strtoul(p, NULL, 10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_origin(vobsub_t *vob, const char *line)
|
||||
{
|
||||
|
@ -827,86 +809,6 @@ unsigned int vobsub_rgb_to_yuv(unsigned int rgb)
|
|||
return y << 16 | u << 8 | v;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_palette(vobsub_t *vob, const char *line)
|
||||
{
|
||||
// palette: XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX
|
||||
unsigned int n;
|
||||
n = 0;
|
||||
while (1) {
|
||||
const char *p;
|
||||
int tmp;
|
||||
while (isspace(*line))
|
||||
++line;
|
||||
p = line;
|
||||
while (isxdigit(*p))
|
||||
++p;
|
||||
if (p - line != 6)
|
||||
return -1;
|
||||
tmp = strtoul(line, NULL, 16);
|
||||
vob->palette[n++] = vobsub_palette_to_yuv(tmp);
|
||||
if (n == 16)
|
||||
break;
|
||||
if (*p == ',')
|
||||
++p;
|
||||
line = p;
|
||||
}
|
||||
vob->have_palette = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_custom(vobsub_t *vob, const char *line)
|
||||
{
|
||||
//custom colors: OFF/ON(0/1)
|
||||
if ((strncmp("ON", line + 15, 2) == 0)||strncmp("1", line + 15, 1) == 0)
|
||||
vob->custom=1;
|
||||
else if ((strncmp("OFF", line + 15, 3) == 0)||strncmp("0", line + 15, 1) == 0)
|
||||
vob->custom=0;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_cuspal(vobsub_t *vob, const char *line)
|
||||
{
|
||||
//colors: XXXXXX, XXXXXX, XXXXXX, XXXXXX
|
||||
unsigned int n, tmp;
|
||||
n = 0;
|
||||
line += 40;
|
||||
while(1){
|
||||
const char *p;
|
||||
while (isspace(*line))
|
||||
++line;
|
||||
p=line;
|
||||
while (isxdigit(*p))
|
||||
++p;
|
||||
if (p - line !=6)
|
||||
return -1;
|
||||
tmp = strtoul(line, NULL, 16);
|
||||
vob->cuspal[n++] |= vobsub_rgb_to_yuv(tmp);
|
||||
if (n==4)
|
||||
break;
|
||||
if(*p == ',')
|
||||
++p;
|
||||
line = p;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_tridx(vobsub_t *vob, const char *line)
|
||||
{
|
||||
//tridx: XXXX
|
||||
int tridx, i;
|
||||
tridx = strtoul((line + 26), NULL, 2);
|
||||
for (i = 0; i < 4; ++i)
|
||||
if ((tridx << i) & 0x08)
|
||||
vob->cuspal[i] |= 1 << 31;
|
||||
return tridx;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_delay(vobsub_t *vob, const char *line)
|
||||
{
|
||||
|
@ -941,26 +843,6 @@ vobsub_set_lang(const char *line)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_forced_subs(vobsub_t *vob, const char *line)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
p = line;
|
||||
while (isspace(*p))
|
||||
++p;
|
||||
|
||||
if (strncasecmp("on",p,2) == 0){
|
||||
vob->forced_subs=~0;
|
||||
return 0;
|
||||
} else if (strncasecmp("off",p,3) == 0){
|
||||
vob->forced_subs=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd)
|
||||
{
|
||||
|
@ -973,6 +855,12 @@ vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd)
|
|||
if (line_size < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
vob->extradata = realloc(vob->extradata, vob->extradata_len+line_size+1);
|
||||
memcpy(vob->extradata+vob->extradata_len, line, line_size);
|
||||
vob->extradata_len += line_size;
|
||||
vob->extradata[vob->extradata_len] = 0;
|
||||
|
||||
if (*line == 0 || *line == '\r' || *line == '\n' || *line == '#')
|
||||
continue;
|
||||
else if (strncmp("langidx:", line, 8) == 0)
|
||||
|
@ -981,19 +869,10 @@ vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd)
|
|||
res = vobsub_parse_delay(vob, line);
|
||||
else if (strncmp("id:", line, 3) == 0)
|
||||
res = vobsub_parse_id(vob, line + 3);
|
||||
else if (strncmp("palette:", line, 8) == 0)
|
||||
res = vobsub_parse_palette(vob, line + 8);
|
||||
else if (strncmp("size:", line, 5) == 0)
|
||||
res = vobsub_parse_size(vob, line + 5);
|
||||
else if (strncmp("org:", line, 4) == 0)
|
||||
res = vobsub_parse_origin(vob, line + 4);
|
||||
else if (strncmp("timestamp:", line, 10) == 0)
|
||||
res = vobsub_parse_timestamp(vob, line + 10);
|
||||
else if (strncmp("custom colors:", line, 14) == 0)
|
||||
//custom colors: ON/OFF, tridx: XXXX, colors: XXXXXX, XXXXXX, XXXXXX,XXXXXX
|
||||
res = vobsub_parse_cuspal(vob, line) + vobsub_parse_tridx(vob, line) + vobsub_parse_custom(vob, line);
|
||||
else if (strncmp("forced subs:", line, 12) == 0)
|
||||
res = vobsub_parse_forced_subs(vob, line + 12);
|
||||
else {
|
||||
mp_msg(MSGT_VOBSUB,MSGL_V, "vobsub: ignoring %s", line);
|
||||
continue;
|
||||
|
@ -1115,11 +994,10 @@ vobsub_open(const char *const name,const char *const ifo,const int force,void**
|
|||
/* NOOP */ ;
|
||||
rar_close(fd);
|
||||
}
|
||||
/* if no palette in .idx then use custom colors */
|
||||
if ((vob->custom == 0)&&(vob->have_palette!=1))
|
||||
vob->custom = 1;
|
||||
if (spu && vob->orig_frame_width && vob->orig_frame_height)
|
||||
*spu = spudec_new_scaled_vobsub(vob->palette, vob->cuspal, vob->custom, vob->orig_frame_width, vob->orig_frame_height);
|
||||
if (spu)
|
||||
*spu = spudec_new_scaled(vob->palette, vob->orig_frame_width, vob->orig_frame_height, vob->extradata, vob->extradata_len);
|
||||
if (vob->extradata)
|
||||
free(vob->extradata);
|
||||
|
||||
/* read the indexed mpeg_stream */
|
||||
strcpy(buf, name);
|
||||
|
@ -1252,15 +1130,6 @@ int vobsub_get_index_by_id(void *vobhandle, int id)
|
|||
return j;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
vobsub_get_forced_subs_flag(void const * const vobhandle)
|
||||
{
|
||||
if (vobhandle)
|
||||
return ((vobsub_t*) vobhandle)->forced_subs;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
vobsub_set_from_lang(void *vobhandle, unsigned char * lang)
|
||||
{
|
||||
|
|
1
vobsub.h
1
vobsub.h
|
@ -24,7 +24,6 @@ extern void *vobsub_out_open(const char *basename, const unsigned int *palette,
|
|||
extern void vobsub_out_output(void *me, const unsigned char *packet, int len, double pts);
|
||||
extern void vobsub_out_close(void *me);
|
||||
extern int vobsub_set_from_lang(void *vobhandle, unsigned char * lang);
|
||||
extern unsigned int vobsub_get_forced_subs_flag(void const * const vobhandle);
|
||||
extern void vobsub_seek(void * vobhandle, float pts);
|
||||
|
||||
#endif /* MPLAYER_VOBSUB_H */
|
||||
|
|
Loading…
Reference in New Issue