Re: [FFmpeg-devel] [PATCH v2 8/9] lavc/ccaption_dec: implement positioning for closed captions

2016-01-13 Thread wm4
On Wed, 13 Jan 2016 08:57:30 +0100
Clément Bœsch  wrote:

> On Tue, Jan 12, 2016 at 05:42:59PM -0800, Aman Gupta wrote:
> > From: Aman Gupta 
> > 
> > Positioning math is based on the guidelines in
> > https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/608toVTT.html#positioning-in-cea-608
> > ---
> >  libavcodec/ccaption_dec.c | 29 +
> >  1 file changed, 25 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c  
> [...]
> > +x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j);
> > +y = ASS_DEFAULT_PLAYRESY * (0.1 + 0.0533 * i);
> > +av_bprintf(>buffer, "{\\an7}{\\pos(%d,%d)}", x, y);
> > +  
> 
> I'd be happier if the default alignment could be passed to
> ff_ass_subtitle_header() instead.
> 
> Also, how confident are you about the support of the position? Because if
> it's incorrect in some cases, the default positioning is probably much
> better.

That's just my position as a single API-user, but I think it would be
good if the ASS producers that the style can be completely overridden.
It doesn't make much sense to force applications to display the (in
other cases) completely arbitrary style libavcodec makes up.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 8/9] lavc/ccaption_dec: implement positioning for closed captions

2016-01-12 Thread Clément Bœsch
On Tue, Jan 12, 2016 at 05:42:59PM -0800, Aman Gupta wrote:
> From: Aman Gupta 
> 
> Positioning math is based on the guidelines in
> https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/608toVTT.html#positioning-in-cea-608
> ---
>  libavcodec/ccaption_dec.c | 29 +
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
[...]
> +x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j);
> +y = ASS_DEFAULT_PLAYRESY * (0.1 + 0.0533 * i);
> +av_bprintf(>buffer, "{\\an7}{\\pos(%d,%d)}", x, y);
> +

I'd be happier if the default alignment could be passed to
ff_ass_subtitle_header() instead.

Also, how confident are you about the support of the position? Because if
it's incorrect in some cases, the default positioning is probably much
better.

[...]

-- 
Clément B.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 8/9] lavc/ccaption_dec: implement positioning for closed captions

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

Positioning math is based on the guidelines in
https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/608toVTT.html#positioning-in-cea-608
---
 libavcodec/ccaption_dec.c | 29 +
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 1c8a0d0..4ec063e 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -316,7 +316,7 @@ static void roll_up(CCaptionSubContext *ctx)
 
 static int capture_screen(CCaptionSubContext *ctx)
 {
-int i;
+int i, j, tab = 0;
 struct Screen *screen = ctx->screen + ctx->active_screen;
 enum cc_font prev_font = CCFONT_REGULAR;
 av_bprint_clear(>buffer);
@@ -325,13 +325,30 @@ static int capture_screen(CCaptionSubContext *ctx)
 {
 if (CHECK_FLAG(screen->row_used, i)) {
 const char *row = screen->characters[i];
+j = 0;
+while (row[j] == ' ')
+j++;
+if (!tab || j < tab)
+tab = j;
+}
+}
+
+for (i = 0; screen->row_used && i < SCREEN_ROWS; i++)
+{
+if (CHECK_FLAG(screen->row_used, i)) {
+const char *row = screen->characters[i];
 const char *font = screen->fonts[i];
-int j = 0;
+int x, y, seen_char = 0;
+j = 0;
 
 /* skip leading space */
-while (row[j] == ' ')
+while (row[j] == ' ' && j < tab)
 j++;
 
+x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j);
+y = ASS_DEFAULT_PLAYRESY * (0.1 + 0.0533 * i);
+av_bprintf(>buffer, "{\\an7}{\\pos(%d,%d)}", x, y);
+
 for (; j < SCREEN_COLUMNS; j++) {
 const char *e_tag = "", *s_tag = "";
 
@@ -365,8 +382,12 @@ static int capture_screen(CCaptionSubContext *ctx)
 prev_font = font[j];
 if (row[j] == 1)
 av_bprintf(>buffer, "%s%s\u266A", e_tag, s_tag);
-else
+else if (row[j] == ' ' && !seen_char)
+av_bprintf(>buffer, "%s%s\\h", e_tag, s_tag);
+else {
 av_bprintf(>buffer, "%s%s%c", e_tag, s_tag, row[j]);
+seen_char = 1;
+}
 
 }
 av_bprintf(>buffer, "\\N");
-- 
2.5.3

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel