[FFmpeg-devel] [PATCH v2] avformat/hlsenc: add hls_fmp4_init_resend option

2020-04-06 Thread Steven Liu
add option for resend init file after m3u8 refresh everytime.

Signed-off-by: Steven Liu 
---
 doc/muxers.texi  |  3 +++
 libavformat/hlsenc.c | 41 -
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index d304181671..8f2dcc4610 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -836,6 +836,9 @@ fmp4 files may be used in HLS version 7 and above.
 @item hls_fmp4_init_filename @var{filename}
 Set filename to the fragment files header file, default filename is 
@file{init.mp4}.
 
+@item hls_fmp4_init_refresh @var{filename}
+Resend init file after m3u8 file refresh every time, default is @var{0}.
+
 When @code{var_stream_map} is set with two or more variant streams, the
 @var{filename} pattern must contain the string "%v", this string specifies
 the position of variant stream index in the generated init file names.
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index b4c72b6e54..dbf0381b75 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -119,6 +119,7 @@ typedef struct VariantStream {
 int packets_written;
 int init_range_length;
 uint8_t *temp_buffer;
+uint8_t *init_buffer;
 
 AVFormatContext *avf;
 AVFormatContext *vtt_avf;
@@ -192,6 +193,7 @@ typedef struct HLSContext {
 char *segment_filename;
 char *fmp4_init_filename;
 int segment_type;
+int resend_init_file;  ///< resend init file into disk after refresh m3u8
 
 int use_localtime;  ///< flag to expand filename with localtime
 int use_localtime_mkdir;///< flag to mkdir dirname in timebased filename
@@ -2234,6 +2236,23 @@ static int hls_write_header(AVFormatContext *s)
 return ret;
 }
 
+static int hls_init_file_refresh(AVFormatContext *s, VariantStream *vs)
+{
+HLSContext *hls = s->priv_data;
+AVDictionary *options = NULL;
+int ret = 0;
+
+set_http_options(s, , hls);
+ret = hlsenc_io_open(s, >out, hls->fmp4_init_filename, );
+av_dict_free();
+if (ret < 0)
+return ret;
+avio_write(vs->out, vs->init_buffer, vs->init_range_length);
+hlsenc_io_close(s, >out, hls->fmp4_init_filename);
+
+return ret;
+}
+
 static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 HLSContext *hls = s->priv_data;
@@ -2246,7 +2265,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 int range_length = 0;
 const char *proto = NULL;
 int use_temp_file = 0;
-uint8_t *buffer = NULL;
 VariantStream *vs = NULL;
 char *old_filename = NULL;
 
@@ -2332,9 +2350,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 avio_flush(oc->pb);
 if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 if (!vs->init_range_length) {
-range_length = avio_close_dyn_buf(oc->pb, );
-avio_write(vs->out, buffer, range_length);
-av_freep();
+range_length = avio_close_dyn_buf(oc->pb, >init_buffer);
+if (range_length <= 0)
+return AVERROR(EINVAL);
+avio_write(vs->out, vs->init_buffer, range_length);
+if (!hls->resend_init_file)
+av_freep(>init_buffer);
 vs->init_range_length = range_length;
 avio_open_dyn_buf(>pb);
 vs->packets_written = 0;
@@ -2446,6 +2467,14 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 }
 
+if (hls->resend_init_file && hls->segment_type == SEGMENT_TYPE_FMP4) {
+ret = hls_init_file_refresh(s, vs);
+if (ret < 0) {
+av_freep(_filename);
+return ret;
+}
+}
+
 if (hls->flags & HLS_SINGLE_FILE) {
 vs->number++;
 vs->start_pos += vs->size;
@@ -2510,7 +2539,8 @@ static void hls_free_variant_streams(struct HLSContext 
*hls)
 }
 
 avformat_free_context(vs->avf);
-
+if (hls->resend_init_file)
+av_freep(>init_buffer);
 hls_free_segments(vs->segments);
 hls_free_segments(vs->old_segments);
 av_freep(>m3u8_name);
@@ -3010,6 +3040,7 @@ static const AVOption options[] = {
 {"mpegts",   "make segment file to mpegts files in m3u8", 0, 
AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_MPEGTS }, 0, UINT_MAX,   E, 
"segment_type"},
 {"fmp4",   "make segment file to fragment mp4 files in m3u8", 0, 
AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_FMP4 }, 0, UINT_MAX,   E, 
"segment_type"},
 {"hls_fmp4_init_filename", "set fragment mp4 file init filename", 
OFFSET(fmp4_init_filename),   AV_OPT_TYPE_STRING, {.str = "init.mp4"},  
  0,   0, E},
+{"hls_fmp4_init_resend", "resend fragment mp4 init file after refresh m3u8 
every time", OFFSET(resend_init_file), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
 {"hls_flags", "set flags affecting HLS playlist and media file 

Re: [FFmpeg-devel] [PATCH 13/23] lavc/movtextenc: keep values in native byte order till written

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:52:08 -0600
John Stebbins  wrote:

> ---
>  libavcodec/movtextenc.c | 38 ++
>  1 file changed, 22 insertions(+), 16 deletions(-)
> 
> diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
> index 8638e303fe..5e5b786f44 100644
> --- a/libavcodec/movtextenc.c
> +++ b/libavcodec/movtextenc.c
> @@ -68,7 +68,6 @@ typedef struct {
>  HilightcolorBox hclr;
>  int count;
>  uint8_t box_flags;
> -uint16_t style_entries;
>  uint16_t style_fontID;
>  uint8_t style_fontsize;
>  uint32_t style_color;
> @@ -96,10 +95,11 @@ static void encode_styl(MovTextContext *s,
> uint32_t tsmb_type) {
>  int j;
>  uint32_t tsmb_size;
> +uint16_t style_entries;
>  if (s->box_flags & STYL_BOX) {
>  tsmb_size = s->count * STYLE_RECORD_SIZE + SIZE_ADD;
>  tsmb_size = AV_RB32(_size);
> -s->style_entries = AV_RB16(>count);
> +style_entries = AV_RB16(>count);
>  s->style_fontID = 0x00 | 0x01<<8;
>  s->style_fontsize = 0x12;
>  s->style_color = MKTAG(0xFF, 0xFF, 0xFF, 0xFF);
> @@ -107,10 +107,14 @@ static void encode_styl(MovTextContext *s,
> uint32_t tsmb_type) but will come from ASS style in the future*/
>  av_bprint_append_any(>buffer, _size, 4);
>  av_bprint_append_any(>buffer, _type, 4);
> -av_bprint_append_any(>buffer, >style_entries, 2);
> +av_bprint_append_any(>buffer, _entries, 2);
>  for (j = 0; j < s->count; j++) {
> -av_bprint_append_any(>buffer,
> >style_attributes[j]->style_start, 2);
> -av_bprint_append_any(>buffer,
> >style_attributes[j]->style_end, 2);
> +uint16_t style_start, style_end;
> +
> +style_start  =
> AV_RB16(>style_attributes[j]->style_start);
> +style_end=
> AV_RB16(>style_attributes[j]->style_end);
> +av_bprint_append_any(>buffer, _start, 2);
> +av_bprint_append_any(>buffer, _end, 2);
>  av_bprint_append_any(>buffer, >style_fontID, 2);
>  av_bprint_append_any(>buffer,
> >style_attributes[j]->style_flag, 1);
> av_bprint_append_any(>buffer, >style_fontsize, 1); @@ -123,13
> +127,16 @@ static void encode_styl(MovTextContext *s, uint32_t
> tsmb_type) static void encode_hlit(MovTextContext *s, uint32_t
> tsmb_type) { uint32_t tsmb_size;
> +uint16_t start, end;
>  if (s->box_flags & HLIT_BOX) {
>  tsmb_size = 12;
>  tsmb_size = AV_RB32(_size);
> +start = AV_RB16(>hlit.start);
> +end   = AV_RB16(>hlit.end);
>  av_bprint_append_any(>buffer, _size, 4);
>  av_bprint_append_any(>buffer, _type, 4);
> -av_bprint_append_any(>buffer, >hlit.start, 2);
> -av_bprint_append_any(>buffer, >hlit.end, 2);
> +av_bprint_append_any(>buffer, , 2);
> +av_bprint_append_any(>buffer, , 2);
>  }
>  }
>  
> @@ -222,10 +229,10 @@ static void mov_text_style_cb(void *priv, const
> char style, int close) }
>  
>  s->style_attributes_temp->style_flag = 0;
> -s->style_attributes_temp->style_start =
> AV_RB16(>text_pos);
> +s->style_attributes_temp->style_start = s->text_pos;
>  } else {
>  if (s->style_attributes_temp->style_flag) { //break the
> style record here and start a new one
> -s->style_attributes_temp->style_end =
> AV_RB16(>text_pos);
> +s->style_attributes_temp->style_end = s->text_pos;
>  av_dynarray_add(>style_attributes, >count,
> s->style_attributes_temp); s->style_attributes_temp =
> av_malloc(sizeof(*s->style_attributes_temp)); if
> (!s->style_attributes_temp) { @@ -236,10 +243,10 @@ static void
> mov_text_style_cb(void *priv, const char style, int close) }
>  
>  s->style_attributes_temp->style_flag =
> s->style_attributes[s->count - 1]->style_flag;
> -s->style_attributes_temp->style_start =
> AV_RB16(>text_pos);
> +s->style_attributes_temp->style_start = s->text_pos;
>  } else {
>  s->style_attributes_temp->style_flag = 0;
> -s->style_attributes_temp->style_start =
> AV_RB16(>text_pos);
> +s->style_attributes_temp->style_start = s->text_pos;
>  }
>  }
>  switch (style){
> @@ -257,7 +264,7 @@ static void mov_text_style_cb(void *priv, const
> char style, int close) av_log(s->avctx, AV_LOG_WARNING, "Ignoring
> unmatched close tag\n"); return;
>  } else {
> -s->style_attributes_temp->style_end = AV_RB16(>text_pos);
> +s->style_attributes_temp->style_end = s->text_pos;
>  av_dynarray_add(>style_attributes, >count,
> s->style_attributes_temp); 
>  s->style_attributes_temp =
> av_malloc(sizeof(*s->style_attributes_temp)); @@ -282,7 +289,7 @@
> static void mov_text_style_cb(void *priv, const char style, int
> close) break; }
>  if 

Re: [FFmpeg-devel] [PATCH 12/23] lavc/movtextenc: use correct color component order

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:52:07 -0600
John Stebbins  wrote:

> ---
>  libavcodec/movtextenc.c | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
> index c19ef384bc..8638e303fe 100644
> --- a/libavcodec/movtextenc.c
> +++ b/libavcodec/movtextenc.c
> @@ -39,6 +39,7 @@
>  #define HLIT_BOX   (1<<1)
>  #define HCLR_BOX   (1<<2)
>  
> +#define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c)
> >> 16) & 0xff)) #define av_bprint_append_any(buf, data, size)
> >> av_bprint_append_data(buf, ((const char*)data), size)
>  
>  typedef struct {
> @@ -134,13 +135,14 @@ static void encode_hlit(MovTextContext *s,
> uint32_t tsmb_type) 
>  static void encode_hclr(MovTextContext *s, uint32_t tsmb_type)
>  {
> -uint32_t tsmb_size;
> +uint32_t tsmb_size, color;
>  if (s->box_flags & HCLR_BOX) {
>  tsmb_size = 12;
>  tsmb_size = AV_RB32(_size);
> +color = AV_RB32(>hclr.color);
>  av_bprint_append_any(>buffer, _size, 4);
>  av_bprint_append_any(>buffer, _type, 4);
> -av_bprint_append_any(>buffer, >hclr.color, 4);
> +av_bprint_append_any(>buffer, , 4);
>  }
>  }
>  
> @@ -289,6 +291,8 @@ static void mov_text_style_cb(void *priv, const
> char style, int close) static void mov_text_color_cb(void *priv,
> unsigned int color, unsigned int color_id) {
>  MovTextContext *s = priv;
> +
> +color = BGR_TO_RGB(color) << 8;
>  if (color_id == 2) {//secondary color changes
>  if (s->box_flags & HLIT_BOX) {  //close tag
>  s->hlit.end = AV_RB16(>text_pos);
> @@ -296,7 +300,7 @@ static void mov_text_color_cb(void *priv,
> unsigned int color, unsigned int color s->box_flags |= HCLR_BOX;
>  s->box_flags |= HLIT_BOX;
>  s->hlit.start = AV_RB16(>text_pos);
> -s->hclr.color = color | (0xFF << 24);  //set alpha value
> to FF
> +s->hclr.color = color | 0xFF;  //set alpha value to FF
>  }
>  }
>  /* If there are more than one secondary color changes in ASS,
> take start of

LGTM


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avfilter/vf_drawtext: only test available exceptions

2020-04-06 Thread Rosen Penev
soft float systems do not define these macros under musl.

Fixes: Ticket7102

Signed-off-by: Rosen Penev 
---
 libavfilter/vf_drawtext.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 887a686d16..abe1ca6c35 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1085,10 +1085,12 @@ static int func_eval_expr_int_format(AVFilterContext 
*ctx, AVBPrint *bp,
 
 feclearexcept(FE_ALL_EXCEPT);
 intval = res;
+#if defined(FE_INVALID) && defined(FE_OVERFLOW) && defined(FE_UNDERFLOW)
 if ((ret = fetestexcept(FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW))) {
 av_log(ctx, AV_LOG_ERROR, "Conversion of floating-point result to int 
failed. Control register: 0x%08x. Conversion result: %d\n", ret, intval);
 return AVERROR(EINVAL);
 }
+#endif
 
 if (argc == 3)
 av_strlcatf(fmt_str, sizeof(fmt_str), "0%u", positions);
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 09/23] lavc/movtextdec: restore active style color after hilite

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:52:04 -0600
John Stebbins  wrote:

> ---
>  libavcodec/movtextdec.c | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index 4d5dcdf5e7..f3a504b47b 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -376,6 +376,7 @@ static int text_to_ass(AVBPrint *buf, const char
> *text, const char *text_end, int text_pos = 0;
>  int style_active = 0;
>  int entry = 0;
> +int color = m->d.color;
>  
>  if (text < text_end && m->box_flags & TWRP_BOX) {
>  if (m->w.wrap_flag == 1) {
> @@ -404,9 +405,10 @@ static int text_to_ass(AVBPrint *buf, const char
> *text, const char *text_end, if (m->s[entry]->style_fontID ==
> m->ftab[i]->fontID) av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font);
>  }
> -if (m->d.color != m->s[entry]->color)
> -av_bprintf(buf, "{\\1c%X&}",
> -   RGB_TO_BGR(m->s[entry]->color));
> +if (m->d.color != m->s[entry]->color) {
> +color = m->s[entry]->color;
> +av_bprintf(buf, "{\\1c%X&}",
> RGB_TO_BGR(color));
> +}
>  if (m->d.alpha != m->s[entry]->alpha)
>  av_bprintf(buf, "{\\1a%02X&}", 255 -
> m->s[entry]->alpha); }
> @@ -414,6 +416,7 @@ static int text_to_ass(AVBPrint *buf, const char
> *text, const char *text_end, if (style_active) {
>  av_bprintf(buf, "{\\r}");
>  style_active = 0;
> +color = m->d.color;
>  }
>  entry++;
>  }
> @@ -435,9 +438,10 @@ static int text_to_ass(AVBPrint *buf, const char
> *text, const char *text_end, }
>  if (text_pos == m->h.hlit_end) {
>  if (m->box_flags & HCLR_BOX) {
> -av_bprintf(buf, "{\\2c&}");
> +av_bprintf(buf, "{\\2c%X&}",
> RGB_TO_BGR(m->d.color)); } else {
> -av_bprintf(buf,
> "{\\1c&}{\\2c&}");
> +av_bprintf(buf, "{\\1c%X&}{\\2c%X&}",
> +   RGB_TO_BGR(color),
> RGB_TO_BGR(m->d.color)); }
>  }
>  }

LGTM.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 08/23] lavc/movtextdec: add color and alpha style tags

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:52:03 -0600
John Stebbins  wrote:

> ---
>  libavcodec/movtextdec.c | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index eb9c7f5755..4d5dcdf5e7 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -76,6 +76,8 @@ typedef struct {
>  uint8_t bold;
>  uint8_t italic;
>  uint8_t underline;
> +int color;
> +uint8_t alpha;
>  uint8_t fontsize;
>  uint16_t style_fontID;
>  } StyleBox;
> @@ -329,14 +331,16 @@ static int decode_styl(const uint8_t *tsmb,
> MovTextContext *m, AVPacket *avpkt) m->s_temp->underline =
> !!(m->s_temp->style_flag & STYLE_FLAG_UNDERLINE); tsmb++;
>  m->s_temp->fontsize = AV_RB8(tsmb);
> +tsmb++;
> +m->s_temp->color = AV_RB24(tsmb);
> +tsmb += 3;
> +m->s_temp->alpha = AV_RB8(tsmb);
> +tsmb++;
>  av_dynarray_add(>s, >count_s, m->s_temp);
>  if(!m->s) {
>  mov_text_cleanup(m);
>  return AVERROR(ENOMEM);
>  }
> -tsmb++;
> -// text-color-rgba
> -tsmb += 4;
>  }
>  return 0;
>  }
> @@ -400,6 +404,11 @@ static int text_to_ass(AVBPrint *buf, const char
> *text, const char *text_end, if (m->s[entry]->style_fontID ==
> m->ftab[i]->fontID) av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font);
>  }
> +if (m->d.color != m->s[entry]->color)
> +av_bprintf(buf, "{\\1c%X&}",
> +   RGB_TO_BGR(m->s[entry]->color));
> +if (m->d.alpha != m->s[entry]->alpha)
> +av_bprintf(buf, "{\\1a%02X&}", 255 -
> m->s[entry]->alpha); }
>  if (text_pos == m->s[entry]->style_end) {
>  if (style_active) {

LGTM.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 06/23] lavc/movtextdec: make sure default font name is set

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:52:01 -0600
John Stebbins  wrote:

> ---
>  libavcodec/movtextdec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index 6c7d93702e..2481c71af6 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -52,7 +52,7 @@
>  
>  typedef struct {
>  uint16_t fontID;
> -char *font;
> +const char *font;
>  uint8_t fontsize;
>  int color;
>  int back_color;
> @@ -251,6 +251,8 @@ static int mov_text_tx3g(AVCodecContext *avctx,
> MovTextContext *m) m->ftab_temp = NULL;
>  tx3g_ptr = tx3g_ptr + font_length;
>  }
> +// In case of broken header, init default font
> +m->d.font = ASS_DEFAULT_FONT;
>  for (i = 0; i < m->ftab_entries; i++) {
>  if (m->d.fontID == m->ftab[i]->fontID)
>  m->d.font = m->ftab[i]->font;

LGTM.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 07/23] lavc/movtextdec: add alpha default to ass header colors

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:52:02 -0600
John Stebbins  wrote:

> ---
>  libavcodec/movtextdec.c| 14 ++
>  tests/ref/fate/sub-movtext |  2 +-
>  2 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index 2481c71af6..eb9c7f5755 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -55,7 +55,9 @@ typedef struct {
>  const char *font;
>  uint8_t fontsize;
>  int color;
> +uint8_t alpha;
>  int back_color;
> +uint8_t back_alpha;
>  uint8_t bold;
>  uint8_t italic;
>  uint8_t underline;
> @@ -186,7 +188,9 @@ static int mov_text_tx3g(AVCodecContext *avctx,
> MovTextContext *m) }
>  // Background Color
>  m->d.back_color = AV_RB24(tx3g_ptr);
> -tx3g_ptr += 4;
> +tx3g_ptr += 3;
> +m->d.back_alpha = AV_RB8(tx3g_ptr);
> +tx3g_ptr += 1;
>  // BoxRecord
>  tx3g_ptr += 8;
>  // StyleRecord
> @@ -203,7 +207,9 @@ static int mov_text_tx3g(AVCodecContext *avctx,
> MovTextContext *m) m->d.fontsize = *tx3g_ptr++;
>  // Primary color
>  m->d.color = AV_RB24(tx3g_ptr);
> -tx3g_ptr += 4;
> +tx3g_ptr += 3;
> +m->d.alpha = AV_RB8(tx3g_ptr);
> +tx3g_ptr += 1;
>  // FontRecord
>  // FontRecord Size
>  tx3g_ptr += 4;
> @@ -463,8 +469,8 @@ static int mov_text_init(AVCodecContext *avctx) {
>  ret = mov_text_tx3g(avctx, m);
>  if (ret == 0) {
>  return ff_ass_subtitle_header(avctx, m->d.font,
> m->d.fontsize,
> -RGB_TO_BGR(m->d.color),
> -RGB_TO_BGR(m->d.back_color),
> +(255 - m->d.alpha) << 24 |
> RGB_TO_BGR(m->d.color),
> +(255 - m->d.back_alpha) << 24 |
> RGB_TO_BGR(m->d.back_color), m->d.bold, m->d.italic, m->d.underline,
>  ASS_DEFAULT_BORDERSTYLE, m->d.alignment);
>  } else
> diff --git a/tests/ref/fate/sub-movtext b/tests/ref/fate/sub-movtext
> index 94ed22d318..6047060918 100644
> --- a/tests/ref/fate/sub-movtext
> +++ b/tests/ref/fate/sub-movtext
> @@ -6,7 +6,7 @@ PlayResY: 288
>  
>  [V4+ Styles]
>  Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour,
> OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut,
> ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow,
> Alignment, MarginL, MarginR, MarginV, Encoding -Style:
> Default,Serif,18,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
> +Style:
> Default,Serif,18,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
> [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR,
> MarginV, Effect, Text

LGTM.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 02/23] lavc/movtextdec: simplify style record walk

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 22:09:22 +
John Stebbins  wrote:

> 
> I went back and double checked this in the spec before changing the
> code.
> 
> "The styles shall be ordered by starting character offset, and the
> starting offset of one style record shall be greater than or equal to
> the ending character offset of the preceding record; styles records
> shall not overlap their character ranges."

Alright. Great! LGTM then.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/aacdec: fix compilation under soft float MIPS

2020-04-06 Thread Rosen Penev
On Mon, Apr 6, 2020 at 2:42 PM Carl Eugen Hoyos  wrote:
>
> Am Mo., 6. Apr. 2020 um 07:29 Uhr schrieb Rosen Penev :
> >
> > Place HAVE_MIPSFPU further up so that functions that use floating point
> > ASM are defined away. Otherwise compilation failures result when soft
> > float in enabled on the toolchain.
>
> Could this fix ticket #7102?
> If yes, please mention it in the commit message.
No. This is totally unrelated.I am not touching vf_drawtext at all.
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 11/14] h264_sei: parse the picture timing SEIs correctly

2020-04-06 Thread Michael Niedermayer
On Fri, Mar 27, 2020 at 01:57:45PM +0100, Anton Khirnov wrote:
> Those SEIs refer to the currently active SPS. However, since the SEI
> NALUs precede the coded picture data in the bitstream, the active SPS is
> in general not known when we are decoding the SEI.
> 
> Therefore, store the content of the picture timing SEIs and actually
> parse it when the active SPS is known.
> ---
>  libavcodec/h264_parser.c |  9 +
>  libavcodec/h264_sei.c| 82 +++-
>  libavcodec/h264_sei.h| 11 ++
>  libavcodec/h264_slice.c  | 10 +
>  4 files changed, 78 insertions(+), 34 deletions(-)

probably ok

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are best at talking, realize last or never when they are wrong.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 12/14] h264_ps: make the PPS hold a reference to its SPS

2020-04-06 Thread Michael Niedermayer
On Fri, Mar 27, 2020 at 01:57:46PM +0100, Anton Khirnov wrote:
> It represents the relationship between them more naturally and will be
> useful in the following commits.
> 
> Allows significantly more frames in fate-h264-attachment-631 to be
> decoded.
> ---
>  libavcodec/h264_parser.c   |  16 +---
>  libavcodec/h264_ps.c   |  30 +-
>  libavcodec/h264_ps.h   |   4 +-
>  libavcodec/h264_slice.c|  27 +-
>  libavcodec/h264dec.c   |   4 +-
>  tests/ref/fate/h264-attachment-631 | 148 +
>  6 files changed, 184 insertions(+), 45 deletions(-)

Assuming this breaks no h264 files, LGTM

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Any man who breaks a law that conscience tells him is unjust and willingly 
accepts the penalty by staying in jail in order to arouse the conscience of 
the community on the injustice of the law is at that moment expressing the 
very highest respect for law. - Martin Luther King Jr


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 13/14] h264dec: rename flush_dpb()

2020-04-06 Thread Michael Niedermayer
On Fri, Mar 27, 2020 at 01:57:47PM +0100, Anton Khirnov wrote:
> The name is misleading, this function does a lot more than just flushing
> the DPB.
> ---
>  libavcodec/h264dec.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

still LGTM

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Any man who breaks a law that conscience tells him is unjust and willingly 
accepts the penalty by staying in jail in order to arouse the conscience of 
the community on the injustice of the law is at that moment expressing the 
very highest respect for law. - Martin Luther King Jr


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 14/14] h264dec: do not set picture_structure on init

2020-04-06 Thread Michael Niedermayer
On Fri, Mar 27, 2020 at 01:57:48PM +0100, Anton Khirnov wrote:
> This has been cargo culted from mpegvideo and serves no useful purpose.
> It will be initialize correctly in h264_field_start()
> ---
>  libavcodec/h264dec.c | 1 -
>  1 file changed, 1 deletion(-)

LGTM

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Elect your leaders based on what they did after the last election, not
based on what they say before an election.



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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] ERROR: avisynth/avisynth_c.h not found

2020-04-06 Thread Helmut K. C. Tessarek
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512


On 2020-04-05 20:02, Marton Balint wrote:
> The headers got removed because the ffmpeg source tree is no place for
> third party library headers.

I get that and it makes sense.

> Yes, avisynth was an exception, not anymore.

I also get that, but the commit message should have mentioned that.

> Actually with the change it got documented that you need to install the
> headers.
> 
> https://www.ffmpeg.org/general.html#AviSynth

Thanks for the info. Yet again, I would have expected something in the
commit message.
I ususally don't care, but this commit broke the build process.

> Sometimes you have to follow up on your compile scripts to be able to
> build the newest ffmpeg. Considering that how easy avisynth upstream made
> it to install the headers, I am sure this is only a small nuisance.

I can't tell you how often I had to change the script to compile ffmpeg.

It's not a problem, but when I run into a compile issue, I check what the
problem was. "header missing" pointed me to commit 0c75acb4ce
(compat/avisynth: remove avisynth headers), yet there was nothing in the
commit message.

Cheers,
  K. C.

- -- 
regards Helmut K. C. Tessarek  KeyID 0x172380A011EF4944
Key fingerprint = 8A55 70C1 BD85 D34E ADBC 386C 1723 80A0 11EF 4944

/*
   Thou shalt not follow the NULL pointer for chaos and madness
   await thee at its end.
*/
-BEGIN PGP SIGNATURE-

iQIzBAEBCgAdFiEE191csiqpm8f5Ln9WvgmFNJ1E3QAFAl6LsEgACgkQvgmFNJ1E
3QDCig//Q5lesp0lIsZShjH6p72V9D/cgY9v9bg+wS0Io7N5xORkeLpnXd981xyF
2E09MYt/GGyzoOcn6IQoHhCkB/5nY7/Ly+Lz4iEbhCiOel5FApnts9rswLI5mQKX
l0OOA6Y/mxu1oJ0QIAZSWneOVsPQ/1zy7aFjnWOTNoGBmE/jd4OrDkisiY75zChX
yX19mARcvMJFXGXxCtUcLj3PX95P9/CUDV3wQgWgF+H7nVA60uFw1DTirUeOdPRm
llUU1wDFRp1oxaCDNxjwPwlQUCp041HMNFtpIQzfXpcKmli5f6FmmIceHyIl0WER
ELKM/3N1YNCOEvjWp2MTWvaeWA/RdDswSBUJCJEc1evoTXcUUd8naTkyPbwBnpd5
lbu1lziq6uLHMQ+NF9mjf//yYQJA+z64++Xt/Gd9DFm0nLsqxdZIEemINrhYtxDQ
qnXE5urS7FyhDj7CL5S+DSTaLcEKW6K7Jmny3PEVhfg8iiYJDMZAClfJOzMIh+Iq
p6mFgGYSbk1JOq71utduqsKy7sPqny63T5vSCDbF9oNAqAIjGIfwJChxpqg9JuTB
4uCnhud/iLQ94V94tYQVHBx2sJpSvcT4U7G4ZSYX+FpK4afbm0pZz0+qGJALpbCl
K8ZJaha0lPgj7Rc86W4oKI/HKyWSB5e9vUuH+h3CadN5ExA6G4M=
=LCWn
-END PGP SIGNATURE-
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread Nicolas George
phunkyfish (12020-04-06):
> ---
>  libavformat/rtsp.c | 50 +-
>  1 file changed, 41 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..2b59a9330d 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -21,6 +21,7 @@
>  
>  #include "libavutil/avassert.h"
>  #include "libavutil/base64.h"
> +#include "libavutil/bprint.h"
>  #include "libavutil/avstring.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/mathematics.h"
> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> +char host[500], filters_buf[1000];
>  int ret, port;
>  URLContext* in = NULL;
>  int payload_type;
> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p;
> +AVBPrint sdp;
>  
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,16 +2516,40 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>   NULL, 0, s->url);
>  
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
> +   addr.ss_family == AF_INET ? 4 : 6, host);
> +
> +p = strchr(s->url, '?');
> +if (p) {
> +static const char *filters[][2] = {{"sources", "incl"}, {"block", 
> "excl"}, {NULL, NULL}};
> +int i;
> +char *q;
> +for (i = 0; filters[i][0]; i++) {
> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
> filters[i][0], p)) {
> +q = filters_buf;
> +while ((q = strchr(q, ',')) != NULL)
> +*q = ' ';
> +av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
> +   filters[i][1],
> +   addr.ss_family == AF_INET ? 4 : 6, host,
> +   filters_buf);

> +if (sdp.len != sdp.size)
> +goto fail_nobuf;

Only check at the end.

> +}
> +}
> +}
> +
> +av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
> +   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> +   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> +   port, payload_type);
> +av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);

> +if (sdp.len != sdp.size)
> +goto fail_nobuf;

av_bprint_is_complete(). Is this test even correct? Did you test the
code?

>  avcodec_parameters_free();
>  
> -ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
> +ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL, NULL, 
> NULL);
>  s->pb = 
>  
>  /* sdp_read_header initializes this again */
> @@ -2532,9 +2559,14 @@ static int rtp_read_header(AVFormatContext *s)
>  
>  ret = sdp_read_header(s);
>  s->pb = NULL;
> +av_bprint_finalize(, NULL);
>  return ret;
>  
> +fail_nobuf:

> +ret = AVERROR(ENOBUFS);

This is not the error code you are looking for.

> +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
> sdp-headers\n");
>  fail:
> +av_bprint_finalize(, NULL);
>  avcodec_parameters_free();
>  if (in)
>  ffurl_close(in);

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add photocd decoder

2020-04-06 Thread Carl Eugen Hoyos
Am Fr., 21. Dez. 2018 um 19:48 Uhr schrieb Paul B Mahol :
>
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/photocd.c| 493 

Would you like to commit some variant of your patch?
Possibly with a need for strict...

I believe the code ripens much better within the git repository ;-)

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread Ross Nicholson
Ok, latest patch uses AVBPrint. Please let me know if my usage is correct,
I have not used it before.

In the meantime I will get some users to test this.

On Mon, 6 Apr 2020 at 20:57, Marton Balint  wrote:

>
>
> On Mon, 6 Apr 2020, phunkyfish wrote:
>
> > ---
> > libavformat/rtsp.c | 47 ++
> > 1 file changed, 39 insertions(+), 8 deletions(-)
> >
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index cd6fc32a29..0d0bc2be0d 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
> > static int rtp_read_header(AVFormatContext *s)
> > {
> > uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> > -char host[500], sdp[500];
> > -int ret, port;
> > +char host[500], sdp[1000], filters_buf[1000];
> > +int ret, port, sdp_length, nc;
> > URLContext* in = NULL;
> > int payload_type;
> > AVCodecParameters *par = NULL;
> > @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
> > AVIOContext pb;
> > socklen_t addrlen = sizeof(addr);
> > RTSPState *rt = s->priv_data;
> > +const char *p;
> >
> > if (!ff_network_init())
> > return AVERROR(EIO);
> > @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
> > av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
> >  NULL, 0, s->url);
> >
> > -snprintf(sdp, sizeof(sdp),
> > - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> > - addr.ss_family == AF_INET ? 4 : 6, host,
> > - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> > - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> > - port, payload_type);
> > +sdp_length = snprintf(sdp, sizeof(sdp),
> > +  "v=0\r\nc=IN IP%d %s\r\n",
> > +  addr.ss_family == AF_INET ? 4 : 6, host);
>
> Please use an AVBPrint buffer instead of snprintf()-ing to sdp.
>
> Thanks,
> Marton
>
> > +
> > +p = strchr(s->url, '?');
> > +if (p) {
> > +static const char *filters[][2] = {{"sources", "incl"},
> {"block", "excl"}, {NULL, NULL}};
> > +int i;
> > +char *q;
> > +for (i = 0; filters[i][0]; i++) {
> > +if (av_find_info_tag(filters_buf, sizeof(filters_buf),
> filters[i][0], p)) {
> > +q = filters_buf;
> > +while ((q = strchr(q, ',')) != NULL)
> > +*q = ' ';
> > +nc = snprintf(sdp + sdp_length, sizeof(sdp) -
> sdp_length,
> > +  "a=source-filter:%s IN IP%d %s %s\r\n",
> > +  filters[i][1],
> > +  addr.ss_family == AF_INET ? 4 : 6, host,
> > +  filters_buf);
> > +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> > +goto fail_nobuf;
> > +sdp_length += nc;
> > +}
> > +}
> > +}
> > +
> > +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> > +  "m=%s %d RTP/AVP %d\r\n",
> > +  par->codec_type == AVMEDIA_TYPE_DATA  ? "application"
> :
> > +  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" :
> "audio",
> > +  port, payload_type);
> > av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> > +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> > +goto fail_nobuf;
> > avcodec_parameters_free();
> >
> > ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
> > @@ -2534,6 +2562,9 @@ static int rtp_read_header(AVFormatContext *s)
> > s->pb = NULL;
> > return ret;
> >
> > +fail_nobuf:
> > +ret = AVERROR(ENOBUFS);
> > +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space
> for sdp-headers\n");
> > fail:
> > avcodec_parameters_free();
> > if (in)
> > --
> > 2.24.1 (Apple Git-126)
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 02/23] lavc/movtextdec: simplify style record walk

2020-04-06 Thread John Stebbins
On Mon, 2020-04-06 at 14:46 -0700, Philip Langdale wrote:
> On Mon, 6 Apr 2020 11:51:57 -0600
> John Stebbins  wrote:
> 
> > It's not necessary to walk the style record list twice per subtitle
> > character.  style records are in order and do not overlap.
> > ---
> >  libavcodec/movtextdec.c | 38 -
> > -
> >  1 file changed, 20 insertions(+), 18 deletions(-)
> > 
> > diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> > index 05becaf64d..47a8401119 100644
> > --- a/libavcodec/movtextdec.c
> > +++ b/libavcodec/movtextdec.c
> > @@ -355,8 +355,9 @@ static int text_to_ass(AVBPrint *buf, const
> > char
> > *text, const char *text_end, {
> >  MovTextContext *m = avctx->priv_data;
> >  int i = 0;
> > -int j = 0;
> >  int text_pos = 0;
> > +int style_active = 0;
> > +int entry = 0;
> >  
> >  if (text < text_end && m->box_flags & TWRP_BOX) {
> >  if (m->w.wrap_flag == 1) {
> > @@ -369,26 +370,27 @@ static int text_to_ass(AVBPrint *buf, const
> > char *text, const char *text_end, while (text < text_end) {
> >  int len;
> >  
> > -if (m->box_flags & STYL_BOX) {
> > -for (i = 0; i < m->style_entries; i++) {
> > -if (m->s[i]->style_flag && text_pos ==
> > m->s[i]->style_end) {
> > -av_bprintf(buf, "{\\r}");
> > +if ((m->box_flags & STYL_BOX) && entry < m->style_entries) 
> > {
> > +if (text_pos == m->s[entry]->style_start) {
> > +style_active = 1;
> > +if (m->s[entry]->style_flag & STYLE_FLAG_BOLD)
> > +av_bprintf(buf, "{\\b1}");
> > +if (m->s[entry]->style_flag & STYLE_FLAG_ITALIC)
> > +av_bprintf(buf, "{\\i1}");
> > +if (m->s[entry]->style_flag &
> > STYLE_FLAG_UNDERLINE)
> > +av_bprintf(buf, "{\\u1}");
> > +av_bprintf(buf, "{\\fs%d}", m->s[entry]-
> > >fontsize);
> > +for (i = 0; i < m->ftab_entries; i++) {
> > +if (m->s[entry]->style_fontID ==
> > m->ftab[i]->fontID)
> > +av_bprintf(buf, "{\\fn%s}",
> > m->ftab[i]->font); }
> >  }
> > -for (i = 0; i < m->style_entries; i++) {
> > -if (m->s[i]->style_flag && text_pos ==
> > m->s[i]->style_start) {
> > -if (m->s[i]->style_flag & STYLE_FLAG_BOLD)
> > -av_bprintf(buf, "{\\b1}");
> > -if (m->s[i]->style_flag & STYLE_FLAG_ITALIC)
> > -av_bprintf(buf, "{\\i1}");
> > -if (m->s[i]->style_flag &
> > STYLE_FLAG_UNDERLINE)
> > -av_bprintf(buf, "{\\u1}");
> > -av_bprintf(buf, "{\\fs%d}", m->s[i]-
> > >fontsize);
> > -for (j = 0; j < m->ftab_entries; j++) {
> > -if (m->s[i]->style_fontID ==
> > m->ftab[j]->fontID)
> > -av_bprintf(buf, "{\\fn%s}",
> > m->ftab[j]->font);
> > -}
> > +if (text_pos == m->s[entry]->style_end) {
> > +if (style_active) {
> > +av_bprintf(buf, "{\\r}");
> > +style_active = 0;
> >  }
> > +entry++;
> >  }
> >  }
> >  if (m->box_flags & HLIT_BOX) {
> 
> OK. I could not convince myself originally that styles could not
> overlap, but I could easily have missed that in the spec.
> 

I went back and double checked this in the spec before changing the
code.

"The styles shall be ordered by starting character offset, and the
starting offset of one style record shall be greater than or equal to
the ending character offset of the preceding record; styles records
shall not overlap their character ranges."
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 05/23] lavc/movtextdec: only write fontsize, fontID tags if not default

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:52:00 -0600
John Stebbins  wrote:

> ---
>  libavcodec/movtextdec.c | 20 +++-
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index a3e37d013d..6c7d93702e 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -51,8 +51,9 @@
>  #define RGB_TO_BGR(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c)
> >> 16) & 0xff)) 
>  typedef struct {
> +uint16_t fontID;
>  char *font;
> -int fontsize;
> +uint8_t fontsize;
>  int color;
>  int back_color;
>  uint8_t bold;
> @@ -146,7 +147,6 @@ static int mov_text_tx3g(AVCodecContext *avctx,
> MovTextContext *m) uint8_t *tx3g_ptr = avctx->extradata;
>  int i, box_size, font_length;
>  int8_t v_align, h_align;
> -int style_fontID;
>  StyleBox s_default;
>  
>  m->count_f = 0;
> @@ -192,7 +192,7 @@ static int mov_text_tx3g(AVCodecContext *avctx,
> MovTextContext *m) // StyleRecord
>  tx3g_ptr += 4;
>  // fontID
> -style_fontID = AV_RB16(tx3g_ptr);
> +m->d.fontID = AV_RB16(tx3g_ptr);
>  tx3g_ptr += 2;
>  // face-style-flags
>  s_default.style_flag = *tx3g_ptr++;
> @@ -252,7 +252,7 @@ static int mov_text_tx3g(AVCodecContext *avctx,
> MovTextContext *m) tx3g_ptr = tx3g_ptr + font_length;
>  }
>  for (i = 0; i < m->ftab_entries; i++) {
> -if (style_fontID == m->ftab[i]->fontID)
> +if (m->d.fontID == m->ftab[i]->fontID)
>  m->d.font = m->ftab[i]->font;
>  }
>  return 0;
> @@ -385,11 +385,13 @@ static int text_to_ass(AVBPrint *buf, const
> char *text, const char *text_end, av_bprintf(buf, "{\\i%d}",
> m->s[entry]->italic); if (m->s[entry]->underline ^ m->d.underline)
>  av_bprintf(buf, "{\\u%d}",
> m->s[entry]->underline);
> -av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize);
> -for (i = 0; i < m->ftab_entries; i++) {
> -if (m->s[entry]->style_fontID ==
> m->ftab[i]->fontID)
> -av_bprintf(buf, "{\\fn%s}",
> m->ftab[i]->font);
> -}
> +if (m->s[entry]->fontsize != m->d.fontsize)
> +av_bprintf(buf, "{\\fs%d}",
> m->s[entry]->fontsize);
> +if (m->s[entry]->style_fontID != m->d.fontID)
> +for (i = 0; i < m->ftab_entries; i++) {
> +if (m->s[entry]->style_fontID ==
> m->ftab[i]->fontID)
> +av_bprintf(buf, "{\\fn%s}",
> m->ftab[i]->font);
> +}
>  }
>  if (text_pos == m->s[entry]->style_end) {
>  if (style_active) {

LGTM.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 04/23] lavc/movtextdec: handle changes to default style flags

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:51:59 -0600
John Stebbins  wrote:

> Style flags were only being turned on.  If the default was on and
> style record turned off, style flag remained on.
> ---
>  libavcodec/movtextdec.c | 24 +++-
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index d6896562c2..a3e37d013d 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -55,9 +55,9 @@ typedef struct {
>  int fontsize;
>  int color;
>  int back_color;
> -int bold;
> -int italic;
> -int underline;
> +uint8_t bold;
> +uint8_t italic;
> +uint8_t underline;
>  int alignment;
>  } MovTextDefault;
>  
> @@ -70,6 +70,9 @@ typedef struct {
>  uint16_t style_start;
>  uint16_t style_end;
>  uint8_t style_flag;
> +uint8_t bold;
> +uint8_t italic;
> +uint8_t underline;
>  uint8_t fontsize;
>  uint16_t style_fontID;
>  } StyleBox;
> @@ -313,6 +316,9 @@ static int decode_styl(const uint8_t *tsmb,
> MovTextContext *m, AVPacket *avpkt) m->s_temp->style_fontID =
> AV_RB16(tsmb); tsmb += 2;
>  m->s_temp->style_flag = AV_RB8(tsmb);
> +m->s_temp->bold = !!(m->s_temp->style_flag &
> STYLE_FLAG_BOLD);
> +m->s_temp->italic = !!(m->s_temp->style_flag &
> STYLE_FLAG_ITALIC);
> +m->s_temp->underline = !!(m->s_temp->style_flag &
> STYLE_FLAG_UNDERLINE); tsmb++;
>  m->s_temp->fontsize = AV_RB8(tsmb);
>  av_dynarray_add(>s, >count_s, m->s_temp);
> @@ -373,12 +379,12 @@ static int text_to_ass(AVBPrint *buf, const
> char *text, const char *text_end, if ((m->box_flags & STYL_BOX) &&
> entry < m->style_entries) { if (text_pos == m->s[entry]->style_start)
> { style_active = 1;
> -if (m->s[entry]->style_flag & STYLE_FLAG_BOLD)
> -av_bprintf(buf, "{\\b1}");
> -if (m->s[entry]->style_flag & STYLE_FLAG_ITALIC)
> -av_bprintf(buf, "{\\i1}");
> -if (m->s[entry]->style_flag & STYLE_FLAG_UNDERLINE)
> -av_bprintf(buf, "{\\u1}");
> +if (m->s[entry]->bold ^ m->d.bold)
> +av_bprintf(buf, "{\\b%d}", m->s[entry]->bold);
> +if (m->s[entry]->italic ^ m->d.italic)
> +av_bprintf(buf, "{\\i%d}", m->s[entry]->italic);
> +if (m->s[entry]->underline ^ m->d.underline)
> +av_bprintf(buf, "{\\u%d}",
> m->s[entry]->underline); av_bprintf(buf, "{\\fs%d}",
> m->s[entry]->fontsize); for (i = 0; i < m->ftab_entries; i++) {
>  if (m->s[entry]->style_fontID ==
> m->ftab[i]->fontID)

LGTM.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] movtext decode/encode improvements

2020-04-06 Thread John Stebbins
On Mon, 2020-04-06 at 13:16 -0700, Philip Langdale wrote:
> On Mon, 6 Apr 2020 11:51:55 -0600
> John Stebbins  wrote:
> 
> > Patch series adds more complete decoding and encoding of color,
> > alpha,
> > font size, font name, and style tags for movtext.  It also fixes a
> > number of bugs.
> > 
> 
> Hi John,
> 
> Thanks for doing all of this! I'll try and take a look at these over
> the next few days.
> 
> 
> 

Thanks.  A heads up though.  I need to have a second look at patches 10
and 23 relating to frame sizes and font sizes.  I've been reading
libass code to get a deeper understanding of how it manages font sizes
and I think I've done that wrong.

ass font size is relative to a fixed 288 pixel height (I assumed it was
relative to PlayResY in the script).  And mov text font size is
relative to the specified subtitle track height which should be the
same as the video height.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 03/23] lavc/movtextdec: fix bold, italic, underline flags

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:51:58 -0600
John Stebbins  wrote:

> They should be 0 or 1 so that 0 or -1 is written to the ass header
> ---
>  libavcodec/movtextdec.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index 47a8401119..d6896562c2 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -193,9 +193,9 @@ static int mov_text_tx3g(AVCodecContext *avctx,
> MovTextContext *m) tx3g_ptr += 2;
>  // face-style-flags
>  s_default.style_flag = *tx3g_ptr++;
> -m->d.bold = s_default.style_flag & STYLE_FLAG_BOLD;
> -m->d.italic = s_default.style_flag & STYLE_FLAG_ITALIC;
> -m->d.underline = s_default.style_flag & STYLE_FLAG_UNDERLINE;
> +m->d.bold = !!(s_default.style_flag & STYLE_FLAG_BOLD);
> +m->d.italic = !!(s_default.style_flag & STYLE_FLAG_ITALIC);
> +m->d.underline = !!(s_default.style_flag & STYLE_FLAG_UNDERLINE);
>  // fontsize
>  m->d.fontsize = *tx3g_ptr++;
>  // Primary color

LGTM.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 02/23] lavc/movtextdec: simplify style record walk

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:51:57 -0600
John Stebbins  wrote:

> It's not necessary to walk the style record list twice per subtitle
> character.  style records are in order and do not overlap.
> ---
>  libavcodec/movtextdec.c | 38 --
>  1 file changed, 20 insertions(+), 18 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index 05becaf64d..47a8401119 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -355,8 +355,9 @@ static int text_to_ass(AVBPrint *buf, const char
> *text, const char *text_end, {
>  MovTextContext *m = avctx->priv_data;
>  int i = 0;
> -int j = 0;
>  int text_pos = 0;
> +int style_active = 0;
> +int entry = 0;
>  
>  if (text < text_end && m->box_flags & TWRP_BOX) {
>  if (m->w.wrap_flag == 1) {
> @@ -369,26 +370,27 @@ static int text_to_ass(AVBPrint *buf, const
> char *text, const char *text_end, while (text < text_end) {
>  int len;
>  
> -if (m->box_flags & STYL_BOX) {
> -for (i = 0; i < m->style_entries; i++) {
> -if (m->s[i]->style_flag && text_pos ==
> m->s[i]->style_end) {
> -av_bprintf(buf, "{\\r}");
> +if ((m->box_flags & STYL_BOX) && entry < m->style_entries) {
> +if (text_pos == m->s[entry]->style_start) {
> +style_active = 1;
> +if (m->s[entry]->style_flag & STYLE_FLAG_BOLD)
> +av_bprintf(buf, "{\\b1}");
> +if (m->s[entry]->style_flag & STYLE_FLAG_ITALIC)
> +av_bprintf(buf, "{\\i1}");
> +if (m->s[entry]->style_flag & STYLE_FLAG_UNDERLINE)
> +av_bprintf(buf, "{\\u1}");
> +av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize);
> +for (i = 0; i < m->ftab_entries; i++) {
> +if (m->s[entry]->style_fontID ==
> m->ftab[i]->fontID)
> +av_bprintf(buf, "{\\fn%s}",
> m->ftab[i]->font); }
>  }
> -for (i = 0; i < m->style_entries; i++) {
> -if (m->s[i]->style_flag && text_pos ==
> m->s[i]->style_start) {
> -if (m->s[i]->style_flag & STYLE_FLAG_BOLD)
> -av_bprintf(buf, "{\\b1}");
> -if (m->s[i]->style_flag & STYLE_FLAG_ITALIC)
> -av_bprintf(buf, "{\\i1}");
> -if (m->s[i]->style_flag & STYLE_FLAG_UNDERLINE)
> -av_bprintf(buf, "{\\u1}");
> -av_bprintf(buf, "{\\fs%d}", m->s[i]->fontsize);
> -for (j = 0; j < m->ftab_entries; j++) {
> -if (m->s[i]->style_fontID ==
> m->ftab[j]->fontID)
> -av_bprintf(buf, "{\\fn%s}",
> m->ftab[j]->font);
> -}
> +if (text_pos == m->s[entry]->style_end) {
> +if (style_active) {
> +av_bprintf(buf, "{\\r}");
> +style_active = 0;
>  }
> +entry++;
>  }
>  }
>  if (m->box_flags & HLIT_BOX) {

OK. I could not convince myself originally that styles could not
overlap, but I could easily have missed that in the spec.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 01/23] lavc/movtextdec: fix ass header colors

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:51:56 -0600
John Stebbins  wrote:

> A conversion from rgb to bgr is necessary
> ---
>  libavcodec/movtextdec.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index c38c5edce6..05becaf64d 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -48,6 +48,8 @@
>  #define TOP_CENTER  8
>  #define TOP_RIGHT   9
>  
> +#define RGB_TO_BGR(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c)
> >> 16) & 0xff)) +
>  typedef struct {
>  char *font;
>  int fontsize;
> @@ -448,10 +450,11 @@ static int mov_text_init(AVCodecContext *avctx)
> { MovTextContext *m = avctx->priv_data;
>  ret = mov_text_tx3g(avctx, m);
>  if (ret == 0) {
> -return ff_ass_subtitle_header(avctx, m->d.font,
> m->d.fontsize, m->d.color,
> -m->d.back_color, m->d.bold,
> m->d.italic,
> -m->d.underline,
> ASS_DEFAULT_BORDERSTYLE,
> -m->d.alignment);
> +return ff_ass_subtitle_header(avctx, m->d.font,
> m->d.fontsize,
> +RGB_TO_BGR(m->d.color),
> +RGB_TO_BGR(m->d.back_color),
> +m->d.bold, m->d.italic, m->d.underline,
> +ASS_DEFAULT_BORDERSTYLE, m->d.alignment);
>  } else
>  return ff_ass_subtitle_header_default(avctx);
>  }

LGTM.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread phunkyfish
---
 libavformat/rtsp.c | 50 +-
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..2b59a9330d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -21,6 +21,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/base64.h"
+#include "libavutil/bprint.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
@@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
+char host[500], filters_buf[1000];
 int ret, port;
 URLContext* in = NULL;
 int payload_type;
@@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p;
+AVBPrint sdp;
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,16 +2516,40 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
-av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
+   addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
+   filters[i][1],
+   addr.ss_family == AF_INET ? 4 : 6, host,
+   filters_buf);
+if (sdp.len != sdp.size)
+goto fail_nobuf;
+}
+}
+}
+
+av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
+   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+   port, payload_type);
+av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
+if (sdp.len != sdp.size)
+goto fail_nobuf;
 avcodec_parameters_free();
 
-ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL, NULL, 
NULL);
 s->pb = 
 
 /* sdp_read_header initializes this again */
@@ -2532,9 +2559,14 @@ static int rtp_read_header(AVFormatContext *s)
 
 ret = sdp_read_header(s);
 s->pb = NULL;
+av_bprint_finalize(, NULL);
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
+av_bprint_finalize(, NULL);
 avcodec_parameters_free();
 if (in)
 ffurl_close(in);
-- 
2.24.1 (Apple Git-126)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/aacdec: fix compilation under soft float MIPS

2020-04-06 Thread Carl Eugen Hoyos
Am Mo., 6. Apr. 2020 um 07:29 Uhr schrieb Rosen Penev :
>
> Place HAVE_MIPSFPU further up so that functions that use floating point
> ASM are defined away. Otherwise compilation failures result when soft
> float in enabled on the toolchain.

Could this fix ticket #7102?
If yes, please mention it in the commit message.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Carl Eugen Hoyos
Am Mo., 6. Apr. 2020 um 23:13 Uhr schrieb Nicolas George :
>
> Carl Eugen Hoyos (12020-04-06):
> > Thank you, I had never realized this in all the years I (thought I) had
> > to specify --enable-decoder=rawvideo,wrapped_avframe...
>
> I am not sure exactly what you are saying.

I tried to explain that for many years, when I tested a regression and
hit mentioned commit (which happens often), I had to recompile
because I did not realize I could just force the rawvideo encoder.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Nicolas George
Carl Eugen Hoyos (12020-04-06):
> Thank you, I had never realized this in all the years I (thought I) had
> to specify --enable-decoder=rawvideo,wrapped_avframe...

I am not sure exactly what you are saying. You would need the
corresponding encoder, of course, whatever it is. And if it's not the
default, specifying it would be necessary.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Carl Eugen Hoyos
Am Mo., 6. Apr. 2020 um 19:58 Uhr schrieb Nicolas George :
>
> Carl Eugen Hoyos (12020-04-06):
> > Is it possible to support both codecs?
>
> Of course it it possible. And this is exactly the right thing to do
> (modulo the question of which raw frame API we keep).
>
> > Commit 64ceeac2 changed the only supported format for the
> > null muxer without any version bump.
> > (While this is a very important muxer for me, I agree that my
> > argumentation above is not completely compelling.)
>
> null is a different case: nobody will use null specifically, if they use
> it, they use it as a placeholder for generic code capable of handling
> any muxer. And since it is generic code, it will handle any codec.
>
> But anyway, you are reading this commit wrongly. It does not remove
> support for rawvideo in null, rawvideo is still supported in null, as
> any other codec. This commit only changes the default codec.

Thank you, I had never realized this in all the years I (thought I) had
to specify --enable-decoder=rawvideo,wrapped_avframe...

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] movtext decode/encode improvements

2020-04-06 Thread Philip Langdale
On Mon, 6 Apr 2020 11:51:55 -0600
John Stebbins  wrote:

> Patch series adds more complete decoding and encoding of color, alpha,
> font size, font name, and style tags for movtext.  It also fixes a
> number of bugs.
> 

Hi John,

Thanks for doing all of this! I'll try and take a look at these over
the next few days.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v13] libavcodec/jpeg2000dec.c: Add support for PPT marker

2020-04-06 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds functional changes to support the
PPT marker. This patch fixes bug ticket #4610.
---
 libavcodec/jpeg2000dec.c | 85 ++--
 1 file changed, 74 insertions(+), 11 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 732d88e6fc..97c38ae5f7 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile {
 Jpeg2000QuantStyle  qntsty[4];
 Jpeg2000POC poc;
 Jpeg2000TileParttile_part[32];
+uint8_t has_ppt;// whether this tile has a ppt 
marker
+uint8_t *packed_headers;// contains packed headers. 
Used only along with PPT marker
+int packed_headers_size;// size in bytes of the packed 
headers
+GetByteContext  packed_headers_stream;  // byte context corresponding 
to packed headers
 uint16_t tp_idx;// Tile-part index
 int coord[2][2];// border coordinates {{x0, x1}, {y0, 
y1}}
 } Jpeg2000Tile;
@@ -855,6 +859,34 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
 return 0;
 }
 
+static int get_ppt(Jpeg2000DecoderContext *s, int n)
+{
+Jpeg2000Tile *tile;
+
+if (s->curtileno < 0)
+return AVERROR_INVALIDDATA;
+
+tile = >tile[s->curtileno];
+if (tile->tp_idx != 0) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "PPT marker can occur only on first tile part of a tile.\n");
+return AVERROR_INVALIDDATA;
+}
+
+tile->has_ppt = 1;  // this tile has a ppt marker
+bytestream2_get_byte(>g); // Zppt is skipped and not used
+tile->packed_headers = av_realloc(tile->packed_headers,
+  tile->packed_headers_size + n - 3);
+if (!tile->packed_headers)
+return AVERROR(ENOMEM);
+memcpy(tile->packed_headers + tile->packed_headers_size,
+   s->g.buffer, n - 3);
+tile->packed_headers_size += n - 3;
+bytestream2_skip(>g, n - 3);
+
+return 0;
+}
+
 static int init_tile(Jpeg2000DecoderContext *s, int tileno)
 {
 int compno;
@@ -927,6 +959,19 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
 return res;
 }
 
+static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
+ int *tp_index)
+{
+s->g = tile->tile_part[*tp_index].tpg;
+if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
+}
+if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
+}
+
 static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile 
*tile, int *tp_index,
   Jpeg2000CodingStyle *codsty,
   Jpeg2000ResLevel *rlevel, int precno,
@@ -938,19 +983,15 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 if (layno < rlevel->band[0].prec[precno].decoded_layers)
 return 0;
 rlevel->band[0].prec[precno].decoded_layers = layno + 1;
-
-if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
-if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
-s->g = tile->tile_part[++(*tp_index)].tpg;
-}
-}
-
-if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
-bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
+// Select stream to read from
+if (tile->has_ppt)
+s->g = tile->packed_headers_stream;
+else
+select_stream(s, tile, tp_index);
 
 if (!(ret = get_bits(s, 1))) {
 jpeg2000_flush(s);
-return 0;
+goto skip_data;
 } else if (ret < 0)
 return ret;
 
@@ -1056,6 +1097,11 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead 
%X\n", bytestream2_peek_be32(>g));
 }
 
+// Save state of stream
+if (tile->has_ppt) {
+tile->packed_headers_stream = s->g;
+select_stream(s, tile, tp_index);
+}
 for (bandno = 0; bandno < rlevel->nbands; bandno++) {
 Jpeg2000Band *band = rlevel->band + bandno;
 Jpeg2000Prec *prec = band->prec + precno;
@@ -1097,6 +1143,15 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 av_freep(>lengthinc);
 }
 }
+// Save state of stream
+tile->tile_part[*tp_index].tpg = s->g;
+return 0;
+
+skip_data:
+if (tile->has_ppt)
+tile->packed_headers_stream = s->g;
+else
+tile->tile_part[*tp_index].tpg = s->g;
 return 0;
 }
 
@@ -1929,6 +1984,11 @@ static int 
jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
 av_log(s->avctx, AV_LOG_ERROR, 

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread Marton Balint



On Mon, 6 Apr 2020, phunkyfish wrote:


---
libavformat/rtsp.c | 47 ++
1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..0d0bc2be0d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
static int rtp_read_header(AVFormatContext *s)
{
uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
URLContext* in = NULL;
int payload_type;
AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
AVIOContext pb;
socklen_t addrlen = sizeof(addr);
RTSPState *rt = s->priv_data;
+const char *p;

if (!ff_network_init())
return AVERROR(EIO);
@@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
 NULL, 0, s->url);

-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp, sizeof(sdp),
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);


Please use an AVBPrint buffer instead of snprintf()-ing to sdp.

Thanks,
Marton


+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
avcodec_parameters_free();

ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
@@ -2534,6 +2562,9 @@ static int rtp_read_header(AVFormatContext *s)
s->pb = NULL;
return ret;

+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
fail:
avcodec_parameters_free();
if (in)
--
2.24.1 (Apple Git-126)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Nicolas George
Marton Balint (12020-04-06):
> avdevice/xv and avdevice/opengl are rarely used outside of ffmpeg CLI
> invocations, so I don't think it is worth supporting the inferior rawvideo.

They are used.

> If you feel strongly about this then let's drop rawvideo support after the
> API bump.

No, let's keep it.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Marton Balint



On Mon, 6 Apr 2020, Nicolas George wrote:


Marton Balint (12020-04-06):

Signed-off-by: Marton Balint 
---
 libavdevice/xv.c | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)


Thanks for working on this.

Adding support for the more efficient API is a good idea.

On the other hand, if applications use this device or a similar one
specifically (I do in some of mine, I am certainly not alone), they
would hardcode rawvideo. Therefore, we cannot remove support for
rawvideo.


avdevice/xv and avdevice/opengl are rarely used outside of ffmpeg CLI 
invocations, so I don't think it is worth supporting the inferior 
rawvideo. If you feel strongly about this then let's drop rawvideo support 
after the API bump.


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 11/23] lavc/ass_split: fix parsing utf8 scripts

2020-04-06 Thread John Stebbins
The [Script Info] section was skipped if starts with UTF8 BOM
---
 libavcodec/ass_split.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index 67da7c6d84..c2c388d9f0 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -376,6 +376,8 @@ ASSSplitContext *ff_ass_split(const char *buf)
 ASSSplitContext *ctx = av_mallocz(sizeof(*ctx));
 if (!ctx)
 return NULL;
+if (buf && !memcmp(buf, "\xef\xbb\xbf", 3)) // Skip UTF-8 BOM header
+buf += 3;
 ctx->current_section = -1;
 if (ass_split(ctx, buf) < 0) {
 ff_ass_split_free(ctx);
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 11/23] lavc/ass_split: fix parsing utf8 scripts

2020-04-06 Thread Nicolas George
John Stebbins (12020-04-06):
> Oh, whoops, I missed that ass_split gets called for a number of things.
> This belongs at the beginning of ff_ass_split() I believe?

I think so too.

> In the sample I ran into this with, there's a BOM at the beginning of
> the mkv private data for the track.

I think the private data is supposed to be the beginning of the file.
Also, I think the BOM should not be there when embedding, but we can
support slightly invalid files.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v13] libavcodec/jpeg2000dec.c: Add support for PPT marker

2020-04-06 Thread Gautam Ramakrishnan
On Mon, Apr 6, 2020 at 5:41 PM Michael Niedermayer
 wrote:
>
> On Mon, Apr 06, 2020 at 09:23:26AM +0530, Gautam Ramakrishnan wrote:
> > On Mon, Apr 6, 2020 at 1:16 AM Michael Niedermayer
> >  wrote:
> > >
> > > On Sun, Apr 05, 2020 at 04:13:28PM +0530, gautamr...@gmail.com wrote:
> > > > From: Gautam Ramakrishnan 
> > > >
> > > > This patch adds functional changes to support the
> > > > PPT marker. This patch fixes bug ticket #4610.
> > > > ---
> > > >  libavcodec/jpeg2000dec.c | 88 +++-
> > > >  1 file changed, 77 insertions(+), 11 deletions(-)
> > > >
> > > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> > > > index 732d88e6fc..2af3c61c37 100644
> > > > --- a/libavcodec/jpeg2000dec.c
> > > > +++ b/libavcodec/jpeg2000dec.c
> > > > @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile {
> > > >  Jpeg2000QuantStyle  qntsty[4];
> > > >  Jpeg2000POC poc;
> > > >  Jpeg2000TileParttile_part[32];
> > > > +uint8_t has_ppt;// whether this tile 
> > > > has a ppt marker
> > > > +uint8_t *packed_headers;// contains packed 
> > > > headers. Used only along with PPT marker
> > > > +int packed_headers_size;// size in bytes of 
> > > > the packed headers
> > > > +GetByteContext  packed_headers_stream;  // byte context 
> > > > corresponding to packed headers
> > > >  uint16_t tp_idx;// Tile-part index
> > > >  int coord[2][2];// border coordinates {{x0, 
> > > > x1}, {y0, y1}}
> > > >  } Jpeg2000Tile;
> > > > @@ -855,6 +859,37 @@ static int get_plt(Jpeg2000DecoderContext *s, int 
> > > > n)
> > > >  return 0;
> > > >  }
> > > >
> > > > +static int get_ppt(Jpeg2000DecoderContext *s, int n)
> > > > +{
> > > > +Jpeg2000Tile *tile;
> > > > +
> > > > +if (s->curtileno < 0)
> > > > +return AVERROR_INVALIDDATA;
> > > > +
> > > > +tile = >tile[s->curtileno];
> > > > +if (tile->tp_idx != 0) {
> > > > +av_log(s->avctx, AV_LOG_ERROR,
> > > > +   "PPT marker can occur only on first tile part of a 
> > > > tile.\n");
> > > > +return AVERROR_INVALIDDATA;
> > > > +}
> > > > +
> > > > +tile->has_ppt = 1;  // this tile has a ppt marker
> > > > +bytestream2_get_byte(>g); // Zppt is skipped and not used
> > >
> > >
> > > > +if (!tile->packed_headers)
> > > > +tile->packed_headers = av_malloc(n - 3);
> > > > +else
> > > > +tile->packed_headers = av_realloc(tile->packed_headers,
> > > > +  tile->packed_headers_size + 
> > > > n - 3);
> > >
> > > why is the special case with av_malloc() needed ?
> > >
> > The if else is to check whether this is the first time this tile is being
> > allocated its packed headers. If packed headers does not exist
> > exist, create it. The else condition is just to add a new packed
> > header to it.
>
> what is the problem with
>
> av_realloc(tile->packed_headers,  tile->packed_headers_size + n - 3);
> when tile->packed_headers is NULL and tile->packed_headers_size is 0 for the
> first allocation ?
>
Oh!! Thanks for clearing that out. I did not know realloc could be
used like that.
Was a bit skeptical about writing it that way. I'll test that out and resubmit.
>
> thx
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> In fact, the RIAA has been known to suggest that students drop out
> of college or go to community college in order to be able to afford
> settlements. -- The RIAA
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



-- 
-
Gautam |
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 11/23] lavc/ass_split: fix parsing utf8 scripts

2020-04-06 Thread John Stebbins
On Mon, 2020-04-06 at 20:08 +0200, Nicolas George wrote:
> John Stebbins (12020-04-06):
> > The [Script Info] section was skipped if starts with UTF8 BOM
> > ---
> >  libavcodec/ass_split.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
> > index 67da7c6d84..94c32667af 100644
> > --- a/libavcodec/ass_split.c
> > +++ b/libavcodec/ass_split.c
> > @@ -354,6 +354,9 @@ static int ass_split(ASSSplitContext *ctx,
> > const char *buf)
> >  if (ctx->current_section >= 0)
> >  buf = ass_split_section(ctx, buf);
> >  
> > +if(!memcmp(buf, "\xef\xbb\xbf", 3)) { // Skip UTF-8 BOM header
> > +buf += 3;
> > +}
> 
> This doesn't look correct: BOM should be skipped only at the very
> beginning of the file. And the braces could be skipped.
> 
> >  while (buf && *buf) {
> >  if (sscanf(buf, "[%15[0-9A-Za-z+ ]]%c", section, ) == 2)
> > {
> >  buf += strcspn(buf, "\n");
> 
> 

Oh, whoops, I missed that ass_split gets called for a number of things.
This belongs at the beginning of ff_ass_split() I believe?

In the sample I ran into this with, there's a BOM at the beginning of
the mkv private data for the track.

I'll remove the braces...

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 11/23] lavc/ass_split: fix parsing utf8 scripts

2020-04-06 Thread Nicolas George
John Stebbins (12020-04-06):
> The [Script Info] section was skipped if starts with UTF8 BOM
> ---
>  libavcodec/ass_split.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
> index 67da7c6d84..94c32667af 100644
> --- a/libavcodec/ass_split.c
> +++ b/libavcodec/ass_split.c
> @@ -354,6 +354,9 @@ static int ass_split(ASSSplitContext *ctx, const char 
> *buf)
>  if (ctx->current_section >= 0)
>  buf = ass_split_section(ctx, buf);
>  

> +if(!memcmp(buf, "\xef\xbb\xbf", 3)) { // Skip UTF-8 BOM header
> +buf += 3;
> +}

This doesn't look correct: BOM should be skipped only at the very
beginning of the file. And the braces could be skipped.

>  while (buf && *buf) {
>  if (sscanf(buf, "[%15[0-9A-Za-z+ ]]%c", section, ) == 2) {
>  buf += strcspn(buf, "\n");

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 01/23] lavc/movtextdec: fix ass header colors

2020-04-06 Thread Nicolas George
John Stebbins (12020-04-06):
> A conversion from rgb to bgr is necessary
> ---
>  libavcodec/movtextdec.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index c38c5edce6..05becaf64d 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -48,6 +48,8 @@
>  #define TOP_CENTER  8
>  #define TOP_RIGHT   9
>  
> +#define RGB_TO_BGR(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 
> 0xff))
> +
>  typedef struct {
>  char *font;
>  int fontsize;
> @@ -448,10 +450,11 @@ static int mov_text_init(AVCodecContext *avctx) {
>  MovTextContext *m = avctx->priv_data;
>  ret = mov_text_tx3g(avctx, m);
>  if (ret == 0) {
> -return ff_ass_subtitle_header(avctx, m->d.font, m->d.fontsize, 
> m->d.color,
> -m->d.back_color, m->d.bold, m->d.italic,
> -m->d.underline, ASS_DEFAULT_BORDERSTYLE,
> -m->d.alignment);

> +return ff_ass_subtitle_header(avctx, m->d.font, m->d.fontsize,
> +RGB_TO_BGR(m->d.color),
> +RGB_TO_BGR(m->d.back_color),
> +m->d.bold, m->d.italic, m->d.underline,
> +ASS_DEFAULT_BORDERSTYLE, m->d.alignment);

Indentation is off. It was off before, but since the lines are changed
it should be ok now.

Can't judge on semantic.

>  } else
>  return ff_ass_subtitle_header_default(avctx);
>  }

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread Ross Nicholson
> sdp_length is used uninitialized here it is used uninitialized in the
> version that was merged as b71685865fe761925feedda3cd0b288224d9a509. The
> newer versions [2], [3] don't exhibit this flaw.
>
> [3] and [1] also have a flaw in common that [2] and this one are
> lacking: The semicolon of the definition of const char *p is missing.
>
> Finally, neither of these versions here seems to have been based upon
> git master which contains a call to av_log() directly after the above
> snprintf.
>
> - Andreas

Andreas,

Apologies I did not get back to you sooner I was indisposed.

I have updated the patch now which should be correct, addressing your
comments.

On Mon, 6 Apr 2020 at 17:56, phunkyfish  wrote:

> ---
>  libavformat/rtsp.c | 47 ++
>  1 file changed, 39 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..0d0bc2be0d 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> -int ret, port;
> +char host[500], sdp[1000], filters_buf[1000];
> +int ret, port, sdp_length, nc;
>  URLContext* in = NULL;
>  int payload_type;
>  AVCodecParameters *par = NULL;
> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p;
>
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>   NULL, 0, s->url);
>
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> +sdp_length = snprintf(sdp, sizeof(sdp),
> +  "v=0\r\nc=IN IP%d %s\r\n",
> +  addr.ss_family == AF_INET ? 4 : 6, host);
> +
> +p = strchr(s->url, '?');
> +if (p) {
> +static const char *filters[][2] = {{"sources", "incl"}, {"block",
> "excl"}, {NULL, NULL}};
> +int i;
> +char *q;
> +for (i = 0; filters[i][0]; i++) {
> +if (av_find_info_tag(filters_buf, sizeof(filters_buf),
> filters[i][0], p)) {
> +q = filters_buf;
> +while ((q = strchr(q, ',')) != NULL)
> +*q = ' ';
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "a=source-filter:%s IN IP%d %s %s\r\n",
> +  filters[i][1],
> +  addr.ss_family == AF_INET ? 4 : 6, host,
> +  filters_buf);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
> +sdp_length += nc;
> +}
> +}
> +}
> +
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "m=%s %d RTP/AVP %d\r\n",
> +  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> +  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" :
> "audio",
> +  port, payload_type);
>  av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
>  avcodec_parameters_free();
>
>  ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
> @@ -2534,6 +2562,9 @@ static int rtp_read_header(AVFormatContext *s)
>  s->pb = NULL;
>  return ret;
>
> +fail_nobuf:
> +ret = AVERROR(ENOBUFS);
> +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space
> for sdp-headers\n");
>  fail:
>  avcodec_parameters_free();
>  if (in)
> --
> 2.24.1 (Apple Git-126)
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 22/23] lavc/movtextenc: add font name handling

2020-04-06 Thread John Stebbins
Initializes the mov text sample description from the ASS header and
creates an mov font table from the fonts available in the ASS Styles.
---
 libavcodec/ass_split.c  |   5 +
 libavcodec/ass_split.h  |   8 ++
 libavcodec/movtextenc.c | 253 
 3 files changed, 216 insertions(+), 50 deletions(-)

diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index 94c32667af..9d5a66f931 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -599,3 +599,8 @@ ASSStyle *ff_ass_style_get(ASSSplitContext *ctx, const char 
*style)
 return ass->styles + i;
 return NULL;
 }
