[FFmpeg-devel] [PATCH 3/4] doc/filters: add tonemap_opencl document.

2018-10-28 Thread Ruiling Song
Signed-off-by: Ruiling Song 
---
 doc/filters.texi | 96 
 1 file changed, 96 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 83df460..f884ba4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16387,6 +16387,7 @@ tmix=frames=3:weights="-1 2 -1":scale=1
 @end example
 @end itemize
 
+@anchor{tonemap}
 @section tonemap
 Tone map colors from different dynamic ranges.
 
@@ -18440,6 +18441,101 @@ Apply sobel operator with scale set to 2 and delta 
set to 10
 @end example
 @end itemize
 
+@section tonemap_opencl
+
+Perform HDR(PQ/HLG) to SDR conversion with tone-mapping.
+
+It accepts the following parameters:
+
+@table @option
+@item tonemap
+Specify the tone-mapping operator to be used. Same as tonemap option in 
@ref{tonemap}.
+
+@item param
+Tune the tone mapping algorithm. same as param option in @ref{tonemap}.
+
+@item desat
+Apply desaturation for highlights that exceed this level of brightness. The
+higher the parameter, the more color information will be preserved. This
+setting helps prevent unnaturally blown-out colors for super-highlights, by
+(smoothly) turning into white instead. This makes images feel more natural,
+at the cost of reducing information about out-of-range colors.
+
+The default value is 0.5, and the algorithm here is a little different from
+the cpu version tonemap currently. A setting of 0.0 disables this option.
+
+@item threshold
+The tonemapping algorithm parameters is fine-tuned per each scene. And a 
threshold
+is used to detect whether the scene has changed or not. If the distance beween
+the current frame average brightness and the current running average exceeds
+a threshold value, we would re-calculate scene average and peak brightness.
+The default value is 0.2.
+
+@item format
+Specify the output pixel format.
+
+Currently supported formats are:
+@table @var
+@item p010
+@item nv12
+@end table
+
+@item range, r
+Set the output color range.
+
+Possible values are:
+@table @var
+@item tv/mpeg
+@item pc/jpeg
+@end table
+
+Default is same as input.
+
+@item primaries, p
+Set the output color primaries.
+
+Possible values are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is same as input.
+
+@item transfer, t
+Set the output transfer characteristics.
+
+Possible values are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is bt709.
+
+@item matrix, m
+Set the output colorspace matrix.
+
+Possible value are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is same as input.
+
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Convert HDR(PQ/HLG) video to bt2020-transfer-characteristic p010 format using 
linear operator.
+@example
+-i INPUT -vf 
"format=p010,hwupload,tonemap_opencl=t=bt2020:tonemap=linear:format=p010,hwdownload,format=p010"
 OUTPUT
+@end example
+@end itemize
+
 @section unsharp_opencl
 
 Sharpen or blur the input video.
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 2/4] lavfi/opencl: Handle overlay input formats correctly.

2018-10-28 Thread Ruiling Song
The main input may have alpha channel, we just ignore it.
Also add some checks for incompatible input formats.

Signed-off-by: Ruiling Song 
---
 libavfilter/vf_overlay_opencl.c | 58 -
 1 file changed, 46 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_overlay_opencl.c b/libavfilter/vf_overlay_opencl.c
