[xiph-commits] r17502 - trunk/ffmpeg2theora/src
oggk at svn.xiph.org
oggk at svn.xiph.org
Sun Oct 10 07:56:00 PDT 2010
Author: oggk
Date: 2010-10-10 07:56:00 -0700 (Sun, 10 Oct 2010)
New Revision: 17502
Modified:
trunk/ffmpeg2theora/src/ffmpeg2theora.c
trunk/ffmpeg2theora/src/ffmpeg2theora.h
trunk/ffmpeg2theora/src/subtitles.c
trunk/ffmpeg2theora/src/theorautils.c
trunk/ffmpeg2theora/src/theorautils.h
Log:
support display coordinates in SRT input; OK'd by j.
Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c 2010-10-10 14:55:10 UTC (rev 17501)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c 2010-10-10 14:56:00 UTC (rev 17502)
@@ -1693,7 +1693,7 @@
while (ks->subtitles_count < ks->num_subtitles && sub->t0-1.0 <= avtime+this->start_time) {
#ifdef HAVE_KATE
if (sub->text) {
- oggmux_add_kate_text(&info, i, sub->t0, sub->t1, sub->text, sub->len);
+ oggmux_add_kate_text(&info, i, sub->t0, sub->t1, sub->text, sub->len, sub->x1, sub->x2, sub->y1, sub->y2);
}
else {
oggmux_add_kate_image(&info, i, sub->t0, sub->t1, &sub->kr, &sub->kp, &sub->kb);
Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.h
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.h 2010-10-10 14:55:10 UTC (rev 17501)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.h 2010-10-10 14:56:00 UTC (rev 17502)
@@ -13,6 +13,7 @@
kate_palette kp;
kate_bitmap kb;
#endif
+ int x1,x2,y1,y2;
} ff2theora_subtitle;
typedef struct ff2theora_kate_stream{
Modified: trunk/ffmpeg2theora/src/subtitles.c
===================================================================
--- trunk/ffmpeg2theora/src/subtitles.c 2010-10-10 14:55:10 UTC (rev 17501)
+++ trunk/ffmpeg2theora/src/subtitles.c 2010-10-10 14:56:00 UTC (rev 17502)
@@ -343,6 +343,7 @@
int id;
static char text[4096];
int h0,m0,s0,ms0,h1,m1,s1,ms1;
+ int x1,x2,y1,y2;
double t0=0.0;
double t1=0.0;
static char str[4096];
@@ -397,17 +398,25 @@
}
break;
case need_timing:
- ret=sscanf(str,"%d:%d:%d%*[.,]%d --> %d:%d:%d%*[.,]%d\n",&h0,&m0,&s0,&ms0,&h1,&m1,&s1,&ms1);
- if (ret!=8 || (h0|m0|s0|ms0)<0 || (h1|m1|s1|ms1)<0) {
- warn(frontend, this->filename, line, "Syntax error: %s",str);
+ ret=sscanf(str,"%d:%d:%d%*[.,]%d --> %d:%d:%d%*[.,]%d %*[xX]1: %d %*[xX]2: %d %*[yY]1: %d %*[yY]2: %d\n",&h0,&m0,&s0,&ms0,&h1,&m1,&s1,&ms1,&x1,&x2,&y1,&y2);
+ if (ret!=12) {
+ x1=y1=x2=y2=-INT_MAX;
+ ret=sscanf(str,"%d:%d:%d%*[.,]%d --> %d:%d:%d%*[.,]%d\n",&h0,&m0,&s0,&ms0,&h1,&m1,&s1,&ms1);
+ if (ret!=8) {
+ warn(frontend, this->filename, line, "Syntax error: %s",str);
+ fclose(f);
+ free(this->subtitles);
+ return -1;
+ }
+ }
+ t0=hmsms2s(h0,m0,s0,ms0);
+ t1=hmsms2s(h1,m1,s1,ms1);
+ if ((h0|m0|s0|ms0)<0 || (h1|m1|s1|ms1)<0) {
+ warn(frontend, this->filename, line, "Bad timestamp specification: %s",str);
fclose(f);
free(this->subtitles);
return -1;
}
- else {
- t0=hmsms2s(h0,m0,s0,ms0);
- t1=hmsms2s(h1,m1,s1,ms1);
- }
need=need_text;
break;
case need_text:
@@ -452,6 +461,10 @@
this->subtitles[this->num_subtitles].len = len;
this->subtitles[this->num_subtitles].t0 = t0;
this->subtitles[this->num_subtitles].t1 = t1;
+ this->subtitles[this->num_subtitles].x1 = x1;
+ this->subtitles[this->num_subtitles].x2 = x2;
+ this->subtitles[this->num_subtitles].y1 = y1;
+ this->subtitles[this->num_subtitles].y2 = y2;
this->num_subtitles++;
}
need=need_id;
@@ -522,6 +535,10 @@
ks->subtitles[ks->num_subtitles].len = utf8len;
ks->subtitles[ks->num_subtitles].t0 = t;
ks->subtitles[ks->num_subtitles].t1 = t+duration;
+ ks->subtitles[ks->num_subtitles].x1 = -INT_MAX;
+ ks->subtitles[ks->num_subtitles].x2 = -INT_MAX;
+ ks->subtitles[ks->num_subtitles].y1 = -INT_MAX;
+ ks->subtitles[ks->num_subtitles].y2 = -INT_MAX;
ks->num_subtitles++;
}
}
Modified: trunk/ffmpeg2theora/src/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/src/theorautils.c 2010-10-10 14:55:10 UTC (rev 17501)
+++ trunk/ffmpeg2theora/src/theorautils.c 2010-10-10 14:56:00 UTC (rev 17502)
@@ -1319,10 +1319,24 @@
* @param text the utf-8 text
* @param len the number of bytes in the text
*/
-void oggmux_add_kate_text (oggmux_info *info, int idx, double t0, double t1, const char *text, size_t len) {
+void oggmux_add_kate_text (oggmux_info *info, int idx, double t0, double t1, const char *text, size_t len, int x1, int x2, int y1, int y2) {
ogg_packet op;
oggmux_kate_stream *ks=info->kate_streams+idx;
int ret;
+ if (x1!=-INT_MAX && y1!=-INT_MAX && x2!=-INT_MAX && y2!=-INT_MAX) {
+ kate_region kr;
+ kate_region_init(&kr);
+ kr.metric=kate_pixel;
+ kr.x=x1;
+ kr.y=y1;
+ kr.w=x2-x1+1;
+ kr.h=y2-y1+1;
+ ret=kate_encode_set_region(&ks->k,&kr);
+ if (ret<0) {
+ fprintf(stderr,"Error setting region: %d\n",ret);
+ return;
+ }
+ }
ret = kate_ogg_encode_text(&ks->k, t0, t1, text, len, &op);
if (ret>=0) {
if (!info->skeleton_3 && info->passno != 1) {
Modified: trunk/ffmpeg2theora/src/theorautils.h
===================================================================
--- trunk/ffmpeg2theora/src/theorautils.h 2010-10-10 14:55:10 UTC (rev 17501)
+++ trunk/ffmpeg2theora/src/theorautils.h 2010-10-10 14:56:00 UTC (rev 17502)
@@ -168,7 +168,7 @@
extern void oggmux_add_video (oggmux_info *info, th_ycbcr_buffer ycbcr, int e_o_s);
extern void oggmux_add_audio (oggmux_info *info, int16_t * readbuffer, int bytesread, int samplesread,int e_o_s);
#ifdef HAVE_KATE
-extern void oggmux_add_kate_text (oggmux_info *info, int idx, double t0, double t1, const char *text, size_t len);
+extern void oggmux_add_kate_text (oggmux_info *info, int idx, double t0, double t1, const char *text, size_t len, int x1, int x2, int y1, int y2);
extern void oggmux_add_kate_image (oggmux_info *info, int idx, double t0, double t1, const kate_region *kr, const kate_palette *kp, const kate_bitmap *kb);
extern void oggmux_add_kate_end_packet (oggmux_info *info, int idx, double t);
#endif
More information about the commits
mailing list