[xiph-commits] r15453 - in trunk/vorbis-tools: . oggenc oggenc/man
ivo at svn.xiph.org
ivo at svn.xiph.org
Sat Oct 25 08:13:12 PDT 2008
Author: ivo
Date: 2008-10-25 08:13:12 -0700 (Sat, 25 Oct 2008)
New Revision: 15453
Modified:
trunk/vorbis-tools/CHANGES
trunk/vorbis-tools/oggenc/lyrics.c
trunk/vorbis-tools/oggenc/man/oggenc.1
trunk/vorbis-tools/oggenc/oggenc.c
Log:
Final Kate support changes by ogg.k.ogg.k:
* Handle LRC files with non centisecond precision
* Enable Skeleton by default
* Fix Skeleton serial not being set
Closes #1403
Modified: trunk/vorbis-tools/CHANGES
===================================================================
--- trunk/vorbis-tools/CHANGES 2008-10-25 13:41:58 UTC (rev 15452)
+++ trunk/vorbis-tools/CHANGES 2008-10-25 15:13:12 UTC (rev 15453)
@@ -27,6 +27,7 @@
* oggenc: fixed the encoding of extended characters in Windows (#268)
* oggenc: validate raw UTF-8 sent to oggenc (#268)
* oggenc: include the PID in the RNG seed to get a unique serial (#1432)
+ * oggenc: lyrics support using .lrc as source; requires libkate (#1403)
* ogginfo: support for information in Kate streams (#1360)
* vcut: 64 bit fixes (#1366)
* vorbiscomment: correct memory allocation (#472)
Modified: trunk/vorbis-tools/oggenc/lyrics.c
===================================================================
--- trunk/vorbis-tools/oggenc/lyrics.c 2008-10-25 13:41:58 UTC (rev 15452)
+++ trunk/vorbis-tools/oggenc/lyrics.c 2008-10-25 15:13:12 UTC (rev 15453)
@@ -235,13 +235,27 @@
km->durations[km->ncurves-1]=dt;
}
+static int fraction_to_milliseconds(int fraction,int digits)
+{
+ while (digits<3) {
+ fraction*=10;
+ ++digits;
+ }
+ while (digits>3) {
+ fraction/=10;
+ --digits;
+ }
+ return fraction;
+}
+
static kate_motion *process_enhanced_lrc_tags(char *str,kate_float start_time,kate_float end_time,int line)
{
char *start,*end;
int ret;
- int m,s,cs;
+ int m,s,fs;
kate_motion *km=NULL;
kate_float current_time = start_time;
+ int f0,f1;
if (!str) return NULL;
@@ -253,16 +267,17 @@
if (!end) break;
/* we found a <> pair, parse it */
- ret=sscanf(start,"<%d:%d.%d>",&m,&s,&cs);
+ f0=f1=-1;
+ ret=sscanf(start,"<%d:%d.%n%d%n>",&m,&s,&f0,&fs,&f1);
/* remove the <> tag from input to get raw text */
memmove(start,end+1,strlen(end+1)+1);
- if (ret!=3 || (m|s|cs)<0) {
+ if (ret<3 || (f0|f1)<0 || f0>=f1 || (m|s|fs)<0) {
fprintf(stderr, _("WARNING - line %d: failed to process enhanced LRC tag (%*.*s) - ignored\n"),line,(int)(end-start+1),(int)(end-start+1),start);
}
else {
- kate_float tag_time=hmsms2s(0,m,s,cs*10);
+ kate_float tag_time=hmsms2s(0,m,s,fraction_to_milliseconds(fs,f1-f0));
/* if this is the first tag in this line, create a kate motion */
if (!km) {
@@ -296,12 +311,13 @@
oe_lyrics *lyrics;
static char str[4096];
static char lyrics_line[4096]="";
- int m,s,cs;
+ int m,s,fs;
double t,start_time = -1.0;
int offset;
int ret;
unsigned line=0;
kate_motion *km;
+ int f0,f1;
if (!f) return NULL;
@@ -309,8 +325,8 @@
fgets2(str,sizeof(str),f);
++line;
while (!feof(f)) {
- ret = sscanf(str, "[%d:%d.%d]%n\n",&m,&s,&cs,&offset);
- if (ret == 3)
+ ret = sscanf(str, "[%d:%d.%d]%n\n",&m,&s,&fs,&offset);
+ if (ret >= 3)
break;
fgets2(str,sizeof(str),f);
++line;
@@ -329,13 +345,14 @@
while (!feof(f)) {
/* ignore empty lines */
if (!is_line_empty(str)) {
- ret=sscanf(str, "[%d:%d.%d]%n\n",&m,&s,&cs,&offset);
- if (ret != 3 || (m|s|cs)<0) {
+ f0=f1=-1;
+ ret=sscanf(str, "[%d:%d.%n%d%n]%n\n",&m,&s,&f0,&fs,&f1,&offset);
+ if (ret<3 || (f0|f1)<0 || f1<=f0 || (m|s|fs)<0) {
fprintf(stderr,_("ERROR - line %u: Syntax error: %s\n"),line,str);
free_lyrics(lyrics);
return NULL;
}
- t=hmsms2s(0,m,s,cs*10);
+ t=hmsms2s(0,m,s,fraction_to_milliseconds(fs,f1-f0));
if (start_time>=0.0 && !is_line_empty(lyrics_line)) {
km=process_enhanced_lrc_tags(lyrics_line,start_time,t,line);
@@ -436,12 +453,12 @@
void free_lyrics(oe_lyrics *lyrics)
{
+#ifdef HAVE_KATE
size_t n,c;
if (lyrics) {
for (n=0; n<lyrics->count; ++n) {
oe_lyrics_item *li=&lyrics->lyrics[n];
free(li->text);
-#ifdef HAVE_KATE
if (li->km) {
for (c=0; c<li->km->ncurves; ++c) {
free(li->km->curves[c]->pts);
@@ -451,16 +468,20 @@
free(li->km->durations);
free(li->km);
}
-#endif
}
free(lyrics->lyrics);
free(lyrics);
}
+#endif
}
const oe_lyrics_item *get_lyrics(const oe_lyrics *lyrics, double t, size_t *idx)
{
+#ifdef HAVE_KATE
if (!lyrics || *idx>=lyrics->count) return NULL;
if (lyrics->lyrics[*idx].t0 > t) return NULL;
return &lyrics->lyrics[(*idx)++];
+#else
+ return NULL;
+#endif
}
Modified: trunk/vorbis-tools/oggenc/man/oggenc.1
===================================================================
--- trunk/vorbis-tools/oggenc/man/oggenc.1 2008-10-25 13:41:58 UTC (rev 15452)
+++ trunk/vorbis-tools/oggenc/man/oggenc.1 2008-10-25 15:13:12 UTC (rev 15453)
@@ -227,6 +227,8 @@
.B kateenc(1)
should be used instead.
When embedding lyrics, the default output file extention is ".oga".
+Note that adding lyrics to a stream will automatically enable Skeleton
+(see the \fB-k\fR option for more information about Skeleton).
.IP "-Y language-string, --lyrics-language language-string"
Sets the language for the corresponding lyrics file to
Modified: trunk/vorbis-tools/oggenc/oggenc.c
===================================================================
--- trunk/vorbis-tools/oggenc/oggenc.c 2008-10-25 13:41:58 UTC (rev 15452)
+++ trunk/vorbis-tools/oggenc/oggenc.c 2008-10-25 15:13:12 UTC (rev 15453)
@@ -147,9 +147,9 @@
start in the same second will generate different serial numbers. */
srand(time(NULL) ^ getpid());
opt.serial = rand();
- opt.skeleton_serial = opt.serial + numfiles;
- opt.kate_serial = opt.skeleton_serial + numfiles;
}
+ opt.skeleton_serial = opt.serial + numfiles;
+ opt.kate_serial = opt.skeleton_serial + numfiles;
for(i = 0; i < numfiles; i++)
{
@@ -170,6 +170,7 @@
/* Set various encoding defaults */
enc_opts.serialno = opt.serial++;
+ enc_opts.skeleton_serialno = opt.skeleton_serial++;
enc_opts.kate_serialno = opt.kate_serial++;
enc_opts.progress_update = update_statistics_full;
enc_opts.start_encode = start_encode_full;
@@ -955,6 +956,7 @@
#ifdef HAVE_KATE
opt->lyrics = realloc(opt->lyrics, (++opt->lyrics_count)*sizeof(char *));
opt->lyrics[opt->lyrics_count - 1] = strdup(optarg);
+ opt->with_skeleton = 1;
#else
fprintf(stderr, _("WARNING: Kate support not compiled in; lyrics will not be included.\n"));
#endif
More information about the commits
mailing list