index e9c8532..320c1a5 100644
--- a/libavfilter/vf_overlay_opencl.c
+++ b/libavfilter/vf_overlay_opencl.c
@@ -37,7 +37,7 @@ typedef struct OverlayOpenCLContext {
 
 FFFrameSync  fs;
 
-int  nb_planes;
+int  nb_color_planes;
 int  x_subsample;
 int  y_subsample;
 int  alpha_separate;
@@ -46,6 +46,22 @@ typedef struct OverlayOpenCLContext {
 int  y_position;
 } OverlayOpenCLContext;
 
+static int has_planar_alpha(const AVPixFmtDescriptor *fmt) {
+int nb_components;
+int has_alpha = !!(fmt->flags & AV_PIX_FMT_FLAG_ALPHA);
+if (!has_alpha) return 0;
+
+nb_components = fmt->nb_components;
+// PAL8
+if (nb_components < 2) return 0;
+
+if (fmt->comp[nb_components - 1].plane >
+fmt->comp[nb_components - 2].plane)
+return 1;
+else
+return 0;
+}
+
 static int overlay_opencl_load(AVFilterContext *avctx,
enum AVPixelFormat main_format,
enum AVPixelFormat overlay_format)
@@ -55,10 +71,13 @@ static int overlay_opencl_load(AVFilterContext *avctx,
 const char *source = ff_opencl_source_overlay;
 const char *kernel;
 const AVPixFmtDescriptor *main_desc, *overlay_desc;
-int err, i, main_planes, overlay_planes;
+int err, i, main_planes, overlay_planes, overlay_alpha,
+main_planar_alpha, overlay_planar_alpha;
 
 main_desc= av_pix_fmt_desc_get(main_format);
 overlay_desc = av_pix_fmt_desc_get(overlay_format);
+overlay_alpha = !!(overlay_desc->flags & AV_PIX_FMT_FLAG_ALPHA);
+main_planar_alpha = has_planar_alpha(main_desc);
 
 main_planes = overlay_planes = 0;
 for (i = 0; i < main_desc->nb_components; i++)
@@ -68,7 +87,7 @@ static int overlay_opencl_load(AVFilterContext *avctx,
 overlay_planes = FFMAX(overlay_planes,
overlay_desc->comp[i].plane + 1);
 
-ctx->nb_planes = main_planes;
+ctx->nb_color_planes = main_planar_alpha ? (main_planes - 1) : main_planes;
 ctx->x_subsample = 1 << main_desc->log2_chroma_w;
 ctx->y_subsample = 1 << main_desc->log2_chroma_h;
 
@@ -80,15 +99,30 @@ static int overlay_opencl_load(AVFilterContext *avctx,
ctx->x_subsample, ctx->y_subsample);
 }
 
-if (main_planes == overlay_planes) {
-if (main_desc->nb_components == overlay_desc->nb_components)
-kernel = "overlay_no_alpha";
-else
-kernel = "overlay_internal_alpha";
+if ((main_desc->flags & AV_PIX_FMT_FLAG_RGB) !=
+(overlay_desc->flags & AV_PIX_FMT_FLAG_RGB)) {
+av_log(avctx, AV_LOG_ERROR, "mixed YUV/RGB input formats.\n");
+return AVERROR(EINVAL);
+}
+
+if (main_desc->log2_chroma_w != overlay_desc->log2_chroma_w ||
+main_desc->log2_chroma_h != overlay_desc->log2_chroma_h) {
+av_log(avctx, AV_LOG_ERROR, "incompatible chroma sub-sampling.\n");
+return AVERROR(EINVAL);
+}
+
+if (!overlay_alpha) {
 ctx->alpha_separate = 0;
+kernel = "overlay_no_alpha";
 } else {
-kernel = "overlay_external_alpha";
-ctx->alpha_separate = 1;
+overlay_planar_alpha = has_planar_alpha(overlay_desc);
+if (overlay_planar_alpha) {
+ctx->alpha_separate = 1;
+kernel = "overlay_external_alpha";
+} else {
+ctx->alpha_separate = 0;
+kernel = "overlay_internal_alpha";
+}
 }
 
 av_log(avctx, AV_LOG_DEBUG, "Using kernel %s.\n", kernel);
@@ -155,7 +189,7 @@ static int overlay_opencl_blend(FFFrameSync *fs)
 goto fail;
 }
 
-for (plane = 0; plane < ctx->nb_planes; plane++) {
+for (plane = 0; plane < ctx->nb_color_planes; plane++) {
 kernel_arg = 0;
 
 mem = (cl_mem)output->data[plane];
@@ -171,7 +205,7 @@ static int overlay_opencl_blend(FFFrameSync *fs)
 kernel_arg++;
 
 if (ctx->alpha_separate) {
-mem = (cl_mem)input_overlay->data[ctx->nb_planes];
+mem = (cl_mem)input_overlay->data[ctx->nb_color_planes];
 CL_SET_KERNEL_ARG(ctx->kernel, kernel_arg, cl_mem, );
 kernel_arg++;
 }
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 4/4] lavfi/opencl: remove peak option of tonemap_opencl

2018-10-28 Thread Ruiling Song
Since the filter use auto-calculate the peak value,
the option does not work as expected. So, remove it.

Signed-off-by: Ruiling Song 
---
 libavfilter/vf_tonemap_opencl.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index cd293c2..88b3107 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -62,7 +62,6 @@ typedef struct TonemapOpenCLContext {
 
 enum TonemapAlgorithm tonemap;
 enum AVPixelFormatformat;
-doublepeak;
 doubleparam;
 doubledesat_param;
 doubletarget_peak;
@@ -349,7 +348,7 @@ static int tonemap_opencl_filter_frame(AVFilterLink 
*inlink, AVFrame *input)
 AVFrame *output = NULL;
 cl_int cle;
 int err;
-double peak = ctx->peak;
+double peak;
 
 AVHWFramesContext *input_frames_ctx =
 (AVHWFramesContext*)input->hw_frames_ctx->data;
@@ -371,8 +370,7 @@ static int tonemap_opencl_filter_frame(AVFilterLink 
*inlink, AVFrame *input)
 if (err < 0)
 goto fail;
 
-if (!peak)
-peak = ff_determine_signal_peak(input);
+peak = ff_determine_signal_peak(input);
 
 if (ctx->trc != -1)
 output->color_trc = ctx->trc;
@@ -518,7 +516,6 @@ static const AVOption tonemap_opencl_options[] = {
 { "limited",   0,   0, AV_OPT_TYPE_CONST, 
{.i64 = AVCOL_RANGE_MPEG}, 0, 0, FLAGS, "range" },
 { "full",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = AVCOL_RANGE_JPEG}, 0, 0, FLAGS, "range" },
 { "format","output pixel format", OFFSET(format), 
AV_OPT_TYPE_PIXEL_FMT, {.i64 = AV_PIX_FMT_NONE}, AV_PIX_FMT_NONE, INT_MAX, 
FLAGS, "fmt" },
-{ "peak",  "signal peak override", OFFSET(peak), AV_OPT_TYPE_DOUBLE, 
{.dbl = 0}, 0, DBL_MAX, FLAGS },
 { "param", "tonemap parameter",   OFFSET(param), AV_OPT_TYPE_DOUBLE, 
{.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
 { "desat", "desaturation parameter",   OFFSET(desat_param), 
AV_OPT_TYPE_DOUBLE, {.dbl = 0.5}, 0, DBL_MAX, FLAGS },
 { "threshold", "scene detection threshold",   OFFSET(scene_threshold), 
AV_OPT_TYPE_DOUBLE, {.dbl = 0.2}, 0, DBL_MAX, FLAGS },
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 2/4] lavfi/opencl: Handle overlay input formats correctly.

2018-10-28 Thread Ruiling Song
The main input may have alpha channel, we just ignore it.
Also add some checks for incompatible input formats.

Signed-off-by: Ruiling Song 
---
 libavfilter/vf_overlay_opencl.c | 58 -
 1 file changed, 46 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_overlay_opencl.c b/libavfilter/vf_overlay_opencl.c
index e9c8532..320c1a5 100644
--- a/libavfilter/vf_overlay_opencl.c
+++ b/libavfilter/vf_overlay_opencl.c
@@ -37,7 +37,7 @@ typedef struct OverlayOpenCLContext {
 
 FFFrameSync  fs;
 
-int  nb_planes;
+int  nb_color_planes;
 int  x_subsample;
 int  y_subsample;
 int  alpha_separate;
@@ -46,6 +46,22 @@ typedef struct OverlayOpenCLContext {
 int  y_position;
 } OverlayOpenCLContext;
 
+static int has_planar_alpha(const AVPixFmtDescriptor *fmt) {
+int nb_components;
+int has_alpha = !!(fmt->flags & AV_PIX_FMT_FLAG_ALPHA);
+if (!has_alpha) return 0;
+
+nb_components = fmt->nb_components;
+// PAL8
+if (nb_components < 2) return 0;
+
+if (fmt->comp[nb_components - 1].plane >
+fmt->comp[nb_components - 2].plane)
+return 1;
+else
+return 0;
+}
+
 static int overlay_opencl_load(AVFilterContext *avctx,
enum AVPixelFormat main_format,
enum AVPixelFormat overlay_format)
@@ -55,10 +71,13 @@ static int overlay_opencl_load(AVFilterContext *avctx,
 const char *source = ff_opencl_source_overlay;
 const char *kernel;
 const AVPixFmtDescriptor *main_desc, *overlay_desc;
-int err, i, main_planes, overlay_planes;
+int err, i, main_planes, overlay_planes, overlay_alpha,
+main_planar_alpha, overlay_planar_alpha;
 
 main_desc= av_pix_fmt_desc_get(main_format);
 overlay_desc = av_pix_fmt_desc_get(overlay_format);
+overlay_alpha = !!(overlay_desc->flags & AV_PIX_FMT_FLAG_ALPHA);
+main_planar_alpha = has_planar_alpha(main_desc);
 
 main_planes = overlay_planes = 0;
 for (i = 0; i < main_desc->nb_components; i++)
@@ -68,7 +87,7 @@ static int overlay_opencl_load(AVFilterContext *avctx,
 overlay_planes = FFMAX(overlay_planes,
overlay_desc->comp[i].plane + 1);
 
-ctx->nb_planes = main_planes;
+ctx->nb_color_planes = main_planar_alpha ? (main_planes - 1) : main_planes;
 ctx->x_subsample = 1 << main_desc->log2_chroma_w;
 ctx->y_subsample = 1 << main_desc->log2_chroma_h;
 
@@ -80,15 +99,30 @@ static int overlay_opencl_load(AVFilterContext *avctx,
ctx->x_subsample, ctx->y_subsample);
 }
 
-if (main_planes == overlay_planes) {
-if (main_desc->nb_components == overlay_desc->nb_components)
-kernel = "overlay_no_alpha";
-else
-kernel = "overlay_internal_alpha";
+if ((main_desc->flags & AV_PIX_FMT_FLAG_RGB) !=
+(overlay_desc->flags & AV_PIX_FMT_FLAG_RGB)) {
+av_log(avctx, AV_LOG_ERROR, "mixed YUV/RGB input formats.\n");
+return AVERROR(EINVAL);
+}
+
+if (main_desc->log2_chroma_w != overlay_desc->log2_chroma_w ||
+main_desc->log2_chroma_h != overlay_desc->log2_chroma_h) {
+av_log(avctx, AV_LOG_ERROR, "incompatible chroma sub-sampling.\n");
+return AVERROR(EINVAL);
+}
+
+if (!overlay_alpha) {
 ctx->alpha_separate = 0;
+kernel = "overlay_no_alpha";
 } else {
-kernel = "overlay_external_alpha";
-ctx->alpha_separate = 1;
+overlay_planar_alpha = has_planar_alpha(overlay_desc);
+if (overlay_planar_alpha) {
+ctx->alpha_separate = 1;
+kernel = "overlay_external_alpha";
+} else {
+ctx->alpha_separate = 0;
+kernel = "overlay_internal_alpha";
+}
 }
 
 av_log(avctx, AV_LOG_DEBUG, "Using kernel %s.\n", kernel);
@@ -155,7 +189,7 @@ static int overlay_opencl_blend(FFFrameSync *fs)
 goto fail;
 }
 
-for (plane = 0; plane < ctx->nb_planes; plane++) {
+for (plane = 0; plane < ctx->nb_color_planes; plane++) {
 kernel_arg = 0;
 
 mem = (cl_mem)output->data[plane];
@@ -171,7 +205,7 @@ static int overlay_opencl_blend(FFFrameSync *fs)
 kernel_arg++;
 
 if (ctx->alpha_separate) {
-mem = (cl_mem)input_overlay->data[ctx->nb_planes];
+mem = (cl_mem)input_overlay->data[ctx->nb_color_planes];
 CL_SET_KERNEL_ARG(ctx->kernel, kernel_arg, cl_mem, );
 kernel_arg++;
 }
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 3/4] doc/filters: add tonemap_opencl document.

2018-10-28 Thread Ruiling Song
Signed-off-by: Ruiling Song 
---
 doc/filters.texi | 96 
 1 file changed, 96 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 83df460..f884ba4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16387,6 +16387,7 @@ tmix=frames=3:weights="-1 2 -1":scale=1
 @end example
 @end itemize
 
+@anchor{tonemap}
 @section tonemap
 Tone map colors from different dynamic ranges.
 
@@ -18440,6 +18441,101 @@ Apply sobel operator with scale set to 2 and delta 
set to 10
 @end example
 @end itemize
 
+@section tonemap_opencl
+
+Perform HDR(PQ/HLG) to SDR conversion with tone-mapping.
+
+It accepts the following parameters:
+
+@table @option
+@item tonemap
+Specify the tone-mapping operator to be used. Same as tonemap option in 
@ref{tonemap}.
+
+@item param
+Tune the tone mapping algorithm. same as param option in @ref{tonemap}.
+
+@item desat
+Apply desaturation for highlights that exceed this level of brightness. The
+higher the parameter, the more color information will be preserved. This
+setting helps prevent unnaturally blown-out colors for super-highlights, by
+(smoothly) turning into white instead. This makes images feel more natural,
+at the cost of reducing information about out-of-range colors.
+
+The default value is 0.5, and the algorithm here is a little different from
+the cpu version tonemap currently. A setting of 0.0 disables this option.
+
+@item threshold
+The tonemapping algorithm parameters is fine-tuned per each scene. And a 
threshold
+is used to detect whether the scene has changed or not. If the distance beween
+the current frame average brightness and the current running average exceeds
+a threshold value, we would re-calculate scene average and peak brightness.
+The default value is 0.2.
+
+@item format
+Specify the output pixel format.
+
+Currently supported formats are:
+@table @var
+@item p010
+@item nv12
+@end table
+
+@item range, r
+Set the output color range.
+
+Possible values are:
+@table @var
+@item tv/mpeg
+@item pc/jpeg
+@end table
+
+Default is same as input.
+
+@item primaries, p
+Set the output color primaries.
+
+Possible values are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is same as input.
+
+@item transfer, t
+Set the output transfer characteristics.
+
+Possible values are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is bt709.
+
+@item matrix, m
+Set the output colorspace matrix.
+
+Possible value are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is same as input.
+
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Convert HDR(PQ/HLG) video to bt2020-transfer-characteristic p010 format using 
linear operator.
+@example
+-i INPUT -vf 
"format=p010,hwupload,tonemap_opencl=t=bt2020:tonemap=linear:format=p010,hwdownload,format=p010"
 OUTPUT
+@end example
+@end itemize
+
 @section unsharp_opencl
 
 Sharpen or blur the input video.
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 1/4] doc/filters: add document for opencl filters

2018-10-28 Thread Ruiling Song
Signed-off-by: Danil Iashchenko 
Signed-off-by: Ruiling Song 
---
Seems like Danil is not working on this recently.
So I re-submit this patch to address the comment over overlay_opencl.

Thanks!
Ruiling
 doc/filters.texi | 486 +++
 1 file changed, 486 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index cadf78c..83df460 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10485,6 +10485,7 @@ A floating point number which specifies chroma temporal 
strength. It defaults to
 @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
 @end table
 
+@anchor{hwdownload}
 @section hwdownload
 
 Download hardware frames to system memory.
@@ -10575,6 +10576,7 @@ ways if there are any additional constraints on that 
filter's output.
 Do not use it without fully understanding the implications of its use.
 @end table
 
+@anchor{hwupload}
 @section hwupload
 
 Upload system memory frames to hardware surfaces.
@@ -18014,6 +18016,490 @@ pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} 
is 1.
 
 @c man end VIDEO FILTERS
 
+@chapter OpenCL Video Filters
+@c man begin OPENCL VIDEO FILTERS
+
+Below is a description of the currently available OpenCL video filters.
+
+To enable compilation of these filters you need to configure FFmpeg with
+@code{--enable-opencl}.
+
+Running OpenCL filters requires you to initialize a hardware device and to 
pass that device to all filters in any filter graph.
+@table @option
+
+@item -init_hw_device opencl[=@var{name}][:@var{device}[,@var{key=value}...]]
+Initialise a new hardware device of type @var{opencl} called @var{name}, using 
the
+given device parameters.
+
+@item -filter_hw_device @var{name}
+Pass the hardware device called @var{name} to all filters in any filter graph.
+
+@end table
+
+For more detailed information see 
@url{https://www.ffmpeg.org/ffmpeg.html#Advanced-Video-options}
+
+@itemize
+@item
+Example of choosing the first device on the second platform and running 
avgblur_opencl filter with default parameters on it.
+@example
+-init_hw_device opencl=gpu:1.0 -filter_hw_device gpu -i INPUT -vf "hwupload, 
avgblur_opencl, hwdownload" OUTPUT
+@end example
+@end itemize
+
+Since OpenCL filters are not able to access frame data in normal memory, all 
frame data needs to be uploaded(@ref{hwupload}) to hardware surfaces connected 
to the appropriate device before being used and then 
downloaded(@ref{hwdownload}) back to normal memory. Note that @ref{hwupload} 
will upload to a surface with the same layout as the software frame, so it may 
be necessary to add a @ref{format} filter immediately before to get the input 
into the right format and @ref{hwdownload} does not support all formats on the 
output - it may be necessary to insert an additional @ref{format} filter 
immediately following in the graph to get the output in a supported format.
+
+@section avgblur_opencl
+
+Apply average blur filter.
+
+The filter accepts the following options:
+
+@table @option
+@item sizeX
+Set horizontal radius size.
+Range is @code{[1, 1024]} and default value is @code{1}.
+
+@item planes
+Set which planes to filter. Default value is @code{0xf}, by which all planes 
are processed.
+
+@item sizeY
+Set vertical radius size. Range is @code{[1, 1024]} and default value is 
@code{0}. If zero, @code{sizeX} value will be used.
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Apply average blur filter with horizontal and vertical size of 3, setting each 
pixel of the output to the average value of the 7x7 region centered on it in 
the input. For pixels on the edges of the image, the region does not extend 
beyond the image boundaries, and so out-of-range coordinates are not used in 
the calculations.
+@example
+-i INPUT -vf "hwupload, avgblur_opencl=3, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section boxblur_opencl
+
+Apply a boxblur algorithm to the input video.
+
+It accepts the following parameters:
+
+@table @option
+
+@item luma_radius, lr
+@item luma_power, lp
+@item chroma_radius, cr
+@item chroma_power, cp
+@item alpha_radius, ar
+@item alpha_power, ap
+
+@end table
+
+A description of the accepted options follows.
+
+@table @option
+@item luma_radius, lr
+@item chroma_radius, cr
+@item alpha_radius, ar
+Set an expression for the box radius in pixels used for blurring the
+corresponding input plane.
+
+The radius value must be a non-negative number, and must not be
+greater than the value of the expression @code{min(w,h)/2} for the
+luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
+planes.
+
+Default value for @option{luma_radius} is "2". If not specified,
+@option{chroma_radius} and @option{alpha_radius} default to the
+corresponding value set for @option{luma_radius}.
+
+The expressions can contain the following constants:
+@table @option
+@item w
+@item h
+The input width and height in pixels.
+
+@item cw
+@item ch
+The input chroma image width and height in pixels.
+
+@item hsub
+@item 

Re: [FFmpeg-devel] [PATCH V4] Add a filter implementing HDR image generation from a single exposure using deep CNNs

2018-10-28 Thread Guo, Yejun
any more comment? thanks.

> -Original Message-
> From: Guo, Yejun
> Sent: Tuesday, October 23, 2018 6:46 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun ; Guo
> Subject: [PATCH V4] Add a filter implementing HDR image generation from a
> single exposure using deep CNNs
> 
> see the algorithm's paper and code below.
> 
> the filter's parameter looks like:
> sdr2hdr=model_filename=/path_to_tensorflow_graph.pb:out_fmt=gbrp10l
> e
> 
> The input of the deep CNN model is RGB24 while the output is float for each
> color channel. This is the filter's default behavior to output format with
> gbrpf32le. And gbrp10le is also supported as the output, so we can see the
> rendering result in a player, as a reference.
> 
> To generate the model file, we need modify the original script a little.
> - set name='y' for y_final within script at
> https://github.com/gabrieleilertsen/hdrcnn/blob/master/network.py
> - add the following code to the script at
> https://github.com/gabrieleilertsen/hdrcnn/blob/master/hdrcnn_predict.py
> 
> graph = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def,
> ["y"]) tf.train.write_graph(graph, '.', 'graph.pb', as_text=False)
> 
> The filter only works when tensorflow C api is supported in the system,
> native backend is not supported since there are some different types of
> layers in the deep CNN model, besides CONV and DEPTH_TO_SPACE.
> 
> https://arxiv.org/pdf/1710.07480.pdf:
>   author   = "Eilertsen, Gabriel and Kronander, Joel, and Denes, Gyorgy 
> and
> Mantiuk, Rafał and Unger, Jonas",
>   title= "HDR image reconstruction from a single exposure using deep
> CNNs",
>   journal  = "ACM Transactions on Graphics (TOG)",
>   number   = "6",
>   volume   = "36",
>   articleno= "178",
>   year = "2017"
> 
> https://github.com/gabrieleilertsen/hdrcnn
> 
> btw, as a whole solution, metadata should also be generated from the sdr
> video, so to be encoded as a HDR video. Not supported yet.
> This patch just focuses on this paper.
> 
> Signed-off-by: Guo, Yejun 
> ---
>  configure|   1 +
>  doc/filters.texi |  35 +++
>  libavfilter/Makefile |   1 +
>  libavfilter/allfilters.c |   1 +
>  libavfilter/vf_sdr2hdr.c | 268
> +++
>  5 files changed, 306 insertions(+)
>  create mode 100644 libavfilter/vf_sdr2hdr.c
> 
> diff --git a/configure b/configure
> index 85d5dd5..5e2efba 100755
> --- a/configure
> +++ b/configure
> @@ -3438,6 +3438,7 @@ scale2ref_filter_deps="swscale"
>  scale_filter_deps="swscale"
>  scale_qsv_filter_deps="libmfx"
>  select_filter_select="pixelutils"
> +sdr2hdr_filter_deps="libtensorflow"
>  sharpness_vaapi_filter_deps="vaapi"
>  showcqt_filter_deps="avcodec avformat swscale"
>  showcqt_filter_suggest="libfontconfig libfreetype"
> diff --git a/doc/filters.texi b/doc/filters.texi index 17e2549..bba9f87 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -14672,6 +14672,41 @@ Scale a subtitle stream (b) to match the main
> video (a) in size before overlayin  @end example  @end itemize
> 
> +@section sdr2hdr
> +
> +HDR image generation from a single exposure using deep CNNs with
> TensorFlow C library.
> +
> +@itemize
> +@item
> +paper:  see @url{https://arxiv.org/pdf/1710.07480.pdf}
> +
> +@item
> +code with model and trained parameters: see
> +@url{https://github.com/gabrieleilertsen/hdrcnn}
> +@end itemize
> +
> +The filter accepts the following options:
> +
> +@table @option
> +
> +@item model_filename
> +Set path to model file specifying network architecture and its parameters.
> +
> +@item out_fmt
> +the data format of the filter's output.
> +
> +It accepts the following values:
> +@table @samp
> +@item gbrpf32le
> +force gbrpf32le output
> +
> +@item gbrp10le
> +force gbrp10le output
> +@end table
> +
> +Default value is @samp{gbrpf32le}.
> +
> +@end table
> +
>  @anchor{selectivecolor}
>  @section selectivecolor
> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 
> 62cc2f5..88e7da6
> 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -360,6 +360,7 @@ OBJS-$(CONFIG_SOBEL_OPENCL_FILTER)   +=
> vf_convolution_opencl.o opencl.o
>  OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
>  OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o
>  OBJS-$(CONFIG_SR_FILTER) += vf_sr.o
> +OBJS-$(CONFIG_SDR2HDR_FILTER)+= vf_sdr2hdr.o
>  OBJS-$(CONFIG_SSIM_FILTER)   += vf_ssim.o framesync.o
>  OBJS-$(CONFIG_STEREO3D_FILTER)   += vf_stereo3d.o
>  OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o
> framesync.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 
> 5e72803..1645c0f
> 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -319,6 +319,7 @@ extern AVFilter ff_vf_scale_npp;  extern AVFilter
> ff_vf_scale_qsv;  extern AVFilter ff_vf_scale_vaapi;  extern AVFilter
> 

Re: [FFmpeg-devel] [PATCH] cbs_vp9: Ensure that reserved zero bits are actually zero

2018-10-28 Thread James Almer
On 10/27/2018 4:41 PM, Mark Thompson wrote:
> ---
> On 27/10/18 20:26, James Almer wrote:
>> On 10/27/2018 4:13 PM, James Almer wrote:
>>> On 10/27/2018 4:11 PM, Mark Thompson wrote:
 On 26/10/18 20:37, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/cbs_vp9_syntax_template.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/cbs_vp9_syntax_template.c 
> b/libavcodec/cbs_vp9_syntax_template.c
> index 0db0f52a6d..b4a7f65e85 100644
> --- a/libavcodec/cbs_vp9_syntax_template.c
> +++ b/libavcodec/cbs_vp9_syntax_template.c
> @@ -65,6 +65,7 @@ static int FUNC(color_config)(CodedBitstreamContext 
> *ctx, RWContext *rw,
>  if (profile == 1 || profile == 3) {
>  infer(subsampling_x, 0);
>  infer(subsampling_y, 0);
> +f(1, color_config_reserved_zero);
>  }
>  }
>  
>

 This and the one above should probably be called "reserved_zero" for trace 
 purposes.  Not sure where the longer name came from.

>>>
>>> Yeah, the spec simply says reserved_zero, so i'll change it.
>>
>> Looks like you came up with the longer name because there's another
>> "reserved_zero" field in the uncompressed header, and of course you
>> couldn't use it for both.
>>
>> The solution would be to move the color config fields to its own struct
>> called VP9RawColorConfig, like you did in cbs av1.
> 
> Or this, so we don't store them at all :)
> 
> 
>  libavcodec/cbs_vp9.c | 13 +
>  libavcodec/cbs_vp9.h |  2 --
>  libavcodec/cbs_vp9_syntax_template.c |  6 +++---
>  3 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c
> index 7498be4b73..c03ce986c0 100644
> --- a/libavcodec/cbs_vp9.c
> +++ b/libavcodec/cbs_vp9.c
> @@ -314,6 +314,12 @@ static int cbs_vp9_write_le(CodedBitstreamContext *ctx, 
> PutBitContext *pbc,
>  current->name = prob; \
>  } while (0)
>  
> +#define fixed(width, name, value) do { \
> +av_unused uint32_t fixed_value = value; \
> +CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
> +   0, _value, value, value)); \
> +} while (0)
> +
>  #define infer(name, value) do { \
>  current->name = value; \
>  } while (0)
> @@ -331,6 +337,7 @@ static int cbs_vp9_write_le(CodedBitstreamContext *ctx, 
> PutBitContext *pbc,
>  #undef fle
>  #undef delta_q
>  #undef prob
> +#undef fixed
>  #undef infer
>  #undef byte_alignment
>  
> @@ -370,6 +377,11 @@ static int cbs_vp9_write_le(CodedBitstreamContext *ctx, 
> PutBitContext *pbc,
>  xf(8, name.prob, current->name, subs, __VA_ARGS__); \
>  } while (0)
>  
> +#define fixed(width, name, value) do { \
> +CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
> +0, value, value, value)); \
> +} while (0)
> +
>  #define infer(name, value) do { \
>  if (current->name != (value)) { \
>  av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
> @@ -392,6 +404,7 @@ static int cbs_vp9_write_le(CodedBitstreamContext *ctx, 
> PutBitContext *pbc,
>  #undef fle
>  #undef delta_q
>  #undef prob
> +#undef fixed
>  #undef infer
>  #undef byte_alignment
>  
> diff --git a/libavcodec/cbs_vp9.h b/libavcodec/cbs_vp9.h
> index 7eee6d5e9e..ac66da5af1 100644
> --- a/libavcodec/cbs_vp9.h
> +++ b/libavcodec/cbs_vp9.h
> @@ -84,7 +84,6 @@ typedef struct VP9RawFrameHeader {
>  uint8_t frame_marker;
>  uint8_t profile_low_bit;
>  uint8_t profile_high_bit;
> -uint8_t profile_reserved_zero;
>  
>  uint8_t show_existing_frame;
>  uint8_t frame_to_show_map_idx;
> @@ -99,7 +98,6 @@ typedef struct VP9RawFrameHeader {
>  uint8_t color_range;
>  uint8_t subsampling_x;
>  uint8_t subsampling_y;
> -uint8_t color_config_reserved_zero;
>  
>  uint8_t refresh_frame_flags;
>  
> diff --git a/libavcodec/cbs_vp9_syntax_template.c 
> b/libavcodec/cbs_vp9_syntax_template.c
> index cd5b83a4f5..ec8463e6d7 100644
> --- a/libavcodec/cbs_vp9_syntax_template.c
> +++ b/libavcodec/cbs_vp9_syntax_template.c
> @@ -59,7 +59,7 @@ static int FUNC(color_config)(CodedBitstreamContext *ctx, 
> RWContext *rw,
>  if (profile == 1 || profile == 3) {
>  f(1, subsampling_x);
>  f(1, subsampling_y);
> -f(1, color_config_reserved_zero);
> +fixed(1, reserved_zero, 0);
>  } else {
>  infer(subsampling_x, 1);
>  infer(subsampling_y, 1);
> @@ -69,7 +69,7 @@ static int FUNC(color_config)(CodedBitstreamContext *ctx, 
> RWContext *rw,
>  if (profile == 1 || profile == 3) {
>  infer(subsampling_x, 0);
>  infer(subsampling_y, 0);
> -f(1, color_config_reserved_zero);
> +fixed(1, reserved_zero, 0);
>  }
>  }
>  
> @@ -278,7 +278,7 @@ 

Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable vaapi rotation feature via call Intel iHD driver

2018-10-28 Thread myp...@gmail.com
On Fri, Oct 26, 2018 at 11:26 PM Paul B Mahol  wrote:
>
> On 10/26/18, Zhou, Zachary  wrote:
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> >> Rostislav Pehlivanov
> >> Sent: Friday, October 26, 2018 9:02 PM
> >> To: FFmpeg development discussions and patches 
> >> Subject: Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable vaapi
> >> rotation feature via call Intel iHD driver
> >>
> >> On Fri, 26 Oct 2018 at 04:10, Zhou, Zachary 
> >> wrote:
> >>
> >> >
> >> >
> >> > > -Original Message-
> >> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >> > > Behalf Of sean darcy
> >> > > Sent: Thursday, October 25, 2018 11:51 PM
> >> > > To: ffmpeg-devel@ffmpeg.org
> >> > > Subject: Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable
> >> > > vaapi rotation feature via call Intel iHD driver
> >> > >
> >> > > On 10/25/18 2:52 AM, Zachary Zhou wrote:
> >> > > > It supports clockwise rotation by 0/90/180/270 degrees defined in
> >> > > > va/va_vpp.h, tested following command line on SKL platform
> >> > > >
> >> > > > dir=0 for 0   degree
> >> > > > dir=1 for 90  degree
> >> > > > dir=2 for 180 degree
> >> > > > dir=3 for 270 degree
> >> > > >
> >> > > > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
> >> > > > -hwaccel_output_format vaapi -i input.264 -vf
> >> > > > "rotation_vaapi=dir=1"
> >> > > > -c:v h264_vaapi output.h264
> >> > > >
> >> > > > Signed-off-by: Zachary Zhou 
> >> > > > ---
> >> > > >   configure |   3 +
> >> > > >   libavfilter/Makefile  |   1 +
> >> > > >   libavfilter/allfilters.c  |   1 +
> >> > > >   libavfilter/vaapi_vpp.h   |   1 +
> >> > > >   libavfilter/vf_rotate_vaapi.c | 252
> >> > ++
> >> > > >   5 files changed, 258 insertions(+)
> >> > > >   create mode 100644 libavfilter/vf_rotate_vaapi.c
> >> > > >
> >> > > > diff --git a/configure b/configure index 85d5dd5962..33aced3d78
> >> > > > 100755
> >> > > > --- a/configure
> >> > > > +++ b/configure
> >> > > > @@ -6390,6 +6390,9 @@ if enabled vaapi; then
> >> > > >   fi
> >> > > >
> >> > > >   check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0,
> >> 0)"
> >> > > > +if ! check_struct "va/va.h" "struct _VAProcPipelineCaps"
> >> > rotation_flags;
> >> > > then
> >> > > > +disable rotation_vaapi_filter
> >> > > > +fi
> >> > > >   fi
> >> > > >
> >> > > >   if enabled_all opencl libdrm ; then diff --git
> >> > > > a/libavfilter/Makefile b/libavfilter/Makefile index
> >> > > > 108a2f87d7..534650364a 100644
> >> > > > --- a/libavfilter/Makefile
> >> > > > +++ b/libavfilter/Makefile
> >> > > > @@ -349,6 +349,7 @@ OBJS-$(CONFIG_SETRANGE_FILTER)   +=
> >> > > vf_setparams.o
> >> > > >   OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o
> >> > > >   OBJS-$(CONFIG_SETTB_FILTER)  += settb.o
> >> > > >   OBJS-$(CONFIG_SHARPNESS_VAAPI_FILTER)+= vf_misc_vaapi.o
> >> > > vaapi_vpp.o
> >> > > > +OBJS-$(CONFIG_ROTATION_VAAPI_FILTER) += vf_rotate_vaapi.o
> >> > > vaapi_vpp.o
> >> > > >   OBJS-$(CONFIG_SHOWINFO_FILTER)   += vf_showinfo.o
> >> > > >   OBJS-$(CONFIG_SHOWPALETTE_FILTER)+= vf_showpalette.o
> >> > > >   OBJS-$(CONFIG_SHUFFLEFRAMES_FILTER)  +=
> >> > > > vf_shuffleframes.o
> >> > > > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> >> > > > index
> >> > > > 557590850b..4b90a7f440 100644
> >> > > > --- a/libavfilter/allfilters.c
> >> > > > +++ b/libavfilter/allfilters.c
> >> > > > @@ -333,6 +333,7 @@ extern AVFilter ff_vf_setrange;
> >> > > >   extern AVFilter ff_vf_setsar;
> >> > > >   extern AVFilter ff_vf_settb;
> >> > > >   extern AVFilter ff_vf_sharpness_vaapi;
> >> > > > +extern AVFilter ff_vf_rotation_vaapi;
> >> > > >   extern AVFilter ff_vf_showinfo;
> >> > > >   extern AVFilter ff_vf_showpalette;
> >> > > >   extern AVFilter ff_vf_shuffleframes; diff --git
> >> > > > a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h index
> >> > > > 0bc31018d4..cfe19b689f 100644
> >> > > > --- a/libavfilter/vaapi_vpp.h
> >> > > > +++ b/libavfilter/vaapi_vpp.h
> >> > > > @@ -44,6 +44,7 @@ typedef struct VAAPIVPPContext {
> >> > > >   int output_width;   // computed width
> >> > > >   int output_height;  // computed height
> >> > > >
> >> > > > +int rotation_state;
> >> > > >   VABufferID filter_buffers[VAProcFilterCount];
> >> > > >   intnb_filter_buffers;
> >> > > >
> >> > > > diff --git a/libavfilter/vf_rotate_vaapi.c
> >> > > > b/libavfilter/vf_rotate_vaapi.c new file mode 100644 index
> >> > > > 00..34c270e9c7
> >> > > > --- /dev/null
> >> > > > +++ b/libavfilter/vf_rotate_vaapi.c
> >> > > > @@ -0,0 +1,252 @@
> >> > > > +/*
> >> > > > + * This file is part of FFmpeg.
> >> > > > + *
> >> > > > + * FFmpeg is free software; you can redistribute it and/or
> >> > > > + * modify it under 

Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable vaapi rotation feature via call Intel iHD driver

2018-10-28 Thread Zhou, Zachary


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> sean darcy
> Sent: Saturday, October 27, 2018 3:07 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable vaapi
> rotation feature via call Intel iHD driver
> 
> On 10/26/18 11:18 AM, Paul B Mahol wrote:
> > On 10/26/18, Zhou, Zachary  wrote:
> >>
> >>
> >>> -Original Message-
> >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >>> Behalf Of Rostislav Pehlivanov
> >>> Sent: Friday, October 26, 2018 9:02 PM
> >>> To: FFmpeg development discussions and patches
> >>> 
> >>> Subject: Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable
> >>> vaapi rotation feature via call Intel iHD driver
> >>>
> >>> On Fri, 26 Oct 2018 at 04:10, Zhou, Zachary 
> >>> wrote:
> >>>
> 
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf Of sean darcy
> > Sent: Thursday, October 25, 2018 11:51 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable
> > vaapi rotation feature via call Intel iHD driver
> >
> > On 10/25/18 2:52 AM, Zachary Zhou wrote:
> >> It supports clockwise rotation by 0/90/180/270 degrees defined in
> >> va/va_vpp.h, tested following command line on SKL platform
> >>
> >> dir=0 for 0   degree
> >> dir=1 for 90  degree
> >> dir=2 for 180 degree
> >> dir=3 for 270 degree
> >>
> >> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
> >> -hwaccel_output_format vaapi -i input.264 -vf
> >> "rotation_vaapi=dir=1"
> >> -c:v h264_vaapi output.h264
> >>
> >> Signed-off-by: Zachary Zhou 
> >> ---
> >>configure |   3 +
> >>libavfilter/Makefile  |   1 +
> >>libavfilter/allfilters.c  |   1 +
> >>libavfilter/vaapi_vpp.h   |   1 +
> >>libavfilter/vf_rotate_vaapi.c | 252
>  ++
> >>5 files changed, 258 insertions(+)
> >>create mode 100644 libavfilter/vf_rotate_vaapi.c
> >>
> >> diff --git a/configure b/configure index 85d5dd5962..33aced3d78
> >> 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -6390,6 +6390,9 @@ if enabled vaapi; then
> >>fi
> >>
> >>check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1,
> >> 0,
> >>> 0)"
> >> +if ! check_struct "va/va.h" "struct _VAProcPipelineCaps"
>  rotation_flags;
> > then
> >> +disable rotation_vaapi_filter
> >> +fi
> >>fi
> >>
> >>if enabled_all opencl libdrm ; then diff --git
> >> a/libavfilter/Makefile b/libavfilter/Makefile index
> >> 108a2f87d7..534650364a 100644
> >> --- a/libavfilter/Makefile
> >> +++ b/libavfilter/Makefile
> >> @@ -349,6 +349,7 @@ OBJS-$(CONFIG_SETRANGE_FILTER)   +=
> > vf_setparams.o
> >>OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o
> >>OBJS-$(CONFIG_SETTB_FILTER)  += settb.o
> >>OBJS-$(CONFIG_SHARPNESS_VAAPI_FILTER)+= vf_misc_vaapi.o
> > vaapi_vpp.o
> >> +OBJS-$(CONFIG_ROTATION_VAAPI_FILTER) += vf_rotate_vaapi.o
> > vaapi_vpp.o
> >>OBJS-$(CONFIG_SHOWINFO_FILTER)   += vf_showinfo.o
> >>OBJS-$(CONFIG_SHOWPALETTE_FILTER)+= vf_showpalette.o
> >>OBJS-$(CONFIG_SHUFFLEFRAMES_FILTER)  +=
> >> vf_shuffleframes.o
> >> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> >> index
> >> 557590850b..4b90a7f440 100644
> >> --- a/libavfilter/allfilters.c
> >> +++ b/libavfilter/allfilters.c
> >> @@ -333,6 +333,7 @@ extern AVFilter ff_vf_setrange;
> >>extern AVFilter ff_vf_setsar;
> >>extern AVFilter ff_vf_settb;
> >>extern AVFilter ff_vf_sharpness_vaapi;
> >> +extern AVFilter ff_vf_rotation_vaapi;
> >>extern AVFilter ff_vf_showinfo;
> >>extern AVFilter ff_vf_showpalette;
> >>extern AVFilter ff_vf_shuffleframes; diff --git
> >> a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h index
> >> 0bc31018d4..cfe19b689f 100644
> >> --- a/libavfilter/vaapi_vpp.h
> >> +++ b/libavfilter/vaapi_vpp.h
> >> @@ -44,6 +44,7 @@ typedef struct VAAPIVPPContext {
> >>int output_width;   // computed width
> >>int output_height;  // computed height
> >>
> >> +int rotation_state;
> >>VABufferID filter_buffers[VAProcFilterCount];
> >>intnb_filter_buffers;
> >>
> >> diff --git a/libavfilter/vf_rotate_vaapi.c
> >> b/libavfilter/vf_rotate_vaapi.c new file mode 100644 index
> >> 00..34c270e9c7
> >> --- /dev/null
> >> +++ b/libavfilter/vf_rotate_vaapi.c
> >> @@ -0,0 

Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable vaapi rotation feature via call Intel iHD driver

2018-10-28 Thread Zhou, Zachary


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Michael Niedermayer
> Sent: Saturday, October 27, 2018 5:16 AM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V2] libavfilter/vaapi: enable vaapi
> rotation feature via call Intel iHD driver
> 
> On Thu, Oct 25, 2018 at 02:52:01PM +0800, Zachary Zhou wrote:
> > It supports clockwise rotation by 0/90/180/270 degrees defined in
> > va/va_vpp.h, tested following command line on SKL platform
> >
> > dir=0 for 0   degree
> > dir=1 for 90  degree
> > dir=2 for 180 degree
> > dir=3 for 270 degree
> >
> > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
> > -hwaccel_output_format vaapi -i input.264 -vf "rotation_vaapi=dir=1"
> > -c:v h264_vaapi output.h264
> >
> > Signed-off-by: Zachary Zhou 
> > ---
> >  configure |   3 +
> >  libavfilter/Makefile  |   1 +
> >  libavfilter/allfilters.c  |   1 +
> >  libavfilter/vaapi_vpp.h   |   1 +
> >  libavfilter/vf_rotate_vaapi.c | 252
> > ++
> >  5 files changed, 258 insertions(+)
> >  create mode 100644 libavfilter/vf_rotate_vaapi.c
> 
> still fails to build on 32bit x86
> 
> src/libavfilter/vf_rotate_vaapi.c: In function
> ‘rotation_vaapi_build_filter_params’:
> src/libavfilter/vf_rotate_vaapi.c:69:23: error: ‘VAProcPipelineCaps’ has no
> member named ‘rotation_flags’
>  if (!pipeline_caps.rotation_flags) {
>^
> src/libavfilter/vf_rotate_vaapi.c:95:33: error: ‘VAProcPipelineCaps’ has no
> member named ‘rotation_flags’
>  support_flag = pipeline_caps.rotation_flags &
>  ^
> src/libavfilter/vf_rotate_vaapi.c: In function ‘rotation_vaapi_filter_frame’:
> src/libavfilter/vf_rotate_vaapi.c:152:15: error:
> ‘VAProcPipelineParameterBuffer’ has no member named ‘rotation_state’
>  params.rotation_state = vpp_ctx->rotation_state;
>^
> make: *** [libavfilter/vf_rotate_vaapi.o] Error 1
> make: *** Waiting for unfinished jobs
> 
> grep VAAPI ffbuild/config.mak
> !HAVE_VAAPI_DRM=yes
> !HAVE_VAAPI_X11=yes
> !HAVE_OPENCL_VAAPI_BEIGNET=yes
> !HAVE_OPENCL_VAAPI_INTEL_MEDIA=yes
> !CONFIG_VAAPI_ENCODE_EXAMPLE=yes
> !CONFIG_VAAPI_TRANSCODE_EXAMPLE=yes
> !CONFIG_VAAPI=yes
> !CONFIG_VAAPI_1=yes
> !CONFIG_VAAPI_ENCODE=yes
> !CONFIG_H264_VAAPI_ENCODER=yes
> !CONFIG_HEVC_VAAPI_ENCODER=yes
> !CONFIG_MJPEG_VAAPI_ENCODER=yes
> !CONFIG_MPEG2_VAAPI_ENCODER=yes
> !CONFIG_VP8_VAAPI_ENCODER=yes
> !CONFIG_VP9_VAAPI_ENCODER=yes
> !CONFIG_H263_VAAPI_HWACCEL=yes
> !CONFIG_H264_VAAPI_HWACCEL=yes
> !CONFIG_HEVC_VAAPI_HWACCEL=yes
> !CONFIG_MJPEG_VAAPI_HWACCEL=yes
> !CONFIG_MPEG2_VAAPI_HWACCEL=yes
> !CONFIG_MPEG4_VAAPI_HWACCEL=yes
> !CONFIG_VC1_VAAPI_HWACCEL=yes
> !CONFIG_VP8_VAAPI_HWACCEL=yes
> !CONFIG_VP9_VAAPI_HWACCEL=yes
> !CONFIG_WMV3_VAAPI_HWACCEL=yes
> !CONFIG_DEINTERLACE_VAAPI_FILTER=yes
> !CONFIG_DENOISE_VAAPI_FILTER=yes
> !CONFIG_PROCAMP_VAAPI_FILTER=yes
> !CONFIG_SCALE_VAAPI_FILTER=yes
> !CONFIG_SHARPNESS_VAAPI_FILTER=yes
> CONFIG_ROTATION_VAAPI_FILTER=yes
> 
> [...]

Thanks Michael, Can you share your command line for the build script configure ?
Do I need more setting on the configure file ?

> --
> Michael GnuPG fingerprint:
> 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> If you drop bombs on a foreign country and kill a hundred thousand innocent
> people, expect your government to call the consequence "unprovoked
> inhuman terrorist attacks" and use it to justify dropping more bombs and
> killing more people. The technology changed, the idea is old.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] libavformat: add multiple PCR streams in MPEGTS muxer

2018-10-28 Thread fjdh7h+2jnbu7gpkuczk
From 44c9f3d96c5969349bd2dc4d63e9a8b8e6b5a0e2 Mon Sep 17 00:00:00 2001
From: M. Sanders 
Date: Sat, 27 Oct 2018 21:39:44 +0200
Subject: [PATCH] libavformat: add multiple PCR streams in MPEGTS muxer

---
This simple patch adds two new options to the MPEG-TS muxer.
You can use them to mark PCRs in additional VIDEO and/or AUDIO streams.
It's useful when you will remux the output with pid filtering tools.
For example, if you put PCR in all audio streams, then you can filter 
each audio stream to create a radio service.
PCR marks do not disturb outgoing stream, but it is not recommended 
to do so as a regular rule.

 doc/muxers.texi |  6 ++
 libavformat/mpegtsenc.c | 19 +--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f18543e83d..328707d0ed 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1528,6 +1528,12 @@ is @code{-1}, which results in shifting timestamps so 
that they start from 0.
 @item omit_video_pes_length @var{boolean}
 Omit the PES packet length for video packets. Default is @code{1} (true).
 
+@item pcr_all_video @var{boolean}
+Include PCR values in all video streams. Default is @code{0} (false).
+
+@item pcr_all_audio @var{boolean}
+Include PCR values in all audio streams. Default is @code{0} (false).
+
 @item pcr_period @var{integer}
 Override the default PCR retransmission time in milliseconds. Ignored if
 variable muxrate is selected. Default is @code{20}.
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 3339e26d50..caef817a3d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -113,6 +113,8 @@ typedef struct MpegTSWrite {
 double sdt_period;
 int64_t last_pat_ts;
 int64_t last_sdt_ts;
+int pcr_all_video;
+int pcr_all_audio;
 
 int omit_video_pes_length;
 } MpegTSWrite;
@@ -1178,11 +1180,18 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 int64_t pcr = -1; /* avoid warning */
 int64_t delay = av_rescale(s->max_delay, 9, AV_TIME_BASE);
 int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && 
!ts_st->prev_payload_key;
+int force_pcr = 0;
 
 av_assert0(ts_st->payload != buf || st->codecpar->codec_type != 
AVMEDIA_TYPE_VIDEO);
 if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codecpar->codec_type 
== AVMEDIA_TYPE_VIDEO) {
 force_pat = 1;
 }
+if (ts->pcr_all_video && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+force_pcr = 1;
+}
+if (ts->pcr_all_audio && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+force_pcr = 1;
+}
 
 is_start = 1;
 while (payload_size > 0) {
@@ -1190,7 +1199,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 force_pat = 0;
 
 write_pcr = 0;
-if (ts_st->pid == ts_st->service->pcr_pid) {
+if (ts_st->pid == ts_st->service->pcr_pid || force_pcr) {
 if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on 
frames
 ts_st->service->pcr_packet_count++;
 if (ts_st->service->pcr_packet_count >=
@@ -1228,7 +1237,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 }
 if (key && is_start && pts != AV_NOPTS_VALUE) {
 // set Random Access for key frames
-if (ts_st->pid == ts_st->service->pcr_pid)
+if (ts_st->pid == ts_st->service->pcr_pid || force_pcr)
 write_pcr = 1;
 set_af_flag(buf, 0x40);
 q = get_ts_payload_start(buf);
@@ -1951,6 +1960,12 @@ static const AVOption options[] = {
 { "omit_video_pes_length", "Omit the PES packet length for video packets",
   offsetof(MpegTSWrite, omit_video_pes_length), AV_OPT_TYPE_BOOL,
   { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+{ "pcr_all_video", "Include PCR values in all video streams",
+  offsetof(MpegTSWrite, pcr_all_video), AV_OPT_TYPE_BOOL,
+  { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+{ "pcr_all_audio", "Include PCR values in all audio streams",
+  offsetof(MpegTSWrite, pcr_all_audio), AV_OPT_TYPE_BOOL,
+  { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
 { "pcr_period", "PCR retransmission time in milliseconds",
   offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT,
   { .i64 = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-- 
2.11.0






Sent using Guerrillamail.com
Block or report abuse: 
https://www.guerrillamail.com//abuse/?a=R0d5FQgHDrAQngu40HgZfwTCSoSfwNA%3D


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


[FFmpeg-devel] [PATCH] libavformat: add multiple PCR streams in MPEGTS muxer

2018-10-28 Thread fix45u+5vw5dhzga3hjs
From 44c9f3d96c5969349bd2dc4d63e9a8b8e6b5a0e2 Mon Sep 17 00:00:00 2001
From: M. Sanders 
Date: Sat, 27 Oct 2018 21:39:44 +0200
Subject: [PATCH] libavformat: add multiple PCR streams in MPEGTS muxer

---
This simple patch adds two new options to the MPEG-TS muxer.
You can use them to mark PCRs in additional VIDEO and/or AUDIO streams.
It's useful when you will remux the output with pid filtering tools.
For example, if you put PCR in all audio streams, then you can filter 
each audio stream to create a radio service.
PCR marks do not disturb outgoing stream, but it is not recommended 
to do so as a regular rule.

 doc/muxers.texi |  6 ++
 libavformat/mpegtsenc.c | 19 +--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f18543e83d..328707d0ed 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1528,6 +1528,12 @@ is @code{-1}, which results in shifting timestamps so 
that they start from 0.
 @item omit_video_pes_length @var{boolean}
 Omit the PES packet length for video packets. Default is @code{1} (true).
 
+@item pcr_all_video @var{boolean}
+Include PCR values in all video streams. Default is @code{0} (false).
+
+@item pcr_all_audio @var{boolean}
+Include PCR values in all audio streams. Default is @code{0} (false).
+
 @item pcr_period @var{integer}
 Override the default PCR retransmission time in milliseconds. Ignored if
 variable muxrate is selected. Default is @code{20}.
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 3339e26d50..caef817a3d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -113,6 +113,8 @@ typedef struct MpegTSWrite {
 double sdt_period;
 int64_t last_pat_ts;
 int64_t last_sdt_ts;
+int pcr_all_video;
+int pcr_all_audio;
 
 int omit_video_pes_length;
 } MpegTSWrite;
@@ -1178,11 +1180,18 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 int64_t pcr = -1; /* avoid warning */
 int64_t delay = av_rescale(s->max_delay, 9, AV_TIME_BASE);
 int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && 
!ts_st->prev_payload_key;
+int force_pcr = 0;
 
 av_assert0(ts_st->payload != buf || st->codecpar->codec_type != 
AVMEDIA_TYPE_VIDEO);
 if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codecpar->codec_type 
== AVMEDIA_TYPE_VIDEO) {
 force_pat = 1;
 }
+if (ts->pcr_all_video && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+force_pcr = 1;
+}
+if (ts->pcr_all_audio && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+force_pcr = 1;
+}
 
 is_start = 1;
 while (payload_size > 0) {
@@ -1190,7 +1199,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 force_pat = 0;
 
 write_pcr = 0;
-if (ts_st->pid == ts_st->service->pcr_pid) {
+if (ts_st->pid == ts_st->service->pcr_pid || force_pcr) {
 if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on 
frames
 ts_st->service->pcr_packet_count++;
 if (ts_st->service->pcr_packet_count >=
@@ -1228,7 +1237,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 }
 if (key && is_start && pts != AV_NOPTS_VALUE) {
 // set Random Access for key frames
-if (ts_st->pid == ts_st->service->pcr_pid)
+if (ts_st->pid == ts_st->service->pcr_pid || force_pcr)
 write_pcr = 1;
 set_af_flag(buf, 0x40);
 q = get_ts_payload_start(buf);
@@ -1951,6 +1960,12 @@ static const AVOption options[] = {
 { "omit_video_pes_length", "Omit the PES packet length for video packets",
   offsetof(MpegTSWrite, omit_video_pes_length), AV_OPT_TYPE_BOOL,
   { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+{ "pcr_all_video", "Include PCR values in all video streams",
+  offsetof(MpegTSWrite, pcr_all_video), AV_OPT_TYPE_BOOL,
+  { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+{ "pcr_all_audio", "Include PCR values in all audio streams",
+  offsetof(MpegTSWrite, pcr_all_audio), AV_OPT_TYPE_BOOL,
+  { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
 { "pcr_period", "PCR retransmission time in milliseconds",
   offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT,
   { .i64 = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-- 
2.11.0






Sent using Guerrillamail.com
Block or report abuse: 
https://www.guerrillamail.com//abuse/?a=R0d5FQgHDrAQngu40HgZfwTCSoSfwNA%3D


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


[FFmpeg-devel] libavformat: add multiple PCR streams in MPEGTS muxer

2018-10-28 Thread fjdh7h+2jnbu7gpkuczk
This simple patch adds two new options to the MPEG-TS muxer.
You can use them to mark PCRs in additional VIDEO and/or AUDIO streams.
It's useful when you will remux the output with pid filtering tools.
For example, if you put PCR in all audio streams, then you can filter 
each audio stream to create a radio service.
PCR marks do not disturb outgoing stream, but it is not recommended 
to do so as a regular rule.

M. Sanders






Sent using Guerrillamail.com
Block or report abuse: 
https://www.guerrillamail.com//abuse/?a=R0d5FQgHDrAQngu40HgZfwTCSoSfwNA%3D


0001-libavformat-add-multiple-PCR-streams-in-MPEGTS-muxer.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libavformat: add multiple PCR streams in MPEGTS muxer

2018-10-28 Thread fix45u+5vw5dhzga3hjs
From 44c9f3d96c5969349bd2dc4d63e9a8b8e6b5a0e2 Mon Sep 17 00:00:00 2001
From: M. Sanders 
Date: Sat, 27 Oct 2018 21:39:44 +0200
Subject: [PATCH] libavformat: add multiple PCR streams in MPEGTS muxer

---
This simple patch adds two new options to the MPEG-TS muxer.
You can use them to mark PCRs in additional VIDEO and/or AUDIO streams.
It's useful when you will remux the output with pid filtering tools.
For example, if you put PCR in all audio streams, then you can filter 
each audio stream to create a radio service.
PCR marks do not disturb outgoing stream, but it is not recommended 
to do so as a regular rule.

 doc/muxers.texi |  6 ++
 libavformat/mpegtsenc.c | 19 +--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f18543e83d..328707d0ed 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1528,6 +1528,12 @@ is @code{-1}, which results in shifting timestamps so 
that they start from 0.
 @item omit_video_pes_length @var{boolean}
 Omit the PES packet length for video packets. Default is @code{1} (true).
 
+@item pcr_all_video @var{boolean}
+Include PCR values in all video streams. Default is @code{0} (false).
+
+@item pcr_all_audio @var{boolean}
+Include PCR values in all audio streams. Default is @code{0} (false).
+
 @item pcr_period @var{integer}
 Override the default PCR retransmission time in milliseconds. Ignored if
 variable muxrate is selected. Default is @code{20}.
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 3339e26d50..caef817a3d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -113,6 +113,8 @@ typedef struct MpegTSWrite {
 double sdt_period;
 int64_t last_pat_ts;
 int64_t last_sdt_ts;
+int pcr_all_video;
+int pcr_all_audio;
 
 int omit_video_pes_length;
 } MpegTSWrite;
@@ -1178,11 +1180,18 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 int64_t pcr = -1; /* avoid warning */
 int64_t delay = av_rescale(s->max_delay, 9, AV_TIME_BASE);
 int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && 
!ts_st->prev_payload_key;
+int force_pcr = 0;
 
 av_assert0(ts_st->payload != buf || st->codecpar->codec_type != 
AVMEDIA_TYPE_VIDEO);
 if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codecpar->codec_type 
== AVMEDIA_TYPE_VIDEO) {
 force_pat = 1;
 }
+if (ts->pcr_all_video && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+force_pcr = 1;
+}
+if (ts->pcr_all_audio && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+force_pcr = 1;
+}
 
 is_start = 1;
 while (payload_size > 0) {
@@ -1190,7 +1199,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 force_pat = 0;
 
 write_pcr = 0;
-if (ts_st->pid == ts_st->service->pcr_pid) {
+if (ts_st->pid == ts_st->service->pcr_pid || force_pcr) {
 if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on 
frames
 ts_st->service->pcr_packet_count++;
 if (ts_st->service->pcr_packet_count >=
@@ -1228,7 +1237,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 }
 if (key && is_start && pts != AV_NOPTS_VALUE) {
 // set Random Access for key frames
-if (ts_st->pid == ts_st->service->pcr_pid)
+if (ts_st->pid == ts_st->service->pcr_pid || force_pcr)
 write_pcr = 1;
 set_af_flag(buf, 0x40);
 q = get_ts_payload_start(buf);
@@ -1951,6 +1960,12 @@ static const AVOption options[] = {
 { "omit_video_pes_length", "Omit the PES packet length for video packets",
   offsetof(MpegTSWrite, omit_video_pes_length), AV_OPT_TYPE_BOOL,
   { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+{ "pcr_all_video", "Include PCR values in all video streams",
+  offsetof(MpegTSWrite, pcr_all_video), AV_OPT_TYPE_BOOL,
+  { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+{ "pcr_all_audio", "Include PCR values in all audio streams",
+  offsetof(MpegTSWrite, pcr_all_audio), AV_OPT_TYPE_BOOL,
+  { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
 { "pcr_period", "PCR retransmission time in milliseconds",
   offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT,
   { .i64 = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-- 
2.11.0






Sent using Guerrillamail.com
Block or report abuse: 
https://www.guerrillamail.com//abuse/?a=R0d5FQgHDrAQngu40HgZfwTCSoSfwNA%3D


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


[FFmpeg-devel] [PATCH] avcodec/mpegaudio_parser: Consume more than 0 bytes in case of the unsupported mp3adu case

2018-10-28 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
10966/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MP3ADU_fuzzer-5348695024336896
Fixes: 
10969/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MP3ADUFLOAT_fuzzer-5691669402877952

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mpegaudio_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c
index a109f12701..1005e89aae 100644
--- a/libavcodec/mpegaudio_parser.c
+++ b/libavcodec/mpegaudio_parser.c
@@ -101,7 +101,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
 "MP3ADU full parser");
 *poutbuf = NULL;
 *poutbuf_size = 0;
-return 0; /* parsers must not return error codes */
+return buf_size; /* parsers must not return error 
codes */
 }
 
 break;
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH 1/2] lavc/amfenc: moving amf common code (library and context) to lavu/hwcontext_amf from amfenc to be reused in other amf components

2018-10-28 Thread Mark Thompson
On 10/07/18 15:28, Alexander Kravchenko wrote:
> ---
>  libavcodec/amfenc.c| 247 +
>  libavcodec/amfenc.h|  27 +---
>  libavutil/Makefile |   2 +
>  libavutil/hwcontext.c  |   4 +
>  libavutil/hwcontext.h  |   1 +
>  libavutil/hwcontext_amf.c  | 271 
> +
>  libavutil/hwcontext_amf.h  |  54 
>  libavutil/hwcontext_internal.h |   1 +
>  8 files changed, 368 insertions(+), 239 deletions(-)
>  create mode 100644 libavutil/hwcontext_amf.c
>  create mode 100644 libavutil/hwcontext_amf.h

I think this would make more sense as two patches - one to add the new code in 
libavutil, another to change libavcodec to use it.

(Below reordered to reflect that.)

> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 9ed24cfc82..c7d7f8b2d6 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -168,6 +168,7 @@ OBJS-$(CONFIG_QSV)  += hwcontext_qsv.o
>  OBJS-$(CONFIG_VAAPI)+= hwcontext_vaapi.o
>  OBJS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.o
>  OBJS-$(CONFIG_VDPAU)+= hwcontext_vdpau.o
> +OBJS-$(CONFIG_AMF)  += hwcontext_amf.o

Ordering.

>  
>  OBJS += $(COMPAT_OBJS:%=../compat/%)
>  
> @@ -183,6 +184,7 @@ SKIPHEADERS-$(CONFIG_OPENCL)   += 
> hwcontext_opencl.h
>  SKIPHEADERS-$(CONFIG_VAAPI)+= hwcontext_vaapi.h
>  SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.h
>  SKIPHEADERS-$(CONFIG_VDPAU)+= hwcontext_vdpau.h
> +SKIPHEADERS-$(CONFIG_AMF)  += hwcontext_amf.h
>  
>  TESTPROGS = adler32 \
>  aes \
> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> index f1e404ab20..1a11c64764 100644
> --- a/libavutil/hwcontext.c
> +++ b/libavutil/hwcontext.c
> @@ -58,6 +58,9 @@ static const HWContextType * const hw_table[] = {
>  #endif
>  #if CONFIG_MEDIACODEC
>  _hwcontext_type_mediacodec,
> +#endif
> +#if CONFIG_AMF
> +_hwcontext_type_amf,
>  #endif
>  NULL,
>  };
> @@ -73,6 +76,7 @@ static const char *const hw_type_names[] = {
>  [AV_HWDEVICE_TYPE_VDPAU]  = "vdpau",
>  [AV_HWDEVICE_TYPE_VIDEOTOOLBOX] = "videotoolbox",
>  [AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",
> +[AV_HWDEVICE_TYPE_AMF] = "amf",

Ignoring the mediacodec entry, these look ordered.  I think put amf at the 
start in each case.

>  };
>  
>  enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
> index f5a4b62387..b18591205a 100644
> --- a/libavutil/hwcontext.h
> +++ b/libavutil/hwcontext.h
> @@ -36,6 +36,7 @@ enum AVHWDeviceType {
>  AV_HWDEVICE_TYPE_DRM,
>  AV_HWDEVICE_TYPE_OPENCL,
>  AV_HWDEVICE_TYPE_MEDIACODEC,
> +AV_HWDEVICE_TYPE_AMF,
>  };
>  
>  typedef struct AVHWDeviceInternal AVHWDeviceInternal;
> diff --git a/libavutil/hwcontext_amf.c b/libavutil/hwcontext_amf.c
> new file mode 100644
> index 00..a4c3c4f4c1
> --- /dev/null
> +++ b/libavutil/hwcontext_amf.c
> @@ -0,0 +1,271 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include 
> +
> +#include "config.h"
> +
> +#include "avassert.h"
> +#include "avstring.h"
> +#include "common.h"

These three headers are all unused?

> +#include "hwcontext.h"
> +#include "hwcontext_internal.h"
> +#include "hwcontext_amf.h"
> +
> +#if CONFIG_D3D11VA
> +#include "libavutil/hwcontext_d3d11va.h"

No need for the path, this is libavutil.

> +#endif
> +
> +#if CONFIG_DXVA2
> +#define COBJMACROS
> +#include "libavutil/hwcontext_dxva2.h"

And here.

> +#endif
> +
> +#ifdef _WIN32
> +#include "compat/w32dlfcn.h"
> +#else
> +#include 
> +#endif
> +
> +/**
> +* Error handling helper
> +*/
> +#define AMFAV_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
> +if (!(exp)) { \
> +av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
> +return ret_value; \
> +}
> +
> +static const AVClass amflib_class = {
> +.class_name = "amf",
> +.item_name = av_default_item_name,
> + 

Re: [FFmpeg-devel] [PATCH 2/2] lavf/vf_scale_amf: AMF scaler/format converter filter implementation

2018-10-28 Thread Mark Thompson
On 10/07/18 15:30, Alexander Kravchenko wrote:
> ---
>  configure  |   1 +
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_scale_amf.c | 623 
> +
>  4 files changed, 626 insertions(+)
>  create mode 100644 libavfilter/vf_scale_amf.c
> 
> diff --git a/configure b/configure
> index b1a4dcfc42..321e9bdb70 100755
> --- a/configure
> +++ b/configure
> @@ -3385,6 +3385,7 @@ rubberband_filter_deps="librubberband"
>  sab_filter_deps="gpl swscale"
>  scale2ref_filter_deps="swscale"
>  scale_filter_deps="swscale"
> +scale_amf_filter_deps="amf"
>  scale_qsv_filter_deps="libmfx"
>  select_filter_select="pixelutils"
>  sharpness_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 7735c26529..1b35c9dd5e 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -317,6 +317,7 @@ OBJS-$(CONFIG_ROBERTS_OPENCL_FILTER) += 
> vf_convolution_opencl.o opencl.o
>  OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o
>  OBJS-$(CONFIG_SAB_FILTER)+= vf_sab.o
>  OBJS-$(CONFIG_SCALE_FILTER)  += vf_scale.o scale.o
> +OBJS-$(CONFIG_SCALE_AMF_FILTER)  += vf_scale_amf.o scale.o
>  OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o 
> vf_scale_cuda.ptx.o
>  OBJS-$(CONFIG_SCALE_NPP_FILTER)  += vf_scale_npp.o scale.o
>  OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_scale_qsv.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 0ded83ede2..7c7eb1526a 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -303,6 +303,7 @@ extern AVFilter ff_vf_roberts_opencl;
>  extern AVFilter ff_vf_rotate;
>  extern AVFilter ff_vf_sab;
>  extern AVFilter ff_vf_scale;
> +extern AVFilter ff_vf_scale_amf;
>  extern AVFilter ff_vf_scale_cuda;
>  extern AVFilter ff_vf_scale_npp;
>  extern AVFilter ff_vf_scale_qsv;
> diff --git a/libavfilter/vf_scale_amf.c b/libavfilter/vf_scale_amf.c
> new file mode 100644
> index 00..49250281e5
> --- /dev/null
> +++ b/libavfilter/vf_scale_amf.c
> @@ -0,0 +1,623 @@
> +/*
> + * 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
> + */
> +
> +/**
> + * @file
> + * scale video filter - AMF
> + */
> +
> +#include 
> +#include 
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/pixdesc.h"
> +#include "libavutil/time.h"
> +
> +#include "libavutil/hwcontext.h"
> +#include "libavutil/hwcontext_amf.h"
> +
> +#include "AMF/components/VideoConverter.h"

Probably angle brackets.

> +
> +#include "avfilter.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "video.h"
> +#include "scale.h"
> +
> +#if CONFIG_DXVA2
> +#include 
> +#endif
> +
> +#if CONFIG_D3D11VA
> +#include 
> +#endif

Already included by hwcontext_amf.h.

> +
> +#define AMFAV_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
> +if (!(exp)) { \
> +av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
> +return ret_value; \
> +}
> +
> +#define AMFAV_GOTO_FAIL_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
> +if (!(exp)) { \
> +av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
> +ret = ret_value; \
> +goto fail; \
> +}
> +
> +typedef struct FormatMap {
> +enum AVPixelFormat   av_format;
> +enum AMF_SURFACE_FORMAT  amf_format;
> +} FormatMap;

There is no reason to name this structure when you're only defining one of 
them.  Just do "static const struct { } format_map[] = { };".

> +
> +static const FormatMap format_map[] =
> +{
> +{ AV_PIX_FMT_NV12,   AMF_SURFACE_NV12 },
> +
> +{ AV_PIX_FMT_BGR0,   AMF_SURFACE_BGRA },
> +{ AV_PIX_FMT_BGRA,   AMF_SURFACE_BGRA },
> +
> +{ AV_PIX_FMT_RGB0,   AMF_SURFACE_RGBA },
> +{ AV_PIX_FMT_RGBA,   AMF_SURFACE_RGBA },
> +
> +{ AV_PIX_FMT_0RGB,   AMF_SURFACE_ARGB },
> +{ AV_PIX_FMT_ARGB,   AMF_SURFACE_ARGB },
> +
> +{ AV_PIX_FMT_GRAY8,  AMF_SURFACE_GRAY8 },
> +{ AV_PIX_FMT_YUV420P,AMF_SURFACE_YUV420P },
> +{ AV_PIX_FMT_YUYV422,AMF_SURFACE_YUY2 },
> +};
> 

[FFmpeg-devel] [PATCH 2/2] flvdec: Export unknown metadata packets as opaque data

2018-10-28 Thread Martin Storsjö
---
Removed the option and made this behaviour the default.
---
 libavformat/flv.h|  1 +
 libavformat/flvdec.c | 18 ++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavformat/flv.h b/libavformat/flv.h
index 3aabb3adc9..3571b90279 100644
--- a/libavformat/flv.h
+++ b/libavformat/flv.h
@@ -66,6 +66,7 @@ enum {
 FLV_STREAM_TYPE_VIDEO,
 FLV_STREAM_TYPE_AUDIO,
 FLV_STREAM_TYPE_SUBTITLE,
+FLV_STREAM_TYPE_DATA,
 FLV_STREAM_TYPE_NB,
 };
 
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index ffc975f15d..4b9f46902b 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -143,7 +143,9 @@ static AVStream *create_stream(AVFormatContext *s, int 
codec_type)
 st->codecpar->codec_type = codec_type;
 if (s->nb_streams>=3 ||(   s->nb_streams==2
&& s->streams[0]->codecpar->codec_type != 
AVMEDIA_TYPE_SUBTITLE
-   && s->streams[1]->codecpar->codec_type != 
AVMEDIA_TYPE_SUBTITLE))
+   && s->streams[1]->codecpar->codec_type != 
AVMEDIA_TYPE_SUBTITLE
+   && s->streams[0]->codecpar->codec_type != 
AVMEDIA_TYPE_DATA
+   && s->streams[1]->codecpar->codec_type != 
AVMEDIA_TYPE_DATA))
 s->ctx_flags &= ~AVFMTCTX_NOHEADER;
 if (codec_type == AVMEDIA_TYPE_AUDIO) {
 st->codecpar->bit_rate = flv->audio_bit_rate;
@@ -1001,7 +1003,7 @@ retry:
 int type;
 meta_pos = avio_tell(s->pb);
 type = flv_read_metabody(s, next);
-if (type == 0 && dts == 0 || type < 0 || type == TYPE_UNKNOWN) 
{
+if (type == 0 && dts == 0 || type < 0) {
 if (type < 0 && flv->validate_count &&
 flv->validate_index[0].pos > next &&
 flv->validate_index[0].pos - 4 < next
@@ -1015,6 +1017,8 @@ retry:
 return flv_data_packet(s, pkt, dts, next);
 } else if (type == TYPE_ONCAPTION) {
 return flv_data_packet(s, pkt, dts, next);
+} else if (type == TYPE_UNKNOWN) {
+stream_type = FLV_STREAM_TYPE_DATA;
 }
 avio_seek(s->pb, meta_pos, SEEK_SET);
 }
@@ -1054,10 +1058,13 @@ skip:
 } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
 if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
 break;
+} else if (stream_type == FLV_STREAM_TYPE_DATA) {
+if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
+break;
 }
 }
 if (i == s->nb_streams) {
-static const enum AVMediaType stream_types[] = 
{AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE};
+static const enum AVMediaType stream_types[] = 
{AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE, 
AVMEDIA_TYPE_DATA};
 st = create_stream(s, stream_types[stream_type]);
 if (!st)
 return AVERROR(ENOMEM);
@@ -1153,6 +1160,8 @@ retry_duration:
 size -= ret;
 } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
 st->codecpar->codec_id = AV_CODEC_ID_TEXT;
+} else if (stream_type == FLV_STREAM_TYPE_DATA) {
+st->codecpar->codec_id = AV_CODEC_ID_NONE; // Opaque AMF data
 }
 
 if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
@@ -1253,7 +1262,8 @@ retry_duration:
 
 if (stream_type == FLV_STREAM_TYPE_AUDIO ||
 ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY) ||
-stream_type == FLV_STREAM_TYPE_SUBTITLE)
+stream_type == FLV_STREAM_TYPE_SUBTITLE ||
+stream_type == FLV_STREAM_TYPE_DATA)
 pkt->flags |= AV_PKT_FLAG_KEY;
 
 leave:
-- 
2.17.1 (Apple Git-112)

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


Re: [FFmpeg-devel] [PATCH 2/2] flvdec: Add an option for exporting unknown metadata packets as opaque data

2018-10-28 Thread Martin Storsjö

On Sun, 28 Oct 2018, Michael Niedermayer wrote:


On Sat, Oct 27, 2018 at 09:22:18PM +0300, Martin Storsjö wrote:

On Sat, 27 Oct 2018, Michael Niedermayer wrote:


On Thu, Oct 25, 2018 at 03:59:17PM +0300, Martin Storsjö wrote:

---
libavformat/flv.h|  1 +
libavformat/flvdec.c | 21 +
2 files changed, 18 insertions(+), 4 deletions(-)


[...]

@@ -1290,6 +1302,7 @@ static const AVOption options[] = {
{ "flv_full_metadata", "Dump full metadata of the onMetadata", 
OFFSET(dump_full_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
{ "flv_ignore_prevtag", "Ignore the Size of previous tag", 
OFFSET(trust_datasize), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
{ "missing_streams", "", OFFSET(missing_streams), AV_OPT_TYPE_INT, { .i64 = 
0 }, 0, 0xFF, VD | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY },
+{ "export_opaque_meta", "", OFFSET(export_opaque_meta), AV_OPT_TYPE_BOOL, 
{ .i64 = 0 }, 0, 1, VD },
{ NULL }


I think this together with doc/demuxers.texi (which doesnt document this)
is not enough to use this option by a user


Oh right, I had forgotten to actually write something here.


also why is this conditional ? is there a disadvantage of always
exporting this ?


Not sure - I thought it'd be less behaviour change and less risk of
potentially confusing packets for unsuspecting users by not doing it by
default. But as any normal flv stream doesn't contain any such packets, it
might be fine to just expose them all the time.


I dont know enough about these to have an oppinion ...

but I just realized another aspect. How do these packets interact with
flvenc ?
Should they be preserved by default ? because if so then they would need
to be exported by default


I guess it depends on what the packets actually are - as it can be 
anything, it's pretty much up to the application what treatment they want 
for them. flvenc right now does write them out properly afaik (a data 
track with codec type AV_CODEC_ID_NONE gets copied straight through into 
FLV_TAG_TYPE_META packets). I guess the sensible default would be to copy 
them, so I guess I'll amend the patch to always export them.


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


Re: [FFmpeg-devel] [PATCH 3/3] libaomenc: Deprecate unused noise-sensitivity option

2018-10-28 Thread Carl Eugen Hoyos
2018-10-28 21:08 GMT+01:00, Mark Thompson :
> ---
> This was in the 4.0 release, unfortunately (and did nothing there as well).

If it has never worked, it can be removed imo.

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


[FFmpeg-devel] [PATCH 2/3] doc/encoders: Add libaom-av1

2018-10-28 Thread Mark Thompson
---
 doc/encoders.texi | 103 ++
 1 file changed, 103 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 1ca0ef1543..3156f5d65c 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1370,6 +1370,109 @@ makes it possible to store non-rgb pix_fmts.
 
 @end table
 
+@section libaom-av1
+
+libaom AV1 encoder wrapper.
+
+Requires the presence of the libaom headers and library during
+configuration.  You need to explicitly configure the build with
+@code{--enable-libaom}.
+
+@subsection Options
+
+The wrapper supports the following standard libavcodec options:
+
+@table @option
+
+@item b
+Set bitrate in bits/second.
+
+@item g
+Set GOP size (maximum distance between key frames).
+
+@item qmin qmax
+Set minimum/maximum quantisation values.  Valid range is from 0 to 63
+(warning: this does not match the quantiser values actually used by AV1
+- divide by four to map real quantiser values to this range).  Defaults
+to min/max (no constraint).
+
+@item minrate maxrate bufsize rc_init_occupancy
+Set rate control buffering parameters.  Not used if not set - defaults
+to unconstrained variable bitrate.
+
+@item threads
+Set the number of threads to use while encoding.  This may require the
+@option{tiles} option to also be set to actually use the specified
+number of threads fully.  Defaults to the number of hardware threads
+supported by the host machine.
+
+@item profile
+Set the encoding profile.  Defaults to using the profile which matches
+the bit depth and chroma subsampling of the input.
+
+@item color_range color_primaries colorspace color_trc
+Set colour properties.  Defaults to using the properties from the input,
+if available.
+
+@end table
+
+The wrapper also has some specific options:
+
+@table @option
+
+@item cpu-used
+Set the quality/encoding speed tradeoff.  Valid range is from 0 to 8,
+higher numbers indicating greater speed and lower quality.  The default
+value is 1, which will be slow and high quality.
+
+@item auto-alt-ref
+Enable use of alternate reference frames.  Defaults to the internal
+default of the library.
+
+@item lag-in-frames
+Set the maximum number of frames which the encoder may keep in flight
+at any one time for lookahead purposes.  Defaults to the internal
+default of the library.
+
+@item error-resilience
+Enable error resilience features:
+@table @option
+@item default
+Improve resilience against losses of whole frames.
+@end table
+Not enabled by default.
+
+@item crf
+Set the quality/size tradeoff for constant-quality and
+constrained-quality modes.  Valid range is 0 to 63, higher numbers
+indicating lower quality and smaller output size.  Only used if set,
+uses the bitrate target only by default.
+
+@item static-thresh
+Set a change threshold on blocks below which they will be skipped by
+the encoder.  Defined in arbitrary units as a nonnegative integer,
+defaulting to zero (no blocks are skipped).
+
+@item drop-threshold
+Set a threshold for dropping frames when close to rate control bounds.
+Defined as a percentage of the target buffer - when the rate control
+buffer falls below this percentage, frames will be dropped until it
+has refilled above the threshold.  Defaults to zero (no frames are
+dropped).
+
+@item tiles
+Set the number of tiles to encode the input video with, as colums x
+rows.  Larger numbers allow greater parallelism in both encoding and
+decoding, but may decrease coding efficiency.  Defaults to the minimum
+number of tiles required by the size of the input video (this is 1x1
+(that is, a single tile) for sizes up to and including 4K).
+
+@item tile-columns tile-rows
+Set the number of tiles as log2 of the number of tile rows and columns.
+Provided for compatibility with libvpx/VP9.
+
+@end table
+
 @section libkvazaar
 
 Kvazaar H.265/HEVC encoder.
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 3/3] libaomenc: Deprecate unused noise-sensitivity option

2018-10-28 Thread Mark Thompson
---
This was in the 4.0 release, unfortunately (and did nothing there as well).


 libavcodec/libaomenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index c5458766cb..0c2eb6517f 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -71,7 +71,7 @@ typedef struct AOMEncoderContext {
 int crf;
 int static_thresh;
 int drop_threshold;
-int noise_sensitivity;
+int noise_sensitivity_unused;
 uint64_t sse[4];
 int have_sse; /**< true if we have pending sse[] */
 uint64_t frame_number;
@@ -980,7 +980,7 @@ static const AVOption options[] = {
 { "crf",  "Select the quality for constant quality mode", 
offsetof(AOMContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE },
 { "static-thresh","A change threshold on blocks below which they will 
be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, INT_MAX, VE },
 { "drop-threshold",   "Frame drop threshold", offsetof(AOMContext, 
drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
-{ "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE},
+{ "noise-sensitivity", "Deprecated, this option does nothing", 
OFFSET(noise_sensitivity_unused), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE | 
AV_OPT_FLAG_DEPRECATED },
 { "tiles","Tile columns x rows", OFFSET(tile_cols), 
AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, VE },
 { "tile-columns", "Log2 of number of tile columns to use", 
OFFSET(tile_cols_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
 { "tile-rows","Log2 of number of tile rows to use",
OFFSET(tile_rows_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 1/3] doc/encoders: Move libxavs2 to correct place in alphabetical order

2018-10-28 Thread Mark Thompson
---
 doc/encoders.texi | 92 +++
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 899faac49b..1ca0ef1543 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2180,6 +2180,52 @@ ffmpeg -i input -c:v libx265 -x265-params 
crf=26:psy-rd=1 output.mp4
 @end example
 @end table
 
+@section libxavs2
+
+xavs2 AVS2-P2/IEEE1857.4 encoder wrapper.
+
+This encoder requires the presence of the libxavs2 headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxavs2}.
+
+@subsection Options
+
+@table @option
+@item lcu_row_threads
+Set the number of parallel threads for rows from 1 to 8 (default 5).
+
+@item initial_qp
+Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
+used to set the initial qp for the first frame.
+
+@item qp
+Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
+used to set the qp value under constant-QP mode.
+
+@item max_qp
+Set the max qp for rate control from 1 to 63 (default 55).
+
+@item min_qp
+Set the min qp for rate control from 1 to 63 (default 20).
+
+@item speed_level
+Set the Speed level from 0 to 9 (default 0). Higher is better but slower.
+
+@item log_level
+Set the log level from -1 to 3 (default 0). -1: none, 0: error,
+1: warning, 2: info, 3: debug.
+
+@item xavs2-params
+Set xavs2 options using a list of @var{key}=@var{value} couples separated
+by ":".
+
+For example to specify libxavs2 encoding options with @option{-xavs2-params}:
+
+@example
+ffmpeg -i input -c:v libxavs2 -xavs2-params preset_level=5 output.avs2
+@end example
+@end table
+
 @section libxvid
 
 Xvid MPEG-4 Part 2 encoder wrapper.
@@ -2791,52 +2837,6 @@ Reduces detail but attempts to preserve color at 
extremely low bitrates.
 
 @end table
 
-@section libxavs2
-
-xavs2 AVS2-P2/IEEE1857.4 encoder wrapper.
-
-This encoder requires the presence of the libxavs2 headers and library
-during configuration. You need to explicitly configure the build with
-@option{--enable-libxavs2}.
-
-@subsection Options
-
-@table @option
-@item lcu_row_threads
-Set the number of parallel threads for rows from 1 to 8 (default 5).
-
-@item initial_qp
-Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
-used to set the initial qp for the first frame.
-
-@item qp
-Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
-used to set the qp value under constant-QP mode.
-
-@item max_qp
-Set the max qp for rate control from 1 to 63 (default 55).
-
-@item min_qp
-Set the min qp for rate control from 1 to 63 (default 20).
-
-@item speed_level
-Set the Speed level from 0 to 9 (default 0). Higher is better but slower.
-
-@item log_level
-Set the log level from -1 to 3 (default 0). -1: none, 0: error,
-1: warning, 2: info, 3: debug.
-
-@item xavs2-params
-Set xavs2 options using a list of @var{key}=@var{value} couples separated
-by ":".
-
-For example to specify libxavs2 encoding options with @option{-xavs2-params}:
-
-@example
-ffmpeg -i input -c:v libxavs2 -xavs2-params preset_level=5 output.avs2
-@end example
-@end table
-
 @c man end VIDEO ENCODERS
 
 @chapter Subtitles Encoders
-- 
2.19.1

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


Re: [FFmpeg-devel] Enquiry re resolving errors reported by stream analysers after transcoding with FFmpeg

2018-10-28 Thread Reuben Martin
> > Errors reported by analysers
> > 
> >   *   Unable to insert PCR on PES (TR-8 requirement from Sky's VRP video
> >   spec for PDL) *   MPEG and AAC audio buffer overflows (Manzanita)
> >   *   PES header data_alignment_indicator flag not set for video and audio
> >   (Manzanita) *   Failed HRD conformance check (Tektronix Cerify)
> >   *   TB overflows (A/V Codec Analyser)
> >   *   PTS (Presentation Timestamp) interval is not constant in audio
> >   stream (A/V Codec Analyser) *   PTS must occur after end of Access Unit
> >   (A/V Codec Analyser)
> >   *   PCR discontinuities (A/V Codec Analyser)
> 
> reproducable testcases would very usefull.
> Iam sure there are bugs in our mpeg ts muxer but possibly some of these are
> also just configuration issues.
> 
> More generally and a maybe this is a little bit a rant ;)
> If all these slightly expensive Analysers would have been available to the
> wider community then the developers who worked on the related code would
> have been aware of the problems with details and would have been able to fix
> these when the code was originally written or at least long ago.
> As it is, its not unknown there are problems in the code but with no details
> and no easy way to test potential fixes, its not so easy to fix for many
> developers. There may be a very small number of developers who know mpeg-ts
> so well they can understand and fix bugs without any way to test but i
> think there are many more people who have a more shallow understaning and
> who have more time who could with detailed information of what is wrong and
> with the ability to test changes be able to fix these as well

I’d like to insert an unsolicited plug for Thierry Lelegard and the TSDuck 
project. Their FOSS toolset has been invaluable for analyzing and manipulating 
mpeg-ts streams.

https://tsduck.io/
https://github.com/tsduck/tsduck

-Reuben



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


[FFmpeg-devel] [PATCH 2/2] vaapi_encode_h265: Reduce SAR to valid range

2018-10-28 Thread Mark Thompson
Matching previous commit for H.264.
---
 libavcodec/vaapi_encode_h265.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 367fa5fde2..8d715f6e93 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -472,18 +472,20 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 {  80, 33 }, {  18, 11 }, {  15, 11 }, {  64, 33 },
 { 160, 99 }, {   4,  3 }, {   3,  2 }, {   2,  1 },
 };
-int i;
+int num, den, i;
+av_reduce(, , avctx->sample_aspect_ratio.num,
+  avctx->sample_aspect_ratio.den, 65535);
 for (i = 0; i < FF_ARRAY_ELEMS(sar_idc); i++) {
-if (avctx->sample_aspect_ratio.num == sar_idc[i].num &&
-avctx->sample_aspect_ratio.den == sar_idc[i].den) {
+if (num == sar_idc[i].num &&
+den == sar_idc[i].den) {
 vui->aspect_ratio_idc = i;
 break;
 }
 }
 if (i >= FF_ARRAY_ELEMS(sar_idc)) {
 vui->aspect_ratio_idc = 255;
-vui->sar_width  = avctx->sample_aspect_ratio.num;
-vui->sar_height = avctx->sample_aspect_ratio.den;
+vui->sar_width  = num;
+vui->sar_height = den;
 }
 vui->aspect_ratio_info_present_flag = 1;
 }
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 1/2] vaapi_encode_h264: Reduce SAR to valid range

2018-10-28 Thread Mark Thompson
The SAR of the input could have a numerator or denominator greater than
2^16 which would then be truncated to a 16-bit integer when written to
the VUI parameters, giving a random result.  Instead, reduce the SAR to
the nearest representable fraction.
---
 libavcodec/vaapi_encode_h264.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 7bb77cfba2..f9402992b8 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -389,18 +389,20 @@ static int 
vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 {  80, 33 }, {  18, 11 }, {  15, 11 }, {  64, 33 },
 { 160, 99 }, {   4,  3 }, {   3,  2 }, {   2,  1 },
 };
-int i;
+int num, den, i;
+av_reduce(, , avctx->sample_aspect_ratio.num,
+  avctx->sample_aspect_ratio.den, 65535);
 for (i = 0; i < FF_ARRAY_ELEMS(sar_idc); i++) {
-if (avctx->sample_aspect_ratio.num == sar_idc[i].num &&
-avctx->sample_aspect_ratio.den == sar_idc[i].den) {
+if (num == sar_idc[i].num &&
+den == sar_idc[i].den) {
 sps->vui.aspect_ratio_idc = i;
 break;
 }
 }
 if (i >= FF_ARRAY_ELEMS(sar_idc)) {
 sps->vui.aspect_ratio_idc = 255;
-sps->vui.sar_width  = avctx->sample_aspect_ratio.num;
-sps->vui.sar_height = avctx->sample_aspect_ratio.den;
+sps->vui.sar_width  = num;
+sps->vui.sar_height = den;
 }
 sps->vui.aspect_ratio_info_present_flag = 1;
 }
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH] libaomenc: Add support for tiles

2018-10-28 Thread Mark Thompson
On 27/10/18 19:58, James Almer wrote:
> On 10/22/2018 7:40 PM, Mark Thompson wrote:
>> Adds an option to specify the number of tile rows and columns, then uses
>> a uniform tiling if possible and otherwise a fixed tiling with equal-sized
>> tiles to fill the frame.
>>
>> Also adds -tile-columns and -tile-rows options to make tilings with
>> power-of-two numbers of tiles, matching the behaviour of the libvpx/VP9
>> encoder.
>> ---
>> On 03/10/18 00:50, Mark Thompson wrote:
>>> ...
>>
>> Ping.
>>
>> (Rebased following e265832c378c3f4dc372f1c0f477810f63dd60fd.)
>>
>> Thanks,
>>
>> - Mark
>>
>>
>>  libavcodec/libaomenc.c | 188 +
>>  1 file changed, 188 insertions(+)
>>
>> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
>> index 045c519f72..c5458766cb 100644
>> --- a/libavcodec/libaomenc.c
>> +++ b/libavcodec/libaomenc.c
>> @@ -34,6 +34,7 @@
>>  #include "libavutil/opt.h"
>>  #include "libavutil/pixdesc.h"
>>  
>> +#include "av1.h"
>>  #include "avcodec.h"
>>  #include "internal.h"
>>  #include "profiles.h"
>> @@ -74,6 +75,10 @@ typedef struct AOMEncoderContext {
>>  uint64_t sse[4];
>>  int have_sse; /**< true if we have pending sse[] */
>>  uint64_t frame_number;
>> +int tile_cols, tile_rows;
>> +int tile_cols_log2, tile_rows_log2;
>> +aom_superblock_size_t superblock_size;
>> +int uniform_tiles;
>>  } AOMContext;
>>  
>>  static const char *const ctlidstr[] = {
>> @@ -85,6 +90,9 @@ static const char *const ctlidstr[] = {
>>  [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
>>  [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
>>  [AV1E_SET_TRANSFER_CHARACTERISTICS] = 
>> "AV1E_SET_TRANSFER_CHARACTERISTICS",
>> +[AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
>> +[AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
>> +[AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS",
>>  };
>>  
>>  static av_cold void log_encoder_error(AVCodecContext *avctx, const char 
>> *desc)
>> @@ -149,6 +157,10 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
>> width, "kf_mode:", cfg->kf_mode,
>> width, "kf_min_dist:", cfg->kf_min_dist,
>> width, "kf_max_dist:", cfg->kf_max_dist);
>> +av_log(avctx, level, "tile settings\n"
>> + "  %*s%d\n  %*s%d\n",
>> +   width, "tile_width_count:",  cfg->tile_width_count,
>> +   width, "tile_height_count:", cfg->tile_height_count);
>>  av_log(avctx, level, "\n");
>>  }
>>  
>> @@ -290,6 +302,169 @@ static void set_color_range(AVCodecContext *avctx)
>>  codecctl_int(avctx, AV1E_SET_COLOR_RANGE, aom_cr);
>>  }
>>  
>> +static int count_uniform_tiling(int dim, int sb_size, int tiles_log2)
>> +{
>> +int sb_dim   = (dim + sb_size - 1) / sb_size;
>> +int tile_dim = (sb_dim + (1 << tiles_log2) - 1) >> tiles_log2;
>> +av_assert0(tile_dim > 0);
>> +return (sb_dim + tile_dim - 1) / tile_dim;
>> +}
>> +
>> +static int choose_tiling(AVCodecContext *avctx,
>> + struct aom_codec_enc_cfg *enccfg)
>> +{
>> +AOMContext *ctx = avctx->priv_data;
>> +int sb_128x128_possible, sb_size, sb_width, sb_height;
>> +int uniform_rows, uniform_cols;
>> +int uniform_64x64_possible, uniform_128x128_possible;
>> +int tile_size, rounding, i;
>> +
>> +if (ctx->tile_cols_log2 >= 0)
>> +ctx->tile_cols = 1 << ctx->tile_cols_log2;
>> +if (ctx->tile_rows_log2 >= 0)
>> +ctx->tile_rows = 1 << ctx->tile_rows_log2;
>> +
>> +if (ctx->tile_cols == 0) {
>> +ctx->tile_cols = (avctx->width + AV1_MAX_TILE_WIDTH - 1) /
>> +AV1_MAX_TILE_WIDTH;
>> +if (ctx->tile_cols > 1) {
>> +av_log(avctx, AV_LOG_DEBUG, "Automatically using %d tile "
>> +   "columns to fill width.\n", ctx->tile_cols);
>> +}
>> +}
>> +av_assert0(ctx->tile_cols > 0);
>> +if (ctx->tile_rows == 0) {
>> +int max_tile_width =
>> +FFALIGN((FFALIGN(avctx->width, 128) +
>> + ctx->tile_cols - 1) / ctx->tile_cols, 128);
>> +ctx->tile_rows =
>> +(max_tile_width * FFALIGN(avctx->height, 128) +
>> + AV1_MAX_TILE_AREA - 1) / AV1_MAX_TILE_AREA;
>> +if (ctx->tile_rows > 1) {
>> +av_log(avctx, AV_LOG_DEBUG, "Automatically using %d tile "
>> +   "rows to fill area.\n", ctx->tile_rows);
>> +}
>> +}
>> +av_assert0(ctx->tile_rows > 0);
>> +
>> +if ((avctx->width  + 63) / 64 < ctx->tile_cols ||
>> +(avctx->height + 63) / 64 < ctx->tile_rows) {
>> +av_log(avctx, AV_LOG_ERROR, "Invalid tile sizing: frame not "
>> +   "large enough to fit specified tile arrangement.\n");
>> +return AVERROR(EINVAL);
>> +}
>> +if (ctx->tile_cols > AV1_MAX_TILE_COLS ||
>> +ctx->tile_rows > AV1_MAX_TILE_ROWS) {
>> +av_log(avctx, 

[FFmpeg-devel] [PATCH v2] fftools/ffmpeg.c: allow forcing input framerate on streamcopy

2018-10-28 Thread Leo Izen
This is v2 of a patch I sent earlier, revised after testing on various streams.

---
 fftools/ffmpeg.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index da4259a9a8..6e81716795 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2045,12 +2045,14 @@ static void do_streamcopy(InputStream *ist, 
OutputStream *ost, const AVPacket *p
 if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO)
 ost->sync_opts++;
 
-if (pkt->pts != AV_NOPTS_VALUE)
+if (ist->framerate.num)
+opkt.pts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->mux_timebase) - 
ost_tb_start_time;
+else if (pkt->pts != AV_NOPTS_VALUE)
 opkt.pts = av_rescale_q(pkt->pts, ist->st->time_base, 
ost->mux_timebase) - ost_tb_start_time;
 else
 opkt.pts = AV_NOPTS_VALUE;
 
-if (pkt->dts == AV_NOPTS_VALUE)
+if (pkt->dts == AV_NOPTS_VALUE || ist->framerate.num)
 opkt.dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->mux_timebase);
 else
 opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, 
ost->mux_timebase);
@@ -2602,7 +2604,7 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
 avpkt = *pkt;
 }
 
-if (pkt && pkt->dts != AV_NOPTS_VALUE) {
+if (pkt && pkt->dts != AV_NOPTS_VALUE && !ist->framerate.num) {
 ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, 
AV_TIME_BASE_Q);
 if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_VIDEO || 
!ist->decoding_needed)
 ist->next_pts = ist->pts = ist->dts;
@@ -3158,8 +3160,15 @@ static int init_output_stream_streamcopy(OutputStream 
*ost)
 else
 sar = par_src->sample_aspect_ratio;
 ost->st->sample_aspect_ratio = par_dst->sample_aspect_ratio = sar;
-ost->st->avg_frame_rate = ist->st->avg_frame_rate;
-ost->st->r_frame_rate = ist->st->r_frame_rate;
+
+if (ist->framerate.num) {
+ost->st->avg_frame_rate = ist->framerate;
+ost->st->r_frame_rate = ist->framerate;
+} else {
+ost->st->avg_frame_rate = ist->st->avg_frame_rate;
+ost->st->r_frame_rate = ist->st->r_frame_rate;
+}
+
 break;
 }
 
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/vp3: Do not initialize unused tables for keyframes in unpack_superblock()

2018-10-28 Thread James Almer
On 10/28/2018 11:04 AM, Michael Niedermayer wrote:
> Fixes: Timeout (139sec -> 102sec)
> Fixes: 
> 9642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-6676767875006464
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vp3.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 0e6da89abb..348416b25d 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -544,8 +544,21 @@ static int unpack_superblocks(Vp3DecodeContext *s, 
> GetBitContext *gb)
>   : s->y_superblock_count);
>  int num_coded_frags = 0;
>  
> +if (s->keyframe) {
> +for (i = sb_start; i < sb_end; i++) {
> +/* iterate through all 16 fragments in a superblock */
> +for (j = 0; j < 16; j++) {
> +/* if the fragment is in bounds, check its coding status 
> */
> +current_fragment = s->superblock_fragments[i * 16 + j];
> +if (current_fragment != -1) {
> +s->coded_fragment_list[plane][num_coded_frags++] =
> +current_fragment;
> +}
> +}
> +}
> +} else {
>  for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
> -if (s->keyframe == 0 && get_bits_left(gb) < 
> plane0_num_coded_frags >> 2) {
> +if (get_bits_left(gb) < plane0_num_coded_frags >> 2) {
>  return AVERROR_INVALIDDATA;
>  }
>  /* iterate through all 16 fragments in a superblock */
> @@ -580,6 +593,7 @@ static int unpack_superblocks(Vp3DecodeContext *s, 
> GetBitContext *gb)
>  }
>  }
>  }
> +}
>  if (!plane)
>  plane0_num_coded_frags = num_coded_frags;
>  s->total_num_coded_frags += num_coded_frags;

Please reindent before you push, either as a separate commit or directly
in this one.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/3] avcodec/vp3: Do not initialize unused tables for keyframes in unpack_superblock()

2018-10-28 Thread Michael Niedermayer
Fixes: Timeout (139sec -> 102sec)
Fixes: 
9642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-6676767875006464

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vp3.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 0e6da89abb..348416b25d 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -544,8 +544,21 @@ static int unpack_superblocks(Vp3DecodeContext *s, 
GetBitContext *gb)
  : s->y_superblock_count);
 int num_coded_frags = 0;
 
+if (s->keyframe) {
+for (i = sb_start; i < sb_end; i++) {
+/* iterate through all 16 fragments in a superblock */
+for (j = 0; j < 16; j++) {
+/* if the fragment is in bounds, check its coding status */
+current_fragment = s->superblock_fragments[i * 16 + j];
+if (current_fragment != -1) {
+s->coded_fragment_list[plane][num_coded_frags++] =
+current_fragment;
+}
+}
+}
+} else {
 for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
-if (s->keyframe == 0 && get_bits_left(gb) < plane0_num_coded_frags 
>> 2) {
+if (get_bits_left(gb) < plane0_num_coded_frags >> 2) {
 return AVERROR_INVALIDDATA;
 }
 /* iterate through all 16 fragments in a superblock */
@@ -580,6 +593,7 @@ static int unpack_superblocks(Vp3DecodeContext *s, 
GetBitContext *gb)
 }
 }
 }
+}
 if (!plane)
 plane0_num_coded_frags = num_coded_frags;
 s->total_num_coded_frags += num_coded_frags;
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 3/3] avcodec/vp3: Do not recalculate coded_fragment_list for keyframes

2018-10-28 Thread Michael Niedermayer
This improves decoding speed of keyframes

Fixes: Timeout (102->27sec)
Fixes: 
9642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-6676767875006464

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vp3.c | 41 +
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index d8421a8315..bf1c0c 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -223,6 +223,10 @@ typedef struct Vp3DecodeContext {
  * which of the fragments are coded */
 int *coded_fragment_list[3];
 
+int *kf_coded_fragment_list;
+int *nkf_coded_fragment_list;
+int num_kf_coded_fragment[3];
+
 VLC dc_vlc[16];
 VLC ac_vlc_1[16];
 VLC ac_vlc_2[16];
@@ -271,7 +275,8 @@ static av_cold void free_tables(AVCodecContext *avctx)
 
 av_freep(>superblock_coding);
 av_freep(>all_fragments);
-av_freep(>coded_fragment_list[0]);
+av_freep(>nkf_coded_fragment_list);
+av_freep(>kf_coded_fragment_list);
 av_freep(>dct_tokens_base);
 av_freep(>superblock_fragments);
 av_freep(>macroblock_coding);
@@ -538,6 +543,9 @@ static int unpack_superblocks(Vp3DecodeContext *s, 
GetBitContext *gb)
 s->total_num_coded_frags = 0;
 memset(s->macroblock_coding, MODE_COPY, s->macroblock_count);
 
+s->coded_fragment_list[0] = s->keyframe ? s->kf_coded_fragment_list
+: s->nkf_coded_fragment_list;
+
 for (plane = 0; plane < 3; plane++) {
 int sb_start = superblock_starts[plane];
 int sb_end   = sb_start + (plane ? s->c_superblock_count
@@ -545,17 +553,21 @@ static int unpack_superblocks(Vp3DecodeContext *s, 
GetBitContext *gb)
 int num_coded_frags = 0;
 
 if (s->keyframe) {
-for (i = sb_start; i < sb_end; i++) {
-/* iterate through all 16 fragments in a superblock */
-for (j = 0; j < 16; j++) {
-/* if the fragment is in bounds, check its coding status */
-current_fragment = s->superblock_fragments[i * 16 + j];
-if (current_fragment != -1) {
-s->coded_fragment_list[plane][num_coded_frags++] =
-current_fragment;
+if (s->num_kf_coded_fragment[plane] == -1) {
+for (i = sb_start; i < sb_end; i++) {
+/* iterate through all 16 fragments in a superblock */
+for (j = 0; j < 16; j++) {
+/* if the fragment is in bounds, check its coding 
status */
+current_fragment = s->superblock_fragments[i * 16 + j];
+if (current_fragment != -1) {
+s->coded_fragment_list[plane][num_coded_frags++] =
+current_fragment;
+}
 }
 }
-}
+s->num_kf_coded_fragment[plane] = num_coded_frags;
+} else
+num_coded_frags = s->num_kf_coded_fragment[plane];
 } else {
 for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
 if (get_bits_left(gb) < plane0_num_coded_frags >> 2) {
@@ -1705,7 +1717,9 @@ static av_cold int allocate_tables(AVCodecContext *avctx)
 s->superblock_coding = av_mallocz(s->superblock_count);
 s->all_fragments = av_mallocz_array(s->fragment_count, 
sizeof(Vp3Fragment));
 
-s->coded_fragment_list[0] = av_mallocz_array(s->fragment_count, 
sizeof(int));
+s-> kf_coded_fragment_list = av_mallocz_array(s->fragment_count, 
sizeof(int));
+s->nkf_coded_fragment_list = av_mallocz_array(s->fragment_count, 
sizeof(int));
+memset(s-> num_kf_coded_fragment, -1, sizeof(s-> num_kf_coded_fragment));
 
 s->dct_tokens_base = av_mallocz_array(s->fragment_count,
   64 * sizeof(*s->dct_tokens_base));
@@ -1717,7 +1731,8 @@ static av_cold int allocate_tables(AVCodecContext *avctx)
 s->macroblock_coding= av_mallocz(s->macroblock_count + 1);
 
 if (!s->superblock_coding|| !s->all_fragments  ||
-!s->dct_tokens_base  || !s->coded_fragment_list[0] ||
+!s->dct_tokens_base  || !s->kf_coded_fragment_list ||
+!s->nkf_coded_fragment_list ||
 !s->superblock_fragments || !s->macroblock_coding  ||
 !s->motion_val[0]|| !s->motion_val[1]) {
 vp3_decode_end(avctx);
@@ -2271,6 +2286,8 @@ static int vp3_init_thread_copy(AVCodecContext *avctx)
 s->superblock_coding  = NULL;
 s->all_fragments  = NULL;
 s->coded_fragment_list[0] = NULL;
+s-> kf_coded_fragment_list= NULL;
+s->nkf_coded_fragment_list= NULL;
 s->dct_tokens_base= NULL;
 s->superblock_fragments   = NULL;
 

[FFmpeg-devel] [PATCH 2/3] avcodec/vp3: Reuse local variable in unpack_superblocks()

2018-10-28 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vp3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 348416b25d..d8421a8315 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -568,7 +568,7 @@ static int unpack_superblocks(Vp3DecodeContext *s, 
GetBitContext *gb)
 if (current_fragment != -1) {
 int coded = s->superblock_coding[i];
 
-if (s->superblock_coding[i] == SB_PARTIALLY_CODED) {
+if (coded == SB_PARTIALLY_CODED) {
 /* fragment may or may not be coded; this is the case
  * that cares about the fragment coding runs */
 if (current_run-- == 0) {
-- 
2.19.1

___
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-10-28 Thread Martin Vignali
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


0002-fate-prores_metadata_bsf-add-test-for-setting-color.patch
Description: Binary data


0001-avcodec-add-prores_metadata-bsf-for-set-the-color.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel