Re: [FFmpeg-devel] [PATCH V1 4/5] lavc/webvttenc: fix ffmpeg -h full can't display webvtt encoder

2019-06-04 Thread myp...@gmail.com
On Wed, Jun 5, 2019 at 4:39 AM Michael Niedermayer
 wrote:
>
> On Tue, Jun 04, 2019 at 01:38:43PM +0800, Jun Zhao wrote:
> > From: Jun Zhao 
> >
> > fix ffmpeg -h full can't display webvtt encoder
> >
> > Signed-off-by: Jun Zhao 
> > ---
> >  libavcodec/webvttenc.c |   13 +
> >  1 files changed, 13 insertions(+), 0 deletions(-)
>
> breaks fate
>
> Assertion *(const AVClass **)avctx->priv_data == codec->priv_class failed at 
> libavcodec/utils.c:1009
> make: *** [fate-sub-webvttenc] Error 134
>
Will check this issue, Thanks
___
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] cbs_h2645: Fix infinite loop in more_rbsp_data

2019-06-04 Thread Andreas Rheinhardt
cbs_h2645_read_more_rbsp_data does not handle malformed input very well:
1. If there were <= 8 bits left in the bitreader, these bits were read
via show_bits. But show_bits requires the number of bits to be read to
be > 0 (internally it shifts by 32 - number of bits to be read which is
undefined behaviour if said number is zero; there is also an assert for
this, but it is only an av_assert2). Furthermore, in this case a shift
by -1 was performed which is of course undefined behaviour, too.
2. If there were > 0 and <= 8 bits left and all of them were zero
(this can only happen for defective input), it was reported that there
was further RBSP data.

This can lead to an infinite loop in H.265's cbs_h265_read_extension_data
corresponding to the [vsp]ps_extension_data_flag syntax elements. If the
relevant flag indicates the (potential) occurence of these syntax elements,
while all bits after this flag are zero, cbs_h2645_read_more_rbsp_data
always returns 1 on x86. Given that a checked bitstream reader is used,
we are also not "saved" by an overflow in the bitstream reader's index.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs_h2645.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 0456937710..becb63a290 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -328,9 +328,11 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 int bits_left = get_bits_left(gbc);
 if (bits_left > 8)
 return 1;
-if (show_bits(gbc, bits_left) == 1 << (bits_left - 1))
+if (bits_left == 0)
 return 0;
-return 1;
+if (show_bits(gbc, bits_left) & MAX_UINT_BITS(bits_left - 1))
+return 1;
+return 0;
 }
 
 #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw))
-- 
2.21.0

___
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 V1 4/5] lavc/webvttenc: fix ffmpeg -h full can't display webvtt encoder

2019-06-04 Thread myp...@gmail.com
On Wed, Jun 5, 2019 at 6:36 AM Hendrik Leppkes  wrote:
>
> On Tue, Jun 4, 2019 at 7:39 AM Jun Zhao  wrote:
> >
> > From: Jun Zhao 
> >
> > fix ffmpeg -h full can't display webvtt encoder
> >
>
> Whats the point of adding an empty help section without any options in it?
> If you use ffmpeg -encoders, for example, you'll get a full list of
> all supported encoders. An empty help section without any contents
> doesn't seem helpful to me.
>
> - Hendrik
Ha, for me, I want to get more information for WebVTT from FFmpeg
command line, so I
used the command like: ffmpeg -h full | grep -i webvtt, but get
noting,  it's quite frustrating
even the WebVTT muxer/decoder/encoder without any options,  I think dumping
a name better than get nothing in this case.
___
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 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata

2019-06-04 Thread Jun Li
Fix #6945
Rotate or/and flip frame according to frame's metadata orientation
---
 fftools/ffmpeg.c| 16 +++-
 fftools/ffmpeg.h|  3 ++-
 fftools/ffmpeg_filter.c | 28 +++-
 3 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 01f04103cf..2f4229a9d0 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2126,6 +2126,19 @@ static int ifilter_has_all_input_formats(FilterGraph *fg)
 return 1;
 }
 
+static int orientation_need_update(InputFilter *ifilter, AVFrame *frame)
+{
+int orientaion = get_frame_orientation(frame);
+int filterst = ifilter->orientation <= 1 ? 0 : // not set
+   ifilter->orientation <= 4 ? 1 : // auto flip
+   2; // auto transpose
+int framest = orientaion <= 1 ? 0 : // not set
+  orientaion <= 4 ? 1 : // auto flip
+  2; // auto transpose
+
+return filterst != framest;
+}
+
 static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
 {
 FilterGraph *fg = ifilter->graph;
@@ -2142,7 +2155,8 @@ static int ifilter_send_frame(InputFilter *ifilter, 
AVFrame *frame)
 break;
 case AVMEDIA_TYPE_VIDEO:
 need_reinit |= ifilter->width  != frame->width ||
-   ifilter->height != frame->height;
+   ifilter->height != frame->height ||
+   orientation_need_update(ifilter, frame);
 break;
 }
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7b6f802082..64278b6ab1 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -244,7 +244,7 @@ typedef struct InputFilter {
 // parameters configured for this input
 int format;
 
-int width, height;
+int width, height, orientation;
 AVRational sample_aspect_ratio;
 
 int sample_rate;
@@ -649,6 +649,7 @@ int init_complex_filtergraph(FilterGraph *fg);
 void sub2video_update(InputStream *ist, AVSubtitle *sub);
 
 int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame);
+int get_frame_orientation(const AVFrame* frame);
 
 int ffmpeg_parse_options(int argc, char **argv);
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 72838de1e2..1fcadb1871 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -743,6 +743,18 @@ static int sub2video_prepare(InputStream *ist, InputFilter 
*ifilter)
 return 0;
 }
 
+int get_frame_orientation(const AVFrame *frame)
+{
+AVDictionaryEntry *entry = NULL;
+int orientation = 0;
+
+// read exif orientation data
+entry = av_dict_get(frame->metadata, "Orientation", NULL, 0);
+if (entry && entry->value)
+orientation = atoi(entry->value);
+return orientation;
+}
+
 static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
 AVFilterInOut *in)
 {
@@ -809,13 +821,18 @@ static int configure_input_video_filter(FilterGraph *fg, 
InputFilter *ifilter,
 if (ist->autorotate) {
 double theta = get_rotation(ist->st);
 
-if (fabs(theta - 90) < 1.0) {
+if (fabs(theta) < 1.0) { // no rotation info in stream meta
+if (ifilter->orientation < 0 || ifilter->orientation > 8) {
+av_log(NULL, AV_LOG_ERROR, "Invalid frame orientation: %i\n", 
ifilter->orientation);
+} else if (ifilter->orientation > 1 && ifilter->orientation <= 4) 
{ // skip 0 (not set) and 1 (orientaion 'Normal') 
+ret = insert_filter(_filter, _idx, "transpose", 
"orientation=auto_flip");
+} else if (ifilter->orientation > 4) {
+ret = insert_filter(_filter, _idx, "transpose", 
"orientation=auto_transpose");
+}
+} else if (fabs(theta - 90) < 1.0) {
 ret = insert_filter(_filter, _idx, "transpose", "clock");
 } else if (fabs(theta - 180) < 1.0) {
-ret = insert_filter(_filter, _idx, "hflip", NULL);
-if (ret < 0)
-return ret;
-ret = insert_filter(_filter, _idx, "vflip", NULL);
+ret = insert_filter(_filter, _idx, "transpose", 
"orientation=rotate180");
 } else if (fabs(theta - 270) < 1.0) {
 ret = insert_filter(_filter, _idx, "transpose", "cclock");
 } else if (fabs(theta) > 1.0) {
@@ -1191,6 +1208,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
const AVFrame *frame)
 ifilter->width   = frame->width;
 ifilter->height  = frame->height;
 ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
+ifilter->orientation = get_frame_orientation(frame);
 
 ifilter->sample_rate = frame->sample_rate;
 ifilter->channels= frame->channels;
-- 
2.17.1

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

To unsubscribe, visit link 

Re: [FFmpeg-devel] [PATCH v6 1/2] lavf/vf_transpose: add exif orientation support

2019-06-04 Thread Jun Li
On Tue, Jun 4, 2019 at 12:50 AM Paul B Mahol  wrote:

> On 5/31/19, Jun Li  wrote:
> > Add exif orientation support and expose an option.
> > ---
> >  libavfilter/hflip.h|   2 +
> >  libavfilter/transpose.h|  14 
> >  libavfilter/vf_hflip.c |  40 ++---
> >  libavfilter/vf_transpose.c | 161 -
> >  4 files changed, 185 insertions(+), 32 deletions(-)
> >
> > diff --git a/libavfilter/hflip.h b/libavfilter/hflip.h
> > index 204090dbb4..4e89bae3fc 100644
> > --- a/libavfilter/hflip.h
> > +++ b/libavfilter/hflip.h
> > @@ -35,5 +35,7 @@ typedef struct FlipContext {
> >
> >  int ff_hflip_init(FlipContext *s, int step[4], int nb_planes);
> >  void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes);
> > +int ff_hflip_config_props(FlipContext* s, AVFilterLink *inlink);
> > +int ff_hflip_filter_slice(FlipContext *s, AVFrame *in, AVFrame *out, int
> > job, int nb_jobs, int vlifp);
> >
> >  #endif /* AVFILTER_HFLIP_H */
> > diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h
> > index aa262b9487..5da08bddc0 100644
> > --- a/libavfilter/transpose.h
> > +++ b/libavfilter/transpose.h
> > @@ -34,4 +34,18 @@ enum TransposeDir {
> >  TRANSPOSE_VFLIP,
> >  };
> >
> > +enum OrientationType {
> > +ORIENTATION_AUTO_TRANSPOSE = -2,
> > +ORIENTATION_AUTO_FLIP = -1,
> > +ORIENTATION_NONE = 0,
> > +ORIENTATION_NORMAL,
> > +ORIENTATION_HFLIP,
> > +ORIENTATION_ROTATE180,
> > +ORIENTATION_VFLIP,
> > +ORIENTATION_HFLIP_ROTATE270CW,
> > +ORIENTATION_ROTATE90CW,
> > +ORIENTATION_HFLIP_ROTATE90CW,
> > +ORIENTATION_ROTATE270CW
> > +};
> > +
> >  #endif
> > diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
> > index b77afc77fc..d24ca5c2e7 100644
> > --- a/libavfilter/vf_hflip.c
> > +++ b/libavfilter/vf_hflip.c
> > @@ -125,9 +125,8 @@ static void hflip_qword_c(const uint8_t *ssrc,
> uint8_t
> > *ddst, int w)
> >  dst[j] = src[-j];
> >  }
> >
> > -static int config_props(AVFilterLink *inlink)
> > +int ff_hflip_config_props(FlipContext* s, AVFilterLink *inlink)
> >  {
> > -FlipContext *s = inlink->dst->priv;
> >  const AVPixFmtDescriptor *pix_desc =
> > av_pix_fmt_desc_get(inlink->format);
> >  const int hsub = pix_desc->log2_chroma_w;
> >  const int vsub = pix_desc->log2_chroma_h;
> > @@ -144,6 +143,12 @@ static int config_props(AVFilterLink *inlink)
> >  return ff_hflip_init(s, s->max_step, nb_planes);
> >  }
> >
> > +static int config_props(AVFilterLink *inlink)
> > +{
> > +FlipContext *s = inlink->dst->priv;
> > +return ff_hflip_config_props(s, inlink);
> > +}
> > +
> >  int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
> >  {
> >  int i;
> > @@ -170,14 +175,10 @@ typedef struct ThreadData {
> >  AVFrame *in, *out;
> >  } ThreadData;
> >
> > -static int filter_slice(AVFilterContext *ctx, void *arg, int job, int
> > nb_jobs)
> > +int ff_hflip_filter_slice(FlipContext *s, AVFrame *in, AVFrame *out, int
> > job, int nb_jobs, int vflip)
> >  {
> > -FlipContext *s = ctx->priv;
> > -ThreadData *td = arg;
> > -AVFrame *in = td->in;
> > -AVFrame *out = td->out;
> >  uint8_t *inrow, *outrow;
> > -int i, plane, step;
> > +int i, plane, step, outlinesize;
> >
> >  for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane];
> > plane++) {
> >  const int width  = s->planewidth[plane];
> > @@ -187,19 +188,36 @@ static int filter_slice(AVFilterContext *ctx, void
> > *arg, int job, int nb_jobs)
> >
> >  step = s->max_step[plane];
> >
> > -outrow = out->data[plane] + start * out->linesize[plane];
> > -inrow  = in ->data[plane] + start * in->linesize[plane] +
> (width -
> > 1) * step;
> > +if (vflip) {
> > +outrow = out->data[plane] + (height - start - 1)*
> > out->linesize[plane];
> > +outlinesize = -out->linesize[plane];
> > +} else {
> > +outrow = out->data[plane] + start * out->linesize[plane];
> > +outlinesize = out->linesize[plane];
> > +}
> > +
> > +inrow = in->data[plane] + start * in->linesize[plane] +  (width
> -
> > 1) * step;
> > +
> >  for (i = start; i < end; i++) {
> >  s->flip_line[plane](inrow, outrow, width);
> >
> >  inrow  += in ->linesize[plane];
> > -outrow += out->linesize[plane];
> > +outrow += outlinesize;
> >  }
> >  }
> >
> >  return 0;
> >  }
> >
> > +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int
> > nb_jobs)
> > +{
> > +FlipContext *s = ctx->priv;
> > +ThreadData *td = arg;
> > +AVFrame *in = td->in;
> > +AVFrame *out = td->out;
> > +return ff_hflip_filter_slice(s, in, out, job, nb_jobs, 0);
> > +}
> > +
> >  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
> >  {
> >  AVFilterContext *ctx  = inlink->dst;
> > diff --git a/libavfilter/vf_transpose.c 

[FFmpeg-devel] [PATCH v7 1/2] lavf/vf_transpose: add exif orientation support

2019-06-04 Thread Jun Li
Add exif orientation support and expose an option.
---
 libavfilter/hflip.h|   2 +
 libavfilter/transpose.h|  14 
 libavfilter/vf_hflip.c |  40 ++---
 libavfilter/vf_transpose.c | 163 -
 4 files changed, 187 insertions(+), 32 deletions(-)

diff --git a/libavfilter/hflip.h b/libavfilter/hflip.h
index 204090dbb4..4e89bae3fc 100644
--- a/libavfilter/hflip.h
+++ b/libavfilter/hflip.h
@@ -35,5 +35,7 @@ typedef struct FlipContext {
 
 int ff_hflip_init(FlipContext *s, int step[4], int nb_planes);
 void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes);
+int ff_hflip_config_props(FlipContext* s, AVFilterLink *inlink);
+int ff_hflip_filter_slice(FlipContext *s, AVFrame *in, AVFrame *out, int job, 
int nb_jobs, int vlifp);
 
 #endif /* AVFILTER_HFLIP_H */
diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h
index aa262b9487..5da08bddc0 100644
--- a/libavfilter/transpose.h
+++ b/libavfilter/transpose.h
@@ -34,4 +34,18 @@ enum TransposeDir {
 TRANSPOSE_VFLIP,
 };
 
+enum OrientationType {
+ORIENTATION_AUTO_TRANSPOSE = -2,
+ORIENTATION_AUTO_FLIP = -1,
+ORIENTATION_NONE = 0,
+ORIENTATION_NORMAL,
+ORIENTATION_HFLIP,
+ORIENTATION_ROTATE180,
+ORIENTATION_VFLIP,
+ORIENTATION_HFLIP_ROTATE270CW,
+ORIENTATION_ROTATE90CW,
+ORIENTATION_HFLIP_ROTATE90CW,
+ORIENTATION_ROTATE270CW
+};
+
 #endif
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index b77afc77fc..d24ca5c2e7 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -125,9 +125,8 @@ static void hflip_qword_c(const uint8_t *ssrc, uint8_t 
*ddst, int w)
 dst[j] = src[-j];
 }
 
-static int config_props(AVFilterLink *inlink)
+int ff_hflip_config_props(FlipContext* s, AVFilterLink *inlink)
 {
-FlipContext *s = inlink->dst->priv;
 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
 const int hsub = pix_desc->log2_chroma_w;
 const int vsub = pix_desc->log2_chroma_h;
@@ -144,6 +143,12 @@ static int config_props(AVFilterLink *inlink)
 return ff_hflip_init(s, s->max_step, nb_planes);
 }
 
+static int config_props(AVFilterLink *inlink)
+{
+FlipContext *s = inlink->dst->priv;
+return ff_hflip_config_props(s, inlink);
+}
+
 int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
 {
 int i;
@@ -170,14 +175,10 @@ typedef struct ThreadData {
 AVFrame *in, *out;
 } ThreadData;
 
-static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
+int ff_hflip_filter_slice(FlipContext *s, AVFrame *in, AVFrame *out, int job, 
int nb_jobs, int vflip)
 {
-FlipContext *s = ctx->priv;
-ThreadData *td = arg;
-AVFrame *in = td->in;
-AVFrame *out = td->out;
 uint8_t *inrow, *outrow;
-int i, plane, step;
+int i, plane, step, outlinesize;
 
 for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; 
plane++) {
 const int width  = s->planewidth[plane];
@@ -187,19 +188,36 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int job, int nb_jobs)
 
 step = s->max_step[plane];
 
-outrow = out->data[plane] + start * out->linesize[plane];
-inrow  = in ->data[plane] + start * in->linesize[plane] + (width - 1) 
* step;
+if (vflip) {
+outrow = out->data[plane] + (height - start - 1)* 
out->linesize[plane];
+outlinesize = -out->linesize[plane];
+} else {
+outrow = out->data[plane] + start * out->linesize[plane];
+outlinesize = out->linesize[plane];
+}
+
+inrow = in->data[plane] + start * in->linesize[plane] +  (width - 1) * 
step;
+
 for (i = start; i < end; i++) {
 s->flip_line[plane](inrow, outrow, width);
 
 inrow  += in ->linesize[plane];
-outrow += out->linesize[plane];
+outrow += outlinesize;
 }
 }
 
 return 0;
 }
 
+static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
+{
+FlipContext *s = ctx->priv;
+ThreadData *td = arg;
+AVFrame *in = td->in;
+AVFrame *out = td->out;
+return ff_hflip_filter_slice(s, in, out, job, nb_jobs, 0);
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx  = inlink->dst;
diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index dd54947bd9..d0b5709d1f 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -39,6 +39,7 @@
 #include "internal.h"
 #include "video.h"
 #include "transpose.h"
+#include "hflip.h"
 
 typedef struct TransVtable {
 void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,
@@ -48,16 +49,22 @@ typedef struct TransVtable {
 int w, int h);
 } TransVtable;
 
-typedef struct TransContext {
-const AVClass *class;
+typedef struct TransContextData {
 int hsub, vsub;
 int planes;
 int pixsteps[4];
+TransVtable vtables[4];

Re: [FFmpeg-devel] [PATCH V1 4/5] lavc/webvttenc: fix ffmpeg -h full can't display webvtt encoder

2019-06-04 Thread Hendrik Leppkes
On Tue, Jun 4, 2019 at 7:39 AM Jun Zhao  wrote:
>
> From: Jun Zhao 
>
> fix ffmpeg -h full can't display webvtt encoder
>

Whats the point of adding an empty help section without any options in it?
If you use ffmpeg -encoders, for example, you'll get a full list of
all supported encoders. An empty help section without any contents
doesn't seem helpful to me.

- Hendrik
___
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 V1 4/5] lavc/webvttenc: fix ffmpeg -h full can't display webvtt encoder

2019-06-04 Thread Michael Niedermayer
On Tue, Jun 04, 2019 at 01:38:43PM +0800, Jun Zhao wrote:
> From: Jun Zhao 
> 
> fix ffmpeg -h full can't display webvtt encoder
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavcodec/webvttenc.c |   13 +
>  1 files changed, 13 insertions(+), 0 deletions(-)

breaks fate

Assertion *(const AVClass **)avctx->priv_data == codec->priv_class failed at 
libavcodec/utils.c:1009
make: *** [fate-sub-webvttenc] Error 134

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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] avcodec/h264_sei: Add experimental acces to truncated SEI data

2019-06-04 Thread Antonin Gouzer
Hello,
Thanks for your response.
It's difficult to say if this is a common issue.
I have hundred of thousands of files like this from an editor.

Even the off by one Size is not standart compliant and it would be
incorrect to not report it as an error/warning

My first idea was to allow the user to attempt reading such data but
not as a default behaviour.
The patch is larger than my use case and allow size off by N.

Do you think that it would be better to reduce the patch to a unique
use case: truncated SEI of  picture timing type, off by one size ?

Regards

Le mar. 4 juin 2019 à 08:12, Reimar Döffinger
 a écrit :
>
>
>
> On 04.06.2019, at 00:21, Antonin Gouzer  wrote:
>
> > ---
> > Some codecs editors had miss interpreted the H264 standart and
> > have coded a wrong size in the SEI data.
> > size = SEI size + 1.
> > The SEI data is detected as "truncated"
> > Ex: 
> > https://drive.google.com/file/d/1cNtLwnfPnyJnYqE7OYhU3SCoLRtuXIUM/view?usp=sharing
> > Command:
> > ffprobe -strict experimental -print_format xml -show_frames -read_intervals 
> > %+0.04 truncated.h264
> > This (simple) patch add the possibility to read this false truncated SEI 
> > data.
> > by setting strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL.
> > The error remain logged.
> >
> > Thanks in advance !
> >
>
> > @@ -425,27 +425,28 @@ int ff_h264_sei_decode(H264SEIContext *h, 
> > GetBitContext *gb,
> > } while (get_bits(gb, 8) == 255);
> >
> > if (size > get_bits_left(gb) / 8) {
> > -av_log(logctx, AV_LOG_ERROR, "SEI type %d size %d truncated at 
> > %d\n",
> > +av_log(avctx, AV_LOG_ERROR, "SEI type %d size %d truncated at 
> > %d\n",
> >type, 8*size, get_bits_left(gb));
> > -return AVERROR_INVALIDDATA;
> > +if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)
> > +return AVERROR_INVALIDDATA;
> > }
> > next = get_bits_count(gb) + 8 * size;
>
> This doesn't seem right, shouldn't you adjust "size"?
> Also if this is reasonably common shouldn't we accept at least the exactly 
> off-by-one case at the default settings?
> ___
> 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] avformat/id3v2enc: write CTOC too

2019-06-04 Thread Paul B Mahol
On 6/4/19, James Almer  wrote:
> On 6/4/2019 11:45 AM, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavformat/id3v2enc.c | 36 
>>  1 file changed, 36 insertions(+)
>>
>> diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
>> index ffe358f019..9b72614447 100644
>> --- a/libavformat/id3v2enc.c
>> +++ b/libavformat/id3v2enc.c
>> @@ -255,6 +255,39 @@ static int write_metadata(AVIOContext *pb,
>> AVDictionary **metadata,
>>  return 0;
>>  }
>>
>> +static int write_ctoc(AVFormatContext *s, ID3v2EncContext *id3, int enc)
>> +{
>> +uint8_t *dyn_buf = NULL;
>> +AVIOContext *dyn_bc = NULL;
>> +char name[123];
>> +int len, ret;
>> +
>> +if ((ret = avio_open_dyn_buf(_bc)) < 0)
>> +goto fail;
>> +
>> +id3->len += avio_put_str(dyn_bc, "toc");
>> +avio_wb16(dyn_bc, 0x03);
>> +avio_w8(dyn_bc, s->nb_chapters);
>> +for (int i = 0; i < s->nb_chapters; i++) {
>> +snprintf(name, 122, "ch%d", i);
>> +id3->len += avio_put_str(dyn_bc, name);
>> +}
>> +len = avio_close_dyn_buf(dyn_bc, _buf);
>> +id3->len += 16 + ID3v2_HEADER_SIZE;
>> +
>> +avio_wb32(s->pb, MKBETAG('C', 'T', 'O', 'C'));
>> +avio_wb32(s->pb, len);
>> +avio_wb16(s->pb, 0);
>> +avio_write(s->pb, dyn_buf, len);
>> +
>> +fail:
>> +if (dyn_bc && !dyn_buf)
>> +avio_close_dyn_buf(dyn_bc, _buf);
>> +av_freep(_buf);
>> +
>> +return ret;
>> +}
>> +
>>  static int write_chapter(AVFormatContext *s, ID3v2EncContext *id3, int
>> id, int enc)
>>  {
>>  const AVRational time_base = {1, 1000};
>> @@ -306,6 +339,9 @@ int ff_id3v2_write_metadata(AVFormatContext *s,
>> ID3v2EncContext *id3)
>>  if ((ret = write_metadata(s->pb, >metadata, id3, enc)) < 0)
>>  return ret;
>>
>> +if ((ret = write_ctoc(s, id3, enc)) < 0)
>
> Shouldn't you check that s->nb_chapters is > 0 before calling this? Or
> within that function, alternatively.
>
> Even if CTOC could be written with 0 chapters, it would be an
> unnecessary bloat in the output file.
>

Agreed, will add check.

>> +return ret;
>> +
>>  for (i = 0; i < s->nb_chapters; i++) {
>>  if ((ret = write_chapter(s, id3, i, enc)) < 0)
>>  return ret;
>>
>
> ___
> 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 V2 2/2] checkasm/vf_gblur: add test for horiz_slice simd

2019-06-04 Thread Michael Niedermayer
On Tue, Jun 04, 2019 at 04:42:09PM +0800, Ruiling Song wrote:
> Signed-off-by: Ruiling Song 
> ---
>  tests/checkasm/Makefile   |  1 +
>  tests/checkasm/checkasm.c |  3 ++
>  tests/checkasm/checkasm.h |  1 +
>  tests/checkasm/vf_gblur.c | 67 +++
>  tests/fate/checkasm.mak   |  1 +
>  5 files changed, 73 insertions(+)
>  create mode 100644 tests/checkasm/vf_gblur.c

this fails here: (ubuntu x86-64)

Test checkasm-vf_gblur failed. Look at tests/data/fate/checkasm-vf_gblur.err 
for details.
checkasm: using random seed 1608403213
test failed comparing 258.619 with 212.24 (abs diff=46.3793 with EPS=0.01)
SSE4.1:
   horiz_slice_sse4 (vf_gblur.c:60)
 - vf_gblur.horiz_slice [FAILED]
checkasm: 1 of 1 tests have failed
make: *** [fate-checkasm-vf_gblur] Error 1



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

You can kill me, but you cannot change the truth.


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 v3 4/5] vaapi_encode: Add ROI support

2019-06-04 Thread Michael Niedermayer
On Tue, Jun 04, 2019 at 12:19:04AM +0100, Mark Thompson wrote:
> ---
> For example:
> 
> $ ./ffmpeg_g -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 
> -hwaccel_output_format vaapi -i in.mp4 -an -vf 
> 'scale_vaapi=96:96,addroi=iw/3:ih/3:iw/3:ih/3:-1/2' -c:v h264_vaapi -rc_mode 
> CQP -global_quality 44 -frames:v 1 test.264
> ...
> $ ldecod.exe
> ...
> $ cat trace_dec.txt | grep qp
> @30SPS: lossless_qpprime_y_zero_flag 0 (  0) 
> @214   PPS: pic_init_qp_minus260100100 ( 18) 
> @226   PPS: chroma_qp_index_offset   1 (  0) 
> @232   PPS: second_chroma_qp_index_offset1 (  0) 
> @261   SH: slice_qp_delta1 (  0) 
> @20 mb_qp_delta (  0)
> @29 mb_qp_delta (  0)
> @35 mb_qp_delta (  0)
> @40 mb_qp_delta (  0)
> @45 mb_qp_delta (  0)
> @50 mb_qp_delta (  0)
> @55 mb_qp_delta (  0)
> @61 mb_qp_delta (  0)
> @66 mb_qp_delta (  0)
> @71 mb_qp_delta (  0)
> @76 mb_qp_delta (  0)
> @81 mb_qp_delta (  0)
> @86 mb_qp_delta (  0)
> @91 mb_qp_delta (  0)
> @96 mb_qp_delta (-25)
> @106mb_qp_delta (  0)
> @112mb_qp_delta ( 25)
> @117mb_qp_delta (  0)
> @122mb_qp_delta (  0)
> @127mb_qp_delta (  0)
> @132mb_qp_delta (-25)
> @138mb_qp_delta (  0)
> @143mb_qp_delta ( 25)
> @148mb_qp_delta (  0)
> @153mb_qp_delta (  0)
> @158mb_qp_delta (  0)
> @163mb_qp_delta (  0)
> @168mb_qp_delta (  0)
> @173mb_qp_delta (  0)
> @178mb_qp_delta (  0)
> @183mb_qp_delta (  0)
> @188mb_qp_delta (  0)
> @193mb_qp_delta (  0)
> @198mb_qp_delta (  0)
> @203mb_qp_delta (  0)
> @208mb_qp_delta (  0)
> 
> 
>  libavcodec/vaapi_encode.c   | 119 
>  libavcodec/vaapi_encode.h   |  16 +
>  libavcodec/vaapi_encode_h264.c  |   2 +
>  libavcodec/vaapi_encode_h265.c  |   2 +
>  libavcodec/vaapi_encode_mpeg2.c |   2 +
>  libavcodec/vaapi_encode_vp8.c   |   2 +
>  libavcodec/vaapi_encode_vp9.c   |   2 +
>  7 files changed, 145 insertions(+)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index dd2a24de04..d2e3a9bee8 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -166,6 +166,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
>  int err, i;
>  char data[MAX_PARAM_BUFFER_SIZE];
>  size_t bit_len;
> +AVFrameSideData *sd;
>  
>  av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" "
> "as type %s.\n", pic->display_order, pic->encode_order,
> @@ -435,6 +436,72 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
>  }
>  }
>  
> +sd = av_frame_get_side_data(pic->input_image,
> +AV_FRAME_DATA_REGIONS_OF_INTEREST);
> +
> +#if VA_CHECK_VERSION(1, 0, 0)
> +if (sd && ctx->roi_allowed) {
> +const AVRegionOfInterest *roi;
> +uint32_t roi_size;
> +VAEncMiscParameterBufferROI param_roi;
> +  

Re: [FFmpeg-devel] [PATCH v3 5/5] lavfi: addroi filter

2019-06-04 Thread Moritz Barsnick
On Tue, Jun 04, 2019 at 00:19:05 +0100, Mark Thompson wrote:
> This can be used to add region of interest side data to video frames.

Very valuable addition for use of ROI the command line tool!

> +Mark regions of interest in a video frame.

Since you're using the plural, it's probably worth mentioning how to
specify several regions.

> +@item x
> +Region distance in pixels from the left edge of the frame.

Mention that it's an expression, and that it (or all four) support "iw"
and "ih".

> +@item qoffset
> +Quantisation offset to apply within the region.
> +
> +Must be in the range -1 to +1.

It would be nice to mention somewhere that it's a float (even though
the text implies that.)

> +@item clear
> +Remove any existing regions of interest marked on the frame before
> +adding the new one.

Mention that it needs to be "1", or that it's a boolean.

Overall, very well described. An example or two would be very welcome
though.

> +for (i = 0; i < 4; i++) {
> +int max_value;
> +switch (i) {

I like avoiding magic numbers such as 4, and would prefer 
sizeof(addroi_param_names)
- but that's probably just me.

> +av_assert0(old_roi_size && sd->size % old_roi_size == 0);

Someone recently posted a patch splitting up composite assert()s. I
don't recall whether it was merged though.

> +static av_cold int addroi_init(AVFilterContext *avctx)
> +{
> +AddROIContext *ctx = avctx->priv;
> +int i, err;
> +
> +for (i = 0; i < 4; i++) {

Magic 4 again (also in uninit()).

Cheers,
Moritz
___
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] libavformat/qsvenc: repeat mpeg2 missing headers [v2]

2019-06-04 Thread Reimar Döffinger


On 04.06.2019, at 15:07, Andreas Håkon  wrote:

> Hi,
> 
> I need to admit that I'm completely wrong in the end. After spending a lot
> of time on a patch to solve the problem (making the MPEG-2 QSV encoder
> compatible with broadcasts), I discovered that this solution works:
> 
> $ ffmpeg  ... -c:v mpeg2_qsv -bsf:v 'dump_extra' -f mpegts ...
> 
> Using this bitstream filter every GOP includes the missing sequence headers.
> However, one flaw persists:
> 
> - The first GOP has duplicated SEQ_START_CODE and EXT_START_CODE headers.
> 
> The problem is that the dump_extra filter re-injects the headers
> without **verifying** their existence.
> 
> Until someone fixes this, I'm commenting it here for documentation.
> In addition, I hope that an example will be incorporated into the
> Documentation as a reference.

I think ideally MPEG-TS/ES/... muxers would detect such cases and print a 
warning suggesting this command, which I think would be much better than 
documentation.
Maybe it could even detect relevant cases and insert it itself.
But either way, ideally someone would spend some time considering what the 
right way is to design this.
___
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] libavformat/mpegtsenc: adaptive alignment for teletext PES packets

2019-06-04 Thread Marton Balint



On Tue, 4 Jun 2019, Andreas Håkon wrote:


Hi Marton,


Thank you for taking the time to review this patch!

‐‐‐ Original Message ‐‐‐
On Sunday, 2 de June de 2019 1:38, Marton Balint  wrote:


On Wed, 22 May 2019, Andreas Håkon wrote:

> Hi,
> Patch to generate aligned Teletext PES packets using the MPEG-TS muxer
> when the TS header contains data.

> The code that generates the PES packets for Teletext data aligns the PES 
packets
> with the boundaries of the TS packets. The strategy used is to insert padding
> stuff into the PES header. The size of this padding alignment currently has a
> fixed size of 36 bytes. And this value is correct when all of the Teletext
> TS packets have payload only. However, inserting some data into the TS header
> breaks this assumption. In this case, the Teletext PES packets are not aligned
> and the end of the PES packet is inserted into an additional TS packet with a
> large amount of TS padding.

What is the data that is inserted into the TS header? Can you give an
example? Are you sure that it is allowed to generate such streams?
Are you seeing such streams in the wild?


It can vary. For example you can add PCR timestamps inside the Teletext stream
(not very common, but possible).


The teletext specs also says, that a DVB teletext stream 
adaptation_field_control is either 01 or 10, which means that either there 
is an adaptation field or there is payload. Having both is NOT allowed.


If PCR needs to be transmitted, then it either has to be on a separate PCR 
PID or if you insist on using the same PID then you must use a separate 
packet with adaptation field only if you want to respect the 
specification.






The DVB teletext spec is very strict about that PES header size and 0x24
is hardcoded there.

https://www.etsi.org/deliver/etsi_en/300400_300499/300472/01.03.01_60/en_300472v010301p.pdf


Yes, you're right. The sentence at section "4.2 PES packet format" indicates:

"PES_header_data_length set to "0x24"." And after it adds:

"PTS and other optional fields may be present in the PES header,
but the header length is always fixed for streams
identified in the Program Specific Information (PSI) by the DVB Teletext 
descriptor"

However, the idea of this restriction is to leave space for PTS data even if
it's not present in the PES packet. And if you don't add any additional stuff
in the TS header, the constraint is satisfied.

Perhaps you'd prefer this behavior to be optional?


Our mpegts muxer should not generate streams which are not compliant with 
the relevant specifications. So the proper way to do what you want seems 
to be generating adaptation field only packets.


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".

Re: [FFmpeg-devel] [PATCH] avformat/id3v2enc: write CTOC too

2019-06-04 Thread James Almer
On 6/4/2019 11:45 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/id3v2enc.c | 36 
>  1 file changed, 36 insertions(+)
> 
> diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
> index ffe358f019..9b72614447 100644
> --- a/libavformat/id3v2enc.c
> +++ b/libavformat/id3v2enc.c
> @@ -255,6 +255,39 @@ static int write_metadata(AVIOContext *pb, AVDictionary 
> **metadata,
>  return 0;
>  }
>  
> +static int write_ctoc(AVFormatContext *s, ID3v2EncContext *id3, int enc)
> +{
> +uint8_t *dyn_buf = NULL;
> +AVIOContext *dyn_bc = NULL;
> +char name[123];
> +int len, ret;
> +
> +if ((ret = avio_open_dyn_buf(_bc)) < 0)
> +goto fail;
> +
> +id3->len += avio_put_str(dyn_bc, "toc");
> +avio_wb16(dyn_bc, 0x03);
> +avio_w8(dyn_bc, s->nb_chapters);
> +for (int i = 0; i < s->nb_chapters; i++) {
> +snprintf(name, 122, "ch%d", i);
> +id3->len += avio_put_str(dyn_bc, name);
> +}
> +len = avio_close_dyn_buf(dyn_bc, _buf);
> +id3->len += 16 + ID3v2_HEADER_SIZE;
> +
> +avio_wb32(s->pb, MKBETAG('C', 'T', 'O', 'C'));
> +avio_wb32(s->pb, len);
> +avio_wb16(s->pb, 0);
> +avio_write(s->pb, dyn_buf, len);
> +
> +fail:
> +if (dyn_bc && !dyn_buf)
> +avio_close_dyn_buf(dyn_bc, _buf);
> +av_freep(_buf);
> +
> +return ret;
> +}
> +
>  static int write_chapter(AVFormatContext *s, ID3v2EncContext *id3, int id, 
> int enc)
>  {
>  const AVRational time_base = {1, 1000};
> @@ -306,6 +339,9 @@ int ff_id3v2_write_metadata(AVFormatContext *s, 
> ID3v2EncContext *id3)
>  if ((ret = write_metadata(s->pb, >metadata, id3, enc)) < 0)
>  return ret;
>  
> +if ((ret = write_ctoc(s, id3, enc)) < 0)

Shouldn't you check that s->nb_chapters is > 0 before calling this? Or
within that function, alternatively.

Even if CTOC could be written with 0 chapters, it would be an
unnecessary bloat in the output file.

> +return ret;
> +
>  for (i = 0; i < s->nb_chapters; i++) {
>  if ((ret = write_chapter(s, id3, i, enc)) < 0)
>  return ret;
> 

___
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/id3v2enc: write CTOC too

2019-06-04 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/id3v2enc.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index ffe358f019..9b72614447 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -255,6 +255,39 @@ static int write_metadata(AVIOContext *pb, AVDictionary 
**metadata,
 return 0;
 }
 
+static int write_ctoc(AVFormatContext *s, ID3v2EncContext *id3, int enc)
+{
+uint8_t *dyn_buf = NULL;
+AVIOContext *dyn_bc = NULL;
+char name[123];
+int len, ret;
+
+if ((ret = avio_open_dyn_buf(_bc)) < 0)
+goto fail;
+
+id3->len += avio_put_str(dyn_bc, "toc");
+avio_wb16(dyn_bc, 0x03);
+avio_w8(dyn_bc, s->nb_chapters);
+for (int i = 0; i < s->nb_chapters; i++) {
+snprintf(name, 122, "ch%d", i);
+id3->len += avio_put_str(dyn_bc, name);
+}
+len = avio_close_dyn_buf(dyn_bc, _buf);
+id3->len += 16 + ID3v2_HEADER_SIZE;
+
+avio_wb32(s->pb, MKBETAG('C', 'T', 'O', 'C'));
+avio_wb32(s->pb, len);
+avio_wb16(s->pb, 0);
+avio_write(s->pb, dyn_buf, len);
+
+fail:
+if (dyn_bc && !dyn_buf)
+avio_close_dyn_buf(dyn_bc, _buf);
+av_freep(_buf);
+
+return ret;
+}
+
 static int write_chapter(AVFormatContext *s, ID3v2EncContext *id3, int id, int 
enc)
 {
 const AVRational time_base = {1, 1000};
@@ -306,6 +339,9 @@ int ff_id3v2_write_metadata(AVFormatContext *s, 
ID3v2EncContext *id3)
 if ((ret = write_metadata(s->pb, >metadata, id3, enc)) < 0)
 return ret;
 
+if ((ret = write_ctoc(s, id3, enc)) < 0)
+return ret;
+
 for (i = 0; i < s->nb_chapters; i++) {
 if ((ret = write_chapter(s, id3, i, enc)) < 0)
 return ret;
-- 
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".

Re: [FFmpeg-devel] [PATCH] bitstream_filters: Correct dump_extradata description

2019-06-04 Thread Gyan



On 04-06-2019 07:11 PM, Andreas Rheinhardt wrote:

The default is to dump extradata to keyframes, not all frames.
Also improve the description of the relevant AVOption.

Signed-off-by: Andreas Rheinhardt 
---
  doc/bitstream_filters.texi  | 2 +-
  libavcodec/dump_extradata_bsf.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 25bbf8372b..40e8adad0f 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -120,7 +120,7 @@ add extradata to all packets
  @end table
  @end table
  
-If not specified it is assumed @samp{e}.

+If not specified it is assumed @samp{k}.
  
  For example the following @command{ffmpeg} command forces a global

  header (thus disabling individual packet headers) in the H.264 packets
diff --git a/libavcodec/dump_extradata_bsf.c b/libavcodec/dump_extradata_bsf.c
index 188a1c619b..7112cd6bd4 100644
--- a/libavcodec/dump_extradata_bsf.c
+++ b/libavcodec/dump_extradata_bsf.c
@@ -81,7 +81,7 @@ fail:
  #define OFFSET(x) offsetof(DumpExtradataContext, x)
  #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
  static const AVOption options[] = {
-{ "freq", "When do dump extradata", OFFSET(freq), AV_OPT_TYPE_INT,
+{ "freq", "When to dump extradata", OFFSET(freq), AV_OPT_TYPE_INT,
  { .i64 = DUMP_FREQ_KEYFRAME }, DUMP_FREQ_KEYFRAME, DUMP_FREQ_ALL, FLAGS, 
"freq" },
  { "k",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_KEYFRAME }, .flags 
= FLAGS, .unit = "freq" },
  { "keyframe", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_KEYFRAME }, .flags 
= FLAGS, .unit = "freq" },


Will apply.

Gyan
___
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] bitstream_filters: Correct dump_extradata description

2019-06-04 Thread Andreas Rheinhardt
The default is to dump extradata to keyframes, not all frames.
Also improve the description of the relevant AVOption.

Signed-off-by: Andreas Rheinhardt 
---
 doc/bitstream_filters.texi  | 2 +-
 libavcodec/dump_extradata_bsf.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 25bbf8372b..40e8adad0f 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -120,7 +120,7 @@ add extradata to all packets
 @end table
 @end table
 
-If not specified it is assumed @samp{e}.
+If not specified it is assumed @samp{k}.
 
 For example the following @command{ffmpeg} command forces a global
 header (thus disabling individual packet headers) in the H.264 packets
diff --git a/libavcodec/dump_extradata_bsf.c b/libavcodec/dump_extradata_bsf.c
index 188a1c619b..7112cd6bd4 100644
--- a/libavcodec/dump_extradata_bsf.c
+++ b/libavcodec/dump_extradata_bsf.c
@@ -81,7 +81,7 @@ fail:
 #define OFFSET(x) offsetof(DumpExtradataContext, x)
 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption options[] = {
-{ "freq", "When do dump extradata", OFFSET(freq), AV_OPT_TYPE_INT,
+{ "freq", "When to dump extradata", OFFSET(freq), AV_OPT_TYPE_INT,
 { .i64 = DUMP_FREQ_KEYFRAME }, DUMP_FREQ_KEYFRAME, DUMP_FREQ_ALL, 
FLAGS, "freq" },
 { "k",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_KEYFRAME 
}, .flags = FLAGS, .unit = "freq" },
 { "keyframe", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_KEYFRAME 
}, .flags = FLAGS, .unit = "freq" },
-- 
2.21.0

___
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] doc/bitstream_filters: Correct dump_extradata description

2019-06-04 Thread Gyan



On 04-06-2019 06:50 PM, Andreas Rheinhardt wrote:

The default is to dump extradata to keyframes, not all frames.

Signed-off-by: Andreas Rheinhardt 
---
  doc/bitstream_filters.texi | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 25bbf8372b..40e8adad0f 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -120,7 +120,7 @@ add extradata to all packets
  @end table
  @end table
  
-If not specified it is assumed @samp{e}.

+If not specified it is assumed @samp{k}.


LGTM. Maybe, correct the description in the AVOption as well

"When do dump extradata" --> "When to dump extradata"

Gyan
___
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] doc/bitstream_filters: Correct dump_extradata description

2019-06-04 Thread Andreas Rheinhardt
The default is to dump extradata to keyframes, not all frames.

Signed-off-by: Andreas Rheinhardt 
---
 doc/bitstream_filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 25bbf8372b..40e8adad0f 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -120,7 +120,7 @@ add extradata to all packets
 @end table
 @end table
 
-If not specified it is assumed @samp{e}.
+If not specified it is assumed @samp{k}.
 
 For example the following @command{ffmpeg} command forces a global
 header (thus disabling individual packet headers) in the H.264 packets
-- 
2.21.0

___
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] fix typo in dashenc

2019-06-04 Thread Gyan



On 04-06-2019 06:29 PM, Alfred E. Heggestad wrote:

On 04/06/2019 14:07, Gyan wrote:



On 04-06-2019 04:28 PM, Alfred E. Heggestad wrote:

Hi Karthick,

thanks for your feedback. here is an updated patch
as you suggested.






From 7879e39c25ede24693f166eb6a63094757d9fb1e Mon Sep 17 00:00:00 2001
From: "Alfred E. Heggestad" 
Date: Tue, 4 Jun 2019 09:39:59 +0200
Subject: [PATCH] dashenc: fix typo in seg_duration description

doc: fix typo (seconds -> microseconds)
---
 doc/muxers.texi   | 2 +-
 libavformat/dashenc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index c73719c421..be02912b29 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -232,7 +232,7 @@ ffmpeg -re -i  -map 0 -map 0 -c:a 
libfdk_aac -c:v libx264

 @item -min_seg_duration @var{microseconds}
 This is a deprecated option to set the segment length in 
microseconds, use @var{seg_duration} instead.

 @item -seg_duration @var{duration}
-Set the segment length in seconds (fractional value can be set). 
The value is
+Set the segment length in microseconds (fractional value can be 
set). The value is
 treated as average segment duration when @var{use_template} is 
enabled and
 @var{use_timeline} is disabled and as minimum segment duration for 
all the other

 use cases.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 94b198ceb8..a70e9d176c 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1863,7 +1863,7 @@ static const AVOption options[] = {
 #if FF_API_DASH_MIN_SEG_DURATION
 { "min_seg_duration", "minimum segment duration (in 
microseconds) (will be deprecated)", OFFSET(min_seg_duration), 
AV_OPT_TYPE_INT, { .i64 = 500 }, 0, INT_MAX, E },

 #endif
-    { "seg_duration", "segment duration (in seconds, fractional 
value can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { 
.i64 = 500 }, 0, INT_MAX, E },
+    { "seg_duration", "segment duration (in microseconds, 
fractional value can be set)", OFFSET(seg_duration), 
AV_OPT_TYPE_DURATION, { .i64 = 500 }, 0, INT_MAX, E },
 { "remove_at_exit", "remove all segments when finished", 
OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { "use_template", "Use SegmentTemplate instead of SegmentList", 
OFFSET(use_template), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
 { "use_timeline", "Use SegmentTimeline in SegmentTemplate", 
OFFSET(use_timeline), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },


This doesn't look right.

I just tested ffmpeg cli with -seg_duration 4 and -seg_duration 
400. The latter failed with "Value 400.00 for parameter 
'seg_duration' out of range [0 - 2147.48]" and the former produced 
segments of duration 4 seconds each.


The field type is AV_OPT_TYPE_DURATION, and the avutil parser returns 
a microsecond value to the caller, but it expects the user string to 
be either HH:MM:SS or MM:SS or S+. Millisecond and microsecond values 
can be fed, with a suffix of ms or us, respectively.





this code is working for me:

ret |= av_opt_set_int(obj, "seg_duration",  1000, 0);



if you look in the declarations of options in dashenc.c:

#if FF_API_DASH_MIN_SEG_DURATION
    { "min_seg_duration", "minimum segment duration (in microseconds) 
(will be deprecated)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { 
.i64 = 500 }, 0, INT_MAX, E },

#endif
    { "seg_duration", "segment duration (in seconds, fractional value 
can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 
500 }, 0, INT_MAX, E },



see the default value:

    .i64 = 500


You should be using av_opt_set(), which will parse the value as per its 
type, which is AV_OPT_TYPE_DURATION and not AV_OPT_TYPE_INT. There is no 
specific setter for DURATION type.


Gyan
___
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] libavformat/qsvenc: repeat mpeg2 missing headers [v2]

2019-06-04 Thread Andreas Håkon
Hi,

I need to admit that I'm completely wrong in the end. After spending a lot
of time on a patch to solve the problem (making the MPEG-2 QSV encoder
compatible with broadcasts), I discovered that this solution works:

$ ffmpeg  ... -c:v mpeg2_qsv -bsf:v 'dump_extra' -f mpegts ...

Using this bitstream filter every GOP includes the missing sequence headers.
However, one flaw persists:

- The first GOP has duplicated SEQ_START_CODE and EXT_START_CODE headers.

The problem is that the dump_extra filter re-injects the headers
without **verifying** their existence.

Until someone fixes this, I'm commenting it here for documentation.
In addition, I hope that an example will be incorporated into the
Documentation as a reference.

In any case, thank you for pointing out the mistake!

Regards.
A.H.

---

___
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] fix typo in dashenc

2019-06-04 Thread Alfred E. Heggestad

On 04/06/2019 14:07, Gyan wrote:



On 04-06-2019 04:28 PM, Alfred E. Heggestad wrote:

Hi Karthick,

thanks for your feedback. here is an updated patch
as you suggested.






From 7879e39c25ede24693f166eb6a63094757d9fb1e Mon Sep 17 00:00:00 2001
From: "Alfred E. Heggestad" 
Date: Tue, 4 Jun 2019 09:39:59 +0200
Subject: [PATCH] dashenc: fix typo in seg_duration description

doc: fix typo (seconds -> microseconds)
---
 doc/muxers.texi   | 2 +-
 libavformat/dashenc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index c73719c421..be02912b29 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -232,7 +232,7 @@ ffmpeg -re -i  -map 0 -map 0 -c:a 
libfdk_aac -c:v libx264

 @item -min_seg_duration @var{microseconds}
 This is a deprecated option to set the segment length in 
microseconds, use @var{seg_duration} instead.

 @item -seg_duration @var{duration}
-Set the segment length in seconds (fractional value can be set). The 
value is
+Set the segment length in microseconds (fractional value can be set). 
The value is
 treated as average segment duration when @var{use_template} is 
enabled and
 @var{use_timeline} is disabled and as minimum segment duration for 
all the other

 use cases.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 94b198ceb8..a70e9d176c 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1863,7 +1863,7 @@ static const AVOption options[] = {
 #if FF_API_DASH_MIN_SEG_DURATION
 { "min_seg_duration", "minimum segment duration (in microseconds) 
(will be deprecated)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { 
.i64 = 500 }, 0, INT_MAX, E },

 #endif
-    { "seg_duration", "segment duration (in seconds, fractional value 
can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 
500 }, 0, INT_MAX, E },
+    { "seg_duration", "segment duration (in microseconds, fractional 
value can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 
= 500 }, 0, INT_MAX, E },
 { "remove_at_exit", "remove all segments when finished", 
OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { "use_template", "Use SegmentTemplate instead of SegmentList", 
OFFSET(use_template), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
 { "use_timeline", "Use SegmentTimeline in SegmentTemplate", 
OFFSET(use_timeline), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },


This doesn't look right.

I just tested ffmpeg cli with -seg_duration 4 and -seg_duration 400. 
The latter failed with "Value 400.00 for parameter 
'seg_duration' out of range [0 - 2147.48]" and the former produced 
segments of duration 4 seconds each.


The field type is AV_OPT_TYPE_DURATION, and the avutil parser returns a 
microsecond value to the caller, but it expects the user string to be 
either HH:MM:SS or MM:SS or S+. Millisecond and microsecond values can 
be fed, with a suffix of ms or us, respectively.





this code is working for me:

ret |= av_opt_set_int(obj, "seg_duration",  1000, 0);



if you look in the declarations of options in dashenc.c:

#if FF_API_DASH_MIN_SEG_DURATION
{ "min_seg_duration", "minimum segment duration (in microseconds) 
(will be deprecated)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { .i64 
= 500 }, 0, INT_MAX, E },

#endif
{ "seg_duration", "segment duration (in seconds, fractional value 
can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 
500 }, 0, INT_MAX, E },



see the default value:

.i64 = 500




/alfred
___
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] fix typo in dashenc

2019-06-04 Thread Gyan



On 04-06-2019 04:28 PM, Alfred E. Heggestad wrote:

Hi Karthick,

thanks for your feedback. here is an updated patch
as you suggested.






From 7879e39c25ede24693f166eb6a63094757d9fb1e Mon Sep 17 00:00:00 2001
From: "Alfred E. Heggestad" 
Date: Tue, 4 Jun 2019 09:39:59 +0200
Subject: [PATCH] dashenc: fix typo in seg_duration description

doc: fix typo (seconds -> microseconds)
---
 doc/muxers.texi   | 2 +-
 libavformat/dashenc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index c73719c421..be02912b29 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -232,7 +232,7 @@ ffmpeg -re -i  -map 0 -map 0 -c:a 
libfdk_aac -c:v libx264

 @item -min_seg_duration @var{microseconds}
 This is a deprecated option to set the segment length in 
microseconds, use @var{seg_duration} instead.

 @item -seg_duration @var{duration}
-Set the segment length in seconds (fractional value can be set). The 
value is
+Set the segment length in microseconds (fractional value can be set). 
The value is
 treated as average segment duration when @var{use_template} is 
enabled and
 @var{use_timeline} is disabled and as minimum segment duration for 
all the other

 use cases.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 94b198ceb8..a70e9d176c 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1863,7 +1863,7 @@ static const AVOption options[] = {
 #if FF_API_DASH_MIN_SEG_DURATION
 { "min_seg_duration", "minimum segment duration (in microseconds) 
(will be deprecated)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { 
.i64 = 500 }, 0, INT_MAX, E },

 #endif
-    { "seg_duration", "segment duration (in seconds, fractional value 
can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 
500 }, 0, INT_MAX, E },
+    { "seg_duration", "segment duration (in microseconds, fractional 
value can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 
= 500 }, 0, INT_MAX, E },
 { "remove_at_exit", "remove all segments when finished", 
OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { "use_template", "Use SegmentTemplate instead of SegmentList", 
OFFSET(use_template), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
 { "use_timeline", "Use SegmentTimeline in SegmentTemplate", 
OFFSET(use_timeline), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },


This doesn't look right.

I just tested ffmpeg cli with -seg_duration 4 and -seg_duration 400. 
The latter failed with "Value 400.00 for parameter 
'seg_duration' out of range [0 - 2147.48]" and the former produced 
segments of duration 4 seconds each.


The field type is AV_OPT_TYPE_DURATION, and the avutil parser returns a 
microsecond value to the caller, but it expects the user string to be 
either HH:MM:SS or MM:SS or S+. Millisecond and microsecond values can 
be fed, with a suffix of ms or us, respectively.


Gyan
___
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 4/5] startcode: Don't return false positives

2019-06-04 Thread Michael Niedermayer
On Mon, Jun 03, 2019 at 10:59:00PM +, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Sun, Jun 02, 2019 at 12:47:18AM +0200, Andreas Rheinhardt wrote:
> >> Until now the function ff_startcode_find_candidate_c did not really
> >> search for startcodes (the startcode 0x00 0x00 0x01 (used in
> >> MPEG-1/2/4, VC-1 and H.264/5) is the only startcode meant here). Instead
> >> it searched for zero bytes and returned the earliest position of a zero
> >> byte. This of course led to lots of false positives - millions per GB
> >> of video.
> >> This has been changed: The first position of the buffer that
> >> may be part of a four-byte startcode is now returned. This excludes zero
> >> bytes that are known not to belong to a startcode, but zero bytes at the
> >> end of a buffer that might be part of a startcode whose second part is in
> >> the next buffer are also returned. This is in accordance with the
> >> expectations of the current callers of ff_startcode_find_candidate_c,
> >> namely the H.264 parser and the VC-1 parser. This is also the reason why
> >> "find_candidate" in the name of the function has been kept.
> >>
> >> Getting rid of lots of function calls with their accompanying overhead
> >> of course brings a speedup with it: Here are some benchmarks for
> >> a 30.2 Mb/s transport stream A (10 iterations of 8192 runs each) and
> >> another 7.4 Mb/s transport stream B (10 iterations of 131072 runs each)
> >> on an x64 Haswell:
> >>
> >>   |   vanilla   | aligned | current: aligned,
> >>   | (unaligned) |  reads  | no false positives
> >> --|-|-|---
> >> A |411578   |  424503 |323355
> >> B | 55476   |   58326 | 44147
> >>
> >> vanilla refers to the state before the switch to aligned reads;
> >> "aligned reads" refers to the state after the switch to aligned reads.
> >>
> >> (Calls to h264_find_frame_end have been timed; given that the amount
> >> of calls to ff_startcode_find_candidate_c has been reduced considerably,
> >> timing them directly would be worthless.)
> >>
> >> Signed-off-by: Andreas Rheinhardt 
> >> ---
> >>  libavcodec/h264dsp.h   |  7 +--
> >>  libavcodec/startcode.c | 98 +-
> >>  libavcodec/vc1dsp.h|  6 +--
> >>  3 files changed, 91 insertions(+), 20 deletions(-)
> >>
> >> diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h
> >> index cbea3173c6..51de7a4e21 100644
> >> --- a/libavcodec/h264dsp.h
> >> +++ b/libavcodec/h264dsp.h
> >> @@ -108,11 +108,8 @@ typedef struct H264DSPContext {
> >>  void (*h264_add_pixels4_clear)(uint8_t *dst, int16_t *block, int 
> >> stride);
> >>  
> >>  /**
> >> - * Search buf from the start for up to size bytes. Return the index
> >> - * of a zero byte, or >= size if not found. Ideally, use lookahead
> >> - * to filter out any zero bytes that are known to not be followed by
> >> - * one or more further zero bytes and a one byte. Better still, filter
> >> - * out any bytes that form the trailing_zero_8bits syntax element too.
> >> + * Search buf from the start for up to size bytes. Return the first 
> >> 0x00
> >> + * that might be part of a (three or four) byte startcode.
> >>   */
> >>  int (*startcode_find_candidate)(const uint8_t *buf, int size);
> >>  } H264DSPContext;
> >> diff --git a/libavcodec/startcode.c b/libavcodec/startcode.c
> >> index b027c191c0..f6105289f1 100644
> >> --- a/libavcodec/startcode.c
> >> +++ b/libavcodec/startcode.c
> >> @@ -22,7 +22,8 @@
> >>   * @file
> >>   * Accelerated start code search function for start codes common to
> >>   * MPEG-1/2/4 video, VC-1, H.264/5
> >> - * @author Michael Niedermayer 
> >> + * @author Michael Niedermayer ,
> >> + * @author Andreas Rheinhardt 
> >>   */
> >>  
> >>  #include "startcode.h"
> >> @@ -31,20 +32,60 @@
> >>  
> >>  int ff_startcode_find_candidate_c(const uint8_t *buf, int size)
> >>  {
> >> -const uint8_t *start = buf, *end = buf + size;
> >> +const uint8_t *start = buf, *end = buf + size, *temp;
> >>  
> >>  #define INITIALIZATION(mod) do {  
> >>  \
> >> -for (; buf < end && (uintptr_t)buf % mod; buf++)  
> >>  \
> >> -if (!*buf)
> >>  \
> >> -return buf - start;   
> >>  \
> >> +if (end - start <= mod + 1)   
> >>  \
> >> +goto near_end;
> >>  \
> >> +/* From this point on until the end of the MAIN_LOOP, 
> >>  \
> >> + * buf is the earliest possible position of a 0x00
> >>  \
> >> + * immediately preceding a startcode's 0x01, i.e. 
> >>  \
> >> + * everything from start to buf (inclusive) is known  
> >>  \
> >> + * to not contain a startcode's 

Re: [FFmpeg-devel] [PATCH 3/5] startcode: Stop overreading

2019-06-04 Thread Michael Niedermayer
On Mon, Jun 03, 2019 at 10:45:00PM +, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Sun, Jun 02, 2019 at 12:47:17AM +0200, Andreas Rheinhardt wrote:
> >> Up until now ff_startcode_find_candidate_c could overread; it relied on
> >> zero-padding after the buffer in order to function correctly. This has
> >> been changed: No overreads occur any more.
> >> The ultimate goal behind all this is to create a high-performance
> >> function for searching of startcodes that can be applied even in
> >> scenarios where the buffer is not padded.
> >>
> >> Signed-off-by: Andreas Rheinhardt 
> >> ---
> >>  libavcodec/startcode.c | 5 +
> >>  1 file changed, 1 insertion(+), 4 deletions(-)
> >>
> >> diff --git a/libavcodec/startcode.c b/libavcodec/startcode.c
> >> index 373572365b..b027c191c0 100644
> >> --- a/libavcodec/startcode.c
> >> +++ b/libavcodec/startcode.c
> >> @@ -41,10 +41,7 @@ int ff_startcode_find_candidate_c(const uint8_t *buf, 
> >> int size)
> >>  
> >>  #define READ(bitness) AV_RN ## bitness ## A
> >>  #define MAIN_LOOP(bitness, mask1, mask2) do { 
> >>  \
> >> -/* we check p < end instead of p + 3 / 7 because it is
> >> - * simpler and there must be AV_INPUT_BUFFER_PADDING_SIZE
> >> - * bytes at the end. */   
> >>  \
> > 
> >> -for (; buf < end; buf += bitness / 8) 
> >>  \
> >> +for (; buf <= end - bitness / 8; buf += bitness / 8)  
> >>  \
> > 
> > is this faster than subtracting  bitness / 8 from end outside the loop ?
> > if not then i would suggest to do it outside as that means 1 thing less
> > the compiler has to optimize out
> > 
> > thx
> In my tests the compiler calculates end - bitness / 8 only once and
> puts it in a register of its own. But I can do it manually, of course.

A compiler also can change between pointers and indexes, yet you change
that by hand in a previous patch. (so it seems the compiler must have
failed there with a trivial and expected optimization)
I think if one optimizes code at the level of detail that you do here
its better not to depend on the compiler more than needed for optimizing
things on top

Thanks

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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] fix typo in dashenc

2019-06-04 Thread Alfred E. Heggestad

Hi Karthick,

thanks for your feedback. here is an updated patch
as you suggested.






From 7879e39c25ede24693f166eb6a63094757d9fb1e Mon Sep 17 00:00:00 2001
From: "Alfred E. Heggestad" 
Date: Tue, 4 Jun 2019 09:39:59 +0200
Subject: [PATCH] dashenc: fix typo in seg_duration description

doc: fix typo (seconds -> microseconds)
---
 doc/muxers.texi   | 2 +-
 libavformat/dashenc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index c73719c421..be02912b29 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -232,7 +232,7 @@ ffmpeg -re -i  -map 0 -map 0 -c:a libfdk_aac 
-c:v libx264

 @item -min_seg_duration @var{microseconds}
 This is a deprecated option to set the segment length in microseconds, 
use @var{seg_duration} instead.

 @item -seg_duration @var{duration}
-Set the segment length in seconds (fractional value can be set). The 
value is
+Set the segment length in microseconds (fractional value can be set). 
The value is

 treated as average segment duration when @var{use_template} is enabled and
 @var{use_timeline} is disabled and as minimum segment duration for all 
the other

 use cases.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 94b198ceb8..a70e9d176c 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1863,7 +1863,7 @@ static const AVOption options[] = {
 #if FF_API_DASH_MIN_SEG_DURATION
 { "min_seg_duration", "minimum segment duration (in microseconds) 
(will be deprecated)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { .i64 
= 500 }, 0, INT_MAX, E },

 #endif
-{ "seg_duration", "segment duration (in seconds, fractional value 
can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 
500 }, 0, INT_MAX, E },
+{ "seg_duration", "segment duration (in microseconds, fractional 
value can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 
500 }, 0, INT_MAX, E },
 { "remove_at_exit", "remove all segments when finished", 
OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { "use_template", "Use SegmentTemplate instead of SegmentList", 
OFFSET(use_template), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
 { "use_timeline", "Use SegmentTimeline in SegmentTemplate", 
OFFSET(use_timeline), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },

--
2.20.1 (Apple Git-117)

___
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] libavformat/qsvenc: repeat mpeg2 missing headers [v2]

2019-06-04 Thread Andreas Håkon
Hi A. Rheinhardt ,


> > Take note that the "dump_extra" filter with the parameter "remove" can be 
> > used to remove
> > the repetition. But contrary to popular belief (IMHO), there is no way to 
> > repeat these
> > headers using a bitstream filter. So for this reason this patch is 
> > necessary.
>
> dump_extra doesn't have a parameter named "remove" at all. You seem to
> confuse it with extract_extradata.

Yes, sorry! You're right. I'm speaking about the use of the "extract_extradata" 
filter with
the "remove" parameter to remove unneeded headers in other containerss.

Thank you.
Regards.
A.H.

---

___
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] Force PCR pid in a PROGRAM

2019-06-04 Thread Andreas Håkon
Hi,

Before coding of a new patch, I prefer to ask here for your ideas and thus 
improve the changes
of acceptance of the patch.

I posted before a patch to select which pid will carry the PCR timestamps. This 
makes sense in
several scenarios: when using a non-video stream to carry PCR, when using 
multiple video
streams, and son on. See it here:
https://patchwork.ffmpeg.org/patch/12874/

However, this patch doesn’t support multiple programs, as only one stream can 
be specified.
Therefore, I like to improve it to allow the selection of the PCR for each 
program.

But, I’m not sure about what the best approach is. Here are some options:

- Enhance the “mpegtsenc” muxer with a multi-program option for selecting the 
PCR.
- Use the “-program” general parameter to mark which stream carries the PCR.

Examples:

$ “ffmpeg ... -f mpegts --progid_pcr_pid 1=101 ...”
   This indicates that for program with id 1 the PCR will be in the pid 101.
$ “ffmpeg ... -program title=Prog1:st=0,pcr:st=1 -f mpegts ...”
   Here the first stream in the Prog1 will carry the PCR.

Please comment on what you prefer/suggest.
Regards.
A. H.

---
___
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] libavformat/qsvenc: repeat mpeg2 missing headers [v2]

2019-06-04 Thread Andreas Rheinhardt
Andreas Håkon:
> On Thursday, 30 de May de 2019 20:48, Reimar Döffinger 
>  wrote:
>> I admit this also applies to the native mpeg2 encoder, so this might be a 
>> design issue
>> in FFmpeg, but it's the background why it feels a bit wrong to do it in the 
>> encoder...
> 
> Take note that the "dump_extra" filter with the parameter "remove" can be 
> used to remove
> the repetition. But contrary to popular belief (IMHO), there is no way to 
> repeat these
> headers using a bitstream filter. So for this reason this patch is necessary.
> 
dump_extra doesn't have a parameter named "remove" at all. You seem to
confuse it with extract_extradata.

- 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] libavformat/qsvenc: repeat mpeg2 missing headers [v2]

2019-06-04 Thread Andreas Håkon
Hi Marton,


‐‐‐ Original Message ‐‐‐
On Thursday, 30 de May de 2019 20:48, Reimar Döffinger 
 wrote:

> On 28.05.2019, at 12:48, Andreas Håkonandreas.ha...@protonmail.com wrote:
>
> > Hi,
> > This patch supersedes #13105 (https://patchwork.ffmpeg.org/patch/13105/)
> > A new (simpler and more robust) implementationof of the reinsertion of the
> > missing headers in the MPEG-2 bitstream from the HW QSV encoder.
> > The problem is quite simple: The bitstream generated by the MPEG-2 QSV
> > encoder only incorporates the SEQ_START_CODE and EXT_START_CODE
> > headers in the first GOP. This generates a result that is not suitable for
> > streaming or broadcasting.
> > With this patch the "mpeg2_qsv" encoder is at the same level as the
> > "mpeg2video", as the software implementation repeats these headers by 
> > default
> > in each GOP.
>
> I am sure I might be missing things, but I would think that this is only 
> necessary
> when muxing into certain containers.
> I.e. I would think when muxing the stream into .mov, .mkv or .nut files your 
> patch
> would only needlessly bloat the size.

Yes and no.

First of all, please let me know which MPEG-2 encoders do not repeat these 
headers
when using MPEG-TS. For streaming repetion is absolutely required. And I feel 
that's
the reason why the native mpeg2 encoder does it.


> I admit this also applies to the native mpeg2 encoder, so this might be a 
> design issue
> in FFmpeg, but it's the background why it feels a bit wrong to do it in the 
> encoder...

Take note that the "dump_extra" filter with the parameter "remove" can be used 
to remove
the repetition. But contrary to popular belief (IMHO), there is no way to 
repeat these
headers using a bitstream filter. So for this reason this patch is necessary.

In any case, if you suggest that this behaviour should be optional, then I can 
add a
parameter to enable it and leave it disabled by default.

You agree?

Regards.
A.H.

---

___
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] libavformat/mpegtsenc: adaptive alignment for teletext PES packets

2019-06-04 Thread Andreas Håkon
Hi Marton,


Thank you for taking the time to review this patch!

‐‐‐ Original Message ‐‐‐
On Sunday, 2 de June de 2019 1:38, Marton Balint  wrote:

> On Wed, 22 May 2019, Andreas Håkon wrote:
>
> > Hi,
> > Patch to generate aligned Teletext PES packets using the MPEG-TS muxer
> > when the TS header contains data.
>
> > The code that generates the PES packets for Teletext data aligns the PES 
> > packets
> > with the boundaries of the TS packets. The strategy used is to insert 
> > padding
> > stuff into the PES header. The size of this padding alignment currently has 
> > a
> > fixed size of 36 bytes. And this value is correct when all of the Teletext
> > TS packets have payload only. However, inserting some data into the TS 
> > header
> > breaks this assumption. In this case, the Teletext PES packets are not 
> > aligned
> > and the end of the PES packet is inserted into an additional TS packet with 
> > a
> > large amount of TS padding.
>
> What is the data that is inserted into the TS header? Can you give an
> example? Are you sure that it is allowed to generate such streams?
> Are you seeing such streams in the wild?

It can vary. For example you can add PCR timestamps inside the Teletext stream
(not very common, but possible).


> The DVB teletext spec is very strict about that PES header size and 0x24
> is hardcoded there.
>
> https://www.etsi.org/deliver/etsi_en/300400_300499/300472/01.03.01_60/en_300472v010301p.pdf

Yes, you're right. The sentence at section "4.2 PES packet format" indicates:

"PES_header_data_length set to "0x24"." And after it adds:

"PTS and other optional fields may be present in the PES header,
but the header length is always fixed for streams
identified in the Program Specific Information (PSI) by the DVB Teletext 
descriptor"

However, the idea of this restriction is to leave space for PTS data even if
it's not present in the PES packet. And if you don't add any additional stuff
in the TS header, the constraint is satisfied.

Perhaps you'd prefer this behavior to be optional?


> So maybe you should use adaptation field stuffing instead to keep the
> alignment?

This is already being done.
The objective is to use the empty space of the PES header when there is data
in the TS header, maintaining the original alignment.


> > +  int header_stuff = (get_ts_payload_start(buf) - buf) - 4;
>
> This is a very bad variable name. Call it adaptation_field_len.

OK.

> > +  if (header_stuff - header_len > 0x24)
> > +  header_stuff = 0;
>
> Are you sure about this check?

YES. When no free space in the PES header then the code is disabled (equivalent
to "adaptation_field_len"/"header_stuff" = 0)... see this line:

> > +  header_len = 0x24 - header_stuff;

And the aligment of the last TS packet is done using TS header stuffing.


So, please Marton, comment if you prefer:
- Change only the ugly name of the var.
- Make behaviour optional.
- Discard the patch.

Regards.
A.H.

---


___
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, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-06-04 Thread Fu, Linjie
> -Original Message-
> From: Fu, Linjie
> Sent: Friday, May 31, 2019 08:35
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [PATCH,v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns
> multiple buffers
> 
> It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to map
> buffer for each slice.
> 
> Currently, assigning new buffer for pkt when multiple buffer returns
> from vaMapBuffer will cover the previous encoded pkt data and lead
> to encode issues.
> 
> Iterate through the buf_list first to find out the total buffer size
> needed for the pkt, allocate the whole pkt to avoid repeated reallocation
> and memcpy, then copy data from each buf to pkt.
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: allocate the whole pkt to avoid repeated reallocation
> and memcpy
> 
>  libavcodec/vaapi_encode.c | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index 2dda451..9c9e5dd 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext
> *avctx,
>  VAAPIEncodeContext *ctx = avctx->priv_data;
>  VACodedBufferSegment *buf_list, *buf;
>  VAStatus vas;
> +int total_size = 0;
> +uint8_t *ptr;
>  int err;
> 
>  err = vaapi_encode_wait(avctx, pic);
> @@ -505,15 +507,21 @@ static int vaapi_encode_output(AVCodecContext
> *avctx,
>  goto fail;
>  }
> 
> +for (buf = buf_list; buf; buf = buf->next)
> +total_size += buf->size;
> +
> +err = av_new_packet(pkt, total_size);
> +ptr = pkt->data;
> +
> +if (err < 0)
> +goto fail_mapped;
> +
>  for (buf = buf_list; buf; buf = buf->next) {
>  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> "(status %08x).\n", buf->size, buf->status);
> 
> -err = av_new_packet(pkt, buf->size);
> -if (err < 0)
> -goto fail_mapped;
> -
> -memcpy(pkt->data, buf->buf, buf->size);
> +memcpy(ptr, buf->buf, buf->size);
> +ptr += buf->size;
>  }
> 
>  if (pic->type == PICTURE_TYPE_IDR)
> --
> 2.7.4

Ping?
This can fix the encoding issue for vaapi_vp8:
ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -f rawvideo 
-pix_fmt yuv420p -s:v 1280x720 -i ./input_I420.yuv -vf 'format=nv12,hwupload' 
-c:v vp8_vaapi -rc_mode CQP -g 1 -global_quality 14 -loop_filter_sharpness 0 
-loop_filter_level 0 -vframes 10 -y out.ivf
___
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/pafvideo: Clear frame buffer later

2019-06-04 Thread Michael Niedermayer
On Sat, May 18, 2019 at 12:27:32AM +0200, Michael Niedermayer wrote:
> This way the clearing can be skipped in case of some errors.
> 
> Fixes: Timeout (11sec -> 344ms)
> Fixes: 
> 14670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PAF_VIDEO_fuzzer-5769534503387136
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/pafvideo.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

will apply patchset

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

There will always be a question for which you do not know the correct answer.


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] avcodec/aacdec_template: skip apply_tns() if max_sfb is 0 (from previous header decode failure)

2019-06-04 Thread Michael Niedermayer
On Sat, May 18, 2019 at 12:01:35PM +0200, Michael Niedermayer wrote:
> Fixes: NULL pointer dereference
> Fixes: 
> 14723/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-5654612436058112
> Fixes: 
> 14724/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-5712607111020544
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/aacdec_template.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


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] avcodec/arbc: Skip tiles in fill_tileX() which are completely outside

2019-06-04 Thread Michael Niedermayer
On Fri, May 10, 2019 at 01:46:49AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2052526848 + 147237888 cannot be represented 
> in type 'int'
> Fixes: 
> 14441/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARBC_fuzzer-5717632944177152
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/arbc.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


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] avcodec/aacdec_fixed: ssign seems always -1 in noise_scale(), simplify

2019-06-04 Thread Michael Niedermayer
On Thu, May 16, 2019 at 01:12:03PM +0200, Michael Niedermayer wrote:
> ---
>  libavcodec/aacdec_fixed.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

will apply patchset

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

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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 V2 2/2] checkasm/vf_gblur: add test for horiz_slice simd