+
+ASS *ff_ass_get(ASSSplitContext *ctx)
+{
+return >ass;
+}
diff --git a/libavcodec/ass_split.h b/libavcodec/ass_split.h
index 30ce77250c..31b8e53242 100644
--- a/libavcodec/ass_split.h
+++ b/libavcodec/ass_split.h
@@ -204,4 +204,12 @@ int ff_ass_split_override_codes(const ASSCodesCallbacks 
*callbacks, void *priv,
  */
 ASSStyle *ff_ass_style_get(ASSSplitContext *ctx, const char *style);
 
+/**
+ * Get ASS structure
+ *
+ * @param ctx Context previously initialized by ff_ass_split().
+ * @return the ASS
+ */
+ASS *ff_ass_get(ASSSplitContext *ctx);
+
 #endif /* AVCODEC_ASS_SPLIT_H */
diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 167dffee6a..a62bdb7eb0 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -79,6 +79,8 @@ typedef struct {
 StyleBox d;
 uint16_t text_pos;
 uint16_t byte_count;
+char ** fonts;
+int font_count;
 } MovTextContext;
 
 typedef struct {
@@ -171,69 +173,198 @@ static const Box box_types[] = {
 
 const static size_t box_count = FF_ARRAY_ELEMS(box_types);
 
-static av_cold int mov_text_encode_init(AVCodecContext *avctx)
+static int mov_text_encode_close(AVCodecContext *avctx)
 {
-/*
- * For now, we'll use a fixed default style. When we add styling
- * support, this will be generated from the ASS style.
- */
-static const uint8_t text_sample_entry[] = {
+MovTextContext *s = avctx->priv_data;
+int i;
+
+ff_ass_split_free(s->ass_ctx);
+if (s->style_attributes) {
+for (i = 0; i < s->count; i++) {
+av_freep(>style_attributes[i]);
+}
+av_freep(>style_attributes);
+}
+av_freep(>fonts);
+av_freep(>style_attributes_temp);
+av_bprint_finalize(>buffer, NULL);
+return 0;
+}
+
+static int encode_sample_description(AVCodecContext *avctx)
+{
+ASS * ass;
+ASSStyle * style;
+int i, j;
+uint32_t tsmb_size, tsmb_type, back_color, style_color;
+uint16_t style_start, style_end, fontID, count;
+int font_names_total_len = 0;
+MovTextContext *s = avctx->priv_data;
+
+static const uint8_t display_and_justification[] = {
 0x00, 0x00, 0x00, 0x00, // uint32_t displayFlags
 0x01,   // int8_t horizontal-justification
 0xFF,   // int8_t vertical-justification
-0x00, 0x00, 0x00, 0x00, // uint8_t background-color-rgba[4]
-// BoxRecord {
+};
+//  0x00, 0x00, 0x00, 0x00, // uint8_t background-color-rgba[4]
+static const uint8_t box_record[] = {
+// BoxRecord {
 0x00, 0x00, // int16_t top
 0x00, 0x00, // int16_t left
 0x00, 0x00, // int16_t bottom
 0x00, 0x00, // int16_t right
-// };
-// StyleRecord {
-0x00, 0x00, // uint16_t startChar
-0x00, 0x00, // uint16_t endChar
-0x00, 0x01, // uint16_t font-ID
-0x00,   // uint8_t face-style-flags
-0x12,   // uint8_t font-size
-0xFF, 0xFF, 0xFF, 0xFF, // uint8_t text-color-rgba[4]
-// };
-// FontTableBox {
-0x00, 0x00, 0x00, 0x12, // uint32_t size
-'f', 't', 'a', 'b', // uint8_t name[4]
-0x00, 0x01, // uint16_t entry-count
-// FontRecord {
-0x00, 0x01, // uint16_t font-ID
-0x05,   // uint8_t font-name-length
-'S', 'e', 'r', 'i', 'f',// uint8_t font[font-name-length]
-// };
-// };
+// };
 };
+// StyleRecord {
+//  0x00, 0x00, // uint16_t startChar
+//  0x00, 0x00, // uint16_t endChar
+//  0x00, 0x01, // uint16_t font-ID
+//  0x00,   // uint8_t face-style-flags
+//  0x12,   // uint8_t font-size
+//  0xFF, 0xFF, 0xFF, 0xFF, // uint8_t text-color-rgba[4]
+// };
+// FontTableBox {
+//  0x00, 0x00, 0x00, 0x12, // uint32_t size
+//  'f', 't', 'a', 'b', // uint8_t name[4]
+//  0x00, 0x01, // uint16_t entry-count
+// FontRecord {
+//  0x00, 0x01, // uint16_t font-ID
+//  0x05,   // uint8_t font-name-length
+//  'S', 'e', 'r', 'i', 'f',// uint8_t 

[FFmpeg-devel] [PATCH 23/23] lavc/movtextenc: add option to scale fontsize with height

2020-04-06 Thread John Stebbins
If the video dimensions are different than the ASS play_res then the
font sizes need to be adjusted to get the same apparent render size.
---
 libavcodec/movtextenc.c | 30 +-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index a62bdb7eb0..3d4371b180 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -21,6 +21,7 @@
 
 #include 
 #include "avcodec.h"
+#include "libavutil/opt.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
@@ -45,6 +46,7 @@
 #define DEFAULT_STYLE_FLAG 0x00
 
 #define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 
0xff))
+#define FONTSIZE_SCALE(s,fs) ((fs) * (s)->font_scale_factor + 0.5)
 #define av_bprint_append_any(buf, data, size)   av_bprint_append_data(buf, 
((const char*)data), size)
 
 typedef struct {
@@ -66,6 +68,7 @@ typedef struct {
 } HilightcolorBox;
 
 typedef struct {
+AVClass *class;
 AVCodecContext *avctx;
 
 ASSSplitContext *ass_ctx;
@@ -81,6 +84,8 @@ typedef struct {
 uint16_t byte_count;
 char ** fonts;
 int font_count;
+double font_scale_factor;
+int frame_height;
 } MovTextContext;
 
 typedef struct {
@@ -236,6 +241,13 @@ static int encode_sample_description(AVCodecContext *avctx)
 
 // Populate sample description from ASS header
 ass = ff_ass_get(s->ass_ctx);
+// Compute font scaling factor based on (optionally) provided
+// output video height and ASS script play_res_y
+if (s->frame_height && ass->script_info.play_res_y)
+s->font_scale_factor = (double)s->frame_height / 
ass->script_info.play_res_y;
+else
+s->font_scale_factor = 1;
+
 style = ff_ass_style_get(s->ass_ctx, "Default");
 if (!style && ass->styles_count) {
 style = >styles[0];
@@ -245,7 +257,7 @@ static int encode_sample_description(AVCodecContext *avctx)
 s->d.style_color= DEFAULT_STYLE_COLOR;
 s->d.style_flag = DEFAULT_STYLE_FLAG;
 if (style) {
-s->d.style_fontsize = style->font_size;
+s->d.style_fontsize = FONTSIZE_SCALE(s, style->font_size);
 s->d.style_color = BGR_TO_RGB(style->primary_color & 0xff) << 8 |
255 - ((uint32_t)style->primary_color >> 24);
 s->d.style_flag = (!!style->bold  * STYLE_FLAG_BOLD)   |
@@ -530,6 +542,7 @@ static void mov_text_font_name_cb(void *priv, const char 
*name)
 
 static void mov_text_font_size_set(MovTextContext *s, int size)
 {
+size = FONTSIZE_SCALE(s, size);
 if (!s->style_attributes_temp ||
 s->style_attributes_temp->style_fontsize == size) {
 // color hasn't changed
@@ -709,12 +722,27 @@ exit:
 return length;
 }
 
+#define OFFSET(x) offsetof(MovTextContext, x)
+#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM
+static const AVOption options[] = {
+{ "height", "Frame height, usually video height", OFFSET(frame_height), 
AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
+{ NULL },
+};
+
+static const AVClass mov_text_encoder_class = {
+.class_name = "MOV text enoder",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 AVCodec ff_movtext_encoder = {
 .name   = "mov_text",
 .long_name  = NULL_IF_CONFIG_SMALL("3GPP Timed Text subtitle"),
 .type   = AVMEDIA_TYPE_SUBTITLE,
 .id = AV_CODEC_ID_MOV_TEXT,
 .priv_data_size = sizeof(MovTextContext),
+.priv_class = _text_encoder_class,
 .init   = mov_text_encode_init,
 .encode_sub = mov_text_encode_frame,
 .close  = mov_text_encode_close,
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 21/23] lavc/movtextenc: simplify initialization of new style record

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextenc.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 2e65489c4d..167dffee6a 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -96,8 +96,7 @@ static void mov_text_cleanup(MovTextContext *s)
 av_freep(>style_attributes);
 }
 if (s->style_attributes_temp) {
-s->style_attributes_temp->style_flag = 0;
-s->style_attributes_temp->style_start = 0;
+*s->style_attributes_temp = s->d;
 }
 }
 
@@ -122,7 +121,7 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 style_start  = AV_RB16(>style_attributes[j]->style_start);
 style_end= AV_RB16(>style_attributes[j]->style_end);
 style_color  = AV_RB32(>style_attributes[j]->style_color);
-style_fontID = AV_RB16(>d.style_fontID);
+style_fontID = AV_RB16(>style_attributes[j]->style_fontID);
 
 av_bprint_append_any(>buffer, _start, 2);
 av_bprint_append_any(>buffer, _end, 2);
@@ -259,14 +258,10 @@ static int mov_text_style_start(MovTextContext *s)
 return 0;
 }
 
-s->style_attributes_temp->style_flag = s->style_attributes[s->count - 
1]->style_flag;
-s->style_attributes_temp->style_color = s->style_attributes[s->count - 
1]->style_color;
-s->style_attributes_temp->style_fontsize = 
s->style_attributes[s->count - 1]->style_fontsize;
+*s->style_attributes_temp = s->d;
 s->style_attributes_temp->style_start = s->text_pos;
 } else { // style entry matches defaults, drop entry
-s->style_attributes_temp->style_flag = s->d.style_flag;
-s->style_attributes_temp->style_color = s->d.style_color;
-s->style_attributes_temp->style_fontsize = s->d.style_fontsize;
+*s->style_attributes_temp = s->d;
 s->style_attributes_temp->style_start = s->text_pos;
 }
 return 1;
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 20/23] lavc/movtextenc: handle cancel overrides callback

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextenc.c | 36 +++-
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 9e657c9635..2e65489c4d 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -396,9 +396,8 @@ static void mov_text_end_cb(void *priv)
 mov_text_style_start((MovTextContext*)priv);
 }
 
-static void mov_text_dialog(MovTextContext *s, ASSDialog *dialog)
+static void mov_text_ass_style_set(MovTextContext *s, ASSStyle *style)
 {
-ASSStyle * style = ff_ass_style_get(s->ass_ctx, dialog->style);
 uint8_tstyle_flags, alpha;
 uint32_t   color;
 
@@ -412,9 +411,27 @@ static void mov_text_dialog(MovTextContext *s, ASSDialog 
*dialog)
 alpha = 255 - ((uint32_t)style->primary_color >> 24);
 mov_text_alpha_set(s, alpha);
 mov_text_font_size_set(s, style->font_size);
+} else {
+// End current style record, go back to defaults
+mov_text_style_start(s);
 }
 }
 
+static void mov_text_dialog(MovTextContext *s, ASSDialog *dialog)
+{
+ASSStyle * style = ff_ass_style_get(s->ass_ctx, dialog->style);
+
+mov_text_ass_style_set(s, style);
+}
+
+static void mov_text_cancel_overrides_cb(void *priv, const char * style_name)
+{
+MovTextContext *s = priv;
+ASSStyle * style = ff_ass_style_get(s->ass_ctx, style_name);
+
+mov_text_ass_style_set(s, style);
+}
+
 static uint16_t utf8_strlen(const char *text, int len)
 {
 uint16_t i = 0, ret = 0;
@@ -454,13 +471,14 @@ static void mov_text_new_line_cb(void *priv, int forced)
 }
 
 static const ASSCodesCallbacks mov_text_callbacks = {
-.text  = mov_text_text_cb,
-.new_line  = mov_text_new_line_cb,
-.style = mov_text_style_cb,
-.color = mov_text_color_cb,
-.alpha = mov_text_alpha_cb,
-.font_size = mov_text_font_size_cb,
-.end   = mov_text_end_cb,
+.text = mov_text_text_cb,
+.new_line = mov_text_new_line_cb,
+.style= mov_text_style_cb,
+.color= mov_text_color_cb,
+.alpha= mov_text_alpha_cb,
+.font_size= mov_text_font_size_cb,
+.cancel_overrides = mov_text_cancel_overrides_cb,
+.end  = mov_text_end_cb,
 };
 
 static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 19/23] lavc/movtextenc: add font size tag handling

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextenc.c | 39 ++-
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index e82393dde7..9e657c9635 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -128,7 +128,7 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 av_bprint_append_any(>buffer, _end, 2);
 av_bprint_append_any(>buffer, _fontID, 2);
 av_bprint_append_any(>buffer, 
>style_attributes[j]->style_flag, 1);
-av_bprint_append_any(>buffer, >d.style_fontsize, 1);
+av_bprint_append_any(>buffer, 
>style_attributes[j]->style_fontsize, 1);
 av_bprint_append_any(>buffer, _color, 4);
 }
 }
@@ -244,8 +244,9 @@ static int mov_text_style_start(MovTextContext *s)
 if (s->style_attributes_temp->style_start == s->text_pos)
 // Still at same text pos, use same entry
 return 1;
-if (s->style_attributes_temp->style_flag  != s->d.style_flag ||
-s->style_attributes_temp->style_color != s->d.style_color) {
+if (s->style_attributes_temp->style_flag != s->d.style_flag  ||
+s->style_attributes_temp->style_color!= s->d.style_color ||
+s->style_attributes_temp->style_fontsize != s->d.style_fontsize) {
 // last style != defaults, end the style entry and start a new one
 s->box_flags |= STYL_BOX;
 s->style_attributes_temp->style_end = s->text_pos;
@@ -260,10 +261,12 @@ static int mov_text_style_start(MovTextContext *s)
 
 s->style_attributes_temp->style_flag = s->style_attributes[s->count - 
1]->style_flag;
 s->style_attributes_temp->style_color = s->style_attributes[s->count - 
1]->style_color;
+s->style_attributes_temp->style_fontsize = 
s->style_attributes[s->count - 1]->style_fontsize;
 s->style_attributes_temp->style_start = s->text_pos;
 } else { // style entry matches defaults, drop entry
 s->style_attributes_temp->style_flag = s->d.style_flag;
 s->style_attributes_temp->style_color = s->d.style_color;
+s->style_attributes_temp->style_fontsize = s->d.style_fontsize;
 s->style_attributes_temp->style_start = s->text_pos;
 }
 return 1;
@@ -371,6 +374,22 @@ static void mov_text_alpha_cb(void *priv, int alpha, int 
alpha_id)
 mov_text_alpha_set(s, 255 - alpha);
 }
 
+static void mov_text_font_size_set(MovTextContext *s, int size)
+{
+if (!s->style_attributes_temp ||
+s->style_attributes_temp->style_fontsize == size) {
+// color hasn't changed
+return;
+}
+if (mov_text_style_start(s))
+s->style_attributes_temp->style_fontsize = size;
+}
+
+static void mov_text_font_size_cb(void *priv, int size)
+{
+mov_text_font_size_set((MovTextContext*)priv, size);
+}
+
 static void mov_text_end_cb(void *priv)
 {
 // End of text, close any open style record
@@ -392,6 +411,7 @@ static void mov_text_dialog(MovTextContext *s, ASSDialog 
*dialog)
 mov_text_color_set(s, color);
 alpha = 255 - ((uint32_t)style->primary_color >> 24);
 mov_text_alpha_set(s, alpha);
+mov_text_font_size_set(s, style->font_size);
 }
 }
 
@@ -434,12 +454,13 @@ static void mov_text_new_line_cb(void *priv, int forced)
 }
 
 static const ASSCodesCallbacks mov_text_callbacks = {
-.text = mov_text_text_cb,
-.new_line = mov_text_new_line_cb,
-.style= mov_text_style_cb,
-.color= mov_text_color_cb,
-.alpha= mov_text_alpha_cb,
-.end  = mov_text_end_cb,
+.text  = mov_text_text_cb,
+.new_line  = mov_text_new_line_cb,
+.style = mov_text_style_cb,
+.color = mov_text_color_cb,
+.alpha = mov_text_alpha_cb,
+.font_size = mov_text_font_size_cb,
+.end   = mov_text_end_cb,
 };
 
 static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 18/23] lavc/movtextenc: add alpha tag handling

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextenc.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 090536b887..e82393dde7 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -351,6 +351,26 @@ static void mov_text_color_cb(void *priv, unsigned int 
color, unsigned int color
  */
 }
 
+static void mov_text_alpha_set(MovTextContext *s, uint8_t alpha)
+{
+if (!s->style_attributes_temp ||
+(s->style_attributes_temp->style_color & 0xff) == alpha) {
+// color hasn't changed
+return;
+}
+if (mov_text_style_start(s))
+s->style_attributes_temp->style_color =
+(s->style_attributes_temp->style_color & 0xff00) | alpha;
+}
+
+static void mov_text_alpha_cb(void *priv, int alpha, int alpha_id)
+{
+MovTextContext *s = priv;
+
+if (alpha_id == 1) // primary alpha changes
+mov_text_alpha_set(s, 255 - alpha);
+}
+
 static void mov_text_end_cb(void *priv)
 {
 // End of text, close any open style record
@@ -360,7 +380,7 @@ static void mov_text_end_cb(void *priv)
 static void mov_text_dialog(MovTextContext *s, ASSDialog *dialog)
 {
 ASSStyle * style = ff_ass_style_get(s->ass_ctx, dialog->style);
-uint8_tstyle_flags;
+uint8_tstyle_flags, alpha;
 uint32_t   color;
 
 if (style) {
@@ -370,6 +390,8 @@ static void mov_text_dialog(MovTextContext *s, ASSDialog 
*dialog)
 mov_text_style_set(s, style_flags);
 color = BGR_TO_RGB(style->primary_color & 0xff) << 8;
 mov_text_color_set(s, color);
+alpha = 255 - ((uint32_t)style->primary_color >> 24);
+mov_text_alpha_set(s, alpha);
 }
 }
 
@@ -416,6 +438,7 @@ static const ASSCodesCallbacks mov_text_callbacks = {
 .new_line = mov_text_new_line_cb,
 .style= mov_text_style_cb,
 .color= mov_text_color_cb,
+.alpha= mov_text_alpha_cb,
 .end  = mov_text_end_cb,
 };
 
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 17/23] lavc/movtextenc: add color tag handling

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextenc.c | 28 
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 4e7d55efcb..090536b887 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -121,7 +121,7 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 
 style_start  = AV_RB16(>style_attributes[j]->style_start);
 style_end= AV_RB16(>style_attributes[j]->style_end);
-style_color  = AV_RB32(>d.style_color);
+style_color  = AV_RB32(>style_attributes[j]->style_color);
 style_fontID = AV_RB16(>d.style_fontID);
 
 av_bprint_append_any(>buffer, _start, 2);
@@ -244,7 +244,8 @@ static int mov_text_style_start(MovTextContext *s)
 if (s->style_attributes_temp->style_start == s->text_pos)
 // Still at same text pos, use same entry
 return 1;
-if (s->style_attributes_temp->style_flag) {
+if (s->style_attributes_temp->style_flag  != s->d.style_flag ||
+s->style_attributes_temp->style_color != s->d.style_color) {
 // last style != defaults, end the style entry and start a new one
 s->box_flags |= STYL_BOX;
 s->style_attributes_temp->style_end = s->text_pos;
@@ -258,9 +259,11 @@ static int mov_text_style_start(MovTextContext *s)
 }
 
 s->style_attributes_temp->style_flag = s->style_attributes[s->count - 
1]->style_flag;
+s->style_attributes_temp->style_color = s->style_attributes[s->count - 
1]->style_color;
 s->style_attributes_temp->style_start = s->text_pos;
 } else { // style entry matches defaults, drop entry
-s->style_attributes_temp->style_flag = 0;
+s->style_attributes_temp->style_flag = s->d.style_flag;
+s->style_attributes_temp->style_color = s->d.style_color;
 s->style_attributes_temp->style_start = s->text_pos;
 }
 return 1;
@@ -313,12 +316,26 @@ static void mov_text_style_cb(void *priv, const char 
style, int close)
 }
 }
 
+static void mov_text_color_set(MovTextContext *s, uint32_t color)
+{
+if (!s->style_attributes_temp ||
+(s->style_attributes_temp->style_color & 0xff00) == color) {
+// color hasn't changed
+return;
+}
+if (mov_text_style_start(s))
+s->style_attributes_temp->style_color = (color & 0xff00) |
+(s->style_attributes_temp->style_color & 0xff);
+}
+
 static void mov_text_color_cb(void *priv, unsigned int color, unsigned int 
color_id)
 {
 MovTextContext *s = priv;
 
 color = BGR_TO_RGB(color) << 8;
-if (color_id == 2) {//secondary color changes
+if (color_id == 1) {//primary color changes
+mov_text_color_set(s, color);
+} else if (color_id == 2) {//secondary color changes
 if (s->box_flags & HLIT_BOX) {  //close tag
 s->hlit.end = s->text_pos;
 } else {
@@ -344,12 +361,15 @@ static void mov_text_dialog(MovTextContext *s, ASSDialog 
*dialog)
 {
 ASSStyle * style = ff_ass_style_get(s->ass_ctx, dialog->style);
 uint8_tstyle_flags;
+uint32_t   color;
 
 if (style) {
 style_flags = (!!style->bold  * STYLE_FLAG_BOLD)   |
   (!!style->italic* STYLE_FLAG_ITALIC) |
   (!!style->underline * STYLE_FLAG_UNDERLINE);
 mov_text_style_set(s, style_flags);
+color = BGR_TO_RGB(style->primary_color & 0xff) << 8;
+mov_text_color_set(s, color);
 }
 }
 
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 16/23] lavc/movtextenc: init style record from ASS dialog style

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextenc.c | 60 ++---
 1 file changed, 50 insertions(+), 10 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index d389111419..4e7d55efcb 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -39,6 +39,11 @@
 #define HLIT_BOX   (1<<1)
 #define HCLR_BOX   (1<<2)
 
+#define DEFAULT_STYLE_FONT_ID  0x01
+#define DEFAULT_STYLE_FONTSIZE 0x12
+#define DEFAULT_STYLE_COLOR0x
+#define DEFAULT_STYLE_FLAG 0x00
+
 #define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 
0xff))
 #define av_bprint_append_any(buf, data, size)   av_bprint_append_data(buf, 
((const char*)data), size)
 
@@ -46,6 +51,9 @@ typedef struct {
 uint16_t style_start;
 uint16_t style_end;
 uint8_t style_flag;
+uint16_t style_fontID;
+uint8_t style_fontsize;
+uint32_t style_color;
 } StyleBox;
 
 typedef struct {
@@ -68,9 +76,7 @@ typedef struct {
 HilightcolorBox hclr;
 int count;
 uint8_t box_flags;
-uint16_t style_fontID;
-uint8_t style_fontsize;
-uint32_t style_color;
+StyleBox d;
 uint16_t text_pos;
 uint16_t byte_count;
 } MovTextContext;
@@ -104,25 +110,26 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 tsmb_size = s->count * STYLE_RECORD_SIZE + SIZE_ADD;
 tsmb_size = AV_RB32(_size);
 style_entries = AV_RB16(>count);
-s->style_fontID = 0x00 | 0x01<<8;
-s->style_fontsize = 0x12;
-s->style_color = MKTAG(0xFF, 0xFF, 0xFF, 0xFF);
 /*The above three attributes are hard coded for now
 but will come from ASS style in the future*/
 av_bprint_append_any(>buffer, _size, 4);
 av_bprint_append_any(>buffer, _type, 4);
 av_bprint_append_any(>buffer, _entries, 2);
 for (j = 0; j < s->count; j++) {
-uint16_t style_start, style_end;
+uint16_t style_start, style_end, style_fontID;
+uint32_t style_color;
 
 style_start  = AV_RB16(>style_attributes[j]->style_start);
 style_end= AV_RB16(>style_attributes[j]->style_end);
+style_color  = AV_RB32(>d.style_color);
+style_fontID = AV_RB16(>d.style_fontID);
+
 av_bprint_append_any(>buffer, _start, 2);
 av_bprint_append_any(>buffer, _end, 2);
-av_bprint_append_any(>buffer, >style_fontID, 2);
+av_bprint_append_any(>buffer, _fontID, 2);
 av_bprint_append_any(>buffer, 
>style_attributes[j]->style_flag, 1);
-av_bprint_append_any(>buffer, >style_fontsize, 1);
-av_bprint_append_any(>buffer, >style_color, 4);
+av_bprint_append_any(>buffer, >d.style_fontsize, 1);
+av_bprint_append_any(>buffer, _color, 4);
 }
 }
 mov_text_cleanup(s);
@@ -220,6 +227,13 @@ static av_cold int mov_text_encode_init(AVCodecContext 
*avctx)
 memcpy(avctx->extradata, text_sample_entry, avctx->extradata_size);
 
 s->ass_ctx = ff_ass_split(avctx->subtitle_header);
+
+// TODO: Initialize from ASS style record
+s->d.style_fontID   = DEFAULT_STYLE_FONT_ID;
+s->d.style_fontsize = DEFAULT_STYLE_FONTSIZE;
+s->d.style_color= DEFAULT_STYLE_COLOR;
+s->d.style_flag = DEFAULT_STYLE_FLAG;
+
 return s->ass_ctx ? 0 : AVERROR_INVALIDDATA;
 }
 
@@ -270,6 +284,17 @@ static uint8_t mov_text_style_to_flag(const char style)
 return style_flag;
 }
 
+static void mov_text_style_set(MovTextContext *s, uint8_t style_flags)
+{
+if (!s->style_attributes_temp ||
+!((s->style_attributes_temp->style_flag & style_flags) ^ style_flags)) 
{
+// setting flags that that are already set
+return;
+}
+if (mov_text_style_start(s))
+s->style_attributes_temp->style_flag |= style_flags;
+}
+
 static void mov_text_style_cb(void *priv, const char style, int close)
 {
 MovTextContext *s = priv;
@@ -315,6 +340,19 @@ static void mov_text_end_cb(void *priv)
 mov_text_style_start((MovTextContext*)priv);
 }
 
+static void mov_text_dialog(MovTextContext *s, ASSDialog *dialog)
+{
+ASSStyle * style = ff_ass_style_get(s->ass_ctx, dialog->style);
+uint8_tstyle_flags;
+
+if (style) {
+style_flags = (!!style->bold  * STYLE_FLAG_BOLD)   |
+  (!!style->italic* STYLE_FLAG_ITALIC) |
+  (!!style->underline * STYLE_FLAG_UNDERLINE);
+mov_text_style_set(s, style_flags);
+}
+}
+
 static uint16_t utf8_strlen(const char *text, int len)
 {
 uint16_t i = 0, ret = 0;
@@ -386,6 +424,7 @@ static int mov_text_encode_frame(AVCodecContext *avctx, 
unsigned char *buf,
 int num;
 dialog = ff_ass_split_dialog(s->ass_ctx, ass, 0, );
 for (; dialog && num--; dialog++) {
+mov_text_dialog(s, dialog);
 ff_ass_split_override_codes(_text_callbacks, s, 
dialog->text);
 

[FFmpeg-devel] [PATCH 14/23] lavc/movtextenc: simplify style record updates

2020-04-06 Thread John Stebbins
Makes style update code easier to extend for style types not yet handled
---
 libavcodec/movtextenc.c | 131 +++-
 1 file changed, 62 insertions(+), 69 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 5e5b786f44..05532cd544 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -89,6 +89,10 @@ static void mov_text_cleanup(MovTextContext *s)
 }
 av_freep(>style_attributes);
 }
+if (s->style_attributes_temp) {
+s->style_attributes_temp->style_flag = 0;
+s->style_attributes_temp->style_start = 0;
+}
 }
 
 static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
@@ -96,7 +100,7 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 int j;
 uint32_t tsmb_size;
 uint16_t style_entries;
-if (s->box_flags & STYL_BOX) {
+if ((s->box_flags & STYL_BOX) && s->count) {
 tsmb_size = s->count * STYLE_RECORD_SIZE + SIZE_ADD;
 tsmb_size = AV_RB32(_size);
 style_entries = AV_RB16(>count);
@@ -120,8 +124,8 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 av_bprint_append_any(>buffer, >style_fontsize, 1);
 av_bprint_append_any(>buffer, >style_color, 4);
 }
-mov_text_cleanup(s);
 }
+mov_text_cleanup(s);
 }
 
 static void encode_hlit(MovTextContext *s, uint32_t tsmb_type)
@@ -201,6 +205,11 @@ static av_cold int mov_text_encode_init(AVCodecContext 
*avctx)
 MovTextContext *s = avctx->priv_data;
 s->avctx = avctx;
 
