Re: [FFmpeg-devel] [PATCH] avcodec/webvttdec: Deal with WebVTT escapes

2015-10-11 Thread Ricardo Constantino
Ok, nevermind. I see the srt and webvttenc samples use \h already, so
that's what you'll want.

On 11 October 2015 at 16:53, Ricardo Constantino  wrote:

>
> On 11 October 2015 at 15:37, Clément Bœsch  wrote:
>
>> nbsp → \h in ASS
>
>
> nevcairiel suggested not relying on \h being parsed as nbsp in .srt with
> VSFilter and Libass, but maybe using the unicode char itself. Unless FFmpeg
> converts \h to the char code in srtenc or something?
> Aegisub converts \h to regular space on exporting to .srt; SubtitleEdit
> leaves as \h.
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/webvttdec: Deal with WebVTT escapes

2015-10-11 Thread Ricardo Constantino
On 11 October 2015 at 15:37, Clément Bœsch  wrote:

> nbsp → \h in ASS


nevcairiel suggested not relying on \h being parsed as nbsp in .srt with
VSFilter and Libass, but maybe using the unicode char itself. Unless FFmpeg
converts \h to the char code in srtenc or something?
Aegisub converts \h to regular space on exporting to .srt; SubtitleEdit
leaves as \h.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/webvttdec: Deal with WebVTT escapes

2015-10-11 Thread Clément Bœsch
On Fri, Oct 09, 2015 at 04:29:03PM +0100, Ricardo Constantino wrote:
> Bare ampersand characters are still accepted, even though out-of-spec.
> Also fixes adjacent tags not being parsed.
> 
> Fixes trac #4915
> 
> Signed-off-by: Ricardo Constantino 
> ---
>  libavcodec/webvttdec.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/webvttdec.c b/libavcodec/webvttdec.c
> index 1284a17..3b98e98 100644
> --- a/libavcodec/webvttdec.c
> +++ b/libavcodec/webvttdec.c
> @@ -37,11 +37,14 @@ static const struct {
>  {"", "{\\b1}"}, {"", "{\\b0}"},
>  {"", "{\\u1}"}, {"", "{\\u0}"},
>  {"{", "\\{"}, {"}", "\\}"}, // escape to avoid ASS markup conflicts
> +{">", ">"}, {"<", "<"},
> +{"‎", ""}, {"‏", ""}, // FIXME: properly honor bidi marks

> +{"&", "&"}, {" ", " "},

nbsp → \h in ASS

See http://docs.aegisub.org/3.2/ASS_Tags/

>  };
>  
>  static int webvtt_event_to_ass(AVBPrint *buf, const char *p)
>  {
> -int i, skip = 0;
> +int i, again, skip = 0;
>  
>  while (*p) {
>  
> @@ -51,13 +54,19 @@ static int webvtt_event_to_ass(AVBPrint *buf, const char 
> *p)
>  if (!strncmp(p, from, len)) {
>  av_bprintf(buf, "%s", webvtt_tag_replace[i].to);
>  p += len;
> +again = 1;
>  break;
>  }
>  }
>  if (!*p)
>  break;
>  
> -if (*p == '<')
> +if (again) {
> +again = 0;
> +skip = 0;
> +continue;
> +}

> +else if (*p == '<')

nit: this else can be kept away to keep the diff small.

[...]

-- 
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] avcodec/webvttdec: Deal with WebVTT escapes

2015-10-09 Thread Ricardo Constantino
Bare ampersand characters are still accepted, even though out-of-spec.
Also fixes adjacent tags not being parsed.

Fixes trac #4915

Signed-off-by: Ricardo Constantino 
---
 libavcodec/webvttdec.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavcodec/webvttdec.c b/libavcodec/webvttdec.c
index 1284a17..3b98e98 100644
--- a/libavcodec/webvttdec.c
+++ b/libavcodec/webvttdec.c
@@ -37,11 +37,14 @@ static const struct {
 {"", "{\\b1}"}, {"", "{\\b0}"},
 {"", "{\\u1}"}, {"", "{\\u0}"},
 {"{", "\\{"}, {"}", "\\}"}, // escape to avoid ASS markup conflicts
+{">", ">"}, {"<", "<"},
+{"‎", ""}, {"‏", ""}, // FIXME: properly honor bidi marks
+{"&", "&"}, {" ", " "},
 };
 
 static int webvtt_event_to_ass(AVBPrint *buf, const char *p)
 {
-int i, skip = 0;
+int i, again, skip = 0;
 
 while (*p) {
 
@@ -51,13 +54,19 @@ static int webvtt_event_to_ass(AVBPrint *buf, const char *p)
 if (!strncmp(p, from, len)) {
 av_bprintf(buf, "%s", webvtt_tag_replace[i].to);
 p += len;
+again = 1;
 break;
 }
 }
 if (!*p)
 break;
 
-if (*p == '<')
+if (again) {
+again = 0;
+skip = 0;
+continue;
+}
+else if (*p == '<')
 skip = 1;
 else if (*p == '>')
 skip = 0;
-- 
2.6.0

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