2019-06-04 Thread Ruiling Song
Signed-off-by: Ruiling Song 
---
 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/vf_gblur.c | 67 +++
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 73 insertions(+)
 create mode 100644 tests/checkasm/vf_gblur.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 886ae33167..f5780eedb2 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -35,6 +35,7 @@ CHECKASMOBJS-$(CONFIG_AVCODEC)  += $(AVCODECOBJS-yes)
 AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o
 AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o
 AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o
+AVFILTEROBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 AVFILTEROBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER)  += vf_threshold.o
 AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index bf51e00eab..3e2ec377be 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -162,6 +162,9 @@ static const struct {
 #if CONFIG_COLORSPACE_FILTER
 { "vf_colorspace", checkasm_check_colorspace },
 #endif
+#if CONFIG_GBLUR_FILTER
+{ "vf_gblur", checkasm_check_vf_gblur },
+#endif
 #if CONFIG_HFLIP_FILTER
 { "vf_hflip", checkasm_check_vf_hflip },
 #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 9b8d2f5419..aed15b5fa4 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -71,6 +71,7 @@ void checkasm_check_sw_rgb(void);
 void checkasm_check_utvideodsp(void);
 void checkasm_check_v210dec(void);
 void checkasm_check_v210enc(void);
+void checkasm_check_vf_gblur(void);
 void checkasm_check_vf_hflip(void);
 void checkasm_check_vf_threshold(void);
 void checkasm_check_vp8dsp(void);
diff --git a/tests/checkasm/vf_gblur.c b/tests/checkasm/vf_gblur.c
new file mode 100644
index 00..582bc7cc0f
--- /dev/null
+++ b/tests/checkasm/vf_gblur.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 
+#include "checkasm.h"
+#include "libavfilter/gblur.h"
+
+#define WIDTH 256
+#define HEIGHT 256
+#define PIXELS (WIDTH * HEIGHT)
+#define BUF_SIZE (PIXELS * 4)
+
+#define randomize_buffers(buf, size) \
+do { \
+int j;   \
+float *tmp_buf = (float *)buf;   \
+for (j = 0; j < size; j++)   \
+tmp_buf[j] = (float)(rnd() & 0xFF); \
+} while (0)
+
+void checkasm_check_vf_gblur(void)
+{
+float *dst_ref = av_malloc(BUF_SIZE);
+float *dst_new = av_malloc(BUF_SIZE);
+int i, j;
+int w = WIDTH;
+int h = HEIGHT;
+int steps = 2;
+float nu = 0.101f;
+float bscale = 1.112f;
+GBlurContext s;
+
+declare_func(void, float *dst, int w, int h, int steps, float nu, float 
bscale);
+
+randomize_buffers(dst_ref, PIXELS);
+memcpy(dst_new, dst_ref, BUF_SIZE);
+
+ff_gblur_init();
+
+if (check_func(s.horiz_slice, "horiz_slice")) {
+call_ref(dst_ref, w, h, steps, nu, bscale);
+call_new(dst_new, w, h, steps, nu, bscale);
+
+if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
+fail();
+}
+bench_new(dst_new, w, h, 1, nu, bscale);
+}
+report("horiz_slice");
+av_freep(_ref);
+av_freep(_new);
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index c453273cd0..618bde509f 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -27,6 +27,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp
  \
 fate-checkasm-v210enc   \
 fate-checkasm-vf_blend  \
 fate-checkasm-vf_colorspace \
+fate-checkasm-vf_gblur  \
 fate-checkasm-vf_hflip  \
 fate-checkasm-vf_threshold  \
 fate-checkasm-videodsp

[FFmpeg-devel] [PATCH V2 1/2] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-04 Thread Ruiling Song
The horizontal pass get ~2x performance with the patch
under single thread.

Tested overall performance using the command(avx2 enabled):
./ffmpeg -i 1080p.mp4 -vf gblur -f null /dev/null
./ffmpeg -i 1080p.mp4 -vf gblur=threads=1 -f null /dev/null
For single thread, the fps improves from 43 to 60, about 40%.
For multi-thread, the fps improves from 110 to 130, about 20%.

v2:
Fix the bug when steps is not one.

Signed-off-by: Ruiling Song 
---
 libavfilter/gblur.h |  55 ++
 libavfilter/vf_gblur.c  |  71 ++---
 libavfilter/x86/Makefile|   2 +
 libavfilter/x86/vf_gblur.asm| 183 
 libavfilter/x86/vf_gblur_init.c |  36 +++
 5 files changed, 308 insertions(+), 39 deletions(-)
 create mode 100644 libavfilter/gblur.h
 create mode 100644 libavfilter/x86/vf_gblur.asm
 create mode 100644 libavfilter/x86/vf_gblur_init.c

diff --git a/libavfilter/gblur.h b/libavfilter/gblur.h
new file mode 100644
index 00..87129801de
--- /dev/null
+++ b/libavfilter/gblur.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Pascal Getreuer
+ * Copyright (c) 2016 Paul B Mahol
+ *
+ * Redistribution and use in source and binary forms, with or without 
modification,
+ * are permitted provided that the following conditions are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials provided
+ *with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AVFILTER_GBLUR_H
+#define AVFILTER_GBLUR_H
+#include "avfilter.h"
+
+typedef struct GBlurContext {
+const AVClass *class;
+
+float sigma;
+float sigmaV;
+int steps;
+int planes;
+
+int depth;
+int planewidth[4];
+int planeheight[4];
+float *buffer;
+float boundaryscale;
+float boundaryscaleV;
+float postscale;
+float postscaleV;
+float nu;
+float nuV;
+int nb_planes;
+void (*horiz_slice)(float *buffer, int width, int height, int steps, float 
nu, float bscale);
+} GBlurContext;
+void ff_gblur_init(GBlurContext *s);
+void ff_gblur_init_x86(GBlurContext *s);
+#endif
diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index b91a8c074a..e71b33da80 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -30,30 +30,10 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "gblur.h"
 #include "internal.h"
 #include "video.h"
 
-typedef struct GBlurContext {
-const AVClass *class;
-
-float sigma;
-float sigmaV;
-int steps;
-int planes;
-
-int depth;
-int planewidth[4];
-int planeheight[4];
-float *buffer;
-float boundaryscale;
-float boundaryscaleV;
-float postscale;
-float postscaleV;
-float nu;
-float nuV;
-int nb_planes;
-} GBlurContext;
-
 #define OFFSET(x) offsetof(GBlurContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
@@ -72,39 +52,44 @@ typedef struct ThreadData {
 int width;
 } ThreadData;
 
-static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+static void horiz_slice_c(float *buffer, int width, int height, int steps,
+  float nu, float bscale)
 {
-GBlurContext *s = ctx->priv;
-ThreadData *td = arg;
-const int height = td->height;
-const int width = td->width;
-const int slice_start = (height *  jobnr   ) / nb_jobs;
-const int slice_end   = (height * (jobnr+1)) / nb_jobs;
-const float boundaryscale = s->boundaryscale;
-const int steps = s->steps;
-const float nu = s->nu;
-float *buffer = s->buffer;
-int y, x, step;
+int step, x, y;
 float *ptr;
-
-/* Filter horizontally along each row */
-for (y = slice_start; y < slice_end; y++) {
+for (y = 0; y < height; y++) {
 for (step = 0; step < steps; step++) {
 ptr = buffer + width * y;
-ptr[0] *= boundaryscale;
+ptr[0] *= bscale;
 
 /* 

Re: [FFmpeg-devel] [PATCH] fix typo in dashenc

2019-06-04 Thread Jeyapal, Karthick

On 6/4/19 1:15 PM, Alfred E. Heggestad wrote:
>
>
>
> From 885abee797458936e39b4a252e96836d3d6e3213 Mon Sep 17 00:00:00 2001
> From: "Alfred E. Heggestad" 
> Date: Tue, 4 Jun 2019 09:39:59 +0200
> Subject: [PATCH] dashenc: fix typo in seg_duration description
>
> ---
>  libavformat/dashenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 94b198ceb8..a70e9d176c 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1863,7 +1863,7 @@ static const AVOption options[] = {
>  #if FF_API_DASH_MIN_SEG_DURATION
>  { "min_seg_duration", "minimum segment duration (in microseconds) (will 
> be deprecated)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { .i64 = 500 
> }, 0, INT_MAX, E },
>  #endif
> -{ "seg_duration", "segment duration (in seconds, fractional value can be 
> set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 500 }, 0, 
> INT_MAX, E },
> +{ "seg_duration", "segment duration (in microseconds, fractional value 
> can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 500 }, 
> 0, INT_MAX, E },
>  { "remove_at_exit", "remove all segments when finished", 
> OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
>  { "use_template", "Use SegmentTemplate instead of SegmentList", 
> OFFSET(use_template), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
>  { "use_timeline", "Use SegmentTimeline in SegmentTemplate", 
> OFFSET(use_timeline), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },

Thanks for the typo fix. Could I also ask you fix the same typo error in 
muxers.texi for seg_duration,?
Cleaner way to fix both in the same commit. 

Regards,
Karthick 

___
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/hls: add http 2.0 version number compare for the http_multiple

2019-06-04 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 7b29b3f5d1..ab4e7b7d50 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1467,7 +1467,7 @@ reload:
 uint8_t *http_version_opt = NULL;
 int r = av_opt_get(v->input, "http_version", AV_OPT_SEARCH_CHILDREN, 
_version_opt);
 if (r >= 0) {
-c->http_multiple = strncmp((const char *)http_version_opt, "1.1", 
3) == 0;
+c->http_multiple = (!strncmp((const char *)http_version_opt, 
"1.1", 3) || !strncmp((const char *)http_version_opt, "2.0", 3));
 av_freep(_version_opt);
 }
 }
-- 
2.17.2 (Apple Git-113)



___
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] fix typo in dashenc

2019-06-04 Thread Steven Liu
Alfred E. Heggestad  于2019年6月4日周二 下午3:52写道:
>
>
>
>
>  From 885abee797458936e39b4a252e96836d3d6e3213 Mon Sep 17 00:00:00 2001
> From: "Alfred E. Heggestad" 
> Date: Tue, 4 Jun 2019 09:39:59 +0200
> Subject: [PATCH] dashenc: fix typo in seg_duration description
>
> ---
>   libavformat/dashenc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 94b198ceb8..a70e9d176c 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1863,7 +1863,7 @@ static const AVOption options[] = {
>   #if FF_API_DASH_MIN_SEG_DURATION
>   { "min_seg_duration", "minimum segment duration (in microseconds)
> (will be deprecated)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { .i64
> = 500 }, 0, INT_MAX, E },
>   #endif
> -{ "seg_duration", "segment duration (in seconds, fractional value
> can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 =
> 500 }, 0, INT_MAX, E },
> +{ "seg_duration", "segment duration (in microseconds, fractional
> value can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 =
> 500 }, 0, INT_MAX, E },
>   { "remove_at_exit", "remove all segments when finished",
> OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
>   { "use_template", "Use SegmentTemplate instead of SegmentList",
> OFFSET(use_template), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
>   { "use_timeline", "Use SegmentTimeline in SegmentTemplate",
> OFFSET(use_timeline), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
> --
> 2.20.1 (Apple Git-117)
>
> ___
> 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".

LGTM

Thanks

Steven
___
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,v3] lavf/qsvvpp:allocate continuous memory

2019-06-04 Thread Linjie Fu
Mediasdk calls CMRT to copy from video to system memory and requires
memory to be continuously allocated across Y and UV.

Add a new path to allocate continuous memory when using system out.
Use av_frame_get_buffer to arrange data according to pixfmt, and remove
the introduced plane_padding.

Signed-off-by: Linjie Fu 
---
 libavfilter/qsvvpp.c | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 5cd1d5d345..c06171444f 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -350,7 +350,7 @@ static QSVFrame *query_frame(QSVVPPContext *s, AVFilterLink 
*outlink)
 {
 AVFilterContext *ctx = outlink->src;
 QSVFrame*out_frame;
-int  ret;
+int  i, ret;
 
 clear_unused_frames(s->out_frame_list);
 
@@ -374,12 +374,26 @@ static QSVFrame *query_frame(QSVVPPContext *s, 
AVFilterLink *outlink)
 out_frame->surface = (mfxFrameSurface1 *)out_frame->frame->data[3];
 } else {
 /* Get a frame with aligned dimensions.
- * Libmfx need system memory being 128x64 aligned */
-out_frame->frame = ff_get_video_buffer(outlink,
-   FFALIGN(outlink->w, 128),
-   FFALIGN(outlink->h, 64));
-if (!out_frame->frame)
+ * Libmfx need system memory being 128x64 aligned
+ * and continuously allocated across Y and UV */
+out_frame->frame = av_frame_alloc();
+if (!out_frame->frame) {
 return NULL;
+}
+
+out_frame->frame->width  = FFALIGN(outlink->w, 128);
+out_frame->frame->height = FFALIGN(outlink->h, 64);
+out_frame->frame->format = outlink->format;
+
+ret = av_frame_get_buffer(out_frame->frame, 128);
+if (ret < 0)
+return NULL;
+
+/* remove plane_padding introduced by av_frame_get_buffer */
+for (i = 1; i < 4; i++) {
+if (out_frame->frame->data[i])
+out_frame->frame->data[i] -= i * 128;
+}
 
 out_frame->frame->width  = outlink->w;
 out_frame->frame->height = outlink->h;
-- 
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] fix typo in dashenc

2019-06-04 Thread Alfred E. Heggestad




From 885abee797458936e39b4a252e96836d3d6e3213 Mon Sep 17 00:00:00 2001
From: "Alfred E. Heggestad" 
Date: Tue, 4 Jun 2019 09:39:59 +0200
Subject: [PATCH] dashenc: fix typo in seg_duration description

---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 94b198ceb8..a70e9d176c 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1863,7 +1863,7 @@ static const AVOption options[] = {
 #if FF_API_DASH_MIN_SEG_DURATION
 { "min_seg_duration", "minimum segment duration (in microseconds) 
(will be deprecated)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { .i64 
= 500 }, 0, INT_MAX, E },

 #endif
-{ "seg_duration", "segment duration (in seconds, fractional value 
can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 
500 }, 0, INT_MAX, E },
+{ "seg_duration", "segment duration (in microseconds, fractional 
value can be set)", OFFSET(seg_duration), AV_OPT_TYPE_DURATION, { .i64 = 
500 }, 0, INT_MAX, E },
 { "remove_at_exit", "remove all segments when finished", 
OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { "use_template", "Use SegmentTemplate instead of SegmentList", 
OFFSET(use_template), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
 { "use_timeline", "Use SegmentTimeline in SegmentTemplate", 
OFFSET(use_timeline), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },

--
2.20.1 (Apple Git-117)

___
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 1/2] lavf/vf_transpose: add exif orientation support

2019-06-04 Thread Paul B Mahol
On 5/31/19, Jun Li  wrote:
> Add exif orientation support and expose an option.
> ---
>  libavfilter/hflip.h|   2 +
>  libavfilter/transpose.h|  14 
>  libavfilter/vf_hflip.c |  40 ++---
>  libavfilter/vf_transpose.c | 161 -
>  4 files changed, 185 insertions(+), 32 deletions(-)
>
> diff --git a/libavfilter/hflip.h b/libavfilter/hflip.h
> index 204090dbb4..4e89bae3fc 100644
> --- a/libavfilter/hflip.h
> +++ b/libavfilter/hflip.h
> @@ -35,5 +35,7 @@ typedef struct FlipContext {
>
>  int ff_hflip_init(FlipContext *s, int step[4], int nb_planes);
>  void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes);
> +int ff_hflip_config_props(FlipContext* s, AVFilterLink *inlink);
> +int ff_hflip_filter_slice(FlipContext *s, AVFrame *in, AVFrame *out, int
> job, int nb_jobs, int vlifp);
>
>  #endif /* AVFILTER_HFLIP_H */
> diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h
> index aa262b9487..5da08bddc0 100644
> --- a/libavfilter/transpose.h
> +++ b/libavfilter/transpose.h
> @@ -34,4 +34,18 @@ enum TransposeDir {
>  TRANSPOSE_VFLIP,
>  };
>
> +enum OrientationType {
> +ORIENTATION_AUTO_TRANSPOSE = -2,
> +ORIENTATION_AUTO_FLIP = -1,
> +ORIENTATION_NONE = 0,
> +ORIENTATION_NORMAL,
> +ORIENTATION_HFLIP,
> +ORIENTATION_ROTATE180,
> +ORIENTATION_VFLIP,
> +ORIENTATION_HFLIP_ROTATE270CW,
> +ORIENTATION_ROTATE90CW,
> +ORIENTATION_HFLIP_ROTATE90CW,
> +ORIENTATION_ROTATE270CW
> +};
> +
>  #endif
> diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
> index b77afc77fc..d24ca5c2e7 100644
> --- a/libavfilter/vf_hflip.c
> +++ b/libavfilter/vf_hflip.c
> @@ -125,9 +125,8 @@ static void hflip_qword_c(const uint8_t *ssrc, uint8_t
> *ddst, int w)
>  dst[j] = src[-j];
>  }
>
> -static int config_props(AVFilterLink *inlink)
> +int ff_hflip_config_props(FlipContext* s, AVFilterLink *inlink)
>  {
> -FlipContext *s = inlink->dst->priv;
>  const AVPixFmtDescriptor *pix_desc =
> av_pix_fmt_desc_get(inlink->format);
>  const int hsub = pix_desc->log2_chroma_w;
>  const int vsub = pix_desc->log2_chroma_h;
> @@ -144,6 +143,12 @@ static int config_props(AVFilterLink *inlink)
>  return ff_hflip_init(s, s->max_step, nb_planes);
>  }
>
> +static int config_props(AVFilterLink *inlink)
> +{
> +FlipContext *s = inlink->dst->priv;
> +return ff_hflip_config_props(s, inlink);
> +}
> +
>  int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
>  {
>  int i;
> @@ -170,14 +175,10 @@ typedef struct ThreadData {
>  AVFrame *in, *out;
>  } ThreadData;
>
> -static int filter_slice(AVFilterContext *ctx, void *arg, int job, int
> nb_jobs)
> +int ff_hflip_filter_slice(FlipContext *s, AVFrame *in, AVFrame *out, int
> job, int nb_jobs, int vflip)
>  {
> -FlipContext *s = ctx->priv;
> -ThreadData *td = arg;
> -AVFrame *in = td->in;
> -AVFrame *out = td->out;
>  uint8_t *inrow, *outrow;
> -int i, plane, step;
> +int i, plane, step, outlinesize;
>
>  for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane];
> plane++) {
>  const int width  = s->planewidth[plane];
> @@ -187,19 +188,36 @@ static int filter_slice(AVFilterContext *ctx, void
> *arg, int job, int nb_jobs)
>
>  step = s->max_step[plane];
>
> -outrow = out->data[plane] + start * out->linesize[plane];
> -inrow  = in ->data[plane] + start * in->linesize[plane] + (width -
> 1) * step;
> +if (vflip) {
> +outrow = out->data[plane] + (height - start - 1)*
> out->linesize[plane];
> +outlinesize = -out->linesize[plane];
> +} else {
> +outrow = out->data[plane] + start * out->linesize[plane];
> +outlinesize = out->linesize[plane];
> +}
> +
> +inrow = in->data[plane] + start * in->linesize[plane] +  (width -
> 1) * step;
> +
>  for (i = start; i < end; i++) {
>  s->flip_line[plane](inrow, outrow, width);
>
>  inrow  += in ->linesize[plane];
> -outrow += out->linesize[plane];
> +outrow += outlinesize;
>  }
>  }
>
>  return 0;
>  }
>
> +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int
> nb_jobs)
> +{
> +FlipContext *s = ctx->priv;
> +ThreadData *td = arg;
> +AVFrame *in = td->in;
> +AVFrame *out = td->out;
> +return ff_hflip_filter_slice(s, in, out, job, nb_jobs, 0);
> +}
> +
>  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>  {
>  AVFilterContext *ctx  = inlink->dst;
> diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
> index dd54947bd9..8b5c8d3f50 100644
> --- a/libavfilter/vf_transpose.c
> +++ b/libavfilter/vf_transpose.c
> @@ -39,6 +39,7 @@
>  #include "internal.h"
>  #include "video.h"
>  #include "transpose.h"
> +#include "hflip.h"
>
>  typedef struct TransVtable {
>  void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,

[FFmpeg-devel] [PATCH] avformat/hls: avformat_find_stream_info when the audio list in the variant

2019-06-04 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 19ea88e706..7b29b3f5d1 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1942,7 +1942,7 @@ static int hls_read_header(AVFormatContext *s)
  * but for other streams we can rely on our user calling 
avformat_find_stream_info()
  * on us if they want to.
  */
-if (pls->is_id3_timestamped) {
+if (pls->is_id3_timestamped || (pls->n_renditions > 0 && 
pls->renditions[0]->type == AVMEDIA_TYPE_AUDIO)) {
 ret = avformat_find_stream_info(pls->ctx, NULL);
 if (ret < 0)
 goto fail;
-- 
2.17.2 (Apple Git-113)



___
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 v2] libavcodec/vp8dec: fix the multi-thread HWAccel decode error

2019-06-04 Thread Wang, Shaofei
> -Original Message-
> From: Xiang, Haihao
> Sent: Tuesday, May 28, 2019 12:23 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Wang, Shaofei 
> Subject: Re: [FFmpeg-devel] [PATCH v2] libavcodec/vp8dec: fix the
> multi-thread HWAccel decode error
> 
> On Thu, 2019-03-28 at 13:28 -0400, Shaofei Wang wrote:
> > Fix the issue: https://github.com/intel/media-driver/issues/317
> >
> > the root cause is update_dimensions will be called multple times when
> > decoder thread number is not only 1, but update_dimensions call
> > get_pixel_format in each decode thread will trigger the
> > hwaccel_uninit/hwaccel_init more than once. But only one hwaccel
> > should be shared with all decode threads.
> > in current context,
> > there are 3 situations in the update_dimensions():
> > 1. First time calling. No matter single thread or multithread,
> >get_pixel_format() should be called after dimensions were
> >set;
> > 2. Dimention changed at the runtime. Dimention need to be
> >updated when macroblocks_base is already allocated,
> >get_pixel_format() should be called to recreate new frames
> >according to updated dimention;
> 
> s/Dimention/dimension ?
OK, should be dimension

> BTW this version of patch doesn't address the concern provided when
> reviewing the first version of patch.
> 
> When (width != s->avctx->width || height != s->avctx->height) is true,
> ff_set_dimensions() is called even if s->macroblocks_base is not allocated, so
> why set dim_reset to (s->macroblocks_base != NULL)? I think dim_reset
> should be set to 1.
If s->macroblocks_base is available, it means macroblocks_base of the context 
 has been already allocated by one of threads, so it's a reset operation when
 (width != s->avctx->width...
If s->macroblocks_base is null, it's not allocated yet, and
(width != s->avctx->width..., just dimension need to be updated but it's not a
dim reset operation. Since we only call get_pixel_format() in the first thread 
or
 in the reset operation

> > if (width  != s->avctx->width || ((width+15)/16 != s->mb_width ||
> > (height+15)/16 != s->mb_height) && s->macroblocks_base ||
> >  height != s->avctx->height) { @@ -196,9 +196,12 @@ int
> > update_dimensions(VP8Context *s, int width, int height, int is_vp7)
> >  ret = ff_set_dimensions(s->avctx, width, height);
> >  if (ret < 0)
> >  return ret;
> > +
> > +dim_reset = (s->macroblocks_base != NULL);
> 
> 
> > 3. Multithread first time calling. After decoder init, the
> >other threads will call update_dimensions() at first time
> >to allocate macroblocks_base and set dimensions.
> >But get_pixel_format() is shouldn't be called due to low
> >level frames and context are already created.
> >
> > In this fix, we only call update_dimensions as need.
> >
> > Signed-off-by: Wang, Shaofei 
> > Reviewed-by: Jun, Zhao 
> > Reviewed-by: Haihao Xiang 
> > ---
> > Previous code reviews:
> > 2019-03-06 9:25 GMT+01:00, Wang, Shaofei :
> > > > -Original Message-
> > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > > > Behalf Of Carl Eugen Hoyos
> > > > Sent: Wednesday, March 6, 2019 3:49 PM
> > > > To: FFmpeg development discussions and patches
> > > > 
> > > > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/vp8dec: fix the
> > > > multi-thread HWAccel decode error
> > > >
> > > > 2018-08-09 9:09 GMT+02:00, Jun Zhao :
> > > > > the root cause is update_dimentions call get_pixel_format will
> > > > > trigger the hwaccel_uninit/hwaccel_init , in current context,
> > > > > there are 3 situations in the update_dimentions():
> > > > > 1. First time calling. No matter single thread or multithread,
> > > > >get_pixel_format() should be called after dimentions were
> > > > >set;
> > > > > 2. Dimention changed at the runtime. Dimention need to be
> > > > >updated when macroblocks_base is already allocated,
> > > > >get_pixel_format() should be called to recreate new frames
> > > > >according to updated dimention; 3. Multithread first time
> > > > > calling. After decoder init, the
> > > > >other threads will call update_dimentions() at first time
> > > > >to allocate macroblocks_base and set dimentions.
> > > > >But get_pixel_format() is shouldn't be called due to low
> > > > >level frames and context are already created.
> > > > > In this fix, we only call update_dimentions as need.
> > > > >
> > > > > Signed-off-by: Wang, Shaofei 
> > > > > Reviewed-by: Jun, Zhao 
> > > > > ---
> > > > >  libavcodec/vp8.c |7 +--
> > > > >  1 files changed, 5 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index
> > > > > 3adfeac..18d1ada 100644
> > > > > --- a/libavcodec/vp8.c
> > > > > +++ b/libavcodec/vp8.c
> > > > > @@ -187,7 +187,7 @@ static av_always_inline  int
> > > > > update_dimensions(VP8Context *s, int width, int height, int is_vp7)  {
> > > > >  AVCodecContext *avctx = s->avctx;
> > > > 

[FFmpeg-devel] [PATCH V2 1/2] libavfilter/dnn: add script to convert TensorFlow model (.pb) to native model (.model)

2019-06-04 Thread Guo, Yejun
For example, given TensorFlow model file espcn.pb,
to generate native model file espcn.model, just run:
python convert.py espcn.pb

In current implementation, the native model file is generated for
specific dnn network with hard-code python scripts maintained out of ffmpeg.
For example, srcnn network used by vf_sr is generated with
https://github.com/HighVoltageRocknRoll/sr/blob/master/generate_header_and_model.py#L85

In this patch, the script is designed as a general solution which
converts general TensorFlow model .pb file into .model file. The script
now has some tricky to be compatible with current implemention, will
be refined step by step.

The script is also added into ffmpeg source tree. It is expected there
will be many more patches and community needs the ownership of it.

Another technical direction is to do the conversion in c/c++ code within
ffmpeg source tree. While .pb file is organized with protocol buffers,
it is not easy to do such work with tiny c/c++ code, see more discussion
at http://ffmpeg.org/pipermail/ffmpeg-devel/2019-May/244496.html. So,
choose the python script.

Signed-off-by: Guo, Yejun 
---
 .gitignore|   1 +
 libavfilter/dnn/python/convert.py |  52 ++
 libavfilter/dnn/python/convert_from_tensorflow.py | 201 ++
 3 files changed, 254 insertions(+)
 create mode 100644 libavfilter/dnn/python/convert.py
 create mode 100644 libavfilter/dnn/python/convert_from_tensorflow.py

diff --git a/.gitignore b/.gitignore
index 0e57cb0..45420da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,4 @@
 /lcov/
 /src
 /mapfile
+/libavfilter/dnn/python/__pycache__/
diff --git a/libavfilter/dnn/python/convert.py 
b/libavfilter/dnn/python/convert.py
new file mode 100644
index 000..662b429
--- /dev/null
+++ b/libavfilter/dnn/python/convert.py
@@ -0,0 +1,52 @@
+# Copyright (c) 2019 Guo Yejun
+#
+# 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
+# 
==
+
+# verified with Python 3.5.2 on Ubuntu 16.04
+import argparse
+import os
+from convert_from_tensorflow import *
+
+def get_arguments():
+parser = argparse.ArgumentParser(description='generate native mode model 
with weights from deep learning model')
+parser.add_argument('--outdir', type=str, default='./', help='where to put 
generated files')
+parser.add_argument('--infmt', type=str, default='tensorflow', 
help='format of the deep learning model')
+parser.add_argument('infile', help='path to the deep learning model with 
weights')
+
+return parser.parse_args()
+
+def main():
+args = get_arguments()
+
+if not os.path.isfile(args.infile):
+print('the specified input file %s does not exist' % args.infile)
+exit(1)
+
+if not os.path.exists(args.outdir):
+print('create output directory %s' % args.outdir)
+os.mkdir(args.outdir)
+
+basefile = os.path.split(args.infile)[1]
+basefile = os.path.splitext(basefile)[0]
+outfile = os.path.join(args.outdir, basefile) + '.model'
+
+if args.infmt == 'tensorflow':
+convert_from_tensorflow(args.infile, outfile)
+
+if __name__ == '__main__':
+main()
diff --git a/libavfilter/dnn/python/convert_from_tensorflow.py 
b/libavfilter/dnn/python/convert_from_tensorflow.py
new file mode 100644
index 000..37049e5
--- /dev/null
+++ b/libavfilter/dnn/python/convert_from_tensorflow.py
@@ -0,0 +1,201 @@
+# Copyright (c) 2019 Guo Yejun
+#
+# 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
+# 

[FFmpeg-devel] [PATCH V2 2/2] doc/filters: update how to generate native model for sr filter

2019-06-04 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 doc/filters.texi | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5db8e03..911cf69 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16554,10 +16554,13 @@ Efficient Sub-Pixel Convolutional Neural Network 
model (ESPCN).
 See @url{https://arxiv.org/abs/1609.05158}.
 @end itemize
 
-Training scripts as well as scripts for model generation can be found at
+Training scripts as well as scripts for model file (.pb) saving can be found at
 @url{https://github.com/XueweiMeng/sr/tree/sr_dnn_native}. Original repository
 is at @url{https://github.com/HighVoltageRocknRoll/sr.git}.
 
+Native model files (.model) can be generated from TensorFlow model
+files (.pb) by using libavfilter/dnn/python/convert.py
+
 The filter accepts the following options:
 
 @table @option
-- 
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".

Re: [FFmpeg-devel] [PATCH v3 3/5] libx265: Update ROI behaviour to match documentation

2019-06-04 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Mark Thompson
> Sent: Tuesday, June 04, 2019 7:19 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v3 3/5] libx265: Update ROI behaviour to match
> documentation
> 
> Equivalent to the previous patch for libx264.
> ---
>  libavcodec/libx265.c | 44 +++-
>  1 file changed, 23 insertions(+), 21 deletions(-)
> 
> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
> index f56def53d5..665b780643 100644
> --- a/libavcodec/libx265.c
> +++ b/libavcodec/libx265.c
> @@ -316,27 +316,36 @@ static av_cold int
> libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
>  int mb_size = (ctx->params->rc.qgSize == 8) ? 8 : 16;
>  int mbx = (frame->width + mb_size - 1) / mb_size;
>  int mby = (frame->height + mb_size - 1) / mb_size;
> +int qp_range = 51 + 6 * (pic->bitDepth - 8);
>  int nb_rois;
> -AVRegionOfInterest *roi;
> +const AVRegionOfInterest *roi;
> +uint32_t roi_size;
>  float *qoffsets; /* will be freed after encode is called.
> */
> +
> +roi = (const AVRegionOfInterest*)sd->data;
> +roi_size = roi->self_size;
> +if (!roi_size || sd->size % roi_size != 0) {
> +av_log(ctx, AV_LOG_ERROR, "Invalid
> AVRegionOfInterest.self_size.\n");
> +return AVERROR(EINVAL);
> +}
> +nb_rois = sd->size / roi_size;
> +
>  qoffsets = av_mallocz_array(mbx * mby, sizeof(*qoffsets));
>  if (!qoffsets)
>  return AVERROR(ENOMEM);
> 
> -nb_rois = sd->size / sizeof(AVRegionOfInterest);
> -roi = (AVRegionOfInterest*)sd->data;
> -for (int count = 0; count < nb_rois; count++) {
> -int starty = FFMIN(mby, roi->top / mb_size);
> -int endy   = FFMIN(mby, (roi->bottom + mb_size - 1)/
> mb_size);
> -int startx = FFMIN(mbx, roi->left / mb_size);
> -int endx   = FFMIN(mbx, (roi->right + mb_size - 1)/
> mb_size);
> +// This list must be iterated in reverse because the first
> +// region in the list applies when regions overlap.
> +for (int i = nb_rois - 1; i >= 0; i--) {
> +int startx, endx, starty, endy;
>  float qoffset;
> 
> -if (roi->self_size == 0) {
> -av_free(qoffsets);
> -av_log(ctx, AV_LOG_ERROR,
> "AVRegionOfInterest.self_size must be set to sizeof(AVRegionOfInterest).\n");
> -return AVERROR(EINVAL);
> -}
> +roi = (const AVRegionOfInterest*)(sd->data + roi_size * i);
> +
> +starty = FFMIN(mby, roi->top / mb_size);
> +endy   = FFMIN(mby, (roi->bottom + mb_size - 1)/
> mb_size);
> +startx = FFMIN(mbx, roi->left / mb_size);
> +endx   = FFMIN(mbx, (roi->right + mb_size - 1)/
> mb_size);
> 
>  if (roi->qoffset.den == 0) {
>  av_free(qoffsets);
> @@ -344,18 +353,11 @@ static av_cold int
> libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
>  return AVERROR(EINVAL);
>  }
>  qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den;
> -qoffset = av_clipf(qoffset, -1.0f, 1.0f);
> -
> -/* qp range of x265 is from 0 to 51, just choose 25 as the
> scale value,
> - * so the range of final qoffset is [-25.0, 25.0].
> - */
> -qoffset = qoffset * 25;
> +qoffset = av_clipf(qoffset * qp_range, -qp_range,
> +qp_range);
> 
>  for (int y = starty; y < endy; y++)
>  for (int x = startx; x < endx; x++)
>  qoffsets[x + y*mbx] = qoffset;
> -
> -roi = (AVRegionOfInterest*)((char*)roi + roi->self_size);
>  }
> 
>  pic->quantOffsets = qoffsets;

looks good to me, thanks.

> --
> 2.20.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 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 v3 2/5] libx264: Update ROI behaviour to match documentation

2019-06-04 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Mark Thompson
> Sent: Tuesday, June 04, 2019 7:19 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v3 2/5] libx264: Update ROI behaviour to match
> documentation
> 
> Fix the quantisation offset - use the whole range, and don't change the
> offset size based on bit depth.
> 
> Iterate the list in reverse order.  The first region in the list is the one
> that applies in the case of overlapping regions.
> ---
>  libavcodec/libx264.c | 53 +---
>  1 file changed, 30 insertions(+), 23 deletions(-)
> 
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 45d07a92fc..dc4b4b100d 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -285,16 +285,18 @@ static int X264_frame(AVCodecContext *ctx,
> AVPacket *pkt, const AVFrame *frame,
>  int nnal, i, ret;
>  x264_picture_t pic_out = {0};
>  int pict_type;
> +int bit_depth;
>  int64_t *out_opaque;
>  AVFrameSideData *sd;
> 
>  x264_picture_init( >pic );
>  x4->pic.img.i_csp   = x4->params.i_csp;
>  #if X264_BUILD >= 153
> -if (x4->params.i_bitdepth > 8)
> +bit_depth = x4->params.i_bitdepth;
>  #else
> -if (x264_bit_depth > 8)
> +bit_depth = x264_bit_depth;
>  #endif
> +if (bit_depth > 8)
>  x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
>  x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
> 
> @@ -359,45 +361,50 @@ static int X264_frame(AVCodecContext *ctx,
> AVPacket *pkt, const AVFrame *frame,
>  if (frame->interlaced_frame == 0) {
>  int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE;
>  int mby = (frame->height + MB_SIZE - 1) / MB_SIZE;
> +int qp_range = 51 + 6 * (bit_depth - 8);
>  int nb_rois;
> -AVRegionOfInterest* roi;
> -float* qoffsets;
> +const AVRegionOfInterest *roi;
> +uint32_t roi_size;
> +float *qoffsets;
> +
> +roi = (const AVRegionOfInterest*)sd->data;
> +roi_size = roi->self_size;
> +if (!roi_size || sd->size % roi_size != 0) {
> +av_log(ctx, AV_LOG_ERROR, "Invalid
> AVRegionOfInterest.self_size.\n");
> +return AVERROR(EINVAL);
> +}
> +nb_rois = sd->size / roi_size;
> +
>  qoffsets = av_mallocz_array(mbx * mby,
> sizeof(*qoffsets));
>  if (!qoffsets)
>  return AVERROR(ENOMEM);
> 
> -nb_rois = sd->size / sizeof(AVRegionOfInterest);
> -roi = (AVRegionOfInterest*)sd->data;
> -for (int count = 0; count < nb_rois; count++) {
> -int starty = FFMIN(mby, roi->top / MB_SIZE);
> -int endy   = FFMIN(mby, (roi->bottom +
> MB_SIZE - 1)/ MB_SIZE);
> -int startx = FFMIN(mbx, roi->left / MB_SIZE);
> -int endx   = FFMIN(mbx, (roi->right + MB_SIZE -
> 1)/ MB_SIZE);
> +// This list must be iterated in reverse because the
> first
> +// region in the list applies when regions overlap.
> +for (int i = nb_rois - 1; i >= 0; i--) {
> +int startx, endx, starty, endy;
>  float qoffset;
> 
> +roi = (const AVRegionOfInterest*)(sd->data +
> roi_size * i);
> +
> +starty = FFMIN(mby, roi->top / MB_SIZE);
> +endy   = FFMIN(mby, (roi->bottom + MB_SIZE -
> 1)/ MB_SIZE);
> +startx = FFMIN(mbx, roi->left / MB_SIZE);
> +endx   = FFMIN(mbx, (roi->right + MB_SIZE -
> 1)/ MB_SIZE);
> +
>  if (roi->qoffset.den == 0) {
>  av_free(qoffsets);
> -av_log(ctx, AV_LOG_ERROR,
> "AVRegionOfInterest.qoffset.den should not be zero.\n");
> +av_log(ctx, AV_LOG_ERROR,
> "AVRegionOfInterest.qoffset.den must not be zero.\n");
>  return AVERROR(EINVAL);
>  }
>  qoffset = roi->qoffset.num * 1.0f /
> roi->qoffset.den;
> -qoffset = av_clipf(qoffset, -1.0f, 1.0f);
> -
> -// 25 is a number that I think it is a possible
> proper scale value.
> -qoffset = qoffset * 25;
> +qoffset = av_clipf(qoffset * qp_range, -qp_range,
> +qp_range);
> 
>  for (int y = starty; y < endy; y++) {
>  for (int x = startx; x < endx; x++) {
>  

Re: [FFmpeg-devel] [PATCH V1 1/5] lavf/hls: Update av_log() log message

2019-06-04 Thread Liu Steven


> 在 2019年6月4日,下午1:38,Jun Zhao  写道:
> 
> From: Jun Zhao 
> 
> Pass correct pointer to av_log() and update some error/warning message,
> it's will help the debugging
> 
> Signed-off-by: Jun Zhao 
> ---
> libavformat/hls.c |   22 ++
> 1 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 19ea88e..1b45fe2 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -476,17 +476,23 @@ static struct rendition *new_rendition(HLSContext *c, 
> struct rendition_info *inf
>  * AVC SEI RBSP anyway */
> return NULL;
> 
> -if (type == AVMEDIA_TYPE_UNKNOWN)
> +if (type == AVMEDIA_TYPE_UNKNOWN) {
> +av_log(c, AV_LOG_WARNING, "Can't support the type: %s\n", 
> info->type);
> return NULL;
> +}
> 
> /* URI is mandatory for subtitles as per spec */
> -if (type == AVMEDIA_TYPE_SUBTITLE && !info->uri[0])
> +if (type == AVMEDIA_TYPE_SUBTITLE && !info->uri[0]) {
> +av_log(c, AV_LOG_ERROR, "The URI tag is REQUIRED for subtitle.\n");
> return NULL;
> +}
> 
> /* TODO: handle subtitles (each segment has to parsed separately) */
> if (c->ctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)
> -if (type == AVMEDIA_TYPE_SUBTITLE)
> +if (type == AVMEDIA_TYPE_SUBTITLE) {
> +av_log(c, AV_LOG_WARNING, "Can't support the subtitle(uri: 
> %s)\n", info->uri);
> return NULL;
> +}
> 
> rend = av_mallocz(sizeof(struct rendition));
> if (!rend)
> @@ -1202,12 +1208,12 @@ static int open_input(HLSContext *c, struct playlist 
> *pls, struct segment *seg,
> if (open_url(pls->parent, , seg->key, c->avio_opts, opts, 
> NULL) == 0) {
> ret = avio_read(pb, pls->key, sizeof(pls->key));
> if (ret != sizeof(pls->key)) {
> -av_log(NULL, AV_LOG_ERROR, "Unable to read key file 
> %s\n",
> +av_log(pls->parent, AV_LOG_ERROR, "Unable to read key 
> file %s\n",
>seg->key);
> }
> ff_format_io_close(pls->parent, );
> } else {
> -av_log(NULL, AV_LOG_ERROR, "Unable to open key file %s\n",
> +av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file 
> %s\n",
>seg->key);
> }
> av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url));
> @@ -1419,7 +1425,7 @@ reload:
> reload_interval = v->target_duration / 2;
> }
> if (v->cur_seq_no < v->start_seq_no) {
> -av_log(NULL, AV_LOG_WARNING,
> +av_log(v->parent, AV_LOG_WARNING,
>"skipping %d segments ahead, expired from playlists\n",
>v->start_seq_no - v->cur_seq_no);
> v->cur_seq_no = v->start_seq_no;
> @@ -1800,7 +1806,7 @@ static int hls_read_header(AVFormatContext *s)
> goto fail;
> 
> if (c->n_variants == 0) {
> -av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
> +av_log(s, AV_LOG_WARNING, "Empty playlist\n");
> ret = AVERROR_EOF;
> goto fail;
> }
> @@ -1815,7 +1821,7 @@ static int hls_read_header(AVFormatContext *s)
> }
> 
> if (c->variants[0]->playlists[0]->n_segments == 0) {
> -av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
> +av_log(s, AV_LOG_WARNING, "Empty segment\n");
> ret = AVERROR_EOF;
> goto fail;
> }
> -- 
> 1.7.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”.

LGTM

Thanks

Steven



___
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/h264_sei: Add experimental acces to truncated SEI data

2019-06-04 Thread Reimar Döffinger


On 04.06.2019, at 00:21, Antonin Gouzer  wrote:

> ---
> Some codecs editors had miss interpreted the H264 standart and
> have coded a wrong size in the SEI data.
> size = SEI size + 1.
> The SEI data is detected as "truncated"
> Ex: 
> https://drive.google.com/file/d/1cNtLwnfPnyJnYqE7OYhU3SCoLRtuXIUM/view?usp=sharing
> Command:
> ffprobe -strict experimental -print_format xml -show_frames -read_intervals 
> %+0.04 truncated.h264 
> This (simple) patch add the possibility to read this false truncated SEI data.
> by setting strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL.
> The error remain logged.
> 
> Thanks in advance !
> 

> @@ -425,27 +425,28 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext 
> *gb,
> } while (get_bits(gb, 8) == 255);
> 
> if (size > get_bits_left(gb) / 8) {
> -av_log(logctx, AV_LOG_ERROR, "SEI type %d size %d truncated at 
> %d\n",
> +av_log(avctx, AV_LOG_ERROR, "SEI type %d size %d truncated at 
> %d\n",
>type, 8*size, get_bits_left(gb));
> -return AVERROR_INVALIDDATA;
> +if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)
> +return AVERROR_INVALIDDATA;
> }
> next = get_bits_count(gb) + 8 * size;

This doesn't seem right, shouldn't you adjust "size"?
Also if this is reasonably common shouldn't we accept at least the exactly 
off-by-one case at the default settings?
___
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 V1 5/5] lavf/webvttenc: fix ffmpeg -h full can't display webvtt muxer

2019-06-04 Thread Jun Zhao
From: Jun Zhao 

fix ffmpeg -h full can't display webvtt muxer

Signed-off-by: Jun Zhao 
---
 libavformat/webvttenc.c |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index 61b7f54..b4e8a61 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -26,6 +26,7 @@
 
 #include "avformat.h"
 #include "internal.h"
+#include "libavutil/opt.h"
 
 static void webvtt_write_time(AVIOContext *pb, int64_t millisec)
 {
@@ -94,6 +95,17 @@ static int webvtt_write_packet(AVFormatContext *ctx, 
AVPacket *pkt)
 return 0;
 }
 
+static const AVOption options[] = {
+{ NULL }
+};
+
+static const AVClass webvtt_muxer_class = {
+.class_name  = "WebVTT muxer",
+.item_name   = av_default_item_name,
+.option  = options,
+.version = LIBAVUTIL_VERSION_INT,
+};
+
 AVOutputFormat ff_webvtt_muxer = {
 .name  = "webvtt",
 .long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
@@ -103,4 +115,5 @@ AVOutputFormat ff_webvtt_muxer = {
 .subtitle_codec= AV_CODEC_ID_WEBVTT,
 .write_header  = webvtt_write_header,
 .write_packet  = webvtt_write_packet,
+.priv_class= _muxer_class,
 };
-- 
1.7.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".