+s->style_attributes_temp = av_mallocz(sizeof(*s->style_attributes_temp));
+if (!s->style_attributes_temp) {
+return AVERROR(ENOMEM);
+}
+
 avctx->extradata_size = sizeof text_sample_entry;
 avctx->extradata = av_mallocz(avctx->extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!avctx->extradata)
@@ -214,85 +223,69 @@ static av_cold int mov_text_encode_init(AVCodecContext 
*avctx)
 return s->ass_ctx ? 0 : AVERROR_INVALIDDATA;
 }
 
-static void mov_text_style_cb(void *priv, const char style, int close)
+// Start a new style box if needed
+static int mov_text_style_start(MovTextContext *s)
 {
-MovTextContext *s = priv;
-if (!close) {
-if (!(s->box_flags & STYL_BOX)) {   //first style entry
-
-s->style_attributes_temp = 
av_malloc(sizeof(*s->style_attributes_temp));
-
-if (!s->style_attributes_temp) {
-av_bprint_clear(>buffer);
-s->box_flags &= ~STYL_BOX;
-return;
-}
-
-s->style_attributes_temp->style_flag = 0;
-s->style_attributes_temp->style_start = s->text_pos;
-} else {
-if (s->style_attributes_temp->style_flag) { //break the style 
record here and start a new one
-s->style_attributes_temp->style_end = s->text_pos;
-av_dynarray_add(>style_attributes, >count, 
s->style_attributes_temp);
-s->style_attributes_temp = 
av_malloc(sizeof(*s->style_attributes_temp));
-if (!s->style_attributes_temp) {
-mov_text_cleanup(s);
-av_bprint_clear(>buffer);
-s->box_flags &= ~STYL_BOX;
-return;
-}
-
-s->style_attributes_temp->style_flag = 
s->style_attributes[s->count - 1]->style_flag;
-s->style_attributes_temp->style_start = s->text_pos;
-} else {
-s->style_attributes_temp->style_flag = 0;
-s->style_attributes_temp->style_start = s->text_pos;
-}
-}
-switch (style){
-case 'b':
-s->style_attributes_temp->style_flag |= STYLE_FLAG_BOLD;
-break;
-case 'i':
-s->style_attributes_temp->style_flag |= STYLE_FLAG_ITALIC;
-break;
-case 'u':
-s->style_attributes_temp->style_flag |= STYLE_FLAG_UNDERLINE;
-break;
-}
-} else if (!s->style_attributes_temp) {
-av_log(s->avctx, AV_LOG_WARNING, "Ignoring unmatched close tag\n");
-return;
-} else {
+// there's an existing style entry
+if (s->style_attributes_temp->style_start == s->text_pos)
+// Still at same text pos, use same entry
+return 1;
+if (s->style_attributes_temp->style_flag) {
+// last style != defaults, end the style entry and start a new one
+s->box_flags |= STYL_BOX;
 s->style_attributes_temp->style_end = s->text_pos;
 av_dynarray_add(>style_attributes, >count, 
s->style_attributes_temp);
-
 s->style_attributes_temp = 
av_malloc(sizeof(*s->style_attributes_temp));
-
 if (!s->style_attributes_temp) {
 mov_text_cleanup(s);
 av_bprint_clear(>buffer);
 s->box_flags &= ~STYL_BOX;
-return;
+return 0;
 }
 
 

[FFmpeg-devel] [PATCH 15/23] lavc/movtextenc: fix unclosed style records

2020-04-06 Thread John Stebbins
The last record at the end of each dialog was never closed
---
 libavcodec/movtextenc.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 05532cd544..d389111419 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -309,6 +309,12 @@ static void mov_text_color_cb(void *priv, unsigned int 
color, unsigned int color
  */
 }
 
+static void mov_text_end_cb(void *priv)
+{
+// End of text, close any open style record
+mov_text_style_start((MovTextContext*)priv);
+}
+
 static uint16_t utf8_strlen(const char *text, int len)
 {
 uint16_t i = 0, ret = 0;
@@ -352,6 +358,7 @@ static const ASSCodesCallbacks mov_text_callbacks = {
 .new_line = mov_text_new_line_cb,
 .style= mov_text_style_cb,
 .color= mov_text_color_cb,
+.end  = mov_text_end_cb,
 };
 
 static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Nicolas George
Carl Eugen Hoyos (12020-04-06):
> Is it possible to support both codecs?

Of course it it possible. And this is exactly the right thing to do
(modulo the question of which raw frame API we keep).

> Commit 64ceeac2 changed the only supported format for the
> null muxer without any version bump.
> (While this is a very important muxer for me, I agree that my
> argumentation above is not completely compelling.)

null is a different case: nobody will use null specifically, if they use
it, they use it as a placeholder for generic code capable of handling
any muxer. And since it is generic code, it will handle any codec.

But anyway, you are reading this commit wrongly. It does not remove
support for rawvideo in null, rawvideo is still supported in null, as
any other codec. This commit only changes the default codec.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 13/23] lavc/movtextenc: keep values in native byte order till written

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextenc.c | 38 ++
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 8638e303fe..5e5b786f44 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -68,7 +68,6 @@ typedef struct {
 HilightcolorBox hclr;
 int count;
 uint8_t box_flags;
-uint16_t style_entries;
 uint16_t style_fontID;
 uint8_t style_fontsize;
 uint32_t style_color;
@@ -96,10 +95,11 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 {
 int j;
 uint32_t tsmb_size;
+uint16_t style_entries;
 if (s->box_flags & STYL_BOX) {
 tsmb_size = s->count * STYLE_RECORD_SIZE + SIZE_ADD;
 tsmb_size = AV_RB32(_size);
-s->style_entries = AV_RB16(>count);
+style_entries = AV_RB16(>count);
 s->style_fontID = 0x00 | 0x01<<8;
 s->style_fontsize = 0x12;
 s->style_color = MKTAG(0xFF, 0xFF, 0xFF, 0xFF);
@@ -107,10 +107,14 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 but will come from ASS style in the future*/
 av_bprint_append_any(>buffer, _size, 4);
 av_bprint_append_any(>buffer, _type, 4);
-av_bprint_append_any(>buffer, >style_entries, 2);
+av_bprint_append_any(>buffer, _entries, 2);
 for (j = 0; j < s->count; j++) {
-av_bprint_append_any(>buffer, 
>style_attributes[j]->style_start, 2);
-av_bprint_append_any(>buffer, 
>style_attributes[j]->style_end, 2);
+uint16_t style_start, style_end;
+
+style_start  = AV_RB16(>style_attributes[j]->style_start);
+style_end= AV_RB16(>style_attributes[j]->style_end);
+av_bprint_append_any(>buffer, _start, 2);
+av_bprint_append_any(>buffer, _end, 2);
 av_bprint_append_any(>buffer, >style_fontID, 2);
 av_bprint_append_any(>buffer, 
>style_attributes[j]->style_flag, 1);
 av_bprint_append_any(>buffer, >style_fontsize, 1);
@@ -123,13 +127,16 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 static void encode_hlit(MovTextContext *s, uint32_t tsmb_type)
 {
 uint32_t tsmb_size;
+uint16_t start, end;
 if (s->box_flags & HLIT_BOX) {
 tsmb_size = 12;
 tsmb_size = AV_RB32(_size);
+start = AV_RB16(>hlit.start);
+end   = AV_RB16(>hlit.end);
 av_bprint_append_any(>buffer, _size, 4);
 av_bprint_append_any(>buffer, _type, 4);
-av_bprint_append_any(>buffer, >hlit.start, 2);
-av_bprint_append_any(>buffer, >hlit.end, 2);
+av_bprint_append_any(>buffer, , 2);
+av_bprint_append_any(>buffer, , 2);
 }
 }
 
@@ -222,10 +229,10 @@ static void mov_text_style_cb(void *priv, const char 
style, int close)
 }
 
 s->style_attributes_temp->style_flag = 0;
-s->style_attributes_temp->style_start = AV_RB16(>text_pos);
+s->style_attributes_temp->style_start = s->text_pos;
 } else {
 if (s->style_attributes_temp->style_flag) { //break the style 
record here and start a new one
-s->style_attributes_temp->style_end = AV_RB16(>text_pos);
+s->style_attributes_temp->style_end = s->text_pos;
 av_dynarray_add(>style_attributes, >count, 
s->style_attributes_temp);
 s->style_attributes_temp = 
av_malloc(sizeof(*s->style_attributes_temp));
 if (!s->style_attributes_temp) {
@@ -236,10 +243,10 @@ static void mov_text_style_cb(void *priv, const char 
style, int close)
 }
 
 s->style_attributes_temp->style_flag = 
s->style_attributes[s->count - 1]->style_flag;
-s->style_attributes_temp->style_start = AV_RB16(>text_pos);
+s->style_attributes_temp->style_start = s->text_pos;
 } else {
 s->style_attributes_temp->style_flag = 0;
-s->style_attributes_temp->style_start = AV_RB16(>text_pos);
+s->style_attributes_temp->style_start = s->text_pos;
 }
 }
 switch (style){
@@ -257,7 +264,7 @@ static void mov_text_style_cb(void *priv, const char style, 
int close)
 av_log(s->avctx, AV_LOG_WARNING, "Ignoring unmatched close tag\n");
 return;
 } else {
-s->style_attributes_temp->style_end = AV_RB16(>text_pos);
+s->style_attributes_temp->style_end = s->text_pos;
 av_dynarray_add(>style_attributes, >count, 
s->style_attributes_temp);
 
 s->style_attributes_temp = 
av_malloc(sizeof(*s->style_attributes_temp));
@@ -282,7 +289,7 @@ static void mov_text_style_cb(void *priv, const char style, 
int close)
 break;
 }
 if (s->style_attributes_temp->style_flag) { //start of new style record
-s->style_attributes_temp->style_start = AV_RB16(>text_pos);
+  

[FFmpeg-devel] [PATCH 10/23] lavc/movtextdec: allow setting subtitle frame dimensions

2020-04-06 Thread John Stebbins
Font sizes are relative to the subtitle frame dimensions. If the
expected frame dimensions are not known, the font sizes will most
likely be incorrect.
---
 libavcodec/ass.c| 30 +++---
 libavcodec/ass.h| 28 
 libavcodec/movtextdec.c | 30 +-
 3 files changed, 80 insertions(+), 8 deletions(-)

diff --git a/libavcodec/ass.c b/libavcodec/ass.c
index a51673fb4e..7c26e3fd6d 100644
--- a/libavcodec/ass.c
+++ b/libavcodec/ass.c
@@ -26,11 +26,13 @@
 #include "libavutil/bprint.h"
 #include "libavutil/common.h"
 
-int ff_ass_subtitle_header(AVCodecContext *avctx,
-   const char *font, int font_size,
-   int color, int back_color,
-   int bold, int italic, int underline,
-   int border_style, int alignment)
+int ff_ass_subtitle_header_full(AVCodecContext *avctx,
+int play_res_x, int play_res_y,
+const char *font, int font_size,
+int primary_color, int secondary_color,
+int outline_color, int back_color,
+int bold, int italic, int underline,
+int border_style, int alignment)
 {
 avctx->subtitle_header = av_asprintf(
  "[Script Info]\r\n"
@@ -67,8 +69,8 @@ int ff_ass_subtitle_header(AVCodecContext *avctx,
  "[Events]\r\n"
  "Format: Layer, Start, End, Style, Name, MarginL, MarginR, 
MarginV, Effect, Text\r\n",
  !(avctx->flags & AV_CODEC_FLAG_BITEXACT) ? 
AV_STRINGIFY(LIBAVCODEC_VERSION) : "",
- ASS_DEFAULT_PLAYRESX, ASS_DEFAULT_PLAYRESY,
- font, font_size, color, color, back_color, back_color,
+ play_res_x, play_res_y, font, font_size,
+ primary_color, secondary_color, outline_color, back_color,
  -bold, -italic, -underline, border_style, alignment);
 
 if (!avctx->subtitle_header)
@@ -77,6 +79,20 @@ int ff_ass_subtitle_header(AVCodecContext *avctx,
 return 0;
 }
 
+int ff_ass_subtitle_header(AVCodecContext *avctx,
+   const char *font, int font_size,
+   int color, int back_color,
+   int bold, int italic, int underline,
+   int border_style, int alignment)
+{
+return ff_ass_subtitle_header_full(avctx,
+   ASS_DEFAULT_PLAYRESX, ASS_DEFAULT_PLAYRESY,
+   font, font_size, color, color,
+   back_color, back_color,
+   bold, italic, underline,
+   border_style, alignment);
+}
+
 int ff_ass_subtitle_header_default(AVCodecContext *avctx)
 {
 return ff_ass_subtitle_header(avctx, ASS_DEFAULT_FONT,
diff --git a/libavcodec/ass.h b/libavcodec/ass.h
index 314b43b686..2c260e4e78 100644
--- a/libavcodec/ass.h
+++ b/libavcodec/ass.h
@@ -47,6 +47,34 @@ typedef struct FFASSDecoderContext {
 int readorder;
 } FFASSDecoderContext;
 
+/**
+ * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
+ * Can specify all fields explicitly
+ *
+ * @param avctx pointer to the AVCodecContext
+ * @param play_res_x subtitle frame width
+ * @param play_res_y subtitle frame height
+ * @param font name of the default font face to use
+ * @param font_size default font size to use
+ * @param primary_color default text color to use (ABGR)
+ * @param secondary_color default secondary text color to use (ABGR)
+ * @param outline_color default outline color to use (ABGR)
+ * @param back_color default background color to use (ABGR)
+ * @param bold 1 for bold text, 0 for normal text
+ * @param italic 1 for italic text, 0 for normal text
+ * @param underline 1 for underline text, 0 for normal text
+ * @param border_style 1 for outline, 3 for opaque box
+ * @param alignment position of the text (left, center, top...), defined after
+ *  the layout of the numpad (1-3 sub, 4-6 mid, 7-9 top)
+ * @return >= 0 on success otherwise an error code <0
+ */
+int ff_ass_subtitle_header_full(AVCodecContext *avctx,
+int play_res_x, int play_res_y,
+const char *font, int font_size,
+int primary_color, int secondary_color,
+int outline_color, int back_color,
+int bold, int italic, int underline,
+int border_style, int alignment);
 /**
  * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
  *
diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index f3a504b47b..4b4da5e0d9 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -21,6 +21,7 @@
 
 #include "avcodec.h"
 #include 

[FFmpeg-devel] [PATCH 11/23] lavc/ass_split: fix parsing utf8 scripts

2020-04-06 Thread John Stebbins
The [Script Info] section was skipped if starts with UTF8 BOM
---
 libavcodec/ass_split.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index 67da7c6d84..94c32667af 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -354,6 +354,9 @@ static int ass_split(ASSSplitContext *ctx, const char *buf)
 if (ctx->current_section >= 0)
 buf = ass_split_section(ctx, buf);
 
+if(!memcmp(buf, "\xef\xbb\xbf", 3)) { // Skip UTF-8 BOM header
+buf += 3;
+}
 while (buf && *buf) {
 if (sscanf(buf, "[%15[0-9A-Za-z+ ]]%c", section, ) == 2) {
 buf += strcspn(buf, "\n");
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 12/23] lavc/movtextenc: use correct color component order

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextenc.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index c19ef384bc..8638e303fe 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -39,6 +39,7 @@
 #define HLIT_BOX   (1<<1)
 #define HCLR_BOX   (1<<2)
 
+#define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 
0xff))
 #define av_bprint_append_any(buf, data, size)   av_bprint_append_data(buf, 
((const char*)data), size)
 
 typedef struct {
@@ -134,13 +135,14 @@ static void encode_hlit(MovTextContext *s, uint32_t 
tsmb_type)
 
 static void encode_hclr(MovTextContext *s, uint32_t tsmb_type)
 {
-uint32_t tsmb_size;
+uint32_t tsmb_size, color;
 if (s->box_flags & HCLR_BOX) {
 tsmb_size = 12;
 tsmb_size = AV_RB32(_size);
+color = AV_RB32(>hclr.color);
 av_bprint_append_any(>buffer, _size, 4);
 av_bprint_append_any(>buffer, _type, 4);
-av_bprint_append_any(>buffer, >hclr.color, 4);
+av_bprint_append_any(>buffer, , 4);
 }
 }
 
@@ -289,6 +291,8 @@ static void mov_text_style_cb(void *priv, const char style, 
int close)
 static void mov_text_color_cb(void *priv, unsigned int color, unsigned int 
color_id)
 {
 MovTextContext *s = priv;
+
+color = BGR_TO_RGB(color) << 8;
 if (color_id == 2) {//secondary color changes
 if (s->box_flags & HLIT_BOX) {  //close tag
 s->hlit.end = AV_RB16(>text_pos);
@@ -296,7 +300,7 @@ static void mov_text_color_cb(void *priv, unsigned int 
color, unsigned int color
 s->box_flags |= HCLR_BOX;
 s->box_flags |= HLIT_BOX;
 s->hlit.start = AV_RB16(>text_pos);
-s->hclr.color = color | (0xFF << 24);  //set alpha value to FF
+s->hclr.color = color | 0xFF;  //set alpha value to FF
 }
 }
 /* If there are more than one secondary color changes in ASS, take start of
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 08/23] lavc/movtextdec: add color and alpha style tags

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextdec.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index eb9c7f5755..4d5dcdf5e7 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -76,6 +76,8 @@ typedef struct {
 uint8_t bold;
 uint8_t italic;
 uint8_t underline;
+int color;
+uint8_t alpha;
 uint8_t fontsize;
 uint16_t style_fontID;
 } StyleBox;
@@ -329,14 +331,16 @@ static int decode_styl(const uint8_t *tsmb, 
MovTextContext *m, AVPacket *avpkt)
 m->s_temp->underline = !!(m->s_temp->style_flag & 
STYLE_FLAG_UNDERLINE);
 tsmb++;
 m->s_temp->fontsize = AV_RB8(tsmb);
+tsmb++;
+m->s_temp->color = AV_RB24(tsmb);
+tsmb += 3;
+m->s_temp->alpha = AV_RB8(tsmb);
+tsmb++;
 av_dynarray_add(>s, >count_s, m->s_temp);
 if(!m->s) {
 mov_text_cleanup(m);
 return AVERROR(ENOMEM);
 }
-tsmb++;
-// text-color-rgba
-tsmb += 4;
 }
 return 0;
 }
@@ -400,6 +404,11 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 if (m->s[entry]->style_fontID == m->ftab[i]->fontID)
 av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font);
 }
+if (m->d.color != m->s[entry]->color)
+av_bprintf(buf, "{\\1c%X&}",
+   RGB_TO_BGR(m->s[entry]->color));
+if (m->d.alpha != m->s[entry]->alpha)
+av_bprintf(buf, "{\\1a%02X&}", 255 - m->s[entry]->alpha);
 }
 if (text_pos == m->s[entry]->style_end) {
 if (style_active) {
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 09/23] lavc/movtextdec: restore active style color after hilite

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextdec.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 4d5dcdf5e7..f3a504b47b 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -376,6 +376,7 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 int text_pos = 0;
 int style_active = 0;
 int entry = 0;
+int color = m->d.color;
 
 if (text < text_end && m->box_flags & TWRP_BOX) {
 if (m->w.wrap_flag == 1) {
@@ -404,9 +405,10 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 if (m->s[entry]->style_fontID == m->ftab[i]->fontID)
 av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font);
 }
-if (m->d.color != m->s[entry]->color)
-av_bprintf(buf, "{\\1c%X&}",
-   RGB_TO_BGR(m->s[entry]->color));
+if (m->d.color != m->s[entry]->color) {
+color = m->s[entry]->color;
+av_bprintf(buf, "{\\1c%X&}", RGB_TO_BGR(color));
+}
 if (m->d.alpha != m->s[entry]->alpha)
 av_bprintf(buf, "{\\1a%02X&}", 255 - m->s[entry]->alpha);
 }
@@ -414,6 +416,7 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 if (style_active) {
 av_bprintf(buf, "{\\r}");
 style_active = 0;
+color = m->d.color;
 }
 entry++;
 }
@@ -435,9 +438,10 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 }
 if (text_pos == m->h.hlit_end) {
 if (m->box_flags & HCLR_BOX) {
-av_bprintf(buf, "{\\2c&}");
+av_bprintf(buf, "{\\2c%X&}", RGB_TO_BGR(m->d.color));
 } else {
-av_bprintf(buf, "{\\1c&}{\\2c&}");
+av_bprintf(buf, "{\\1c%X&}{\\2c%X&}",
+   RGB_TO_BGR(color), RGB_TO_BGR(m->d.color));
 }
 }
 }
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 07/23] lavc/movtextdec: add alpha default to ass header colors

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextdec.c| 14 ++
 tests/ref/fate/sub-movtext |  2 +-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 2481c71af6..eb9c7f5755 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -55,7 +55,9 @@ typedef struct {
 const char *font;
 uint8_t fontsize;
 int color;
+uint8_t alpha;
 int back_color;
+uint8_t back_alpha;
 uint8_t bold;
 uint8_t italic;
 uint8_t underline;
@@ -186,7 +188,9 @@ static int mov_text_tx3g(AVCodecContext *avctx, 
MovTextContext *m)
 }
 // Background Color
 m->d.back_color = AV_RB24(tx3g_ptr);
-tx3g_ptr += 4;
+tx3g_ptr += 3;
+m->d.back_alpha = AV_RB8(tx3g_ptr);
+tx3g_ptr += 1;
 // BoxRecord
 tx3g_ptr += 8;
 // StyleRecord
@@ -203,7 +207,9 @@ static int mov_text_tx3g(AVCodecContext *avctx, 
MovTextContext *m)
 m->d.fontsize = *tx3g_ptr++;
 // Primary color
 m->d.color = AV_RB24(tx3g_ptr);
-tx3g_ptr += 4;
+tx3g_ptr += 3;
+m->d.alpha = AV_RB8(tx3g_ptr);
+tx3g_ptr += 1;
 // FontRecord
 // FontRecord Size
 tx3g_ptr += 4;
@@ -463,8 +469,8 @@ static int mov_text_init(AVCodecContext *avctx) {
 ret = mov_text_tx3g(avctx, m);
 if (ret == 0) {
 return ff_ass_subtitle_header(avctx, m->d.font, m->d.fontsize,
-RGB_TO_BGR(m->d.color),
-RGB_TO_BGR(m->d.back_color),
+(255 - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
+(255 - m->d.back_alpha) << 24 | 
RGB_TO_BGR(m->d.back_color),
 m->d.bold, m->d.italic, m->d.underline,
 ASS_DEFAULT_BORDERSTYLE, m->d.alignment);
 } else
diff --git a/tests/ref/fate/sub-movtext b/tests/ref/fate/sub-movtext
index 94ed22d318..6047060918 100644
--- a/tests/ref/fate/sub-movtext
+++ b/tests/ref/fate/sub-movtext
@@ -6,7 +6,7 @@ PlayResY: 288
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, 
OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, 
Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, 
MarginV, Encoding
-Style: 
Default,Serif,18,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+Style: 
Default,Serif,18,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
 
 [Events]
 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 06/23] lavc/movtextdec: make sure default font name is set

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 6c7d93702e..2481c71af6 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -52,7 +52,7 @@
 
 typedef struct {
 uint16_t fontID;
-char *font;
+const char *font;
 uint8_t fontsize;
 int color;
 int back_color;
@@ -251,6 +251,8 @@ static int mov_text_tx3g(AVCodecContext *avctx, 
MovTextContext *m)
 m->ftab_temp = NULL;
 tx3g_ptr = tx3g_ptr + font_length;
 }
+// In case of broken header, init default font
+m->d.font = ASS_DEFAULT_FONT;
 for (i = 0; i < m->ftab_entries; i++) {
 if (m->d.fontID == m->ftab[i]->fontID)
 m->d.font = m->ftab[i]->font;
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 05/23] lavc/movtextdec: only write fontsize, fontID tags if not default

2020-04-06 Thread John Stebbins
---
 libavcodec/movtextdec.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index a3e37d013d..6c7d93702e 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -51,8 +51,9 @@
 #define RGB_TO_BGR(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 
0xff))
 
 typedef struct {
+uint16_t fontID;
 char *font;
-int fontsize;
+uint8_t fontsize;
 int color;
 int back_color;
 uint8_t bold;
@@ -146,7 +147,6 @@ static int mov_text_tx3g(AVCodecContext *avctx, 
MovTextContext *m)
 uint8_t *tx3g_ptr = avctx->extradata;
 int i, box_size, font_length;
 int8_t v_align, h_align;
-int style_fontID;
 StyleBox s_default;
 
 m->count_f = 0;
@@ -192,7 +192,7 @@ static int mov_text_tx3g(AVCodecContext *avctx, 
MovTextContext *m)
 // StyleRecord
 tx3g_ptr += 4;
 // fontID
-style_fontID = AV_RB16(tx3g_ptr);
+m->d.fontID = AV_RB16(tx3g_ptr);
 tx3g_ptr += 2;
 // face-style-flags
 s_default.style_flag = *tx3g_ptr++;
@@ -252,7 +252,7 @@ static int mov_text_tx3g(AVCodecContext *avctx, 
MovTextContext *m)
 tx3g_ptr = tx3g_ptr + font_length;
 }
 for (i = 0; i < m->ftab_entries; i++) {
-if (style_fontID == m->ftab[i]->fontID)
+if (m->d.fontID == m->ftab[i]->fontID)
 m->d.font = m->ftab[i]->font;
 }
 return 0;
@@ -385,11 +385,13 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 av_bprintf(buf, "{\\i%d}", m->s[entry]->italic);
 if (m->s[entry]->underline ^ m->d.underline)
 av_bprintf(buf, "{\\u%d}", m->s[entry]->underline);
-av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize);
-for (i = 0; i < m->ftab_entries; i++) {
-if (m->s[entry]->style_fontID == m->ftab[i]->fontID)
-av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font);
-}
+if (m->s[entry]->fontsize != m->d.fontsize)
+av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize);
+if (m->s[entry]->style_fontID != m->d.fontID)
+for (i = 0; i < m->ftab_entries; i++) {
+if (m->s[entry]->style_fontID == m->ftab[i]->fontID)
+av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font);
+}
 }
 if (text_pos == m->s[entry]->style_end) {
 if (style_active) {
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 04/23] lavc/movtextdec: handle changes to default style flags

2020-04-06 Thread John Stebbins
Style flags were only being turned on.  If the default was on and style
record turned off, style flag remained on.
---
 libavcodec/movtextdec.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index d6896562c2..a3e37d013d 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -55,9 +55,9 @@ typedef struct {
 int fontsize;
 int color;
 int back_color;
-int bold;
-int italic;
-int underline;
+uint8_t bold;
+uint8_t italic;
+uint8_t underline;
 int alignment;
 } MovTextDefault;
 
@@ -70,6 +70,9 @@ typedef struct {
 uint16_t style_start;
 uint16_t style_end;
 uint8_t style_flag;
+uint8_t bold;
+uint8_t italic;
+uint8_t underline;
 uint8_t fontsize;
 uint16_t style_fontID;
 } StyleBox;
@@ -313,6 +316,9 @@ static int decode_styl(const uint8_t *tsmb, MovTextContext 
*m, AVPacket *avpkt)
 m->s_temp->style_fontID = AV_RB16(tsmb);
 tsmb += 2;
 m->s_temp->style_flag = AV_RB8(tsmb);
+m->s_temp->bold = !!(m->s_temp->style_flag & STYLE_FLAG_BOLD);
+m->s_temp->italic = !!(m->s_temp->style_flag & STYLE_FLAG_ITALIC);
+m->s_temp->underline = !!(m->s_temp->style_flag & 
STYLE_FLAG_UNDERLINE);
 tsmb++;
 m->s_temp->fontsize = AV_RB8(tsmb);
 av_dynarray_add(>s, >count_s, m->s_temp);
@@ -373,12 +379,12 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 if ((m->box_flags & STYL_BOX) && entry < m->style_entries) {
 if (text_pos == m->s[entry]->style_start) {
 style_active = 1;
-if (m->s[entry]->style_flag & STYLE_FLAG_BOLD)
-av_bprintf(buf, "{\\b1}");
-if (m->s[entry]->style_flag & STYLE_FLAG_ITALIC)
-av_bprintf(buf, "{\\i1}");
-if (m->s[entry]->style_flag & STYLE_FLAG_UNDERLINE)
-av_bprintf(buf, "{\\u1}");
+if (m->s[entry]->bold ^ m->d.bold)
+av_bprintf(buf, "{\\b%d}", m->s[entry]->bold);
+if (m->s[entry]->italic ^ m->d.italic)
+av_bprintf(buf, "{\\i%d}", m->s[entry]->italic);
+if (m->s[entry]->underline ^ m->d.underline)
+av_bprintf(buf, "{\\u%d}", m->s[entry]->underline);
 av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize);
 for (i = 0; i < m->ftab_entries; i++) {
 if (m->s[entry]->style_fontID == m->ftab[i]->fontID)
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 03/23] lavc/movtextdec: fix bold, italic, underline flags

2020-04-06 Thread John Stebbins
They should be 0 or 1 so that 0 or -1 is written to the ass header
---
 libavcodec/movtextdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 47a8401119..d6896562c2 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -193,9 +193,9 @@ static int mov_text_tx3g(AVCodecContext *avctx, 
MovTextContext *m)
 tx3g_ptr += 2;
 // face-style-flags
 s_default.style_flag = *tx3g_ptr++;
-m->d.bold = s_default.style_flag & STYLE_FLAG_BOLD;
-m->d.italic = s_default.style_flag & STYLE_FLAG_ITALIC;
-m->d.underline = s_default.style_flag & STYLE_FLAG_UNDERLINE;
+m->d.bold = !!(s_default.style_flag & STYLE_FLAG_BOLD);
+m->d.italic = !!(s_default.style_flag & STYLE_FLAG_ITALIC);
+m->d.underline = !!(s_default.style_flag & STYLE_FLAG_UNDERLINE);
 // fontsize
 m->d.fontsize = *tx3g_ptr++;
 // Primary color
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 02/23] lavc/movtextdec: simplify style record walk

2020-04-06 Thread John Stebbins
It's not necessary to walk the style record list twice per subtitle
character.  style records are in order and do not overlap.
---
 libavcodec/movtextdec.c | 38 --
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 05becaf64d..47a8401119 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -355,8 +355,9 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 {
 MovTextContext *m = avctx->priv_data;
 int i = 0;
-int j = 0;
 int text_pos = 0;
+int style_active = 0;
+int entry = 0;
 
 if (text < text_end && m->box_flags & TWRP_BOX) {
 if (m->w.wrap_flag == 1) {
@@ -369,26 +370,27 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 while (text < text_end) {
 int len;
 
-if (m->box_flags & STYL_BOX) {
-for (i = 0; i < m->style_entries; i++) {
-if (m->s[i]->style_flag && text_pos == m->s[i]->style_end) {
-av_bprintf(buf, "{\\r}");
+if ((m->box_flags & STYL_BOX) && entry < m->style_entries) {
+if (text_pos == m->s[entry]->style_start) {
+style_active = 1;
+if (m->s[entry]->style_flag & STYLE_FLAG_BOLD)
+av_bprintf(buf, "{\\b1}");
+if (m->s[entry]->style_flag & STYLE_FLAG_ITALIC)
+av_bprintf(buf, "{\\i1}");
+if (m->s[entry]->style_flag & STYLE_FLAG_UNDERLINE)
+av_bprintf(buf, "{\\u1}");
+av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize);
+for (i = 0; i < m->ftab_entries; i++) {
+if (m->s[entry]->style_fontID == m->ftab[i]->fontID)
+av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font);
 }
 }
-for (i = 0; i < m->style_entries; i++) {
-if (m->s[i]->style_flag && text_pos == m->s[i]->style_start) {
-if (m->s[i]->style_flag & STYLE_FLAG_BOLD)
-av_bprintf(buf, "{\\b1}");
-if (m->s[i]->style_flag & STYLE_FLAG_ITALIC)
-av_bprintf(buf, "{\\i1}");
-if (m->s[i]->style_flag & STYLE_FLAG_UNDERLINE)
-av_bprintf(buf, "{\\u1}");
-av_bprintf(buf, "{\\fs%d}", m->s[i]->fontsize);
-for (j = 0; j < m->ftab_entries; j++) {
-if (m->s[i]->style_fontID == m->ftab[j]->fontID)
-av_bprintf(buf, "{\\fn%s}", m->ftab[j]->font);
-}
+if (text_pos == m->s[entry]->style_end) {
+if (style_active) {
+av_bprintf(buf, "{\\r}");
+style_active = 0;
 }
+entry++;
 }
 }
 if (m->box_flags & HLIT_BOX) {
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 01/23] lavc/movtextdec: fix ass header colors

2020-04-06 Thread John Stebbins
A conversion from rgb to bgr is necessary
---
 libavcodec/movtextdec.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index c38c5edce6..05becaf64d 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -48,6 +48,8 @@
 #define TOP_CENTER  8
 #define TOP_RIGHT   9
 
+#define RGB_TO_BGR(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 
0xff))
+
 typedef struct {
 char *font;
 int fontsize;
@@ -448,10 +450,11 @@ static int mov_text_init(AVCodecContext *avctx) {
 MovTextContext *m = avctx->priv_data;
 ret = mov_text_tx3g(avctx, m);
 if (ret == 0) {
-return ff_ass_subtitle_header(avctx, m->d.font, m->d.fontsize, 
m->d.color,
-m->d.back_color, m->d.bold, m->d.italic,
-m->d.underline, ASS_DEFAULT_BORDERSTYLE,
-m->d.alignment);
+return ff_ass_subtitle_header(avctx, m->d.font, m->d.fontsize,
+RGB_TO_BGR(m->d.color),
+RGB_TO_BGR(m->d.back_color),
+m->d.bold, m->d.italic, m->d.underline,
+ASS_DEFAULT_BORDERSTYLE, m->d.alignment);
 } else
 return ff_ass_subtitle_header_default(avctx);
 }
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] movtext decode/encode improvements

2020-04-06 Thread John Stebbins
Patch series adds more complete decoding and encoding of color, alpha,
font size, font name, and style tags for movtext.  It also fixes a
number of bugs.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] libavformat/mov: restore use of mfra time as dts

2020-04-06 Thread John Stebbins
This was inadvertantly removed in 4a9d32baca
---
 libavformat/mov.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 16a40debc7..eee98fb69c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4813,6 +4813,11 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 pts = frag_stream_info->first_tfra_pts;
 av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
 ", using it for pts\n", pts);
+} else if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE &&
+c->use_mfra_for == FF_MOV_FLAG_MFRA_DTS) {
+dts = frag_stream_info->first_tfra_pts;
+av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
+", using it for dts\n", pts);
 } else if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE) {
 // FIXME: sidx earliest_presentation_time is *PTS*, s.b.
 // pts = frag_stream_info->sidx_pts;
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread phunkyfish
---
 libavformat/rtsp.c | 47 ++
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..0d0bc2be0d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
 URLContext* in = NULL;
 int payload_type;
 AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p;
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp, sizeof(sdp),
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
 av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
 avcodec_parameters_free();
 
 ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
@@ -2534,6 +2562,9 @@ static int rtp_read_header(AVFormatContext *s)
 s->pb = NULL;
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
 avcodec_parameters_free();
 if (in)
-- 
2.24.1 (Apple Git-126)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v7 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-06 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/pp_bnk.c | 271 +++
>  libavformat/version.h|   2 +-
>  5 files changed, 275 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/pp_bnk.c
> 
> diff --git a/Changelog b/Changelog
> index f1be5d674e..d0c62000d6 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -57,6 +57,7 @@ version :
>  - overlay_cuda filter
>  - switch from AvxSynth to AviSynth+ on Linux
>  - Cunning Developments ADPCM decoder
> +- Pro Pinball Series Soundbank demuxer
>  
>  
>  version 4.2:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 8fd0d43721..9df99133fa 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -428,6 +428,7 @@ OBJS-$(CONFIG_PCM_VIDC_DEMUXER)  += pcmdec.o pcm.o
>  OBJS-$(CONFIG_PCM_VIDC_MUXER)+= pcmenc.o rawenc.o
>  OBJS-$(CONFIG_PJS_DEMUXER)   += pjsdec.o subtitles.o
>  OBJS-$(CONFIG_PMP_DEMUXER)   += pmpdec.o
> +OBJS-$(CONFIG_PP_BNK_DEMUXER)+= pp_bnk.o
>  OBJS-$(CONFIG_PVA_DEMUXER)   += pva.o
>  OBJS-$(CONFIG_PVF_DEMUXER)   += pvfdec.o pcm.o
>  OBJS-$(CONFIG_QCP_DEMUXER)   += qcp.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 39d2c352f5..3919c9e4c1 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -341,6 +341,7 @@ extern AVInputFormat  ff_pcm_u8_demuxer;
>  extern AVOutputFormat ff_pcm_u8_muxer;
>  extern AVInputFormat  ff_pjs_demuxer;
>  extern AVInputFormat  ff_pmp_demuxer;
> +extern AVInputFormat  ff_pp_bnk_demuxer;
>  extern AVOutputFormat ff_psp_muxer;
>  extern AVInputFormat  ff_pva_demuxer;
>  extern AVInputFormat  ff_pvf_demuxer;
> diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c
> new file mode 100644
> index 00..fca0f75666
> --- /dev/null
> +++ b/libavformat/pp_bnk.c
> @@ -0,0 +1,271 @@
> +/*
> + * Pro Pinball Series Soundbank (44c, 22c, 11c, 5c) demuxer.
> + *
> + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +#include "avformat.h"
> +#include "internal.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/avassert.h"
> +#include "libavutil/internal.h"
> +
> +#define PP_BNK_MAX_READ_SIZE4096
> +#define PP_BNK_FILE_HEADER_SIZE 20
> +#define PP_BNK_TRACK_SIZE   20
> +
> +typedef struct PPBnkHeader {
> +uint32_tbank_id;/*< Bank ID, useless for our purposes. */
> +uint32_tsample_rate;/*< Sample rate of the contained tracks. 
> */
> +uint32_talways1;/*< Unknown, always seems to be 1. */
> +uint32_ttrack_count;/*< Number of tracks in the file. */
> +uint32_tflags;  /*< Flags. */
> +} PPBnkHeader;
> +
> +typedef struct PPBnkTrack {
> +uint32_tid; /*< Track ID. Usually track[i].id == 
> track[i-1].id + 1, but not always */
> +uint32_tsize;   /*< Size of the data in bytes. */
> +uint32_tsample_rate;/*< Sample rate. */
> +uint32_talways1_1;  /*< Unknown, always seems to be 1. */
> +uint32_talways1_2;  /*< Unknown, always seems to be 1. */
> +} PPBnkTrack;
> +
> +typedef struct PPBnkCtxTrack {
> +int64_t data_offset;
> +uint32_tdata_size;
> +} PPBnkCtxTrack;
> +
> +typedef struct PPBnkCtx {
> +int track_count;
> +PPBnkCtxTrack   *tracks;
> +uint32_tcurrent_track;
> +uint32_tbytes_read;
> +} PPBnkCtx;
> +
> +enum {
> +PP_BNK_FLAG_PERSIST = (1 << 0), /*< This is a large file, keep in 
> memory. */
> +PP_BNK_FLAG_MUSIC   = (1 << 1), /*< This is music. */
> +PP_BNK_FLAG_MASK= (PP_BNK_FLAG_PERSIST | PP_BNK_FLAG_MUSIC)
> +};
> +
> +static void pp_bnk_parse_header(PPBnkHeader *hdr, const uint8_t *buf)
> +{
> +hdr->bank_id= AV_RL32(buf +  0);
> +hdr->sample_rate= AV_RL32(buf +  4);
> +hdr->always1= AV_RL32(buf +  8);
> +hdr->track_count= AV_RL32(buf + 12);
> +  

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Carl Eugen Hoyos
Am Mo., 6. Apr. 2020 um 16:39 Uhr schrieb Nicolas George :
>
> Carl Eugen Hoyos (12020-04-06):
> > We have done that in the past (for output formats that are not
> > testing-only as xv).
>
> Xv is not testing only. OpenGL even less. This would be
> breaking actual features.

Is it possible to support both codecs?

> What formats are you thinking of? Even if we did, it is
> entirely possible we were wrong then.

Commit 64ceeac2 changed the only supported format for the
null muxer without any version bump.
(While this is a very important muxer for me, I agree that my
argumentation above is not completely compelling.)

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v7 0/2] Pro Pinball Series Soundbank demuxer + decoder.

2020-04-06 Thread Zane van Iperen
Adds support for the soundbank files used by the Pro Pinball series of games.

Please CC for review.

v7:
  - Fix empty lines
  - Use av_malloc_array() instead of av_reallocp_array()
  - Replace multiple av_freep()'s with a goto
  - Minor comment cleanups
  - Ask for a sample if unexpected header values are found

v6:
  - fix tools/probetest failure

v5:
  - add probe function
  - add flag #define's

v4:
  - fix adpcm index table type

v3:
  - fix potential memory leak if read_header() fails
  - fix a buffer overread
  - attempt seek before updating state
  - remove unneeded check
  - naming fixes

v2:
  - Add sanity checks in header fields
  - Formatting and comment fixes
  - Change the struct names to match the files

Zane van Iperen (2):
  avcodec: add support for Cunning Developments' ADPCM
  avformat: add demuxer for Pro Pinball Series' Soundbanks

 Changelog|   2 +
 doc/general.texi |   1 +
 libavcodec/Makefile  |   1 +
 libavcodec/adpcm.c   |  33 +
 libavcodec/adpcm_data.c  |  13 ++
 libavcodec/adpcm_data.h  |   2 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +
 libavcodec/version.h |   4 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/pp_bnk.c | 271 +++
 libavformat/version.h|   2 +-
 14 files changed, 337 insertions(+), 3 deletions(-)
 create mode 100644 libavformat/pp_bnk.c

-- 
2.17.1


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v7 1/2] avcodec: add support for Cunning Developments' ADPCM

2020-04-06 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog   |  1 +
 doc/general.texi|  1 +
 libavcodec/Makefile |  1 +
 libavcodec/adpcm.c  | 33 +
 libavcodec/adpcm_data.c | 13 +
 libavcodec/adpcm_data.h |  2 ++
 libavcodec/allcodecs.c  |  1 +
 libavcodec/avcodec.h|  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/version.h|  4 ++--
 10 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index e6db88af07..f1be5d674e 100644
--- a/Changelog
+++ b/Changelog
@@ -56,6 +56,7 @@ version :
 - CRI HCA demuxer
 - overlay_cuda filter
 - switch from AvxSynth to AviSynth+ on Linux
+- Cunning Developments ADPCM decoder
 
 
 version 4.2:
diff --git a/doc/general.texi b/doc/general.texi
index 4adcc9e742..4aaf506e56 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1102,6 +1102,7 @@ following image formats are supported:
 @item ADPCM G.726@tab  X  @tab  X
 @item ADPCM IMA AMV  @tab @tab  X
 @tab Used in AMV files
+@item ADPCM IMA Cunning Developments  @tab @tab  X
 @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
 @item ADPCM IMA Electronic Arts SEAD  @tab @tab  X
 @item ADPCM IMA Funcom   @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c1c9a44f2b..e799077f09 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -839,6 +839,7 @@ OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o 
adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER)  += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_IMA_CUNNING_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER)  += adpcm.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index e9abddc43c..89c4572538 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -16,6 +16,7 @@
  * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen 
(z...@zanevaniperen.com)
  * Ubisoft ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com)
  * High Voltage Software ALP decoder by Zane van Iperen 
(z...@zanevaniperen.com)
+ * Cunning Developments decoder by Zane van Iperen (z...@zanevaniperen.com)
  *
  * This file is part of FFmpeg.
  *
@@ -109,6 +110,9 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
 unsigned int max_channels = 2;
 
 switch(avctx->codec->id) {
+case AV_CODEC_ID_ADPCM_IMA_CUNNING:
+max_channels = 1;
+break;
 case AV_CODEC_ID_ADPCM_DTK:
 case AV_CODEC_ID_ADPCM_EA:
 min_channels = 2;
@@ -325,6 +329,26 @@ static inline int16_t 
adpcm_ima_mtf_expand_nibble(ADPCMChannelStatus *c, int nib
 return (int16_t)c->predictor;
 }
 
+static inline int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, 
int8_t nibble)
+{
+int step_index;
+int predictor;
+int step;
+
+nibble = sign_extend(nibble & 0xF, 4);
+
+step = ff_adpcm_ima_cunning_step_table[c->step_index];
+step_index = c->step_index + ff_adpcm_ima_cunning_index_table[abs(nibble)];
+step_index = av_clip(step_index, 0, 60);
+
+predictor = c->predictor + (step * nibble);
+
+c->predictor = av_clip_int16(predictor);
+c->step_index = step_index;
+
+return (int16_t)c->predictor;
+}
+
 static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, 
GetBitContext *gb, int bps)
 {
 int nibble, step_index, predictor, sign, delta, diff, step, shift;
@@ -713,6 +737,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 /* simple 4-bit adpcm */
 case AV_CODEC_ID_ADPCM_CT:
 case AV_CODEC_ID_ADPCM_IMA_APC:
+case AV_CODEC_ID_ADPCM_IMA_CUNNING:
 case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
 case AV_CODEC_ID_ADPCM_IMA_OKI:
 case AV_CODEC_ID_ADPCM_IMA_WS:
@@ -1304,6 +1329,13 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 samples += avctx->channels;
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_CUNNING:
+while (bytestream2_get_bytes_left() > 0) {
+int v = bytestream2_get_byteu();
+*samples++ = adpcm_ima_cunning_expand_nibble(>status[0], v & 
0x0F);
+*samples++ = adpcm_ima_cunning_expand_nibble(>status[0], v >> 
4);
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_OKI:
 while (bytestream2_get_bytes_left() > 0) {
 int v = bytestream2_get_byteu();
@@ -2053,6 +2085,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS,  
sample_fmts_s16p, adpcm_ea_xas,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16,  adpcm_ima_amv,  
   "ADPCM IMA AMV");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16,  adpcm_ima_apc,  
   "ADPCM IMA CRYO APC");
 

[FFmpeg-devel] [PATCH v7 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-06 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/pp_bnk.c | 271 +++
 libavformat/version.h|   2 +-
 5 files changed, 275 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/pp_bnk.c

diff --git a/Changelog b/Changelog
index f1be5d674e..d0c62000d6 100644
--- a/Changelog
+++ b/Changelog
@@ -57,6 +57,7 @@ version :
 - overlay_cuda filter
 - switch from AvxSynth to AviSynth+ on Linux
 - Cunning Developments ADPCM decoder
+- Pro Pinball Series Soundbank demuxer
 
 
 version 4.2:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8fd0d43721..9df99133fa 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -428,6 +428,7 @@ OBJS-$(CONFIG_PCM_VIDC_DEMUXER)  += pcmdec.o pcm.o
 OBJS-$(CONFIG_PCM_VIDC_MUXER)+= pcmenc.o rawenc.o
 OBJS-$(CONFIG_PJS_DEMUXER)   += pjsdec.o subtitles.o
 OBJS-$(CONFIG_PMP_DEMUXER)   += pmpdec.o
+OBJS-$(CONFIG_PP_BNK_DEMUXER)+= pp_bnk.o
 OBJS-$(CONFIG_PVA_DEMUXER)   += pva.o
 OBJS-$(CONFIG_PVF_DEMUXER)   += pvfdec.o pcm.o
 OBJS-$(CONFIG_QCP_DEMUXER)   += qcp.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 39d2c352f5..3919c9e4c1 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -341,6 +341,7 @@ extern AVInputFormat  ff_pcm_u8_demuxer;
 extern AVOutputFormat ff_pcm_u8_muxer;
 extern AVInputFormat  ff_pjs_demuxer;
 extern AVInputFormat  ff_pmp_demuxer;
+extern AVInputFormat  ff_pp_bnk_demuxer;
 extern AVOutputFormat ff_psp_muxer;
 extern AVInputFormat  ff_pva_demuxer;
 extern AVInputFormat  ff_pvf_demuxer;
diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c
new file mode 100644
index 00..fca0f75666
--- /dev/null
+++ b/libavformat/pp_bnk.c
@@ -0,0 +1,271 @@
+/*
+ * Pro Pinball Series Soundbank (44c, 22c, 11c, 5c) demuxer.
+ *
+ * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "avformat.h"
+#include "internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/avassert.h"
+#include "libavutil/internal.h"
+
+#define PP_BNK_MAX_READ_SIZE4096
+#define PP_BNK_FILE_HEADER_SIZE 20
+#define PP_BNK_TRACK_SIZE   20
+
+typedef struct PPBnkHeader {
+uint32_tbank_id;/*< Bank ID, useless for our purposes. */
+uint32_tsample_rate;/*< Sample rate of the contained tracks. */
+uint32_talways1;/*< Unknown, always seems to be 1. */
+uint32_ttrack_count;/*< Number of tracks in the file. */
+uint32_tflags;  /*< Flags. */
+} PPBnkHeader;
+
+typedef struct PPBnkTrack {
+uint32_tid; /*< Track ID. Usually track[i].id == 
track[i-1].id + 1, but not always */
+uint32_tsize;   /*< Size of the data in bytes. */
+uint32_tsample_rate;/*< Sample rate. */
+uint32_talways1_1;  /*< Unknown, always seems to be 1. */
+uint32_talways1_2;  /*< Unknown, always seems to be 1. */
+} PPBnkTrack;
+
+typedef struct PPBnkCtxTrack {
+int64_t data_offset;
+uint32_tdata_size;
+} PPBnkCtxTrack;
+
+typedef struct PPBnkCtx {
+int track_count;
+PPBnkCtxTrack   *tracks;
+uint32_tcurrent_track;
+uint32_tbytes_read;
+} PPBnkCtx;
+
+enum {
+PP_BNK_FLAG_PERSIST = (1 << 0), /*< This is a large file, keep in memory. 
*/
+PP_BNK_FLAG_MUSIC   = (1 << 1), /*< This is music. */
+PP_BNK_FLAG_MASK= (PP_BNK_FLAG_PERSIST | PP_BNK_FLAG_MUSIC)
+};
+
+static void pp_bnk_parse_header(PPBnkHeader *hdr, const uint8_t *buf)
+{
+hdr->bank_id= AV_RL32(buf +  0);
+hdr->sample_rate= AV_RL32(buf +  4);
+hdr->always1= AV_RL32(buf +  8);
+hdr->track_count= AV_RL32(buf + 12);
+hdr->flags  = AV_RL32(buf + 16);
+}
+
+static void pp_bnk_parse_track(PPBnkTrack *trk, const uint8_t *buf)
+{
+trk->id = AV_RL32(buf +  0);
+trk->size   = AV_RL32(buf +  4);
+trk->sample_rate= AV_RL32(buf +  8);
+

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Nicolas George
Carl Eugen Hoyos (12020-04-06):
> We have done that in the past (for output formats that are not
> testing-only as xv).

Xv is not testing only. OpenGL even less. This would be breaking actual
features. What formats are you thinking of? Even if we did, it is
entirely possible we were wrong then.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Carl Eugen Hoyos
Am Mo., 6. Apr. 2020 um 14:31 Uhr schrieb Nicolas George :
>
> Marton Balint (12020-04-06):
> > Signed-off-by: Marton Balint 
> > ---
> >  libavdevice/xv.c | 15 +--
> >  1 file changed, 5 insertions(+), 10 deletions(-)
>
> Thanks for working on this.
>
> Adding support for the more efficient API is a good idea.
>
> On the other hand, if applications use this device or a similar one
> specifically (I do in some of mine, I am certainly not alone), they
> would hardcode rawvideo. Therefore, we cannot remove support for
> rawvideo.

We have done that in the past (for output formats that are not
testing-only as xv).

A minor bump would be nice though.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec: add bink2 video decoder

2020-04-06 Thread Paul B Mahol
On 4/6/20, James Almer  wrote:
> On 4/6/2020 7:01 AM, Paul B Mahol wrote:
>> On 3/20/20, Paul B Mahol  wrote:
>>> Signed-off-by: Paul B Mahol 
>>> ---
>>>  configure   |1 +
>>>  libavcodec/Makefile |1 +
>>>  libavcodec/allcodecs.c  |1 +
>>>  libavcodec/avcodec.h|1 +
>>>  libavcodec/bink2.c  |  869 
>>>  libavcodec/bink2f.c | 1125 
>>>  libavcodec/bink2g.c | 1197 +++
>>>  libavcodec/codec_desc.c |7 +
>>>  libavformat/bink.c  |3 +-
>>>  9 files changed, 3203 insertions(+), 2 deletions(-)
>>>  create mode 100644 libavcodec/bink2.c
>>>  create mode 100644 libavcodec/bink2f.c
>>>  create mode 100644 libavcodec/bink2g.c
>>>
>>
>> Will apply soon!
>
> You need to first send an updated patch with the bug/leak fixes that
> people reported applied, so it can be confirmed they are ok.

I fixed all bugs. gonna apply ASAP!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec: add bink2 video decoder

2020-04-06 Thread James Almer
On 4/6/2020 7:01 AM, Paul B Mahol wrote:
> On 3/20/20, Paul B Mahol  wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  configure   |1 +
>>  libavcodec/Makefile |1 +
>>  libavcodec/allcodecs.c  |1 +
>>  libavcodec/avcodec.h|1 +
>>  libavcodec/bink2.c  |  869 
>>  libavcodec/bink2f.c | 1125 
>>  libavcodec/bink2g.c | 1197 +++
>>  libavcodec/codec_desc.c |7 +
>>  libavformat/bink.c  |3 +-
>>  9 files changed, 3203 insertions(+), 2 deletions(-)
>>  create mode 100644 libavcodec/bink2.c
>>  create mode 100644 libavcodec/bink2f.c
>>  create mode 100644 libavcodec/bink2g.c
>>
> 
> Will apply soon!

You need to first send an updated patch with the bug/leak fixes that
people reported applied, so it can be confirmed they are ok.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] mov: Support fake moov boxes disguised as hoov

2020-04-06 Thread Derek Buitenhuis
On 12/08/2019 20:37, Michael Niedermayer wrote:
> probably ok, but same oppinion as you, cleaner solution preferred if anyone
> has a cleaner one

We're seeing some more of these 'hoov' files show up as more apps misuse iOS
APIs, so since this seems to have been OK'd but never pushed, I'll go ahead
and push it tonight or tomorrow if nobody objects.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-06 Thread Paul B Mahol
On 4/6/20, Zane van Iperen  wrote:
> On Mon, 06 Apr 2020 15:00:01 +0200
> "Anton Khirnov"  wrote:
>
>> Quoting Zane van Iperen (2020-03-29 19:18:20)
>> > Signed-off-by: Zane van Iperen 
>> > +static int pp_bnk_read_header(AVFormatContext *s)
>> > +{
>> > +int ret;
>> > +AVStream *st;
>> > +AVCodecParameters *par;
>> > +PPBnkCtx *ctx = s->priv_data;
>> > +uint8_t buf[FFMAX(PP_BNK_FILE_HEADER_SIZE, PP_BNK_TRACK_SIZE)];
>> > +PPBnkHeader hdr;
>> > +
>> > +if ((ret = avio_read(s->pb, buf, PP_BNK_FILE_HEADER_SIZE)) < 0)
>> > +return ret;
>> > +else if (ret != PP_BNK_FILE_HEADER_SIZE)
>> > +return AVERROR(EIO);
>> > +
>> > +pp_bnk_parse_header(, buf);
>> > +
>> > +if (hdr.track_count == 0 || hdr.track_count > INT_MAX)
>> > +return AVERROR_INVALIDDATA;
>> > +
>> > +if (hdr.sample_rate == 0 || hdr.sample_rate > INT_MAX)
>> > +return AVERROR_INVALIDDATA;
>> > +
>> > +if (hdr.always1 != 1) {
>> > +avpriv_request_sample(s, "Non-one header value");
>> > +return AVERROR_PATCHWELCOME;
>> > +}
>> > +
>> > +ctx->track_count = hdr.track_count;
>> > +if ((ret = av_reallocp_array(>tracks, hdr.track_count,
>> > sizeof(PPBnkCtxTrack
>>
>> Why realloc? Seems this is only allocated once.
>
> Good question. Fixed.
>
>
>> > +return ret;
>> > +
>> > +/* Parse and validate each track. */
>> > +for (int i = 0; i < hdr.track_count; i++) {
>> > +PPBnkTrack e;
>> > +
>> > +if ((ret = avio_read(s->pb, buf, PP_BNK_TRACK_SIZE)) < 0) {
>> > +av_freep(>tracks);
>>
>> You are duplicating this free at too many places. Would be better to
>> have a cleanup block at the end and jump to that.
>>
>
> I did that originally, however it's at the awkward spot where doing
> that causes the code to be larger than the way it is currently.
>
> I'll change it.
>
>> > +return ret;
>> > +} else if (ret != PP_BNK_TRACK_SIZE) {
>> > +av_freep(>tracks);
>> > +return AVERROR(EIO);
>> > +}
>> > +
>> > +pp_bnk_parse_track(, buf);
>> > +
>> > +/* The individual sample rates of all tracks must match
>> > that of the file header. */
>> > +if (e.sample_rate != hdr.sample_rate) {
>> > +av_freep(>tracks);
>> > +return AVERROR_INVALIDDATA;
>> > +}
>> > +
>> > +ctx->tracks[i].data_offset = avio_tell(s->pb);
>> > +ctx->tracks[i].data_size   = e.size;
>> > +
>> > +/* Skip over the data to the next stream header. */
>> > +avio_skip(s->pb, e.size);
>> > +}
>> > +
>> > +/* Build the streams. */
>> > +for (int i = 0; i < hdr.track_count; i++) {
>> > +
>>
>> nit: unnecessary empty line
>>
>
> Nit picked.
>
>> > +if (!(st = avformat_new_stream(s, NULL))) {
>> > +av_freep(>tracks);
>> > +return AVERROR(ENOMEM);
>> > +}
>> > +
>> > +par = st->codecpar;
>> > +par->codec_type = AVMEDIA_TYPE_AUDIO;
>> > +par->codec_id   =
>> > AV_CODEC_ID_ADPCM_IMA_CUNNING;
>> > +par->format = AV_SAMPLE_FMT_S16;
>> > +par->channel_layout = AV_CH_LAYOUT_MONO;
>> > +par->channels   = 1;
>> > +par->sample_rate= hdr.sample_rate;
>> > +par->bits_per_coded_sample  = 4;
>> > +par->bits_per_raw_sample= 16;
>> > +par->block_align= 1;
>> > +par->bit_rate   = par->sample_rate *
>> > par->bits_per_coded_sample; +
>> > +avpriv_set_pts_info(st, 64, 1, par->sample_rate);
>> > +st->start_time  = 0;
>> > +st->duration= ctx->tracks[i].data_size * 2;
>> > +}
>> > +
>> > +/* Seek to the start of the first stream. */
>> > +if ((ret = avio_seek(s->pb, ctx->tracks[0].data_offset,
>> > SEEK_SET)) < 0) {
>> > +av_freep(>tracks);
>> > +return ret;
>> > +} else if (ret != ctx->tracks[0].data_offset) {
>> > +av_freep(>tracks);
>> > +return AVERROR(EIO);
>> > +}
>> > +
>> > +return 0;
>> > +}
>> > +
>> > +static int pp_bnk_read_packet(AVFormatContext *s, AVPacket *pkt)
>> > +{
>> > +int64_t ret;
>> > +int size;
>> > +PPBnkCtx *ctx = s->priv_data;
>> > +PPBnkCtxTrack *trk = ctx->tracks + ctx->current_track;
>> > +
>> > +av_assert0(ctx->bytes_read <= trk->data_size);
>> > +
>> > +if (ctx->bytes_read == trk->data_size) {
>> > +
>>
>> nit: unnecessary empty line
>
> Fixed.
>
>>
>> Otherwise looks ok, but would be nice to have some tests.
>>
>
> I have tests ready, the plan was to send them if merged (and after
> samples are uploaded) to avoid https://patchwork.ffmpeg.org/ failures.
>
> Should I include them in this irregardless?

No, Never in same patch.

>
> Zane
>
>> --
>> Anton Khirnov
>> ___
>> ffmpeg-devel 

Re: [FFmpeg-devel] [PATCH v3] avutil/frame: Use av_realloc_array()

2020-04-06 Thread Limin Wang

ping.

On Thu, Dec 26, 2019 at 08:33:38AM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavutil/frame.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index e403809..2e763ef 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -696,11 +696,8 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame 
> *frame,
>  if (!buf)
>  return NULL;
>  
> -if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
> -return NULL;
> -
> -tmp = av_realloc(frame->side_data,
> - (frame->nb_side_data + 1) * sizeof(*frame->side_data));
> +tmp = av_realloc_array(frame->side_data,
> + frame->nb_side_data + 1, sizeof(*frame->side_data));
>  if (!tmp)
>  return NULL;
>  frame->side_data = tmp;
> -- 
> 2.9.5
> 

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH]lavfi/telecine: Mark telecined frames as interlaced

2020-04-06 Thread Carl Eugen Hoyos
Am So., 5. Apr. 2020 um 02:05 Uhr schrieb Carl Eugen Hoyos :
>
> Am So., 5. Apr. 2020 um 01:02 Uhr schrieb Carl Eugen Hoyos 
> :
> >
> > Am Sa., 4. Apr. 2020 um 00:44 Uhr schrieb Carl Eugen Hoyos 
> > :
> > >
> > > Am Sa., 4. Apr. 2020 um 00:40 Uhr schrieb James Almer :
> > > >
> > > > On 4/3/2020 6:37 PM, Carl Eugen Hoyos wrote:
> > > > > Am Fr., 3. Apr. 2020 um 23:19 Uhr schrieb Carl Eugen Hoyos 
> > > > > :
> > > > >
> > > > >> Attached patch marks actually telecined frames as interlaced,
> > > > >> other frames as progressive.
> > > > >
> > > > > New patch with changes to fate attached.
> > > > >
> > > > > Please comment, Carl Eugen
> > > >
> > > > Those yadif tests look wrong. The patch shouldn't affect them.
> > >
> > > Clearly, thank you!
> > >
> > > New patch attached, it should now only change the telecined
> > > frames and leave the other frames as they are, the setfield
> > > filter can be used to force a progressive setting for them.
> >
> > New patch attached that also sets top_field_first
>
> Which had the effect that fate is correct again, new patch attached.
>
> Please comment, Carl Eugen

Ping.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH]lavc/amrwb: Output silence for frames marked as broken

2020-04-06 Thread Carl Eugen Hoyos
Am Mo., 6. Apr. 2020 um 10:42 Uhr schrieb Anton Khirnov :
>
> Quoting Carl Eugen Hoyos (2020-04-05 17:37:15)
> > Am So., 5. Apr. 2020 um 02:01 Uhr schrieb Carl Eugen Hoyos 
> > :
> >
> > > Attached patch makes the output of the file in ticket #7113 very
> > > similar to the reference decoder.
> >
> > New patch attached.
>
> You could say how is this patch different and why.

The source file has changed, the original patch did not
apply anymore.

> It seems that handling ctx->fr_cur_mode > MODE_SID
> is now gone for no obvious reason.

The condition is dead code in current FFmpeg, if the
condition is moved, two error messages are shown for
every invalid (but not corrupt) frame isntead of one
which seems unneeded (but not worth mentioning)
to me.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-06 Thread Zane van Iperen
On Mon, 06 Apr 2020 15:00:01 +0200
"Anton Khirnov"  wrote:

> Quoting Zane van Iperen (2020-03-29 19:18:20)
> > Signed-off-by: Zane van Iperen 
> > +static int pp_bnk_read_header(AVFormatContext *s)
> > +{
> > +int ret;
> > +AVStream *st;
> > +AVCodecParameters *par;
> > +PPBnkCtx *ctx = s->priv_data;
> > +uint8_t buf[FFMAX(PP_BNK_FILE_HEADER_SIZE, PP_BNK_TRACK_SIZE)];
> > +PPBnkHeader hdr;
> > +
> > +if ((ret = avio_read(s->pb, buf, PP_BNK_FILE_HEADER_SIZE)) < 0)
> > +return ret;
> > +else if (ret != PP_BNK_FILE_HEADER_SIZE)
> > +return AVERROR(EIO);
> > +
> > +pp_bnk_parse_header(, buf);
> > +
> > +if (hdr.track_count == 0 || hdr.track_count > INT_MAX)
> > +return AVERROR_INVALIDDATA;
> > +
> > +if (hdr.sample_rate == 0 || hdr.sample_rate > INT_MAX)
> > +return AVERROR_INVALIDDATA;
> > +
> > +if (hdr.always1 != 1) {
> > +avpriv_request_sample(s, "Non-one header value");
> > +return AVERROR_PATCHWELCOME;
> > +}
> > +
> > +ctx->track_count = hdr.track_count;
> > +if ((ret = av_reallocp_array(>tracks, hdr.track_count,
> > sizeof(PPBnkCtxTrack  
> 
> Why realloc? Seems this is only allocated once.

Good question. Fixed.


> > +return ret;
> > +
> > +/* Parse and validate each track. */
> > +for (int i = 0; i < hdr.track_count; i++) {
> > +PPBnkTrack e;
> > +
> > +if ((ret = avio_read(s->pb, buf, PP_BNK_TRACK_SIZE)) < 0) {
> > +av_freep(>tracks);  
> 
> You are duplicating this free at too many places. Would be better to
> have a cleanup block at the end and jump to that.
> 

I did that originally, however it's at the awkward spot where doing
that causes the code to be larger than the way it is currently.

I'll change it.

> > +return ret;
> > +} else if (ret != PP_BNK_TRACK_SIZE) {
> > +av_freep(>tracks);
> > +return AVERROR(EIO);
> > +}
> > +
> > +pp_bnk_parse_track(, buf);
> > +
> > +/* The individual sample rates of all tracks must match
> > that of the file header. */
> > +if (e.sample_rate != hdr.sample_rate) {
> > +av_freep(>tracks);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +ctx->tracks[i].data_offset = avio_tell(s->pb);
> > +ctx->tracks[i].data_size   = e.size;
> > +
> > +/* Skip over the data to the next stream header. */
> > +avio_skip(s->pb, e.size);
> > +}
> > +
> > +/* Build the streams. */
> > +for (int i = 0; i < hdr.track_count; i++) {
> > +  
> 
> nit: unnecessary empty line
> 

Nit picked.

> > +if (!(st = avformat_new_stream(s, NULL))) {
> > +av_freep(>tracks);
> > +return AVERROR(ENOMEM);
> > +}
> > +
> > +par = st->codecpar;
> > +par->codec_type = AVMEDIA_TYPE_AUDIO;
> > +par->codec_id   =
> > AV_CODEC_ID_ADPCM_IMA_CUNNING;
> > +par->format = AV_SAMPLE_FMT_S16;
> > +par->channel_layout = AV_CH_LAYOUT_MONO;
> > +par->channels   = 1;
> > +par->sample_rate= hdr.sample_rate;
> > +par->bits_per_coded_sample  = 4;
> > +par->bits_per_raw_sample= 16;
> > +par->block_align= 1;
> > +par->bit_rate   = par->sample_rate *
> > par->bits_per_coded_sample; +
> > +avpriv_set_pts_info(st, 64, 1, par->sample_rate);
> > +st->start_time  = 0;
> > +st->duration= ctx->tracks[i].data_size * 2;
> > +}
> > +
> > +/* Seek to the start of the first stream. */
> > +if ((ret = avio_seek(s->pb, ctx->tracks[0].data_offset,
> > SEEK_SET)) < 0) {
> > +av_freep(>tracks);
> > +return ret;
> > +} else if (ret != ctx->tracks[0].data_offset) {
> > +av_freep(>tracks);
> > +return AVERROR(EIO);
> > +}
> > +
> > +return 0;
> > +}
> > +
> > +static int pp_bnk_read_packet(AVFormatContext *s, AVPacket *pkt)
> > +{
> > +int64_t ret;
> > +int size;
> > +PPBnkCtx *ctx = s->priv_data;
> > +PPBnkCtxTrack *trk = ctx->tracks + ctx->current_track;
> > +
> > +av_assert0(ctx->bytes_read <= trk->data_size);
> > +
> > +if (ctx->bytes_read == trk->data_size) {
> > +  
> 
> nit: unnecessary empty line

Fixed.

> 
> Otherwise looks ok, but would be nice to have some tests.
> 

I have tests ready, the plan was to send them if merged (and after
samples are uploaded) to avoid https://patchwork.ffmpeg.org/ failures.

Should I include them in this irregardless?

Zane

> --
> Anton Khirnov
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v6 0/2] Pro Pinball Series Soundbank demuxer + decoder.

2020-04-06 Thread Zane van Iperen
On Mon, 6 Apr 2020 15:03:50 +0200
"Andreas Rheinhardt"  wrote:

> >
> > I have a few minor changes but they're just slight comment changes,
> > which aren't worth sending as a v7. I can send them as a separate
> > patch afterwards.
> >  
> This is not good as this separate patch would essentially just be
> avoidable noise. So please send an updated version.
> 

Okay, will do.

Zane

> - Andreas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avformat/oggparsevorbis: Update context on double init

2020-04-06 Thread Michael Niedermayer
On Mon, Apr 06, 2020 at 12:00:21PM +0200, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2020-04-05 00:38:41)
> > Fixes: memleak
> 
> Memleak of what/where/why? This is highly non-obvious.

yes, i tend to be terse on "security" fixes so as not to provide a
"how to exploit" 

what leaks is the AVVorbisParseContext it leaks as there is no check for it
being already allocated.
I attempted to add such a check but that was rejected by paul with no further
comment. 
See: 0113 10:59 To FFmpeg devel (1,4K) [FFmpeg-devel] [PATCH] 
avformat/oggparsevorbis: Error out on double init of vp

This patch works around that by preventing the demuxer allocated extradata
from being replaced by the NULL extradata from the decoder
As there is a check for double allocating the extradata that will protect
also from AVVorbisParseContext double allocation 

that said, the whole back and forth copying of parameters we have in 
libavformat now a days is not pretty and every time i look at it it
feels fragile. Iam a bit surprised this doesnt cause more problems

There are of course other ways to fix this, i did tend towards a
simple (hopefully) easy to backport fix

What do you prefer ?

Thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 12/20] avformat/matroskaenc: Improve Cues in case of no video

2020-04-06 Thread Andreas Rheinhardt
Jan Chren (rindeal):
> On Sun, 5 Apr 2020 at 16:01, Andreas Rheinhardt
>  wrote:
>>
>> The Matroska muxer currently only adds CuePoints in three cases:
>> a) For video keyframes. b) For the first audio frame in a new Cluster if
>> in DASH-mode. c) For subtitles. This means that ordinary Matroska audio
>> files won't have any Cues which impedes seeking.
>>
>> This commit changes this. For every track in a file without video track
>> it is checked and tracked whether a Cue entry has already been added
>> for said track for the current Cluster. This is used to add a Cue entry
>> for each first packet of each track in each Cluster.
>>
>> Implements #3149.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
> 
> Fixed at last, danke schön! This was a very annoying bug.
> 
> One thing I noticed is, however, that the spec recommends "CuePoint
> Elements SHOULD reference audio keyframes at most once every 500
> milliseconds" [1], but this is not checked currently.
> 
> [1]: https://cellar-wg.github.io/matroska-specification/cues.html

I actually pondered whether I should opt for a time-based approach (like
mkvmerge with its 2s) or for the approach that I implemented here. I
chose the latter because with the former one has to perform two seeks
when seeking (when one makes use of the CueRelativePosition element) or
one has to parse a potentially nonnegligible amount of data from the
Cluster. It is the same reason one nowadays starts new Clusters upon
seeing a video keyframe.

That being said it is very hard to break this limit when using the
default values for cluster_size_limit (5 MiB) and cluster_time_limit.
You'd need to have 80 Mib/s to do that and that would be very uncommon
for non-videoo (even for short spikes).

And if the user uses non-default values, then it is because the user
explicitly wants to have smaller Clusters and such a user probably wants
to have more Cue entries. I don't see a reason why an arbitrary value
from the spec should override this (mkvmerge btw also allows to create
files that violate this recommendation if the user opts to add Cue
entries for every frame). I think it should rather be the recommendation
from the spec that should be adapted.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 0/2] Pro Pinball Series Soundbank demuxer + decoder.

2020-04-06 Thread Andreas Rheinhardt
Zane van Iperen:
> On Sun, 29 Mar 2020 17:18:08 +
> "Zane van Iperen"  wrote:
> 
>> Adds support for the soundbank files used by the Pro Pinball series
>> of games.
>>
>> Please CC for review.
>>
>> v6:
>>   - fix tools/probetest failure
>>
>> v5:
>>   - add probe function
>>   - add flag #define's
>>
>> v4:
>>   - fix adpcm index table type
>>
>> v3:
>>   - fix potential memory leak if read_header() fails
>>   - fix a buffer overread
>>   - attempt seek before updating state
>>   - remove unneeded check
>>   - naming fixes
>>
>> v2:
>>   - Add sanity checks in header fields
>>   - Formatting and comment fixes
>>   - Change the struct names to match the files
>>
>> Zane van Iperen (2):
>>   avcodec: add support for Cunning Developments' ADPCM
>>   avformat: add demuxer for Pro Pinball Series' Soundbanks
>>
>>  Changelog|   2 +
>>  doc/general.texi |   1 +
>>  libavcodec/Makefile  |   1 +
>>  libavcodec/adpcm.c   |  33 +
>>  libavcodec/adpcm_data.c  |  13 ++
>>  libavcodec/adpcm_data.h  |   2 +
>>  libavcodec/allcodecs.c   |   1 +
>>  libavcodec/avcodec.h |   1 +
>>  libavcodec/codec_desc.c  |   7 ++
>>  libavcodec/version.h |   4 +-
>>  libavformat/Makefile |   1 +
>>  libavformat/allformats.c |   1 +
>>  libavformat/pp_bnk.c | 263
>> +++ libavformat/version.h|
>> 2 +- 14 files changed, 329 insertions(+), 3 deletions(-)
>>  create mode 100644 libavformat/pp_bnk.c
>>
>> --
>> 2.17.1
>>
> 
> Hi all,
> 
> Could I please have some reviews on this?
> 
> If everything's good I have FATE tests and samples ready, which I will
> send upon merge.
> 
> I have a few minor changes but they're just slight comment changes,
> which aren't worth sending as a v7. I can send them as a separate patch
> afterwards.
> 
This is not good as this separate patch would essentially just be
avoidable noise. So please send an updated version.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v6 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-06 Thread Anton Khirnov
Quoting Zane van Iperen (2020-03-29 19:18:20)
> Signed-off-by: Zane van Iperen 
> +static int pp_bnk_read_header(AVFormatContext *s)
> +{
> +int ret;
> +AVStream *st;
> +AVCodecParameters *par;
> +PPBnkCtx *ctx = s->priv_data;
> +uint8_t buf[FFMAX(PP_BNK_FILE_HEADER_SIZE, PP_BNK_TRACK_SIZE)];
> +PPBnkHeader hdr;
> +
> +if ((ret = avio_read(s->pb, buf, PP_BNK_FILE_HEADER_SIZE)) < 0)
> +return ret;
> +else if (ret != PP_BNK_FILE_HEADER_SIZE)
> +return AVERROR(EIO);
> +
> +pp_bnk_parse_header(, buf);
> +
> +if (hdr.track_count == 0 || hdr.track_count > INT_MAX)
> +return AVERROR_INVALIDDATA;
> +
> +if (hdr.sample_rate == 0 || hdr.sample_rate > INT_MAX)
> +return AVERROR_INVALIDDATA;
> +
> +if (hdr.always1 != 1) {
> +avpriv_request_sample(s, "Non-one header value");
> +return AVERROR_PATCHWELCOME;
> +}
> +
> +ctx->track_count = hdr.track_count;
> +if ((ret = av_reallocp_array(>tracks, hdr.track_count, 
> sizeof(PPBnkCtxTrack

Why realloc? Seems this is only allocated once.
> +return ret;
> +
> +/* Parse and validate each track. */
> +for (int i = 0; i < hdr.track_count; i++) {
> +PPBnkTrack e;
> +
> +if ((ret = avio_read(s->pb, buf, PP_BNK_TRACK_SIZE)) < 0) {
> +av_freep(>tracks);

You are duplicating this free at too many places. Would be better to
have a cleanup block at the end and jump to that.

> +return ret;
> +} else if (ret != PP_BNK_TRACK_SIZE) {
> +av_freep(>tracks);
> +return AVERROR(EIO);
> +}
> +
> +pp_bnk_parse_track(, buf);
> +
> +/* The individual sample rates of all tracks must match that of the 
> file header. */
> +if (e.sample_rate != hdr.sample_rate) {
> +av_freep(>tracks);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +ctx->tracks[i].data_offset = avio_tell(s->pb);
> +ctx->tracks[i].data_size   = e.size;
> +
> +/* Skip over the data to the next stream header. */
> +avio_skip(s->pb, e.size);
> +}
> +
> +/* Build the streams. */
> +for (int i = 0; i < hdr.track_count; i++) {
> +

nit: unnecessary empty line

> +if (!(st = avformat_new_stream(s, NULL))) {
> +av_freep(>tracks);
> +return AVERROR(ENOMEM);
> +}
> +
> +par = st->codecpar;
> +par->codec_type = AVMEDIA_TYPE_AUDIO;
> +par->codec_id   = AV_CODEC_ID_ADPCM_IMA_CUNNING;
> +par->format = AV_SAMPLE_FMT_S16;
> +par->channel_layout = AV_CH_LAYOUT_MONO;
> +par->channels   = 1;
> +par->sample_rate= hdr.sample_rate;
> +par->bits_per_coded_sample  = 4;
> +par->bits_per_raw_sample= 16;
> +par->block_align= 1;
> +par->bit_rate   = par->sample_rate * 
> par->bits_per_coded_sample;
> +
> +avpriv_set_pts_info(st, 64, 1, par->sample_rate);
> +st->start_time  = 0;
> +st->duration= ctx->tracks[i].data_size * 2;
> +}
> +
> +/* Seek to the start of the first stream. */
> +if ((ret = avio_seek(s->pb, ctx->tracks[0].data_offset, SEEK_SET)) < 0) {
> +av_freep(>tracks);
> +return ret;
> +} else if (ret != ctx->tracks[0].data_offset) {
> +av_freep(>tracks);
> +return AVERROR(EIO);
> +}
> +
> +return 0;
> +}
> +
> +static int pp_bnk_read_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +int64_t ret;
> +int size;
> +PPBnkCtx *ctx = s->priv_data;
> +PPBnkCtxTrack *trk = ctx->tracks + ctx->current_track;
> +
> +av_assert0(ctx->bytes_read <= trk->data_size);
> +
> +if (ctx->bytes_read == trk->data_size) {
> +

nit: unnecessary empty line

Otherwise looks ok, but would be nice to have some tests.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/3] avformat: deprecate muxing uncoded frames

2020-04-06 Thread Nicolas George
Marton Balint (12020-04-06):
> The same goal can be achieved using the WRAPPED_AVFRAME codec with the 
> existing
> API.

These two APIs are somewhat redundant, but we need to discuss which one
we want to keep.

WRAPPED_AVFRAME is nice because it goes through the normal code path,
and therefore requires no exception. But on the other hand, it requires
many allocations and de-allocations, which is not good since the purpose
of these API was to be more efficient: if the application has a frame,
which is the most likely, it's more efficient to just pass it. And it's
also simpler for the application, less code, less bugs, less
maintenance.

My opinion: merge the two features, keep the simpler code when the two
overlap:

- Keep the WRAPPED_AVFRAME codec and its encoder/decoder pair, for when
  generic code expects an AVPacket.

- For muxers implementations, keep the write_uncoded_frame callback,
  it's simpler. If a packet with WRAPPED_AVFRAME arrives, have the
  framework de-wrap the frame and call write_uncoded_frame.

- Let applications give uncoded unwrapped frames directly. It's simpler,
  it's more efficient, it's more type-safe.

- Possibly later, introduce the symmetric read_uncoded_frame callback.

> 
> Signed-off-by: Marton Balint 
> ---
>  doc/APIchanges   |  4 

>  libavdevice/alsa_enc.c   |  4 

Any way, I don't think we should deprecate something when we have not
yet moved our code to its replacement. You can count on me for porting
ALSA, when we have decided in which direction we go.

>  libavdevice/opengl_enc.c |  4 
>  libavdevice/pulse_audio_enc.c|  4 
>  libavdevice/version.h|  4 ++--
>  libavdevice/xv.c |  4 
>  libavformat/avformat.h   |  7 +++
>  libavformat/internal.h   |  2 ++
>  libavformat/mux.c| 16 
>  libavformat/uncodedframecrcenc.c |  6 ++
>  libavformat/version.h|  6 +-
>  11 files changed, 58 insertions(+), 3 deletions(-)

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avdevice/opengl: change codec to wrapped avframe

2020-04-06 Thread Nicolas George
Marton Balint (12020-04-06):
> Signed-off-by: Marton Balint 
> ---
>  libavdevice/opengl_enc.c | 54 
> +---
>  1 file changed, 10 insertions(+), 44 deletions(-)

Same remark as for xv: adding support for the more efficient API is
useful; removing support for rawvideo is an API break.

> 
> diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c
> index ae03caa8c5..b8bc46ebb5 100644
> --- a/libavdevice/opengl_enc.c
> +++ b/libavdevice/opengl_enc.c
> @@ -277,7 +277,7 @@ static const struct OpenGLFormatDesc {
>  };
>  
>  static av_cold int opengl_prepare_vertex(AVFormatContext *s);
> -static int opengl_draw(AVFormatContext *h, void *intput, int repaint, int 
> is_pkt);
> +static int opengl_draw(AVFormatContext *h, void *intput, int repaint);
>  static av_cold int opengl_init_context(OpenGLContext *opengl);
>  
>  static av_cold void opengl_deinit_context(OpenGLContext *opengl)
> @@ -320,7 +320,7 @@ static int opengl_resize(AVFormatContext *h, int width, 
> int height)
>  }
>  if ((ret = opengl_prepare_vertex(h)) < 0)
>  goto end;
> -ret = opengl_draw(h, NULL, 1, 0);
> +ret = opengl_draw(h, NULL, 1);
>  }
>end:
>  return ret;
> @@ -1060,8 +1060,8 @@ static av_cold int opengl_write_header(AVFormatContext 
> *h)
>  
>  if (h->nb_streams != 1 ||
>  h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
> -h->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
> -av_log(opengl, AV_LOG_ERROR, "Only a single video stream is 
> supported.\n");
> +h->streams[0]->codecpar->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) {
> +av_log(opengl, AV_LOG_ERROR, "Only a single wrapped avframe stream 
> is supported.\n");
>  return AVERROR(EINVAL);
>  }
>  st = h->streams[0];
> @@ -1124,35 +1124,6 @@ static av_cold int opengl_write_header(AVFormatContext 
> *h)
>  return ret;
>  }
>  

> -static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket 
> *pkt, int comp_index,
> - const AVPixFmtDescriptor *desc)
> -{
> -uint8_t *data = pkt->data;
> -int wordsize = opengl_type_size(opengl->type);
> -int width_chroma = AV_CEIL_RSHIFT(opengl->width, desc->log2_chroma_w);
> -int height_chroma = AV_CEIL_RSHIFT(opengl->height, desc->log2_chroma_h);
> -int plane = desc->comp[comp_index].plane;
> -
> -switch(plane) {
> -case 0:
> -break;
> -case 1:
> -data += opengl->width * opengl->height * wordsize;
> -break;
> -case 2:
> -data += opengl->width * opengl->height * wordsize;
> -data += width_chroma * height_chroma * wordsize;
> -break;
> -case 3:
> -data += opengl->width * opengl->height * wordsize;
> -data += 2 * width_chroma * height_chroma * wordsize;
> -break;
> -default:
> -return NULL;
> -}
> -return data;
> -}

This could probably be replaced with av_image_fill_pointers(). But it is
unrelated.

> -
>  #define LOAD_TEXTURE_DATA(comp_index, sub)   
>\
>  {
>\
>  int width = sub ? AV_CEIL_RSHIFT(opengl->width, desc->log2_chroma_w) : 
> opengl->width;   \
> @@ -1161,7 +1132,7 @@ static uint8_t* opengl_get_plane_pointer(OpenGLContext 
> *opengl, AVPacket *pkt, i
>  int plane = desc->comp[comp_index].plane;
>\
>   
>\
>  glBindTexture(GL_TEXTURE_2D, opengl->texture_name[comp_index]);  
>\
> -if (!is_pkt) {   
>\
> +{
>\
>  GLint length = ((AVFrame *)input)->linesize[plane];  
>\
>  int bytes_per_pixel = opengl_type_size(opengl->type);
>\
>  if (!(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) 
>\
> @@ -1184,14 +1155,10 @@ static uint8_t* 
> opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, i
>  data += length;  
>\
>  }
>\
>  }
>\
> -} else { 
>\
> -data = opengl_get_plane_pointer(opengl, input, comp_index, desc);
>\
> -glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,   
>

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe

2020-04-06 Thread Nicolas George
Marton Balint (12020-04-06):
> Signed-off-by: Marton Balint 
> ---
>  libavdevice/xv.c | 15 +--
>  1 file changed, 5 insertions(+), 10 deletions(-)

Thanks for working on this.

Adding support for the more efficient API is a good idea.

On the other hand, if applications use this device or a similar one
specifically (I do in some of mine, I am certainly not alone), they
would hardcode rawvideo. Therefore, we cannot remove support for
rawvideo.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v13] libavcodec/jpeg2000dec.c: Add support for PPT marker

2020-04-06 Thread Michael Niedermayer
On Mon, Apr 06, 2020 at 09:23:26AM +0530, Gautam Ramakrishnan wrote:
> On Mon, Apr 6, 2020 at 1:16 AM Michael Niedermayer
>  wrote:
> >
> > On Sun, Apr 05, 2020 at 04:13:28PM +0530, gautamr...@gmail.com wrote:
> > > From: Gautam Ramakrishnan 
> > >
> > > This patch adds functional changes to support the
> > > PPT marker. This patch fixes bug ticket #4610.
> > > ---
> > >  libavcodec/jpeg2000dec.c | 88 +++-
> > >  1 file changed, 77 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> > > index 732d88e6fc..2af3c61c37 100644
> > > --- a/libavcodec/jpeg2000dec.c
> > > +++ b/libavcodec/jpeg2000dec.c
> > > @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile {
> > >  Jpeg2000QuantStyle  qntsty[4];
> > >  Jpeg2000POC poc;
> > >  Jpeg2000TileParttile_part[32];
> > > +uint8_t has_ppt;// whether this tile has 
> > > a ppt marker
> > > +uint8_t *packed_headers;// contains packed 
> > > headers. Used only along with PPT marker
> > > +int packed_headers_size;// size in bytes of the 
> > > packed headers
> > > +GetByteContext  packed_headers_stream;  // byte context 
> > > corresponding to packed headers
> > >  uint16_t tp_idx;// Tile-part index
> > >  int coord[2][2];// border coordinates {{x0, x1}, 
> > > {y0, y1}}
> > >  } Jpeg2000Tile;
> > > @@ -855,6 +859,37 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
> > >  return 0;
> > >  }
> > >
> > > +static int get_ppt(Jpeg2000DecoderContext *s, int n)
> > > +{
> > > +Jpeg2000Tile *tile;
> > > +
> > > +if (s->curtileno < 0)
> > > +return AVERROR_INVALIDDATA;
> > > +
> > > +tile = >tile[s->curtileno];
> > > +if (tile->tp_idx != 0) {
> > > +av_log(s->avctx, AV_LOG_ERROR,
> > > +   "PPT marker can occur only on first tile part of a 
> > > tile.\n");
> > > +return AVERROR_INVALIDDATA;
> > > +}
> > > +
> > > +tile->has_ppt = 1;  // this tile has a ppt marker
> > > +bytestream2_get_byte(>g); // Zppt is skipped and not used
> >
> >
> > > +if (!tile->packed_headers)
> > > +tile->packed_headers = av_malloc(n - 3);
> > > +else
> > > +tile->packed_headers = av_realloc(tile->packed_headers,
> > > +  tile->packed_headers_size + n 
> > > - 3);
> >
> > why is the special case with av_malloc() needed ?
> >
> The if else is to check whether this is the first time this tile is being
> allocated its packed headers. If packed headers does not exist
> exist, create it. The else condition is just to add a new packed
> header to it.

what is the problem with

av_realloc(tile->packed_headers,  tile->packed_headers_size + n - 3);
when tile->packed_headers is NULL and tile->packed_headers_size is 0 for the
first allocation ?


thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/4] decode: make sure ff_get_buffer() cleans the frame on failure

2020-04-06 Thread Michael Niedermayer
On Sun, Apr 05, 2020 at 10:32:39PM +0200, Anton Khirnov wrote:
> Merge ff_get_buffer() and get_buffer_internal() to simplify the code.
> ---
>  libavcodec/decode.c | 37 +++--
>  1 file changed, 15 insertions(+), 22 deletions(-)

LGTM

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 00/10] Patch set for the enhancement of libopenh264 encoder

2020-04-06 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Monday, April 6, 2020 17:00
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 00/10] Patch set for the enhancement
> of libopenh264 encoder
> 
> Quoting Linjie Fu (2020-04-05 12:49:38)
> > > From: "Linjie Fu" 
> > > Sent Time: 2020-04-03 23:12:20 (Friday)
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: "Linjie Fu" 
> > > Subject: [FFmpeg-devel] [PATCH 00/10] Patch set for the enhancement
> of libopenh264 encoder
> > >
> > > Docs will be provided later.
> > >
> > > Linjie Fu (10):
> > >   lavc/libopenh264enc: Add default qmin/qmax support
> > > [v2] fix the av_clip logic for iMinQp.
> > >   lavc/libopenh264enc: fix the if-else coding style
> > >   lavc/libopenh264enc: add default gop size and bit rate
> > >   lavc/libopenh264enc: add bit rate control select support
> > >   lavc/libopenh264enc: prompt slice number changing according to cpus
> > >   lavc/libopenh264enc: set slice_mode option to deprecated
> > >   lavc/libopenh264enc: separate svc_encode_init() into several functions
> > > [v2] remove forward declarations.
> > > New:
> > >   lavc/libopenh264enc: add profile high option support
> > >   lavc/libopenh264enc: allow specifying the profile through
> AVCodecContext
> > >   lavc/libopenh264enc: replace cabac option with coder
> > >
> > >  libavcodec/libopenh264enc.c | 361
> ++--
> > >  1 file changed, 246 insertions(+), 115 deletions(-)
> > >
> > Ping for this patch set.
> 
> Would you please send your patchsets as single threads (git send-email
> does that by default unless you use --no-thread). That makes it
> significantly easier to find patches that go together.
> 
Updated, thanks.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 10/10] lavc/libopenh264enc: replace cabac option with coder

2020-04-06 Thread Linjie Fu
Change the default option to -1 and allow the default cabac to be
decided by profile.

Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 70ded55..94faeef 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -46,7 +46,7 @@ typedef struct SVCContext {
 int max_nal_size;
 int skip_frames;
 int skipped;
-int cabac;
+int coder;
 
 // rate control mode
 int rc_mode;
@@ -78,7 +78,12 @@ static const AVOption options[] = {
 #undef PROFILE
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
-{ "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
+{ "coder", "Coder type",  OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, 
-1, 1, VE, "coder" },
+{ "default",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 
INT_MIN, INT_MAX, VE, "coder" },
+{ "cavlc",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "cabac",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "vlc",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "ac",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  
INT_MIN, INT_MAX, VE, "coder" },
 
 { "rc_mode", "Select rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, 
{ .i64 = RC_QUALITY_MODE }, RC_OFF_MODE, RC_TIMESTAMP_MODE, VE, "rc_mode" },
 { "off",   "bit rate control off", 
0, AV_OPT_TYPE_CONST, { .i64 = RC_OFF_MODE }, 0, 0, VE, 
"rc_mode" },
@@ -127,8 +132,15 @@ static av_cold int svc_encode_init_profile(AVCodecContext 
*avctx, SEncParamExt *
 break;
 }
 
-if (s->profile == FF_PROFILE_UNKNOWN)
-s->profile = s->cabac ? FF_PROFILE_H264_HIGH :
+#if FF_API_CODER_TYPE
+FF_DISABLE_DEPRECATION_WARNINGS
+if (s->coder < 0 && avctx->coder_type == FF_CODER_TYPE_AC)
+s->coder = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+if (s->profile == FF_PROFILE_UNKNOWN && s->coder >= 0)
+s->profile = s->coder ? FF_PROFILE_H264_HIGH :
 FF_PROFILE_H264_CONSTRAINED_BASELINE;
 
 switch (s->profile) {
@@ -348,13 +360,6 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 
 (*s->encoder)->GetDefaultParams(s->encoder, );
 
-#if FF_API_CODER_TYPE
-FF_DISABLE_DEPRECATION_WARNINGS
-if (!s->cabac)
-s->cabac = avctx->coder_type == FF_CODER_TYPE_AC;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
 if (err = svc_encode_init_params(avctx, ) < 0)
 return err;
 
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 06/10] lavc/libopenh264enc: set slice_mode option to deprecated

2020-04-06 Thread Linjie Fu
"slice mode" seems to be unnecessary since it could be determined by
-slices/max_nal_size.

default:SM_FIXEDSLCNUM_SLICE mode with cpu-number slices.
-slices N:  SM_FIXEDSLCNUM_SLICE mode with N slices.
-max_nal_size:  SM_SIZELIMITED_SLICE mode with limited size slices.

This could be removed later.

Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 01a85fb..e89cedf 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -40,7 +40,7 @@
 typedef struct SVCContext {
 const AVClass *av_class;
 ISVCEncoder *encoder;
-int slice_mode;
+int slice_mode; // deprecated
 int loopfilter;
 char *profile;
 int max_nal_size;
@@ -54,11 +54,12 @@ typedef struct SVCContext {
 
 #define OFFSET(x) offsetof(SVCContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+#define DEPRECATED AV_OPT_FLAG_DEPRECATED
 static const AVOption options[] = {
 #if OPENH264_VER_AT_LEAST(1, 6)
-{ "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_FIXEDSLCNUM_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
+{ "slice_mode", "set slice mode, use slices/max_nal_size", 
OFFSET(slice_mode), AV_OPT_TYPE_INT, { .i64 = SM_FIXEDSLCNUM_SLICE }, 
SM_SINGLE_SLICE, SM_RESERVED, VE|DEPRECATED, "slice_mode" },
 #else
-{ "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_AUTO_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
+{ "slice_mode", "set slice mode, use slices/max_nal_size", 
OFFSET(slice_mode), AV_OPT_TYPE_INT, { .i64 = SM_AUTO_SLICE }, SM_SINGLE_SLICE, 
SM_RESERVED, VE|DEPRECATED, "slice_mode" },
 #endif
 { "fixed", "a fixed number of slices", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_FIXEDSLCNUM_SLICE }, 0, 0, VE, "slice_mode" },
 #if OPENH264_VER_AT_LEAST(1, 6)
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 07/10] lavc/libopenh264enc: separate svc_encode_init() into several functions

2020-04-06 Thread Linjie Fu
Separate the initialization procedure into different functions.

Make it more readable and easier to be extended.

Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 283 +++-
 1 file changed, 174 insertions(+), 109 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index e89cedf..f02c5fd 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -103,120 +103,51 @@ static av_cold int svc_encode_close(AVCodecContext 
*avctx)
 return 0;
 }
 
-static av_cold int svc_encode_init(AVCodecContext *avctx)
+static av_cold int svc_encode_init_profile(AVCodecContext *avctx, SEncParamExt 
*param)
 {
 SVCContext *s = avctx->priv_data;
-SEncParamExt param = { 0 };
-int err;
-int log_level;
-WelsTraceCallback callback_function;
-AVCPBProperties *props;
 
-if ((err = ff_libopenh264_check_version(avctx)) < 0)
-return err;
+if (s->profile && !strcmp(s->profile, "main"))
+param->iEntropyCodingModeFlag = 1; //< 0:CAVLC  1:CABAC
+else if (!s->profile && s->cabac)
+param->iEntropyCodingModeFlag = 1;
+else
+param->iEntropyCodingModeFlag = 0;
 
-if (WelsCreateSVCEncoder(>encoder)) {
-av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
-return AVERROR_UNKNOWN;
-}
+return 0;
+}
 
-// Pass all libopenh264 messages to our callback, to allow ourselves to 
filter them.
-log_level = WELS_LOG_DETAIL;
-(*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_LEVEL, 
_level);
+static av_cold int svc_encode_init_rate_control(AVCodecContext *avctx, 
SEncParamExt *param)
+{
+SVCContext *s = avctx->priv_data;
 
-// Set the logging callback function to one that uses av_log() (see 
implementation above).
-callback_function = (WelsTraceCallback) ff_libopenh264_trace_callback;
-(*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_CALLBACK, 
_function);
+/* Rate Control */
+param->iRCMode= s->rc_mode;
 
-// Set the AVCodecContext as the libopenh264 callback context so that it 
can be passed to av_log().
-(*s->encoder)->SetOption(s->encoder, 
ENCODER_OPTION_TRACE_CALLBACK_CONTEXT, );
+param->iTargetBitrate = avctx->bit_rate;
+param->iMaxBitrate= FFMAX(avctx->rc_max_rate, 
avctx->bit_rate);
+param->bEnableFrameSkip   = s->skip_frames;
 
-(*s->encoder)->GetDefaultParams(s->encoder, );
+// QP = 0 is not well supported, so default to (1, 51)
+param->iMaxQp = avctx->qmax >= 0 ? 
av_clip(avctx->qmax, 1, 51) : 51;
+param->iMinQp = avctx->qmin >= 0 ? 
av_clip(avctx->qmin, 1, param->iMaxQp) : 1;
+param->bEnableAdaptiveQuant   = 1;
 
-#if FF_API_CODER_TYPE
-FF_DISABLE_DEPRECATION_WARNINGS
-if (!s->cabac)
-s->cabac = avctx->coder_type == FF_CODER_TYPE_AC;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
+param->iSpatialLayerNum   = 1;  // Number of 
dependency(Spatial/CGS) layers used to be encoded
+param->iTemporalLayerNum  = 1;  // Number of temporal layer 
specified
 
-param.fMaxFrameRate  = 1/av_q2d(avctx->time_base);
-param.iPicWidth  = avctx->width;
-param.iPicHeight = avctx->height;
-param.iTargetBitrate = avctx->bit_rate;
-param.iMaxBitrate= FFMAX(avctx->rc_max_rate, 
avctx->bit_rate);
-param.iRCMode= s->rc_mode;
-// QP = 0 is not well supported, so default to (1, 51)
-param.iMaxQp = avctx->qmax >= 0 ? av_clip(avctx->qmax, 
1, 51) : 51;
-param.iMinQp = avctx->qmin >= 0 ? av_clip(avctx->qmin, 
1, param.iMaxQp) : 1;
-param.iTemporalLayerNum  = 1;
-param.iSpatialLayerNum   = 1;
-param.bEnableDenoise = 0;
-param.bEnableBackgroundDetection = 1;
-param.bEnableAdaptiveQuant   = 1;
-param.bEnableFrameSkip   = s->skip_frames;
-param.bEnableLongTermReference   = 0;
-param.iLtrMarkPeriod = 30;
-param.uiIntraPeriod  = avctx->gop_size;
-#if OPENH264_VER_AT_LEAST(1, 4)
-param.eSpsPpsIdStrategy  = CONSTANT_ID;
-#else
-param.bEnableSpsPpsIdAddition= 0;
-#endif
-param.bPrefixNalAddingCtrl   = 0;
-param.iLoopFilterDisableIdc  = !s->loopfilter;
-param.iEntropyCodingModeFlag = 0;
-param.iMultipleThreadIdc = avctx->thread_count;
-if (s->profile && !strcmp(s->profile, "main"))
-param.iEntropyCodingModeFlag = 1;
-else if (!s->profile && s->cabac)
-param.iEntropyCodingModeFlag = 1;
+param->bEnableDenoise = 0;  // Denoise control
+param->bEnableBackgroundDetection = 1;  // Background detection control
 
-param.sSpatialLayers[0].iVideoWidth = param.iPicWidth;
-

[FFmpeg-devel] [PATCH 03/10] lavc/libopenh264enc: add default gop size and bit rate

2020-04-06 Thread Linjie Fu
Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index c7ae5b1..3ff5be7 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -335,6 +335,8 @@ static int svc_encode_frame(AVCodecContext *avctx, AVPacket 
*avpkt,
 }
 
 static const AVCodecDefault svc_enc_defaults[] = {
+{ "b", "2M"},
+{ "g", "120"   },
 { "qmin",  "-1"},
 { "qmax",  "-1"},
 { NULL },
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 09/10] lavc/libopenh264enc: allow specifying the profile through AVCodecContext

2020-04-06 Thread Linjie Fu
Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index d331cfd..70ded55 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -111,6 +111,22 @@ static av_cold int svc_encode_init_profile(AVCodecContext 
*avctx, SEncParamExt *
 {
 SVCContext *s = avctx->priv_data;
 
+/* Allow specifying the libopenh264 profile through AVCodecContext. */
+if (FF_PROFILE_UNKNOWN == s->profile &&
+FF_PROFILE_UNKNOWN != avctx->profile)
+switch (avctx->profile) {
+case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
+break;
+case FF_PROFILE_H264_HIGH:
+s->profile = FF_PROFILE_H264_HIGH;
+break;
+default:
+av_log(avctx, AV_LOG_WARNING,
+   "Unsupported avctx->profile: %d.\n", avctx->profile);
+break;
+}
+
 if (s->profile == FF_PROFILE_UNKNOWN)
 s->profile = s->cabac ? FF_PROFILE_H264_HIGH :
 FF_PROFILE_H264_CONSTRAINED_BASELINE;
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

  1   2   >