Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG decoding uninitialized huffman table

2018-11-08 Thread myp...@gmail.com
On Fri, Nov 9, 2018 at 1:27 PM Eoff, Ullysses A
 wrote:
>
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> > Eoff, Ullysses A
> > Sent: Tuesday, October 30, 2018 11:42 AM
> > To: FFmpeg development discussions and patches 
> > Cc: Zhao, Jun ; Lin, Decai 
> > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG 
> > decoding uninitialized huffman table
> > > -Original Message-
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> > > myp...@gmail.com
> > > Sent: Monday, October 29, 2018 10:52 PM
> > > To: FFmpeg development discussions and patches 
> > > Cc: Zhao, Jun ; Lin, Decai 
> > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG 
> > > decoding uninitialized huffman table
> > >
> > > On Tue, Oct 30, 2018 at 11:41 AM Eoff, Ullysses A
> > >  wrote:
> > > >
> > > > > -Original Message-
> > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> > > > > Of myp...@gmail.com
> > > > > Sent: Monday, October 29, 2018 8:10 PM
> > > > > To: FFmpeg development discussions and patches 
> > > > > 
> > > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG 
> > > > > decoding uninitialized huffman table
> > > > >
> > > > > On Tue, Oct 30, 2018 at 10:41 AM Li, Zhong  wrote:
> > > > > >
> > > > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On 
> > > > > > > Behalf
> > > > > > > Of myp...@gmail.com
> > > > > > > Sent: Tuesday, October 30, 2018 9:02 AM
> > > > > > > To: FFmpeg development discussions and patches
> > > > > > > 
> > > > > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > > > > 
> > > > > > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API 
> > > > > > > MJPEG
> > > > > > > decoding uninitialized huffman table
> > > > > > >
> > > > > > > On Mon, Oct 29, 2018 at 6:39 PM Li, Zhong  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > > > > > > > > Behalf Of Jun Zhao
> > > > > > > > > Sent: Monday, October 29, 2018 6:26 PM
> > > > > > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > > > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > > > > > > 
> > > > > > > > > Subject: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API 
> > > > > > > > > MJPEG
> > > > > > > > > decoding uninitialized huffman table
> > > > > > > > >
> > > > > > > > > From: Jun Zhao 
> > > > > > > > >
> > > > > > > > > Now VA-API HWAccel MJPEG decoding uninitialized huffman 
> > > > > > > > > table, it's
> > > > > > > > > will lead to the decoding error like"Failed to sync surface 
> > > > > > > > > 0x5: 23
> > > > > > > > > (internal decoding error)." in iHD open source driver.
> > > > > > > > >
> > > > > > > > > Signed-off-by: dlin2 
> > > > > > > > > Signed-off-by: Jun Zhao 
> > > > > > > > > ---
> > > > > > > > >  libavcodec/mjpegdec.c |   19 +++
> > > > > > > > >  1 files changed, 19 insertions(+), 0 deletions(-)
> > > > > > > > >
> > > > > > > > > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c 
> > > > > > > > > index
> > > > > > > > > b0cb3ff..89effb6 100644
> > > > > > > > > --- a/libavcodec/mjpegdec.c
> > > > > > > > > +++ b/libavcodec/mjpegdec.c
> > > > > > > > > @@ -75,6 +75,25 @@ static int build_vlc(VLC *vlc, const 
> > > > > > > > > uint8_t
> > > > > > > > > *bits_table, static int 
> > > > > > > > > build_basic_mjpeg_vlc(MJpegDecodeContext *s)
> > > > > > > {
> > > > > > > > >  int ret;
> > > > > > > > > +int i;
> > > > > > > > > +
> > > > > > > > > +/* initialize default huffman tables */
> > > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > > +s->raw_huffman_lengths[0][0][i] =
> > > > > > > > > avpriv_mjpeg_bits_dc_luminance[i + 1];
> > > > > > > > > +for (i = 0; i < 12; i++)
> > > > > > > > > +s->raw_huffman_values[0][0][i] = 
> > > > > > > > > avpriv_mjpeg_val_dc[i];
> > > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > > +s->raw_huffman_lengths[0][1][i] =
> > > > > > > > > avpriv_mjpeg_bits_dc_chrominance[i + 1];
> > > > > > > > > +for (i = 0; i < 12; i++)
> > > > > > > > > +s->raw_huffman_values[0][1][i] = 
> > > > > > > > > avpriv_mjpeg_val_dc[i];
> > > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > > +s->raw_huffman_lengths[1][0][i] =
> > > > > > > > > avpriv_mjpeg_bits_ac_luminance[i + 1];
> > > > > > > > > +for (i = 0; i < 162; i++)
> > > > > > > > > +s->raw_huffman_values[1][0][i] =
> > > > > > > > > avpriv_mjpeg_val_ac_luminance[i];
> > > > > > > > > +for (i = 0; i, le  < 16; i++)
> > > > > > > > > +s->raw_huffman_lengths[1][1][i] =
> > > > > > > > > avpriv_mjpeg_bits_ac_chrominance[i + 1];
> > > > > > > > > +for (i = 0; i < 162; i++)
> > > > > > > > > +s->raw_huffman_values[1][1][i] =
> > > > > > > > > + avpriv_mjpeg_val_ac_chrominance[i];
> > > > > > > > >
> > > > > 

[FFmpeg-devel] [PATCH 5/6] h264_redundant_pps: Make it reference-compatible

2018-11-08 Thread Andreas Rheinhardt
Since c6a63e11092c975b89d824f08682fe31948d3686, the parameter sets
modified as content of PPS units were references shared with the
CodedBitsreamH264Context, so modifying them alters the parsing process
of future access units which meant that frames often got discarded
because invalid values were parsed. This patch makes h264_redundant_pps
compatible with the reality of reference-counted parameter sets.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h264_redundant_pps_bsf.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h264_redundant_pps_bsf.c 
b/libavcodec/h264_redundant_pps_bsf.c
index 79a11c0e30..059eb4d2a7 100644
--- a/libavcodec/h264_redundant_pps_bsf.c
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -40,8 +40,17 @@ typedef struct H264RedundantPPSContext {
 
 
 static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx,
-H264RawPPS *pps)
+CodedBitstreamUnit *unit)
 {
+H264RawPPS *pps;
+int err;
+// The changes we are about to perform affect the parsing process,
+// so we must make sure that the PPS is writeable, otherwise the
+// parsing of the headers will be incorrect and even raise errors.
+if ((err = ff_cbs_h264_make_pps_writeable(>content_ref)) < 0)
+return err;
+pps = unit->content = unit->content_ref->data;
+
 // Record the current value of pic_init_qp in order to fix up
 // following slices, then overwrite with the global value.
 ctx->current_pic_init_qp = pps->pic_init_qp_minus26 + 26;
@@ -89,7 +98,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, 
AVPacket *out)
 if (nal->type == H264_NAL_SPS)
 au_has_sps = 1;
 if (nal->type == H264_NAL_PPS) {
-err = h264_redundant_pps_fixup_pps(ctx, nal->content);
+err = h264_redundant_pps_fixup_pps(ctx, nal);
 if (err < 0)
 goto fail;
 if (!au_has_sps) {
@@ -151,7 +160,7 @@ static int h264_redundant_pps_init(AVBSFContext *bsf)
 
 for (i = 0; i < au->nb_units; i++) {
 if (au->units[i].type == H264_NAL_PPS) {
-err = h264_redundant_pps_fixup_pps(ctx, au->units[i].content);
+err = h264_redundant_pps_fixup_pps(ctx, >units[i]);
 if (err < 0)
 goto fail;
 }
-- 
2.19.0

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


[FFmpeg-devel] [PATCH 6/6] h264_redundant_pps: Fix logging context

2018-11-08 Thread Andreas Rheinhardt
The first element of H264RedundantPPSContext is not a pointer to an
AVClass as required.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h264_redundant_pps_bsf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/h264_redundant_pps_bsf.c 
b/libavcodec/h264_redundant_pps_bsf.c
index 059eb4d2a7..aee245b887 100644
--- a/libavcodec/h264_redundant_pps_bsf.c
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -102,7 +102,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, 
AVPacket *out)
 if (err < 0)
 goto fail;
 if (!au_has_sps) {
-av_log(ctx, AV_LOG_VERBOSE, "Deleting redundant PPS "
+av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS "
"at %"PRId64".\n", in->pts);
 err = ff_cbs_delete_unit(ctx->input, au, i);
 if (err < 0)
-- 
2.19.0

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


[FFmpeg-devel] [PATCH 3/6] cbs_h2645: Create functions to make parameter sets writeable

2018-11-08 Thread Andreas Rheinhardt
av_buffer_make_writable can't be used here, because a shallow copy isn't
enough for parameter sets.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs_h264.h  |  8 
 libavcodec/cbs_h2645.c | 16 
 libavcodec/cbs_h265.h  |  9 +
 3 files changed, 33 insertions(+)

diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index 92277e4750..dc6019765b 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -479,4 +479,12 @@ int ff_cbs_h264_delete_sei_message(CodedBitstreamContext 
*ctx,
CodedBitstreamUnit *nal_unit,
int position);
 
+/**
+ * Create a writeable reference from a reference to a buffer that contains
+ * a parameter set of the kind implied by the function name.
+ */
+int ff_cbs_h264_make_sps_writeable(AVBufferRef **buf);
+int ff_cbs_h264_make_pps_writeable(AVBufferRef **buf);
+
+
 #endif /* AVCODEC_CBS_H264_H */
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index e73706f2e6..a323bb2e8a 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -716,6 +716,22 @@ static int cbs_h26 ## h26n ## _replace_ ## 
ps_var(CodedBitstreamContext *ctx, \
 return AVERROR(ENOMEM); \
 priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## 
_ref[id]->data; \
 return 0; \
+} \
+ \
+int ff_cbs_h26 ## h26n ## _make_ ## ps_var ## _writeable(AVBufferRef **buf) \
+{ \
+if (av_buffer_is_writable(*buf)) {\
+return 0; \
+} else { \
+AVBufferRef *copy = cbs_h26 ## h26n ## _copy_ ## ps_var \
+  ((H26 ## h26n ## Raw ## ps_name*)(*buf)->data); \
+if (copy) { \
+av_buffer_unref(buf); \
+*buf = copy; \
+return 0; \
+} else \
+return AVERROR(ENOMEM); \
+} \
 }
 
 
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index cca1d7590b..9e951cd945 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -581,4 +581,13 @@ typedef struct CodedBitstreamH265Context {
 } CodedBitstreamH265Context;
 
 
+/**
+ * Create a writeable reference from a reference to a buffer that contains
+ * a parameter set of the kind implied by the function name.
+ */
+int ff_cbs_h265_make_vps_writeable(AVBufferRef **buf);
+int ff_cbs_h265_make_sps_writeable(AVBufferRef **buf);
+int ff_cbs_h265_make_pps_writeable(AVBufferRef **buf);
+
+
 #endif /* AVCODEC_CBS_H265_H */
-- 
2.19.0

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


[FFmpeg-devel] [PATCH 2/6] cbs_h2645: Do a deep copy for parameter sets

2018-11-08 Thread Andreas Rheinhardt
This commit solves dangling pointers problems when the content of a
parameter set isn't refcounted in the beginning: Now a deep copy of the
parameter sets is performed.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs_h2645.c | 59 +++---
 1 file changed, 50 insertions(+), 9 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 37b0207420..e73706f2e6 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -674,7 +674,26 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 return 0;
 }
 
-#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element) \
+
+#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element, buffer) \
+static AVBufferRef* cbs_h26 ## h26n ## _copy_ ## ps_var(const H26 ## h26n ## 
Raw ## ps_name *source)\
+{ \
+H26 ## h26n ## Raw ## ps_name *copy; \
+AVBufferRef *copy_ref; \
+copy = av_malloc(sizeof(*source)); \
+if (!copy) \
+return NULL; \
+memcpy(copy, source, sizeof(*source)); \
+copy_ref = av_buffer_create((uint8_t*)copy, sizeof(*source), \
+FREE(h26n, ps_var), NULL, 0); \
+if (!copy_ref) { \
+av_free(copy); \
+return NULL; \
+} \
+cbs_h2645_copy_substructure(h26n, ps_name, ps_var, buffer) \
+return copy_ref; \
+} \
+ \
 static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \
   CodedBitstreamUnit *unit)  \
 { \
@@ -692,21 +711,43 @@ static int cbs_h26 ## h26n ## _replace_ ## 
ps_var(CodedBitstreamContext *ctx, \
 if (unit->content_ref) \
 priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
 else \
-priv->ps_var ## _ref[id] = av_buffer_alloc(sizeof(*ps_var)); \
+priv->ps_var ## _ref[id] = cbs_h26 ## h26n ## _copy_ ## 
ps_var(ps_var); \
 if (!priv->ps_var ## _ref[id]) \
 return AVERROR(ENOMEM); \
 priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## 
_ref[id]->data; \
-if (!unit->content_ref) \
-memcpy(priv->ps_var[id], ps_var, sizeof(*ps_var)); \
 return 0; \
 }
 
 
-cbs_h2645_replace_ps(4, SPS, sps, seq_parameter_set_id)
-cbs_h2645_replace_ps(4, PPS, pps, pic_parameter_set_id)
-cbs_h2645_replace_ps(5, VPS, vps, vps_video_parameter_set_id)
-cbs_h2645_replace_ps(5, SPS, sps, sps_seq_parameter_set_id)
-cbs_h2645_replace_ps(5, PPS, pps, pps_pic_parameter_set_id)
+#define FREE(h26n, ps_var) NULL
+#define cbs_h2645_copy_substructure(h26n, ps_name, ps_var, buffer)
+cbs_h2645_replace_ps(4, SPS, sps, seq_parameter_set_id, )
+#undef cbs_h2645_copy_substructure
+#undef FREE
+
+#define FREE(h26n, ps_var) _h26 ## h26n ## _free_ ## ps_var
+#define cbs_h2645_copy_substructure(h26n, ps_name, ps_var, buffer) \
+if (source->buffer) { \
+copy->buffer ## _ref = av_buffer_allocz(SIZE + 
AV_INPUT_BUFFER_PADDING_SIZE); \
+if (!copy->buffer) { \
+av_buffer_unref(_ref); \
+return NULL; \
+} \
+copy->buffer = copy->buffer ## _ref->data; \
+memcpy(copy->buffer, source->buffer, SIZE); \
+}
+
+#define SIZE (copy->pic_size_in_map_units_minus1 + 1)
+cbs_h2645_replace_ps(4, PPS, pps, pic_parameter_set_id, slice_group_id)
+#undef SIZE
+
+#define SIZE ((copy->extension_data.bit_length + 7) / 8)
+cbs_h2645_replace_ps(5, VPS, vps, vps_video_parameter_set_id, 
extension_data.data)
+cbs_h2645_replace_ps(5, SPS, sps, sps_seq_parameter_set_id, 
extension_data.data)
+cbs_h2645_replace_ps(5, PPS, pps, pps_pic_parameter_set_id, 
extension_data.data)
+#undef SIZE
+#undef FREE
+
 
 static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx,
   CodedBitstreamUnit *unit)
-- 
2.19.0

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


[FFmpeg-devel] [PATCH 0/6] h264_redundant_pps: Make bsf refcount-compliant

2018-11-08 Thread Andreas Rheinhardt
Commit c6a63e11092c975b89d824f08682fe31948d3686 made the parameter sets
of both the CodedBitstreamH264Context and CodedBitstreamH265Context
reference-counted and also stopped copying the parameter sets read from
input; instead, the content of the parameter set units read from input
are now shared with the parameter sets in the respective contexts. This
means that said parameter sets are usually not writeable and ignoring
this can have adverse consequences.

An example of this is seen in the h264_redundant_pps bitstream filter.
It modifies two parameters of the H264RawPPS returned as content of
parameter sets unit encountered in input. By modifying these two
parameters (or actually, by modifying weighted_pred_flag), the PPS used
to parse future input (i.e. from the next access unit onwards) has been
changed and the result are parsing errors, because now
pred_weight_table() is presumed, even when it actually isn't there.

(The usage in h264_metadata is not dangerous, since no parameters that
are essential for the parsing process are changed in said bitstream
filter. But this is of course against the principle of refcounted
data.)

Here is a sample for which this bitstream filter was designed:
https://www.dropbox.com/s/76l8kml3qleyovw/H264_redundant_pps.sample.mkv?dl=0
Using the current version of h264_redundant_pps leads to a flood of
error messages and reduces the size from 38.3 MB to 16.8 MB because of
discarded packets.

In order to fix this, I created a function to perform deep copies of
parameter sets and also functions to make the references to (content)
parameter sets writeable. This also fixes dangling pointers problems
(currently a shallow copy is performed when a parameter set is replaced
by a parameter set that is not refcounted; now it's a deep copy).

I am unsure what arguments the make_writeable function(s) should take: A
CodedBitstreamUnit * or simply an AVBuffer ** like the normal
av_buffer_make_writable. In the end I opted for the latter, because of
the similarity to the normal writeable-function and because I can't rule
out that there might be situations in which one wants to copy a
refcounted parameter set that is not part of a unit. But notice that
using the unit would have its advantages, too: One could automatically
update the content-buffer and one could use the CodedBitstreamUnitType
to know which type of parameter set it is and therefore reduce the
number of functions needed (given that the nal_unit_types of H.264 and
H.265 parameter sets don't overlap, one could even use one function for
all). If you want to, I'll change this.

I have also included a patch to create several of the free functions via
a macro. Their similarity allows this.

Furthermore, there are two more things wrong with h264_redundant_pps: It
heavily leaks memory when there are errors (and now there are always
errors). And using -loglevel verbose or above easily produces crashes,
because the wrong logging context has been used in an av_log. There are
patches to address these issues.

Finally, this patchset is (re)based on top of the current Git head, as
required. My earlier patchset "Improve performance of writing slices"
also modifies libavcodec/cbs_h2645.c, but at different places, so there
won't be merge conflicts and it will be easy to rebase one on top of
another.


Andreas Rheinhardt (6):
  cbs_h2645: Unify the free-functions via macro
  cbs_h2645: Do a deep copy for parameter sets
  cbs_h2645: Create functions to make parameter sets writeable
  h264_redundant_pps: Fix memleak in case of errors
  h264_redundant_pps: Make it reference-compatible
  h264_redundant_pps: Fix logging context

 libavcodec/cbs_h264.h   |   8 ++
 libavcodec/cbs_h2645.c  | 130 +---
 libavcodec/cbs_h265.h   |   9 ++
 libavcodec/h264_redundant_pps_bsf.c |  59 +
 4 files changed, 138 insertions(+), 68 deletions(-)

-- 
2.19.0

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


[FFmpeg-devel] [PATCH 1/6] cbs_h2645: Unify the free-functions via macro

2018-11-08 Thread Andreas Rheinhardt
The similarity between several free-functions is exploited to create
them via a common macro.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs_h2645.c | 55 --
 1 file changed, 15 insertions(+), 40 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index e55bd00183..37b0207420 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -414,13 +414,22 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 #undef allocate
 
 
-static void cbs_h264_free_pps(void *unit, uint8_t *content)
-{
-H264RawPPS *pps = (H264RawPPS*)content;
-av_buffer_unref(>slice_group_id_ref);
-av_freep();
+#define cbs_h2645_free(h26n, name, var, buffer) \
+static void cbs_h26 ## h26n ## _free_ ## var(void *unit, uint8_t *content) \
+{ \
+H26 ## h26n ## Raw ## name *var = (H26 ## h26n ## Raw ## name*)content; \
+av_buffer_unref(>buffer ## _ref); \
+av_freep(); \
 }
 
+cbs_h2645_free(4, PPS, pps, slice_group_id)
+cbs_h2645_free(5, VPS, vps, extension_data.data)
+cbs_h2645_free(5, SPS, sps, extension_data.data)
+cbs_h2645_free(5, PPS, pps, extension_data.data)
+
+cbs_h2645_free(4, Slice, slice, data)
+cbs_h2645_free(5, Slice, slice, data)
+
 static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload)
 {
 switch (payload->payload_type) {
@@ -452,41 +461,6 @@ static void cbs_h264_free_sei(void *unit, uint8_t *content)
 av_freep();
 }
 
-static void cbs_h264_free_slice(void *unit, uint8_t *content)
-{
-H264RawSlice *slice = (H264RawSlice*)content;
-av_buffer_unref(>data_ref);
-av_freep();
-}
-
-static void cbs_h265_free_vps(void *unit, uint8_t *content)
-{
-H265RawVPS *vps = (H265RawVPS*)content;
-av_buffer_unref(>extension_data.data_ref);
-av_freep();
-}
-
-static void cbs_h265_free_sps(void *unit, uint8_t *content)
-{
-H265RawSPS *sps = (H265RawSPS*)content;
-av_buffer_unref(>extension_data.data_ref);
-av_freep();
-}
-
-static void cbs_h265_free_pps(void *unit, uint8_t *content)
-{
-H265RawPPS *pps = (H265RawPPS*)content;
-av_buffer_unref(>extension_data.data_ref);
-av_freep();
-}
-
-static void cbs_h265_free_slice(void *unit, uint8_t *content)
-{
-H265RawSlice *slice = (H265RawSlice*)content;
-av_buffer_unref(>data_ref);
-av_freep();
-}
-
 static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload)
 {
 switch (payload->payload_type) {
@@ -727,6 +701,7 @@ static int cbs_h26 ## h26n ## _replace_ ## 
ps_var(CodedBitstreamContext *ctx, \
 return 0; \
 }
 
+
 cbs_h2645_replace_ps(4, SPS, sps, seq_parameter_set_id)
 cbs_h2645_replace_ps(4, PPS, pps, pic_parameter_set_id)
 cbs_h2645_replace_ps(5, VPS, vps, vps_video_parameter_set_id)
-- 
2.19.0

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


Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG decoding uninitialized huffman table

2018-11-08 Thread Eoff, Ullysses A


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> Eoff, Ullysses A
> Sent: Thursday, November 08, 2018 9:27 PM
> To: FFmpeg development discussions and patches 
> Cc: Zhao, Jun ; Lin, Decai 
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG decoding 
> uninitialized huffman table
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> > Eoff, Ullysses A
> > Sent: Tuesday, October 30, 2018 11:42 AM
> > To: FFmpeg development discussions and patches 
> > Cc: Zhao, Jun ; Lin, Decai 
> > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG 
> > decoding uninitialized huffman table
> > > -Original Message-
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> > > myp...@gmail.com
> > > Sent: Monday, October 29, 2018 10:52 PM
> > > To: FFmpeg development discussions and patches 
> > > Cc: Zhao, Jun ; Lin, Decai 
> > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG 
> > > decoding uninitialized huffman table
> > >
> > > On Tue, Oct 30, 2018 at 11:41 AM Eoff, Ullysses A
> > >  wrote:
> > > >
> > > > > -Original Message-
> > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> > > > > Of myp...@gmail.com
> > > > > Sent: Monday, October 29, 2018 8:10 PM
> > > > > To: FFmpeg development discussions and patches 
> > > > > 
> > > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG 
> > > > > decoding uninitialized huffman table
> > > > >
> > > > > On Tue, Oct 30, 2018 at 10:41 AM Li, Zhong  wrote:
> > > > > >
> > > > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On 
> > > > > > > Behalf
> > > > > > > Of myp...@gmail.com
> > > > > > > Sent: Tuesday, October 30, 2018 9:02 AM
> > > > > > > To: FFmpeg development discussions and patches
> > > > > > > 
> > > > > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > > > > 
> > > > > > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API 
> > > > > > > MJPEG
> > > > > > > decoding uninitialized huffman table
> > > > > > >
> > > > > > > On Mon, Oct 29, 2018 at 6:39 PM Li, Zhong  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > > > > > > > > Behalf Of Jun Zhao
> > > > > > > > > Sent: Monday, October 29, 2018 6:26 PM
> > > > > > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > > > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > > > > > > 
> > > > > > > > > Subject: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API 
> > > > > > > > > MJPEG
> > > > > > > > > decoding uninitialized huffman table
> > > > > > > > >
> > > > > > > > > From: Jun Zhao 
> > > > > > > > >
> > > > > > > > > Now VA-API HWAccel MJPEG decoding uninitialized huffman 
> > > > > > > > > table, it's
> > > > > > > > > will lead to the decoding error like"Failed to sync surface 
> > > > > > > > > 0x5: 23
> > > > > > > > > (internal decoding error)." in iHD open source driver.
> > > > > > > > >
> > > > > > > > > Signed-off-by: dlin2 
> > > > > > > > > Signed-off-by: Jun Zhao 
> > > > > > > > > ---
> > > > > > > > >  libavcodec/mjpegdec.c |   19 +++
> > > > > > > > >  1 files changed, 19 insertions(+), 0 deletions(-)
> > > > > > > > >
> > > > > > > > > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c 
> > > > > > > > > index
> > > > > > > > > b0cb3ff..89effb6 100644
> > > > > > > > > --- a/libavcodec/mjpegdec.c
> > > > > > > > > +++ b/libavcodec/mjpegdec.c
> > > > > > > > > @@ -75,6 +75,25 @@ static int build_vlc(VLC *vlc, const 
> > > > > > > > > uint8_t
> > > > > > > > > *bits_table, static int 
> > > > > > > > > build_basic_mjpeg_vlc(MJpegDecodeContext *s)
> > > > > > > {
> > > > > > > > >  int ret;
> > > > > > > > > +int i;
> > > > > > > > > +
> > > > > > > > > +/* initialize default huffman tables */
> > > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > > +s->raw_huffman_lengths[0][0][i] =
> > > > > > > > > avpriv_mjpeg_bits_dc_luminance[i + 1];
> > > > > > > > > +for (i = 0; i < 12; i++)
> > > > > > > > > +s->raw_huffman_values[0][0][i] = 
> > > > > > > > > avpriv_mjpeg_val_dc[i];
> > > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > > +s->raw_huffman_lengths[0][1][i] =
> > > > > > > > > avpriv_mjpeg_bits_dc_chrominance[i + 1];
> > > > > > > > > +for (i = 0; i < 12; i++)
> > > > > > > > > +s->raw_huffman_values[0][1][i] = 
> > > > > > > > > avpriv_mjpeg_val_dc[i];
> > > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > > +s->raw_huffman_lengths[1][0][i] =
> > > > > > > > > avpriv_mjpeg_bits_ac_luminance[i + 1];
> > > > > > > > > +for (i = 0; i < 162; i++)
> > > > > > > > > +s->raw_huffman_values[1][0][i] =
> > > > > > > > > avpriv_mjpeg_val_ac_luminance[i];
> > > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > 

Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG decoding uninitialized huffman table

2018-11-08 Thread Eoff, Ullysses A
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> Eoff, Ullysses A
> Sent: Tuesday, October 30, 2018 11:42 AM
> To: FFmpeg development discussions and patches 
> Cc: Zhao, Jun ; Lin, Decai 
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG decoding 
> uninitialized huffman table
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> > myp...@gmail.com
> > Sent: Monday, October 29, 2018 10:52 PM
> > To: FFmpeg development discussions and patches 
> > Cc: Zhao, Jun ; Lin, Decai 
> > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG 
> > decoding uninitialized huffman table
> >
> > On Tue, Oct 30, 2018 at 11:41 AM Eoff, Ullysses A
> >  wrote:
> > >
> > > > -Original Message-
> > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> > > > Of myp...@gmail.com
> > > > Sent: Monday, October 29, 2018 8:10 PM
> > > > To: FFmpeg development discussions and patches 
> > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG 
> > > > decoding uninitialized huffman table
> > > >
> > > > On Tue, Oct 30, 2018 at 10:41 AM Li, Zhong  wrote:
> > > > >
> > > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On 
> > > > > > Behalf
> > > > > > Of myp...@gmail.com
> > > > > > Sent: Tuesday, October 30, 2018 9:02 AM
> > > > > > To: FFmpeg development discussions and patches
> > > > > > 
> > > > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > > > Subject: Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG
> > > > > > decoding uninitialized huffman table
> > > > > >
> > > > > > On Mon, Oct 29, 2018 at 6:39 PM Li, Zhong  
> > > > > > wrote:
> > > > > > >
> > > > > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > > > > > > > Behalf Of Jun Zhao
> > > > > > > > Sent: Monday, October 29, 2018 6:26 PM
> > > > > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > > > > Cc: Zhao, Jun ; Lin, Decai 
> > > > > > > > 
> > > > > > > > Subject: [FFmpeg-devel] [PATCH] lavc/mjpegdec: fix VA-API MJPEG
> > > > > > > > decoding uninitialized huffman table
> > > > > > > >
> > > > > > > > From: Jun Zhao 
> > > > > > > >
> > > > > > > > Now VA-API HWAccel MJPEG decoding uninitialized huffman table, 
> > > > > > > > it's
> > > > > > > > will lead to the decoding error like"Failed to sync surface 
> > > > > > > > 0x5: 23
> > > > > > > > (internal decoding error)." in iHD open source driver.
> > > > > > > >
> > > > > > > > Signed-off-by: dlin2 
> > > > > > > > Signed-off-by: Jun Zhao 
> > > > > > > > ---
> > > > > > > >  libavcodec/mjpegdec.c |   19 +++
> > > > > > > >  1 files changed, 19 insertions(+), 0 deletions(-)
> > > > > > > >
> > > > > > > > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index
> > > > > > > > b0cb3ff..89effb6 100644
> > > > > > > > --- a/libavcodec/mjpegdec.c
> > > > > > > > +++ b/libavcodec/mjpegdec.c
> > > > > > > > @@ -75,6 +75,25 @@ static int build_vlc(VLC *vlc, const uint8_t
> > > > > > > > *bits_table, static int 
> > > > > > > > build_basic_mjpeg_vlc(MJpegDecodeContext *s)
> > > > > > {
> > > > > > > >  int ret;
> > > > > > > > +int i;
> > > > > > > > +
> > > > > > > > +/* initialize default huffman tables */
> > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > +s->raw_huffman_lengths[0][0][i] =
> > > > > > > > avpriv_mjpeg_bits_dc_luminance[i + 1];
> > > > > > > > +for (i = 0; i < 12; i++)
> > > > > > > > +s->raw_huffman_values[0][0][i] = 
> > > > > > > > avpriv_mjpeg_val_dc[i];
> > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > +s->raw_huffman_lengths[0][1][i] =
> > > > > > > > avpriv_mjpeg_bits_dc_chrominance[i + 1];
> > > > > > > > +for (i = 0; i < 12; i++)
> > > > > > > > +s->raw_huffman_values[0][1][i] = 
> > > > > > > > avpriv_mjpeg_val_dc[i];
> > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > +s->raw_huffman_lengths[1][0][i] =
> > > > > > > > avpriv_mjpeg_bits_ac_luminance[i + 1];
> > > > > > > > +for (i = 0; i < 162; i++)
> > > > > > > > +s->raw_huffman_values[1][0][i] =
> > > > > > > > avpriv_mjpeg_val_ac_luminance[i];
> > > > > > > > +for (i = 0; i < 16; i++)
> > > > > > > > +s->raw_huffman_lengths[1][1][i] =
> > > > > > > > avpriv_mjpeg_bits_ac_chrominance[i + 1];
> > > > > > > > +for (i = 0; i < 162; i++)
> > > > > > > > +s->raw_huffman_values[1][1][i] =
> > > > > > > > + avpriv_mjpeg_val_ac_chrominance[i];
> > > > > > > >
> > > > > > > >  if ((ret = build_vlc(>vlcs[0][0],
> > > > > > avpriv_mjpeg_bits_dc_luminance,
> > > > > > > >   avpriv_mjpeg_val_dc, 12, 0, 0)) < 0)
> > > > > > > > --
> > > > > > > > 1.7.1
> > > > > > >
> > > > > > > Should this be fixed in iHD driver instead of ffmpeg?
> > > > > > No, I don't think driver is a good place to initialize the 

Re: [FFmpeg-devel] [PATCH V2] lavfi/vf_scale_vaapi: add scaling mode setting support.

2018-11-08 Thread myp...@gmail.com
ping?
On Sat, Oct 13, 2018 at 3:59 PM Jun Zhao  wrote:
>
> before this change, scale_vaapi hard coding the scaling mode, add a
> new option "mode" to setting the scaling mode, it can be use to change
> scaling algorithm for performance/quality trade off.
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] fftools/ffmpeg: add an option to forbid the fallback to software path when hardware init fails

2018-11-08 Thread Eoff, Ullysses A
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> Linjie Fu
> Sent: Thursday, November 08, 2018 7:14 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH v2] fftools/ffmpeg: add an option to forbid 
> the fallback to software path when hardware init fails
> 
> Currently ff_get_format will go through all usable choices if the chosen
> format was not supported. It will fallback to software path if the hardware
> init fails.
> 
> Provided an option "-fallback_forbid 1" in user-code to detect frame->format 
> and
> hwaccel_get_buffer in get_buffer. If hardware init fails, returns an error.
> 

I'm not sure I like this option name ("-fallback_forbid").  How about 
"-disable_fallback",
"-hwaccel_or_die", "-require_hwaccel" or "-no_sw_fallback"?  I like the last 
two the most.
Or maybe someone has a better suggestion?

> Signed-off-by: Linjie Fu 
> ---
> 
> [v2] detect hardware init failures in get_buffer and modify in user-code
> 
>  fftools/ffmpeg.c | 2 ++
>  fftools/ffmpeg.h | 1 +
>  fftools/ffmpeg_opt.c | 3 +++
>  3 files changed, 6 insertions(+)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index da4259a9a8..45694fef57 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -2890,6 +2890,8 @@ static int get_buffer(AVCodecContext *s, AVFrame 
> *frame, int flags)
> 
>  if (ist->hwaccel_get_buffer && frame->format == ist->hwaccel_pix_fmt)
>  return ist->hwaccel_get_buffer(s, frame, flags);
> +else if (ist->fallback_forbid)
> +return AVERROR(EINVAL);
> 
>  return avcodec_default_get_buffer2(s, frame, flags);
>  }
> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> index eb1eaf6363..67ddaeaaee 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -365,6 +365,7 @@ typedef struct InputStream {
>  enum AVHWDeviceType hwaccel_device_type;
>  char  *hwaccel_device;
>  enum AVPixelFormat hwaccel_output_format;
> +int fallback_forbid;
> 
>  /* hwaccel context */
>  void  *hwaccel_ctx;
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index d4851a2cd8..314e25565c 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -3600,6 +3600,9 @@ const OptionDef options[] = {
>  { "autorotate",   HAS_ARG | OPT_BOOL | OPT_SPEC |
>OPT_EXPERT | OPT_INPUT,
> { .off = OFFSET(autorotate) },
>  "automatically insert correct rotate filters" },
> +{ "fallback_forbid",  HAS_ARG | OPT_BOOL | OPT_SPEC |
> +  OPT_EXPERT | OPT_INPUT,
> { .off = OFFSET(fallback_forbid)},
> +  "forbid the fallback to default software path when hardware init 
> fails"},
> 
>  /* audio options */
>  { "aframes",OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT, 
>   { .func_arg = opt_audio_frames },
> --
> 2.17.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2] fftools/ffmpeg: add an option to forbid the fallback to software path when hardware init fails

2018-11-08 Thread Linjie Fu
Currently ff_get_format will go through all usable choices if the chosen
format was not supported. It will fallback to software path if the hardware
init fails.

Provided an option "-fallback_forbid 1" in user-code to detect frame->format and
hwaccel_get_buffer in get_buffer. If hardware init fails, returns an error.

Signed-off-by: Linjie Fu 
---

[v2] detect hardware init failures in get_buffer and modify in user-code

 fftools/ffmpeg.c | 2 ++
 fftools/ffmpeg.h | 1 +
 fftools/ffmpeg_opt.c | 3 +++
 3 files changed, 6 insertions(+)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index da4259a9a8..45694fef57 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2890,6 +2890,8 @@ static int get_buffer(AVCodecContext *s, AVFrame *frame, 
int flags)
 
 if (ist->hwaccel_get_buffer && frame->format == ist->hwaccel_pix_fmt)
 return ist->hwaccel_get_buffer(s, frame, flags);
+else if (ist->fallback_forbid)
+return AVERROR(EINVAL);
 
 return avcodec_default_get_buffer2(s, frame, flags);
 }
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index eb1eaf6363..67ddaeaaee 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -365,6 +365,7 @@ typedef struct InputStream {
 enum AVHWDeviceType hwaccel_device_type;
 char  *hwaccel_device;
 enum AVPixelFormat hwaccel_output_format;
+int fallback_forbid;
 
 /* hwaccel context */
 void  *hwaccel_ctx;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index d4851a2cd8..314e25565c 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -3600,6 +3600,9 @@ const OptionDef options[] = {
 { "autorotate",   HAS_ARG | OPT_BOOL | OPT_SPEC |
   OPT_EXPERT | OPT_INPUT,  
  { .off = OFFSET(autorotate) },
 "automatically insert correct rotate filters" },
+{ "fallback_forbid",  HAS_ARG | OPT_BOOL | OPT_SPEC |
+  OPT_EXPERT | OPT_INPUT,  
  { .off = OFFSET(fallback_forbid)},
+  "forbid the fallback to default software path when hardware init fails"},
 
 /* audio options */
 { "aframes",OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,   
{ .func_arg = opt_audio_frames },
-- 
2.17.1

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


Re: [FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg: Refine the do_video_out.

2018-11-08 Thread myp...@gmail.com
On Thu, Nov 8, 2018 at 11:45 PM Carl Eugen Hoyos  wrote:
>
> 2018-11-08 16:35 GMT+01:00, Jun Zhao :
> > Signed-off-by: Jun Zhao 
> > ---
> >  fftools/ffmpeg.c |   62
> > -
> >  1 files changed, 28 insertions(+), 34 deletions(-)
> >
> > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> > index da4259a..e989e7a 100644
> > --- a/fftools/ffmpeg.c
> > +++ b/fftools/ffmpeg.c
> > @@ -1193,33 +1193,27 @@ static void do_video_out(OutputFile *of,
> >  }
> >  ost->last_dropped = nb_frames == nb0_frames && next_picture;
> >
> > -  /* duplicates frame if needed */
> > -  for (i = 0; i < nb_frames; i++) {
> > -AVFrame *in_picture;
> > -av_init_packet();
> > -pkt.data = NULL;
> > -pkt.size = 0;
> > -
> > -if (i < nb0_frames && ost->last_frame) {
> > -in_picture = ost->last_frame;
> > -} else
> > -in_picture = next_picture;
> > +/* duplicates frame if needed */
> > +for (i = 0; i < nb_frames; i++) {
> > +AVFrame *in_picture;
> > +int forced_keyframe = 0;
> > +double pts_time;
> > +av_init_packet();
> > +pkt.data = NULL;
> > +pkt.size = 0;
> >
> > -if (!in_picture)
> > -return;
> > +if (i < nb0_frames && ost->last_frame) {
> > +in_picture = ost->last_frame;
> > +} else
> > +in_picture = next_picture;
>
> This patch seems to mix functional changes with re-indentation.
> The patch will be much easier to review if you move all re-indentation
> into the second patch.
>
> Carl Eugen
Will split the patch and move the re-indentataion to 2nd patch, Thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg: Refine the do_video_out.

2018-11-08 Thread myp...@gmail.com
On Fri, Nov 9, 2018 at 4:24 AM Michael Niedermayer
 wrote:
>
> On Thu, Nov 08, 2018 at 11:35:20PM +0800, Jun Zhao wrote:
> > Signed-off-by: Jun Zhao 
> > ---
> >  fftools/ffmpeg.c |   62 
> > -
> >  1 files changed, 28 insertions(+), 34 deletions(-)
>
> The commit message "Refine the do_video_out." is too terse
> its not clear from it what is done, why it is done, how it is done
>
> thx
>
The v2 patchset will give more detail information in commit message,
thanks the review.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/libvpxenc: add VP8 temporal scalability configuration options

2018-11-08 Thread Carl Eugen Hoyos
2018-11-08 21:44 GMT+01:00, Ard Oerlemans
:

> +#if CONFIG_LIBVPX_VP8_ENCODER
> +if (frame->metadata) {

if (CONFIG_LIBVPX_VP8_ENCODER && frame->metadata)
may be more inline with FFmpeg's code style.

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


Re: [FFmpeg-devel] [PATCH] libvpxenc: extend auto-alt-ref range

2018-11-08 Thread James Zern
On Mon, Nov 5, 2018 at 5:03 PM James Zern  wrote:
>
> On Mon, Nov 5, 2018 at 5:02 PM James Zern  wrote:
> >
> > vp9 now supports [0, 6]
> >
> > Signed-off-by: James Zern 
> > ---
> >  doc/encoders.texi  | 1 +
> >  libavcodec/libvpxenc.c | 6 --
> >  2 files changed, 5 insertions(+), 2 deletions(-)
> >
>
> This version moves the option from COMMON_OPTIONS for comparison.
>

I'll submit this version soon if there aren't any comments. vp8 could
be made a bool in a followup at the cost of compatibility, it's been
in its current state for a couple years.

> > diff --git a/doc/encoders.texi b/doc/encoders.texi
> > index 899faac49b..3c6f5cd70b 100644
> > --- a/doc/encoders.texi
> > +++ b/doc/encoders.texi
> > @@ -1641,6 +1641,7 @@ means unlimited.
> >  @table @option
> >  @item auto-alt-ref
> >  Enable use of alternate reference frames (2-pass only).
> > +Values greater than 1 enable multi-layer alternate reference frames (VP9 
> > only).
> >  @item arnr-max-frames
> >  Set altref noise reduction max frame count.
> >  @item arnr-type
> > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> > index 09f7a88452..827df21fa5 100644
> > --- a/libavcodec/libvpxenc.c
> > +++ b/libavcodec/libvpxenc.c
> > @@ -1067,8 +1067,6 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
> > *pkt,
> >  #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> >
> >  #define COMMON_OPTIONS \
> > -{ "auto-alt-ref","Enable use of alternate reference " \
> > - "frames (2-pass only)",   
> > OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1},  -1,  2, 
> >   VE}, \
> >  { "lag-in-frames",   "Number of frames to look ahead for " \
> >   "alternate reference frame selection",
> > OFFSET(lag_in_frames),   AV_OPT_TYPE_INT, {.i64 = -1},  -1,  
> > INT_MAX, VE}, \
> >  { "arnr-maxframes",  "altref noise reduction max frame count", 
> > OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1},  -1,  
> > INT_MAX, VE}, \
> > @@ -1112,6 +1110,8 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
> > *pkt,
> >  #if CONFIG_LIBVPX_VP8_ENCODER
> >  static const AVOption vp8_options[] = {
> >  COMMON_OPTIONS
> > +{ "auto-alt-ref","Enable use of alternate reference "
> > + "frames (2-pass only)",
> > OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1}, -1,  2, VE},
> >  { "cpu-used","Quality/Speed ratio modifier",
> > OFFSET(cpu_used),AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE},
> >  LEGACY_OPTIONS
> >  { NULL }
> > @@ -1121,6 +1121,8 @@ static const AVOption vp8_options[] = {
> >  #if CONFIG_LIBVPX_VP9_ENCODER
> >  static const AVOption vp9_options[] = {
> >  COMMON_OPTIONS
> > +{ "auto-alt-ref","Enable use of alternate reference "
> > + "frames (2-pass only)",
> > OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
> >  { "cpu-used","Quality/Speed ratio modifier",
> > OFFSET(cpu_used),AV_OPT_TYPE_INT, {.i64 = 1},  -8, 8, VE},
> >  { "lossless","Lossless mode",   
> > OFFSET(lossless),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
> >  { "tile-columns","Number of tile columns to use, log2", 
> > OFFSET(tile_columns),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
> > --
> > 2.19.1.930.g4563a0d9d0-goog
> >
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libvpxenc,vp9: add enable-tpl option

2018-11-08 Thread James Zern
On Sat, Nov 3, 2018 at 2:01 PM James Zern  wrote:
>
> enables temporal dependency model
>
> Signed-off-by: James Zern 
> ---
>  doc/encoders.texi  |  2 ++
>  libavcodec/libvpxenc.c | 11 +++
>  2 files changed, 13 insertions(+)
>

If there aren't any comments I'll submit this one soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/qpeg: Optimize full width runs in qpeg_decode_intra()

2018-11-08 Thread Michael Niedermayer
On Mon, Nov 05, 2018 at 11:17:47PM +0100, Michael Niedermayer wrote:
> This improves the speed of decoding large patches of constant color
> 
> Fixes: Timeout
> Fixes: 
> 10967/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QPEG_fuzzer-5630803793936384
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/qpeg.c | 6 ++
>  1 file changed, 6 insertions(+)

will apply


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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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


[FFmpeg-devel] avfilter/af_headphone : fix memleak

2018-11-08 Thread Martin Vignali
Hello,

Patch in attach should fix the memleak report by coverity
CID 1439934
CID 1439935

Replace return ret, by goto fail.

Martin


0004-avfilter-af_headphone-fix-mem-leak.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avcodec : add prores_metadata bsf and fate test

2018-11-08 Thread Martin Vignali
Le dim. 28 oct. 2018 à 12:59, Martin Vignali  a
écrit :

> Thanks for the comments
>
> New patch in attach
>
> - Change the options, to only authorized few value in prores frame (based
> on rdd36).
> - Change option name to match setparams filter
> - Include intreadwrite instead of bytestream
> - Do not modify the property if set to -1
> - Move av_packet_make_writable at the start of the func
>
> Martin
>
>
>
i will pushed in few days, if no one is against.

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


Re: [FFmpeg-devel] avcodec/prores_aw : add support for alpha encoding

2018-11-08 Thread Martin Vignali
Rebase after prores profile patch
fix stride used by alpha reorganization
and pushed

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


Re: [FFmpeg-devel] [PATCH 1/1] cbs_h264: Fix handling of auxiliary pictures

2018-11-08 Thread Mark Thompson
On 07/11/18 03:47, Andreas Rheinhardt wrote:
> The earlier code used the most recent non-auxiliary slice to determine
> whether an auxiliary slice has the syntax of an IDR slice, even when
> the most recent slice was from a slice of a redundant frame. Now only
> slices of the primary coded picture are used, as the specifications
> mandate.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/cbs_h264_syntax_template.c | 16 +++-
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/cbs_h264_syntax_template.c 
> b/libavcodec/cbs_h264_syntax_template.c
> index dbf9ff1268..aaa4589f4d 100644
> --- a/libavcodec/cbs_h264_syntax_template.c
> +++ b/libavcodec/cbs_h264_syntax_template.c
> @@ -1190,11 +1190,10 @@ static int FUNC(slice_header)(CodedBitstreamContext 
> *ctx, RWContext *rw,
> "in the same access unit.\n");
>  return AVERROR_INVALIDDATA;
>  }
> -} else {
> -h264->last_slice_nal_unit_type =
> -current->nal_unit_header.nal_unit_type;
> -}
> -idr_pic_flag = h264->last_slice_nal_unit_type == H264_NAL_IDR_SLICE;
> +idr_pic_flag = h264->last_slice_nal_unit_type == H264_NAL_IDR_SLICE;
> +} else
> +idr_pic_flag = current->nal_unit_header.nal_unit_type == 
> H264_NAL_IDR_SLICE;
> +
>  
>  ue(first_mb_in_slice, 0, H264_MAX_MB_PIC_SIZE - 1);
>  ue(slice_type, 0, 9);
> @@ -1272,6 +1271,13 @@ static int FUNC(slice_header)(CodedBitstreamContext 
> *ctx, RWContext *rw,
>  
>  if (pps->redundant_pic_cnt_present_flag)
>  ue(redundant_pic_cnt, 0, 127);
> +else
> +infer(redundant_pic_cnt, 0);
> +
> +if (current->nal_unit_header.nal_unit_type != H264_NAL_AUXILIARY_SLICE
> +&& !current->redundant_pic_cnt)
> +h264->last_slice_nal_unit_type =
> +current->nal_unit_header.nal_unit_type;
>  
>  if (slice_type_b)
>  flag(direct_spatial_mv_pred_flag);
> 

Yep; LGTM, and applied.

Thanks!

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


Re: [FFmpeg-devel] [PATCH] libavformat/ffmetadec: use dynamic allocation for line buffer

2018-11-08 Thread François Revol
Hi,

Le 08/11/2018 à 20:50, Michael Niedermayer a écrit :
>> +line = av_malloc(line_size);
>> +if (!line)
>> +return AVERROR(ENOMEM);
> 
> this would use alot of memory for large files, also avio_size() will not
> work with all inputs

Yes I thought so as well, that was a quick fix for a friend in need.

> using av_fast_realloc() or similar should avoid both issues

You mean, having get_line() reallocate 1kB more each time it runs out
without finding a \n?

Btw, I noticed there was an avio_get_line() which was quite similar,
maybe those could be merged?


> 
>>  
>>  while(!avio_feof(s->pb)) {
>> -get_line(s->pb, line, sizeof(line));
>> +get_line(s->pb, line, line_size);
>>  
> 
>>  if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) {
> 
> out of memory access can happen here

Right. Preallocating at least 1kB would fix it though.


François.



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


[FFmpeg-devel] [PATCH] avcodec/libvpxenc: add VP8 temporal scalability configuration options

2018-11-08 Thread Ard Oerlemans
This commit adds configuration options to libvpxenc.c that can be used to
enable VP8 temporal scalability. It also adds a way to programmatically set the
per-frame encoding flags which can be used to control usage and updates of
reference frames while encoding with temporal scalability enabled.
---
 doc/encoders.texi  | 28 ++
 libavcodec/libvpxenc.c | 85 ++
 2 files changed, 113 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 899faac49b..6ecd572ea3 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1654,6 +1654,34 @@ Set number of frames to look ahead for frametype and 
ratecontrol.
 @item error-resilient
 Enable error resiliency features.
 
+@item VP8-specific options
+@table @option
+@item ts-parameters
+Sets the temporal scalability configuration using a :-separated list of
+key=value pairs. For example, to specify temporal scalability parameters
+with @code{ffmpeg}:
+@example
+ffmpeg -i INPUT -c:v libvpx -ts-parameters ts_number_layers=3:\
+ts_target_bitrate=25,50,100:ts_rate_decimator=4,2,1:\
+ts_periodicity=4:ts_layer_id=0,2,1,2 OUTPUT
+@end example
+Below is a brief explanation of each of the parameters, please
+refer to @code{struct vpx_codec_enc_cfg} in @code{vpx/vpx_encoder.h} for more
+details.
+@table @option
+@item ts_number_layers
+Number of temporal coding layers.
+@item ts_target_bitrate
+Target bitrate for each temporal layer.
+@item ts_rate_decimator
+Frame rate decimation factor for each temporal layer.
+@item ts_periodicity
+Length of the sequence defining frame temporal layer membership.
+@item ts_layer_id
+Template defining the membership of frames to temporal layers.
+@end table
+@end table
+
 @item VP9-specific options
 @table @option
 @item lossless
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 09f7a88452..206f17f4cd 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -33,6 +33,7 @@
 #include "libavutil/avassert.h"
 #include "libvpx.h"
 #include "profiles.h"
+#include "libavutil/avstring.h"
 #include "libavutil/base64.h"
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
@@ -98,6 +99,8 @@ typedef struct VPxEncoderContext {
 int rc_undershoot_pct;
 int rc_overshoot_pct;
 
+char *vp8_ts_parameters;
+
 // VP9-only
 int lossless;
 int tile_columns;
@@ -165,6 +168,7 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
 {
 int width = -30;
 int level = AV_LOG_DEBUG;
+int i;
 
 av_log(avctx, level, "vpx_codec_enc_cfg\n");
 av_log(avctx, level, "generic settings\n"
@@ -204,6 +208,25 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
"  %*s%u\n  %*s%u\n",
width, "rc_undershoot_pct:", cfg->rc_undershoot_pct,
width, "rc_overshoot_pct:",  cfg->rc_overshoot_pct);
+av_log(avctx, level, "temporal layering settings\n"
+   "  %*s%u\n", width, "ts_number_layers:", cfg->ts_number_layers);
+av_log(avctx, level,
+   "\n  %*s", width, "ts_target_bitrate:");
+for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
+av_log(avctx, level, "%u ", cfg->ts_target_bitrate[i]);
+av_log(avctx, level, "\n");
+av_log(avctx, level,
+   "\n  %*s", width, "ts_rate_decimator:");
+for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
+av_log(avctx, level, "%u ", cfg->ts_rate_decimator[i]);
+av_log(avctx, level, "\n");
+av_log(avctx, level,
+   "\n  %*s%u\n", width, "ts_periodicity:", cfg->ts_periodicity);
+av_log(avctx, level,
+   "\n  %*s", width, "ts_layer_id:");
+for (i = 0; i < VPX_TS_MAX_PERIODICITY; i++)
+av_log(avctx, level, "%u ", cfg->ts_layer_id[i]);
+av_log(avctx, level, "\n");
 av_log(avctx, level, "decoder buffer model\n"
 "  %*s%u\n  %*s%u\n  %*s%u\n",
 width, "rc_buf_sz:", cfg->rc_buf_sz,
@@ -321,6 +344,41 @@ static av_cold int vpx_free(AVCodecContext *avctx)
 return 0;
 }
 
+#if CONFIG_LIBVPX_VP8_ENCODER
+static void vp8_ts_parse_int_array(int* dest, char *value, size_t value_len, 
int max_entries)
+{
+int dest_idx = 0;
+char *value_end = value + value_len;
+while (value < value_end && dest_idx < max_entries) {
+dest[dest_idx] = strtoul(value, , 10);
+while (value < value_end && (*value == ',' || av_isspace(*value)))
+value++;
+dest_idx++;
+}
+}
+
+static int vp8_ts_param_parse(struct vpx_codec_enc_cfg *enccfg, char *key, 
char *value)
+{
+size_t value_len = strlen(value);
+
+if (!value_len)
+return -1;
+
+if (!strcmp(key, "ts_number_layers"))
+enccfg->ts_number_layers = strtoul(value, , 10);
+else if (!strcmp(key, "ts_target_bitrate"))
+vp8_ts_parse_int_array(enccfg->ts_target_bitrate, value, value_len, 
VPX_TS_MAX_LAYERS);
+else if (!strcmp(key, "ts_rate_decimator"))
+  vp8_ts_parse_int_array(enccfg->ts_rate_decimator, value, value_len, 

Re: [FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg: Refine the do_video_out.

2018-11-08 Thread Michael Niedermayer
On Thu, Nov 08, 2018 at 11:35:20PM +0800, Jun Zhao wrote:
> Signed-off-by: Jun Zhao 
> ---
>  fftools/ffmpeg.c |   62 -
>  1 files changed, 28 insertions(+), 34 deletions(-)

The commit message "Refine the do_video_out." is too terse
its not clear from it what is done, why it is done, how it is done

thx

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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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


Re: [FFmpeg-devel] [PATCH] libavformat/ffmetadec: use dynamic allocation for line buffer

2018-11-08 Thread Michael Niedermayer
On Wed, Nov 07, 2018 at 02:34:43PM +0100, François Revol wrote:
> When adding thumbnails to OGG files, the line can easily go up to 100kB.
> 
> We thus try to allocate the file size or SIZE_MAX to avoid truncation.
> ---
>  libavformat/ffmetadec.c | 21 +
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c
> index 3290b3b7bc..ccbff51c03 100644
> --- a/libavformat/ffmetadec.c
> +++ b/libavformat/ffmetadec.c
> @@ -128,16 +128,26 @@ static int read_tag(const uint8_t *line, AVDictionary 
> **m)
>  static int read_header(AVFormatContext *s)
>  {
>  AVDictionary **m = >metadata;
> -uint8_t line[1024];
> +int64_t line_size = avio_size(s->pb);
> +uint8_t *line;
> +
> +if (line_size < 1 || line_size > SIZE_MAX)
> +   line_size = SIZE_MAX;
> +
> +line = av_malloc(line_size);
> +if (!line)
> +return AVERROR(ENOMEM);

this would use alot of memory for large files, also avio_size() will not
work with all inputs
using av_fast_realloc() or similar should avoid both issues


>  
>  while(!avio_feof(s->pb)) {
> -get_line(s->pb, line, sizeof(line));
> +get_line(s->pb, line, line_size);
>  

>  if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) {

out of memory access can happen here


thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand


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


[FFmpeg-devel] [PATCH] lavf/dashenc: Add support for per-stream container type selection.

2018-11-08 Thread Andrey Semashev
This commit restores the ability to create DASH streams with codecs
that require different containers that was lost after commit
2efdbf7367989cf9d296c25fa3d2aff8d6e25fdd. It extends the dash_segment_type
option syntax to allow to specify segment container types for individual
streams, in addition to the default container type that is applied to
all streams. The extended syntax is backward compatible with the previous
syntax.
---
 doc/muxers.texi   |   8 ++-
 libavformat/dashenc.c | 161 +++---
 2 files changed, 140 insertions(+), 29 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 62f4091e31..4418b38c76 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -289,8 +289,12 @@ Set container format (mp4/webm) options using a @code{:} 
separated list of
 key=value parameters. Values containing @code{:} special characters must be
 escaped.
 
-@item dash_segment_type @var{dash_segment_type}
-Possible values:
+@item -dash_segment_type @var{dash_segment_type}
+Sets the container type for dash segment files. Syntax is " :a,b,c 
:d,e" where  is
+the container type and a, b, c, d and e are the indices of the mapped streams. 
When no indices are specified,
+the container type is set for all streams.
+
+Possible container type values:
 @item mp4
 If this flag is set, the dash segment files will be in in ISOBMFF format. This 
is the default format.
 
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index f8b3d106d5..626dc76413 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -84,6 +84,8 @@ typedef struct OutputStream {
 int64_t first_pts, start_pts, max_pts;
 int64_t last_dts, last_pts;
 int bit_rate;
+SegmentType segment_type;
+const char *format_name;
 
 char codec_str[100];
 int written_len;
@@ -131,8 +133,7 @@ typedef struct DASHContext {
 int64_t timeout;
 int index_correction;
 char *format_options_str;
-SegmentType segment_type;
-const char *format_name;
+const char *segment_types_str;
 } DASHContext;
 
 static struct codec_string {
@@ -188,14 +189,6 @@ static void dashenc_io_close(AVFormatContext *s, 
AVIOContext **pb, char *filenam
 }
 }
 
-static const char *get_format_str(SegmentType segment_type) {
-int i;
-for (i = 0; i < SEGMENT_TYPE_NB; i++)
-if (formats[i].segment_type == segment_type)
-return formats[i].str;
-return NULL;
-}
-
 static int check_file_extension(const char *filename, const char *extension) {
 char *dot;
 if (!filename || !extension)
@@ -375,6 +368,8 @@ static void dash_free(AVFormatContext *s)
 c->nb_as = 0;
 }
 
+av_freep(>segment_types_str);
+
 if (!c->streams)
 return;
 for (i = 0; i < s->nb_streams; i++) {
@@ -621,13 +616,13 @@ static int write_adaptation_set(AVFormatContext *s, 
AVIOContext *out, int as_ind
 if (as->media_type == AVMEDIA_TYPE_VIDEO) {
 AVStream *st = s->streams[i];
 avio_printf(out, "\t\t\tformat_name, os->codec_str, bandwidth_str, 
s->streams[i]->codecpar->width, s->streams[i]->codecpar->height);
+i, os->format_name, os->codec_str, bandwidth_str, 
s->streams[i]->codecpar->width, s->streams[i]->codecpar->height);
 if (st->avg_frame_rate.num)
 avio_printf(out, " frameRate=\"%d/%d\"", 
st->avg_frame_rate.num, st->avg_frame_rate.den);
 avio_printf(out, ">\n");
 } else {
 avio_printf(out, "\t\t\t\n",
-i, c->format_name, os->codec_str, bandwidth_str, 
s->streams[i]->codecpar->sample_rate);
+i, os->format_name, os->codec_str, bandwidth_str, 
s->streams[i]->codecpar->sample_rate);
 avio_printf(out, "\t\t\t\t\n",
 s->streams[i]->codecpar->channels);
 }
@@ -773,6 +768,120 @@ end:
 return 0;
 }
 
+static inline void set_all_segment_types(AVFormatContext *s, int format_idx)
+{
+DASHContext *c = s->priv_data;
+for (int i = 0; i < s->nb_streams; ++i) {
+OutputStream *os = >streams[i];
+os->segment_type = formats[format_idx].segment_type;
+os->format_name = formats[format_idx].str;
+}
+}
+
+static int parse_segment_types(AVFormatContext *s)
+{
+DASHContext *c = s->priv_data;
+const char *p = c->segment_types_str;
+enum { type_expected, type_parsed, parsing_streams } state;
+int i, format_idx;
+
+// Set the default container type in case if some streams are not 
mentioned in the string
+set_all_segment_types(s, 0);
+
+if (!p)
+return 0;
+
+// Parse per-stream container types: mp4 webm:0,1,2 and so on
+state = type_expected;
+format_idx = 0;
+while (*p) {
+if (*p == ' ') {
+if (state == type_parsed)
+set_all_segment_types(s, format_idx);
+
+state = type_expected;
+++p;
+continue;
+}
+
+if (state == type_expected) {
+   

Re: [FFmpeg-devel] [PATCH v2] lavf/isom: add Dolby Vision sample entry codes for HEVC and H.264

2018-11-08 Thread Jan Ekström
On Thu, Nov 8, 2018, 03:39 Carl Eugen Hoyos  2018-11-08 0:11 GMT+01:00, Jan Ekström :
>
> > +{ AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', '1') }, /* HEVC-based Dolby
> > Vision derived from hvc1 */
>
> As said before, this breaks real-world files, the patch is therefore not
> ok.
> (And as said before, the authority hasn't done their homework.)
>
> Carl Eugen
>

I think the authority really doesn't look further than "was this identifier
registered already?", which to be fair is not incorrect since you csn
consider everything outside mpeg-4 ra's lists unofficial/nonstandard.

Now, that said, sure. If the stuff got any real usage and you - I think -
have already handled dvh1 in some other point of code if I recall
correctly, then let's leave that thing at that.

Then regarding the rest. Do I understand correctly that you do not trust
dolby's specification and/or mpeg-4 ra and would only like identifiers be
added that have been seen in the wild?

Best regards,
Jan

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


Re: [FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg: Refine the do_video_out.

2018-11-08 Thread Carl Eugen Hoyos
2018-11-08 16:35 GMT+01:00, Jun Zhao :
> Signed-off-by: Jun Zhao 
> ---
>  fftools/ffmpeg.c |   62
> -
>  1 files changed, 28 insertions(+), 34 deletions(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index da4259a..e989e7a 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -1193,33 +1193,27 @@ static void do_video_out(OutputFile *of,
>  }
>  ost->last_dropped = nb_frames == nb0_frames && next_picture;
>
> -  /* duplicates frame if needed */
> -  for (i = 0; i < nb_frames; i++) {
> -AVFrame *in_picture;
> -av_init_packet();
> -pkt.data = NULL;
> -pkt.size = 0;
> -
> -if (i < nb0_frames && ost->last_frame) {
> -in_picture = ost->last_frame;
> -} else
> -in_picture = next_picture;
> +/* duplicates frame if needed */
> +for (i = 0; i < nb_frames; i++) {
> +AVFrame *in_picture;
> +int forced_keyframe = 0;
> +double pts_time;
> +av_init_packet();
> +pkt.data = NULL;
> +pkt.size = 0;
>
> -if (!in_picture)
> -return;
> +if (i < nb0_frames && ost->last_frame) {
> +in_picture = ost->last_frame;
> +} else
> +in_picture = next_picture;

This patch seems to mix functional changes with re-indentation.
The patch will be much easier to review if you move all re-indentation
into the second patch.

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


[FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg: indent the code

2018-11-08 Thread Jun Zhao
Signed-off-by: Jun Zhao 
---
 fftools/ffmpeg.c |   69 ++---
 1 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e989e7a..dbcc9cf 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1488,7 +1488,6 @@ static int reap_filters(int flush)
 }
 //if (ost->source_index >= 0)
 //*filtered_frame= 
*input_streams[ost->source_index]->decoded_frame; //for me_threshold
-
 switch (av_buffersink_get_type(filter)) {
 case AVMEDIA_TYPE_VIDEO:
 if (!ost->frame_aspect_ratio.num)
@@ -1818,7 +1817,7 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 } else
 av_log(NULL, AV_LOG_INFO, "%s%c", buf.str, end);
 
-fflush(stderr);
+fflush(stderr);
 }
 av_bprint_finalize(, NULL);
 
@@ -1925,46 +1924,46 @@ static void flush_encoders(void)
 av_assert0(0);
 }
 
-av_init_packet();
-pkt.data = NULL;
-pkt.size = 0;
+av_init_packet();
+pkt.data = NULL;
+pkt.size = 0;
 
-update_benchmark(NULL);
+update_benchmark(NULL);
 
-while ((ret = avcodec_receive_packet(enc, )) == 
AVERROR(EAGAIN)) {
-ret = avcodec_send_frame(enc, NULL);
-if (ret < 0) {
-av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n",
-   desc,
-   av_err2str(ret));
-exit_program(1);
-}
-}
-
-update_benchmark("flush_%s %d.%d", desc, ost->file_index, 
ost->index);
-if (ret < 0 && ret != AVERROR_EOF) {
+while ((ret = avcodec_receive_packet(enc, )) == 
AVERROR(EAGAIN)) {
+ret = avcodec_send_frame(enc, NULL);
+if (ret < 0) {
 av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n",
desc,
av_err2str(ret));
 exit_program(1);
 }
-if (ost->logfile && enc->stats_out) {
-fprintf(ost->logfile, "%s", enc->stats_out);
-}
-if (ret == AVERROR_EOF) {
-output_packet(of, , ost, 1);
-break;
-}
-if (ost->finished & MUXER_FINISHED) {
-av_packet_unref();
-continue;
-}
-av_packet_rescale_ts(, enc->time_base, ost->mux_timebase);
-pkt_size = pkt.size;
-output_packet(of, , ost, 0);
-if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && 
vstats_filename) {
-do_video_stats(ost, pkt_size);
-}
+}
+
+update_benchmark("flush_%s %d.%d", desc, ost->file_index, 
ost->index);
+if (ret < 0 && ret != AVERROR_EOF) {
+av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n",
+   desc,
+   av_err2str(ret));
+exit_program(1);
+}
+if (ost->logfile && enc->stats_out) {
+fprintf(ost->logfile, "%s", enc->stats_out);
+}
+if (ret == AVERROR_EOF) {
+output_packet(of, , ost, 1);
+break;
+}
+if (ost->finished & MUXER_FINISHED) {
+av_packet_unref();
+continue;
+}
+av_packet_rescale_ts(, enc->time_base, ost->mux_timebase);
+pkt_size = pkt.size;
+output_packet(of, , ost, 0);
+if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && 
vstats_filename) {
+do_video_stats(ost, pkt_size);
+}
 }
 }
 }
-- 
1.7.1

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


[FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg: Refine the do_video_out.

2018-11-08 Thread Jun Zhao
Signed-off-by: Jun Zhao 
---
 fftools/ffmpeg.c |   62 -
 1 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index da4259a..e989e7a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1193,33 +1193,27 @@ static void do_video_out(OutputFile *of,
 }
 ost->last_dropped = nb_frames == nb0_frames && next_picture;
 
-  /* duplicates frame if needed */
-  for (i = 0; i < nb_frames; i++) {
-AVFrame *in_picture;
-av_init_packet();
-pkt.data = NULL;
-pkt.size = 0;
-
-if (i < nb0_frames && ost->last_frame) {
-in_picture = ost->last_frame;
-} else
-in_picture = next_picture;
+/* duplicates frame if needed */
+for (i = 0; i < nb_frames; i++) {
+AVFrame *in_picture;
+int forced_keyframe = 0;
+double pts_time;
+av_init_packet();
+pkt.data = NULL;
+pkt.size = 0;
 
-if (!in_picture)
-return;
+if (i < nb0_frames && ost->last_frame) {
+in_picture = ost->last_frame;
+} else
+in_picture = next_picture;
 
-in_picture->pts = ost->sync_opts;
+if (!in_picture)
+return;
 
-#if 1
-if (!check_recording_time(ost))
-#else
-if (ost->frame_number >= ost->max_frames)
-#endif
-return;
+in_picture->pts = ost->sync_opts;
 
-{
-int forced_keyframe = 0;
-double pts_time;
+if (!check_recording_time(ost))
+return;
 
 if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | 
AV_CODEC_FLAG_INTERLACED_ME) &&
 ost->top_field_first >= 0)
@@ -1328,18 +1322,18 @@ static void do_video_out(OutputFile *of,
 fprintf(ost->logfile, "%s", enc->stats_out);
 }
 }
-}
-ost->sync_opts++;
-/*
- * For video, number of frames in == number of packets out.
- * But there may be reordering, so we can't throw away frames on encoder
- * flush, we need to limit them here, before they go into encoder.
- */
-ost->frame_number++;
 
-if (vstats_filename && frame_size)
-do_video_stats(ost, frame_size);
-  }
+ost->sync_opts++;
+/*
+ * For video, number of frames in == number of packets out.
+ * But there may be reordering, so we can't throw away frames on 
encoder
+ * flush, we need to limit them here, before they go into encoder.
+ */
+ost->frame_number++;
+
+if (vstats_filename && frame_size)
+do_video_stats(ost, frame_size);
+}
 
 if (!ost->last_frame)
 ost->last_frame = av_frame_alloc();
-- 
1.7.1

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


Re: [FFmpeg-devel] [PATCH]lavf/apngdec: Return eof for incomplete files

2018-11-08 Thread Carl Eugen Hoyos
2018-11-08 13:36 GMT+01:00, Paul B Mahol :
> On 11/8/18, Carl Eugen Hoyos  wrote:
>> 2018-11-08 13:23 GMT+01:00, Paul B Mahol :
>>> On 11/7/18, Carl Eugen Hoyos  wrote:
 2018-11-07 1:07 GMT+01:00, Marton Balint :
>
>
> On Wed, 7 Nov 2018, Carl Eugen Hoyos wrote:
>
>> Hi!
>>
>> Attached patch silences the console flooding for incomplete apng files
>> and fixes ticket #7536:
>> In-stream tag=[0][0][0][0] (0x) len=0 is not implemented.
>> Update your FFmpeg version...
>>
>> Please comment, Carl Eugen
>>
>
>>+
>>+if (pb->eof_reached)
>>+return AVERROR_EOF;
>>+
>
> Why not avio_feof(pb)?

 New patch attached.

 Please comment, Carl Eugen

>>>
>>> Isn't this same patch?
>>
>> Looks different here, the file name is the same though,
>> is that an issue?
>
> Sorry, latest patch is ok.

Thank you!

Patch applied, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/apngdec: Return eof for incomplete files

2018-11-08 Thread Paul B Mahol
On 11/8/18, Carl Eugen Hoyos  wrote:
> 2018-11-08 13:23 GMT+01:00, Paul B Mahol :
>> On 11/7/18, Carl Eugen Hoyos  wrote:
>>> 2018-11-07 1:07 GMT+01:00, Marton Balint :


 On Wed, 7 Nov 2018, Carl Eugen Hoyos wrote:

> Hi!
>
> Attached patch silences the console flooding for incomplete apng files
> and fixes ticket #7536:
> In-stream tag=[0][0][0][0] (0x) len=0 is not implemented.
> Update your FFmpeg version...
>
> Please comment, Carl Eugen
>

>+
>+if (pb->eof_reached)
>+return AVERROR_EOF;
>+

 Why not avio_feof(pb)?
>>>
>>> New patch attached.
>>>
>>> Please comment, Carl Eugen
>>>
>>
>> Isn't this same patch?
>
> Looks different here, the file name is the same though,
> is that an issue?

Sorry, latest patch is ok.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/apngdec: Return eof for incomplete files

2018-11-08 Thread Carl Eugen Hoyos
2018-11-08 13:23 GMT+01:00, Paul B Mahol :
> On 11/7/18, Carl Eugen Hoyos  wrote:
>> 2018-11-07 1:07 GMT+01:00, Marton Balint :
>>>
>>>
>>> On Wed, 7 Nov 2018, Carl Eugen Hoyos wrote:
>>>
 Hi!

 Attached patch silences the console flooding for incomplete apng files
 and fixes ticket #7536:
 In-stream tag=[0][0][0][0] (0x) len=0 is not implemented.
 Update your FFmpeg version...

 Please comment, Carl Eugen

>>>
+
+if (pb->eof_reached)
+return AVERROR_EOF;
+
>>>
>>> Why not avio_feof(pb)?
>>
>> New patch attached.
>>
>> Please comment, Carl Eugen
>>
>
> Isn't this same patch?

Looks different here, the file name is the same though,
is that an issue?

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


Re: [FFmpeg-devel] [PATCH]lavf/apngdec: Return eof for incomplete files

2018-11-08 Thread Paul B Mahol
On 11/7/18, Carl Eugen Hoyos  wrote:
> 2018-11-07 1:07 GMT+01:00, Marton Balint :
>>
>>
>> On Wed, 7 Nov 2018, Carl Eugen Hoyos wrote:
>>
>>> Hi!
>>>
>>> Attached patch silences the console flooding for incomplete apng files
>>> and fixes ticket #7536:
>>> In-stream tag=[0][0][0][0] (0x) len=0 is not implemented.
>>> Update your FFmpeg version...
>>>
>>> Please comment, Carl Eugen
>>>
>>
>>>+
>>>+if (pb->eof_reached)
>>>+return AVERROR_EOF;
>>>+
>>
>> Why not avio_feof(pb)?
>
> New patch attached.
>
> Please comment, Carl Eugen
>

Isn't this same patch?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] add an option to forbid the fallback to sw when hardware init fails

2018-11-08 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Hendrik Leppkes
> Sent: Tuesday, October 30, 2018 17:11
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] add an option to forbid the fallback to
> sw when hardware init fails
> 
> On Tue, Oct 30, 2018 at 10:08 AM Linjie Fu  wrote:
> >
> > Currently ff_get_format will go through all usable choices if the
> > chosen format was not supported. It will fallback to software if
> > the hardware init fails.
> >
> > According to the comment in ticket #7519, provided an option
> > "-fallback_forbid 1" to return directly if hardware init fails
> > and forbid the fallback to software.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/avcodec.h   |  8 
> >  libavcodec/decode.c| 11 +--
> >  libavcodec/options_table.h |  1 +
> >  3 files changed, 18 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 705a3ce4f3..fac3c6acb2 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -3312,6 +3312,14 @@ typedef struct AVCodecContext {
> >   * used as reference pictures).
> >   */
> >  int extra_hw_frames;
> > +
> > +/**
> > + * - forbid the fallback to software path in ff_get_format
> > + * - when the hardware init fails. (0 -> disabled)
> > + * - encoding: unused.
> > + * - decoding: Set by user.
> > + */
> > +int fallback_forbid;
> >  } AVCodecContext;
> >
> 
> This is really something user-code should implement, its easy enough
> to detect in eg. get_buffer2, and return an error from there.
> 
> - Hendrik

Thanks for your review, will modify in user-code and detect in get_buffer().

Best regards,
Linjie, Fu.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel