Re: [FFmpeg-devel] [PATCH 2/4] avcodec/aacdec_template: Check for duplicate elements

2018-10-07 Thread Hendrik Leppkes
On Sat, Jul 28, 2018 at 2:33 PM Michael Niedermayer
 wrote:
>
> Fixes: Timeout
> Fixes: 
> 9552/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-6027842339995648
>
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/aacdec_template.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> index 0c899285dd..b60b31a92c 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -3122,6 +3122,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, 
> void *data,
>  int samples = 0, multiplier, audio_found = 0, pce_found = 0;
>  int is_dmono, sce_count = 0;
>  int payload_alignment;
> +uint8_t che_presence[4][MAX_ELEM_ID] = {{0}};
>
>  ac->frame = data;
>
> @@ -3159,6 +3160,14 @@ static int aac_decode_frame_int(AVCodecContext *avctx, 
> void *data,
>  }
>
>  if (elem_type < TYPE_DSE) {
> +if (che_presence[elem_type][elem_id]) {
> +av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d 
> duplicate\n",
> +   elem_type, elem_id);
> +err = AVERROR_INVALIDDATA;
> +goto fail;
> +}
> +che_presence[elem_type][elem_id] = 1;
> +
>  if (!(che=get_che(ac, elem_type, elem_id))) {
>  av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is 
> not allocated\n",
> elem_type, elem_id);

I've been given a AAC stream that breaks decoding after this patch.
I've opened a ticket with a sample file on Trac:
https://trac.ffmpeg.org/ticket/7477

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


Re: [FFmpeg-devel] [PATCH] avcodec/nvdec: Add support for decoding HEVC 4:4:4 content

2018-10-07 Thread Timo Rothenpieler

On 07.10.2018 04:19, Philip Langdale wrote:

The latest generation video decoder on the Turing chips supports
decoding HEVC 4:4:4. Supporting this is relatively straight-forward;
we need to account for the different chroma format and pick the
right output and sw formats at the right times.

There was one bug which was the hard-coded assumption that the
first chroma plane would be half-height; I fixed this to use the
actual shift value on the plane.

The output formats ('2', and '3') are currently undocumented but
appear to be YUV444P and YUV444P16 based on how they behave.
---
  libavcodec/hevcdec.c |  2 ++
  libavcodec/nvdec.c   | 43 +++
  2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index a3b5c8cb71..508e093ea3 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -409,6 +409,8 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
  #endif
  break;
  case AV_PIX_FMT_YUV420P12:
+case AV_PIX_FMT_YUV444P10:
+case AV_PIX_FMT_YUV444P12:
  #if CONFIG_HEVC_NVDEC_HWACCEL
  *fmt++ = AV_PIX_FMT_CUDA;
  #endif
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index e779be3a45..7e5c1791ea 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -34,6 +34,9 @@
  #include "nvdec.h"
  #include "internal.h"
  
+#define cudaVideoSurfaceFormat_YUV444P 2

+#define cudaVideoSurfaceFormat_YUV444P16 3


This will probably collide once the headers add those values, not sure 
how to properly handle that, but they at least should have a different 
naming scheme.



  typedef struct NVDECDecoder {
  CUvideodecoder decoder;
  
@@ -273,7 +276,8 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
  
  CUVIDDECODECREATEINFO params = { 0 };
  
-int cuvid_codec_type, cuvid_chroma_format;

+cudaVideoSurfaceFormat output_format;
+int cuvid_codec_type, cuvid_chroma_format, chroma_444;
  int ret = 0;
  
  sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);

@@ -291,6 +295,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
  av_log(avctx, AV_LOG_ERROR, "Unsupported chroma format\n");
  return AVERROR(ENOSYS);
  }
+chroma_444 = cuvid_chroma_format == cudaVideoChromaFormat_444;
  
  if (!avctx->hw_frames_ctx) {

  ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA);
@@ -298,6 +303,21 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
  return ret;
  }
  
+switch (sw_desc->comp[0].depth) {

+case 8:
+output_format = chroma_444 ? cudaVideoSurfaceFormat_YUV444P :
+ cudaVideoSurfaceFormat_NV12;
+break;
+case 10:
+case 12:
+output_format = chroma_444 ? cudaVideoSurfaceFormat_YUV444P16 :
+ cudaVideoSurfaceFormat_P016;
+break;
+default:
+av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth\n");
+return AVERROR(ENOSYS);
+}
+
  frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
  
  params.ulWidth = avctx->coded_width;

@@ -305,8 +325,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
  params.ulTargetWidth   = avctx->coded_width;
  params.ulTargetHeight  = avctx->coded_height;
  params.bitDepthMinus8  = sw_desc->comp[0].depth - 8;
-params.OutputFormat= params.bitDepthMinus8 ?
- cudaVideoSurfaceFormat_P016 : 
cudaVideoSurfaceFormat_NV12;
+params.OutputFormat= output_format;
  params.CodecType   = cuvid_codec_type;
  params.ChromaFormat= cuvid_chroma_format;
  params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size;
@@ -388,6 +407,8 @@ static int nvdec_retrieve_data(void *logctx, AVFrame *frame)
  NVDECFrame*cf = (NVDECFrame*)fdd->hwaccel_priv;
  NVDECDecoder *decoder = (NVDECDecoder*)cf->decoder_ref->data;
  
+AVHWFramesContext *hwctx = (AVHWFramesContext *)frame->hw_frames_ctx->data;

+
  CUVIDPROCPARAMS vpp = { 0 };
  NVDECFrame *unmap_data = NULL;
  
@@ -397,6 +418,7 @@ static int nvdec_retrieve_data(void *logctx, AVFrame *frame)
  
  unsigned int pitch, i;

  unsigned int offset = 0;
+int shift_h = 0, shift_v = 0;
  int ret = 0;
  
  vpp.progressive_frame = 1;

@@ -433,10 +455,11 @@ static int nvdec_retrieve_data(void *logctx, AVFrame 
*frame)
  unmap_data->idx_ref = av_buffer_ref(cf->idx_ref);
  unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref);
  
+av_pix_fmt_get_chroma_sub_sample(hwctx->sw_format, &shift_h, &shift_v);

  for (i = 0; frame->linesize[i]; i++) {
  frame->data[i] = (uint8_t*)(devptr + offset);
  frame->linesize[i] = pitch;
-offset += pitch * (frame->height >> (i ? 1 : 0));
+offset += pitch * (frame->height >> (i ? shift_v : 0));
  }
  
  goto finish;

@@ -576,7 +599,7 @@ int ff_nvdec_fr

[FFmpeg-devel] [PATCH] avcodec/aacdec_template: Allow duplicated elements

2018-10-07 Thread Michael Niedermayer
Such streams are invalid according to
4.5.2.1 Top level payloads for the audio object types AAC main, AAC SSR, AAC LC 
and AAC LTP
4.5.2.1.1 Definitions
...cIn the raw_data_block(), several instances of the
same syntactic element may occur, but must have a different 4 bit
element_instance_tag, except for data_stream_element()'s and
fill_element()'s.

Fixes: Ticket7477

Signed-off-by: Michael Niedermayer 
---
 libavcodec/aacdec_template.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index b60b31a92c..dce6035d67 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -3161,12 +3161,15 @@ static int aac_decode_frame_int(AVCodecContext *avctx, 
void *data,
 
 if (elem_type < TYPE_DSE) {
 if (che_presence[elem_type][elem_id]) {
-av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d 
duplicate\n",
+int error = che_presence[elem_type][elem_id] > 1;
+av_log(ac->avctx, error ? AV_LOG_ERROR : AV_LOG_DEBUG, 
"channel element %d.%d duplicate\n",
elem_type, elem_id);
-err = AVERROR_INVALIDDATA;
-goto fail;
+if (error) {
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
 }
-che_presence[elem_type][elem_id] = 1;
+che_presence[elem_type][elem_id]++;
 
 if (!(che=get_che(ac, elem_type, elem_id))) {
 av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not 
allocated\n",
-- 
2.19.0

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


[FFmpeg-devel] [PATCH 0/5] Improvements for EBU R128 plugin

2018-10-07 Thread Daniel Molkentin
Hi,

we are using ffmpeg to monitor audio for use in online video production.
In order to make this more practical, we added a couple of features to the
ebur128 with the help from audio professionals.

Please let me know if they are good for going into master, and if you would
like to see any changes before they can be merged.

Cheers,
  Daniel

Daniel Molkentin (5):
  libavfilter/ebur128: add target level option for EBUR128 visualization
filter
  libavfilter/ebur128: add target value to statistics line
  libavfilter/ebur128: add gaugetype option
  libavfilter/ebur128: introduce target range
  libavfilter/ebur128: add mabsolute parameter

 doc/filters.texi| 21 +-
 libavfilter/f_ebur128.c | 89 +++--
 2 files changed, 87 insertions(+), 23 deletions(-)

-- 
2.17.1

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


[FFmpeg-devel] [PATCH 3/5] libavfilter/ebur128: add gaugetype option

2018-10-07 Thread Daniel Molkentin
Allow to show short term instead of momentary. Useful for monitoring
whilst live mixing.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi|  8 +++-
 libavfilter/f_ebur128.c | 18 --
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index bd5154f9be..40d9006075 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19279,7 +19279,8 @@ time graph to observe the loudness evolution. The 
graphic contains the logged
 message mentioned above, so it is not printed anymore when this option is set,
 unless the verbose logging is set. The main graphing area contains the
 short-term loudness (3 seconds of analysis), and the gauge on the right is for
-the momentary loudness (400 milliseconds).
+the momentary loudness (400 milliseconds), but can optionally be configured
+to instead display short-term loundness (see @var{gaugetype}).
 
 More information about the Loudness Recommendation EBU R128 on
 @url{http://tech.ebu.ch/loudness}.
@@ -19362,6 +19363,11 @@ Set a specific target level (in LUFS) used as relative 
zero in the visualization
 This parameter is optional and has a default value of -23LUFS as specified
 by EBU R128. However, material published online may prefer a level of -16LUFS
 (e.g. for use with podcasts or video platforms).
+
+@item gaugetype
+Set the value displayed by the gauge. Valid values are m (momentary) and s 
(short-term).
+By default the momentary value will be used, but in certain scenarios it may 
be more useful
+to observe the short term value instead (e.g. live mixing).
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 89bfcb0b3e..66d4c4dec7 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -143,6 +143,7 @@ typedef struct EBUR128Context {
 int dual_mono;  ///< whether or not to treat single 
channel input files as dual-mono
 double pan_law; ///< pan law value used to calculate 
dual-mono measurements
 int target; ///< target level in LUFS used to set 
relative zero LU in visualization
+char *gauge_type;   ///< whether gauge shows momentary or short
 } EBUR128Context;
 
 enum {
@@ -170,6 +171,7 @@ static const AVOption ebur128_options[] = {
 { "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F },
 { "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), 
AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F },
 { "target", "set a specific target level in LUFS (-23 to 0)", 
OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
+{ "gaugetype", "sets whether the gauge shows momentrary (m) or short-term 
(s)", OFFSET(gauge_type), AV_OPT_TYPE_STRING, {.str = "m"}, CHAR_MIN, CHAR_MAX, 
V|F },
 { NULL },
 };
 
@@ -517,6 +519,11 @@ static av_cold int init(AVFilterContext *ctx)
 return ret;
 }
 
+if (strcmp(ebur128->gauge_type, "m") && strcmp(ebur128->gauge_type, "s")) {
+av_log(ctx, AV_LOG_ERROR, "Value for gaugetype can only be 'm' or 
's'.\n");
+return AVERROR(EINVAL);
+}
+
 /* summary */
 av_log(ctx, AV_LOG_VERBOSE, "EBU +%d scale\n", ebur128->meter);
 
@@ -741,9 +748,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 if (ebur128->do_video) {
 int x, y, ret;
 uint8_t *p;
+double gauge_value;
+
+if (!strcmp(ebur128->gauge_type, "m")) {
+gauge_value = loudness_400 - ebur128->target;
+} else {
+gauge_value = loudness_3000 - ebur128->target;
+}
 
 const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 
- ebur128->target);
-const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400  
- ebur128->target);
+const int y_loudness_lu_gauge = lu_to_y(ebur128, gauge_value);
 
 /* draw the graph using the short-term loudness */
 p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + 
ebur128->graph.x*3;
@@ -755,7 +769,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 p += pic->linesize[0];
 }
 
-/* draw the gauge using the momentary loudness */
+/* draw the gauge using either momentary or short-term 
loudness */
 p = pic->data[0] + ebur128->gauge.y*pic->linesize[0] + 
ebur128->gauge.x*3;
 for (y = 0; y < ebur128->gauge.h; y++) {
 const uint8_t *c = get_graph_color(ebur128, 
y_loudness_lu_gauge, y);
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 1/5] libavfilter/ebur128: add target level option for EBUR128 visualization filter

2018-10-07 Thread Daniel Molkentin
Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi| 6 ++
 libavfilter/f_ebur128.c | 6 --
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 30a52c4fdb..bd5154f9be 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19356,6 +19356,12 @@ Multi-channel input files are not affected by this 
option.
 @item panlaw
 Set a specific pan law to be used for the measurement of dual mono files.
 This parameter is optional, and has a default value of -3.01dB.
+
+@item target
+Set a specific target level (in LUFS) used as relative zero in the 
visualization.
+This parameter is optional and has a default value of -23LUFS as specified
+by EBU R128. However, material published online may prefer a level of -16LUFS
+(e.g. for use with podcasts or video platforms).
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index a48d3629ce..dfccbff5ec 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -142,6 +142,7 @@ typedef struct EBUR128Context {
 int metadata;   ///< whether or not to inject loudness 
results in frames
 int dual_mono;  ///< whether or not to treat single 
channel input files as dual-mono
 double pan_law; ///< pan law value used to calculate 
dual-mono measurements
+int target; ///< target level in LUFS used to set 
relative zero LU in visualization
 } EBUR128Context;
 
 enum {
@@ -168,6 +169,7 @@ static const AVOption ebur128_options[] = {
 { "true",   "enable true-peak mode",   0, AV_OPT_TYPE_CONST, {.i64 = 
PEAK_MODE_TRUE_PEAKS},INT_MIN, INT_MAX, A|F, "mode" },
 { "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F },
 { "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), 
AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F },
+{ "target", "set a specific target level in LUFS (-23 to 0)", 
OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
 { NULL },
 };
 
@@ -740,8 +742,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 int x, y, ret;
 uint8_t *p;
 
-const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 
+ 23);
-const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400  
+ 23);
+const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 
- ebur128->target);
+const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400  
- ebur128->target);
 
 /* draw the graph using the short-term loudness */
 p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + 
ebur128->graph.x*3;
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 2/5] libavfilter/ebur128: add target value to statistics line

2018-10-07 Thread Daniel Molkentin
Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 libavfilter/f_ebur128.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index dfccbff5ec..89bfcb0b3e 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -735,7 +735,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 loudness_3000 -= ebur128->pan_law;
 }
 
-#define LOG_FMT "M:%6.1f S:%6.1f I:%6.1f LUFS LRA:%6.1f LU"
+#define LOG_FMT "TARGET:%d M:%6.1f S:%6.1f I:%6.1f LUFS LRA:%6.1f 
LU"
 
 /* push one video frame */
 if (ebur128->do_video) {
@@ -768,7 +768,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 /* draw textual info */
 drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
  LOG_FMT " ", // padding to erase trailing 
characters
- loudness_400, loudness_3000,
+ ebur128->target, loudness_400, loudness_3000,
  ebur128->integrated_loudness, 
ebur128->loudness_range);
 
 /* set pts and push frame */
@@ -811,7 +811,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 
 av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
av_ts2timestr(pts, &outlink->time_base),
-   loudness_400, loudness_3000,
+   ebur128->target, loudness_400, loudness_3000,
ebur128->integrated_loudness, ebur128->loudness_range);
 
 #define PRINT_PEAKS(str, sp, ptype) do {\
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 4/5] libavfilter/ebur128: introduce target range

2018-10-07 Thread Daniel Molkentin
This eases meeting the target level during live mixing.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi|  3 +++
 libavfilter/f_ebur128.c | 33 +++--
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 40d9006075..601cbda17c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19282,6 +19282,9 @@ short-term loudness (3 seconds of analysis), and the 
gauge on the right is for
 the momentary loudness (400 milliseconds), but can optionally be configured
 to instead display short-term loundness (see @var{gaugetype}).
 
+The green area marks a  +/- 1LU target range around the target loudness
+(-23LUFS by default, unless modified through @var{target}).
+
 More information about the Loudness Recommendation EBU R128 on
 @url{http://tech.ebu.ch/loudness}.
 
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 66d4c4dec7..182e0cbe98 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -114,6 +114,8 @@ typedef struct EBUR128Context {
 int meter;  ///< select a EBU mode between +9 and +18
 int scale_range;///< the range of LU values according to 
the meter
 int y_zero_lu;  ///< the y value (pixel position) for 0 LU
+int y_opt_max;  ///< the y value (pixel position) for 1 LU
+int y_opt_min;  ///< the y value (pixel position) for -1 LU
 int *y_line_ref;///< y reference values for drawing the LU 
lines in the graph and the gauge
 
 /* audio */
@@ -178,22 +180,31 @@ static const AVOption ebur128_options[] = {
 AVFILTER_DEFINE_CLASS(ebur128);
 
 static const uint8_t graph_colors[] = {
-0xdd, 0x66, 0x66,   // value above 0LU non reached
-0x66, 0x66, 0xdd,   // value below 0LU non reached
-0x96, 0x33, 0x33,   // value above 0LU reached
-0x33, 0x33, 0x96,   // value below 0LU reached
-0xdd, 0x96, 0x96,   // value above 0LU line non reached
-0x96, 0x96, 0xdd,   // value below 0LU line non reached
-0xdd, 0x33, 0x33,   // value above 0LU line reached
-0x33, 0x33, 0xdd,   // value below 0LU line reached
+0xdd, 0x66, 0x66,   // value above 1LU non reached below -1LU (impossible)
+0x66, 0x66, 0xdd,   // value below 1LU non reached below -1LU
+0x96, 0x33, 0x33,   // value above 1LU reached below -1LU (impossible)
+0x33, 0x33, 0x96,   // value below 1LU reached below -1LU
+0xdd, 0x96, 0x96,   // value above 1LU line non reached below -1LU 
(impossible)
+0x96, 0x96, 0xdd,   // value below 1LU line non reached below -1LU
+0xdd, 0x33, 0x33,   // value above 1LU line reached below -1LU (impossible)
+0x33, 0x33, 0xdd,   // value below 1LU line reached below -1LU
+0xdd, 0x66, 0x66,   // value above 1LU non reached above -1LU
+0x66, 0xdd, 0x66,   // value below 1LU non reached above -1LU
+0x96, 0x33, 0x33,   // value above 1LU reached above -1LU
+0x33, 0x96, 0x33,   // value below 1LU reached above -1LU
+0xdd, 0x96, 0x96,   // value above 1LU line non reached above -1LU
+0x96, 0xdd, 0x96,   // value below 1LU line non reached above -1LU
+0xdd, 0x33, 0x33,   // value above 1LU line reached above -1LU
+0x33, 0xdd, 0x33,   // value below 1LU line reached above -1LU
 };
 
 static const uint8_t *get_graph_color(const EBUR128Context *ebur128, int v, 
int y)
 {
-const int below0  = y > ebur128->y_zero_lu;
+const int above_opt_max = y > ebur128->y_opt_max;
+const int below_opt_min = y < ebur128->y_opt_min;
 const int reached = y >= v;
 const int line= ebur128->y_line_ref[y] || y == ebur128->y_zero_lu;
-const int colorid = 4*line + 2*reached + below0;
+const int colorid = 8*below_opt_min+ 4*line + 2*reached + above_opt_max;
 return graph_colors + 3*colorid;
 }
 
@@ -327,6 +338,8 @@ static int config_video_output(AVFilterLink *outlink)
 
 /* draw graph */
 ebur128->y_zero_lu = lu_to_y(ebur128, 0);
+ebur128->y_opt_max = lu_to_y(ebur128, 1);
+ebur128->y_opt_min = lu_to_y(ebur128, -1);
 p = outpicref->data[0] + ebur128->graph.y * outpicref->linesize[0]
+ ebur128->graph.x * 3;
 for (y = 0; y < ebur128->graph.h; y++) {
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 5/5] libavfilter/ebur128: add mabsolute parameter

2018-10-07 Thread Daniel Molkentin
This allows switching between absolute (LUFS) and relativ (LU) display
in the status line.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi|  4 
 libavfilter/f_ebur128.c | 34 +-
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 601cbda17c..dc01c805b2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19371,6 +19371,10 @@ by EBU R128. However, material published online may 
prefer a level of -16LUFS
 Set the value displayed by the gauge. Valid values are m (momentary) and s 
(short-term).
 By default the momentary value will be used, but in certain scenarios it may 
be more useful
 to observe the short term value instead (e.g. live mixing).
+
+@item mabsolute
+Sets whether to display the loudness in LUFS (1, the default) LU relative to 
the target (0).
+This only affects the video output, not the summary or continous log output.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 182e0cbe98..5d58abc741 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -146,6 +146,7 @@ typedef struct EBUR128Context {
 double pan_law; ///< pan law value used to calculate 
dual-mono measurements
 int target; ///< target level in LUFS used to set 
relative zero LU in visualization
 char *gauge_type;   ///< whether gauge shows momentary or short
+int mabsolute; ///< whether to display the statistics in 
LUFS or LU
 } EBUR128Context;
 
 enum {
@@ -174,6 +175,7 @@ static const AVOption ebur128_options[] = {
 { "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), 
AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F },
 { "target", "set a specific target level in LUFS (-23 to 0)", 
OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
 { "gaugetype", "sets whether the gauge shows momentrary (m) or short-term 
(s)", OFFSET(gauge_type), AV_OPT_TYPE_STRING, {.str = "m"}, CHAR_MIN, CHAR_MAX, 
V|F },
+{ "mabsolute", "sets whether the stats should be displayed absolute (LUFS, 
default) or relative (LU) ", OFFSET(mabsolute), AV_OPT_TYPE_BOOL, {.i64 = 1}, 
0, 1, V|F },
 { NULL },
 };
 
@@ -755,7 +757,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 loudness_3000 -= ebur128->pan_law;
 }
 
-#define LOG_FMT "TARGET:%d M:%6.1f S:%6.1f I:%6.1f LUFS LRA:%6.1f 
LU"
+#define LOG_FMT "TARGET:%d LUFSM:%6.1f S:%6.1f I:%6.1f %s   
LRA:%6.1f LU"
 
 /* push one video frame */
 if (ebur128->do_video) {
@@ -793,10 +795,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 }
 
 /* draw textual info */
-drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
- LOG_FMT " ", // padding to erase trailing 
characters
- ebur128->target, loudness_400, loudness_3000,
- ebur128->integrated_loudness, 
ebur128->loudness_range);
+if (ebur128->mabsolute) {
+drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
+ LOG_FMT " ", // padding to erase trailing 
characters
+ ebur128->target, loudness_400, loudness_3000,
+ ebur128->integrated_loudness, "LUFS", 
ebur128->loudness_range);
+} else {
+drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
+ LOG_FMT " ", // padding to erase trailing 
characters
+ ebur128->target, loudness_400-ebur128->target, 
loudness_3000-ebur128->target,
+ ebur128->integrated_loudness-ebur128->target, 
"LU", ebur128->loudness_range);
+}
 
 /* set pts and push frame */
 pic->pts = pts;
@@ -836,10 +845,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 SET_META_PEAK(true,   TRUE);
 }
 
-av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
-   av_ts2timestr(pts, &outlink->time_base),
-   ebur128->target, loudness_400, loudness_3000,
-   ebur128->integrated_loudness, ebur128->loudness_range);
+if (ebur128->mabsolute) {
+av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
+   av_ts2timestr(pts, &outlink->time_base),
+   ebur128->target, loudness_400, loudness_3000,
+   ebur128->integrated_loudness, "LUFS", 
ebur128->loudness_range);
+} else {
+av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
+   av_ts2timestr(pts, &outlink->time_base),

[FFmpeg-devel] H.264 SEI Display Orientation Message support in ffplay

2018-10-07 Thread Omer Iqbal
Hey everyone!

I am developing a video streaming mobile application. In order to support
multiple orientations, I am currently using h.264's SEI Display Orientation
message in my H.264 bitstream. (For more context, my bitstream is
transported over RTMP and packaged as FLV)

I see that ffprobe can detect my Display Orientation messages as
av_frame_side_data of type AV_FRAME_DATA_DISPLAYMATRIX.

However, after reading the source code of ffplay, it seems that it does not
support frame level orientation changes?.  From what I gathered, it will
get a display matrix using av_stream_get_side_data. And I can't find any
place where the stream's display matrix will be changed by a frame level
display matrix.

Can someone help clarify this? Do ffplay and other popular players support
frame level rotation at all?

Thanks!
Omer Iqbal
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/5] libavfilter/ebur128: add gaugetype option

2018-10-07 Thread Paul B Mahol
On 10/7/18, Daniel Molkentin  wrote:
> Allow to show short term instead of momentary. Useful for monitoring
> whilst live mixing.
>
> Signed-off-by: Daniel Molkentin 
> Signed-off-by: Conrad Zelck 
> ---
>  doc/filters.texi|  8 +++-
>  libavfilter/f_ebur128.c | 18 --
>  2 files changed, 23 insertions(+), 3 deletions(-)

Please use AV_OPT_TYPE_INT in combination of AV_OPT_TYPE_CONST, like
all filters do.

Using strcmp is fragile and ugly.

>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index bd5154f9be..40d9006075 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -19279,7 +19279,8 @@ time graph to observe the loudness evolution. The
> graphic contains the logged
>  message mentioned above, so it is not printed anymore when this option is
> set,
>  unless the verbose logging is set. The main graphing area contains the
>  short-term loudness (3 seconds of analysis), and the gauge on the right is
> for
> -the momentary loudness (400 milliseconds).
> +the momentary loudness (400 milliseconds), but can optionally be configured
> +to instead display short-term loundness (see @var{gaugetype}).
>
>  More information about the Loudness Recommendation EBU R128 on
>  @url{http://tech.ebu.ch/loudness}.
> @@ -19362,6 +19363,11 @@ Set a specific target level (in LUFS) used as
> relative zero in the visualization
>  This parameter is optional and has a default value of -23LUFS as specified
>  by EBU R128. However, material published online may prefer a level of
> -16LUFS
>  (e.g. for use with podcasts or video platforms).
> +
> +@item gaugetype
> +Set the value displayed by the gauge. Valid values are m (momentary) and s
> (short-term).
> +By default the momentary value will be used, but in certain scenarios it
> may be more useful
> +to observe the short term value instead (e.g. live mixing).
>  @end table
>
>  @subsection Examples
> diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
> index 89bfcb0b3e..66d4c4dec7 100644
> --- a/libavfilter/f_ebur128.c
> +++ b/libavfilter/f_ebur128.c
> @@ -143,6 +143,7 @@ typedef struct EBUR128Context {
>  int dual_mono;  ///< whether or not to treat single
> channel input files as dual-mono
>  double pan_law; ///< pan law value used to calculate
> dual-mono measurements
>  int target; ///< target level in LUFS used to set
> relative zero LU in visualization
> +char *gauge_type;   ///< whether gauge shows momentary or
> short
>  } EBUR128Context;
>
>  enum {
> @@ -170,6 +171,7 @@ static const AVOption ebur128_options[] = {
>  { "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono),
> AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F },
>  { "panlaw", "set a specific pan law for dual-mono files",
> OFFSET(pan_law), AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0,
> A|F },
>  { "target", "set a specific target level in LUFS (-23 to 0)",
> OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
> +{ "gaugetype", "sets whether the gauge shows momentrary (m) or
> short-term (s)", OFFSET(gauge_type), AV_OPT_TYPE_STRING, {.str = "m"},
> CHAR_MIN, CHAR_MAX, V|F },
>  { NULL },
>  };
>
> @@ -517,6 +519,11 @@ static av_cold int init(AVFilterContext *ctx)
>  return ret;
>  }
>
> +if (strcmp(ebur128->gauge_type, "m") && strcmp(ebur128->gauge_type,
> "s")) {
> +av_log(ctx, AV_LOG_ERROR, "Value for gaugetype can only be 'm' or
> 's'.\n");
> +return AVERROR(EINVAL);
> +}
> +
>  /* summary */
>  av_log(ctx, AV_LOG_VERBOSE, "EBU +%d scale\n", ebur128->meter);
>
> @@ -741,9 +748,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *insamples)
>  if (ebur128->do_video) {
>  int x, y, ret;
>  uint8_t *p;
> +double gauge_value;
> +
> +if (!strcmp(ebur128->gauge_type, "m")) {
> +gauge_value = loudness_400 - ebur128->target;
> +} else {
> +gauge_value = loudness_3000 - ebur128->target;
> +}
>
>  const int y_loudness_lu_graph = lu_to_y(ebur128,
> loudness_3000 - ebur128->target);
> -const int y_loudness_lu_gauge = lu_to_y(ebur128,
> loudness_400  - ebur128->target);
> +const int y_loudness_lu_gauge = lu_to_y(ebur128,
> gauge_value);
>
>  /* draw the graph using the short-term loudness */
>  p = pic->data[0] + ebur128->graph.y*pic->linesize[0] +
> ebur128->graph.x*3;
> @@ -755,7 +769,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *insamples)
>  p += pic->linesize[0];
>  }
>
> -/* draw the gauge using the momentary loudness */
> +/* draw the gauge using either momentary or short-term
> loudness */
>  p = pic->data[0] + ebur128->gauge.y*pic->linesize[0] +
> ebur12

Re: [FFmpeg-devel] H.264 SEI Display Orientation Message support in ffplay

2018-10-07 Thread Dennis Mungai
You might be better served by mpv.
libmpv may be a better implementation for a video player than ffplay.

On Sun, Oct 7, 2018, 19:04 Omer Iqbal  wrote:

> Hey everyone!
>
> I am developing a video streaming mobile application. In order to support
> multiple orientations, I am currently using h.264's SEI Display Orientation
> message in my H.264 bitstream. (For more context, my bitstream is
> transported over RTMP and packaged as FLV)
>
> I see that ffprobe can detect my Display Orientation messages as
> av_frame_side_data of type AV_FRAME_DATA_DISPLAYMATRIX.
>
> However, after reading the source code of ffplay, it seems that it does not
> support frame level orientation changes?.  From what I gathered, it will
> get a display matrix using av_stream_get_side_data. And I can't find any
> place where the stream's display matrix will be changed by a frame level
> display matrix.
>
> Can someone help clarify this? Do ffplay and other popular players support
> frame level rotation at all?
>
> Thanks!
> Omer Iqbal
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] H.264 SEI Display Orientation Message support in ffplay

2018-10-07 Thread Omer Iqbal
Thanks for the suggestion. I took a quick look at mpv. Sadly it does not
seem to support H.264 SEI Display Orientation messages either :(. Please
correct me if I am wrong.
I also glanced at VLC. It doesn’t seem to use AV_FRAME_DATA_DISPLAYMATRIX
either.
I'm curious, does anyone know why this is not implemented in video players?
Considering it is part of the H.264 specification, and ffmpeg supports
decoding it?
Thanks alot!

On Mon, 8 Oct 2018 at 12:13 AM, Dennis Mungai  wrote:

> You might be better served by mpv.
> libmpv may be a better implementation for a video player than ffplay.
>
> On Sun, Oct 7, 2018, 19:04 Omer Iqbal  wrote:
>
> > Hey everyone!
> >
> > I am developing a video streaming mobile application. In order to support
> > multiple orientations, I am currently using h.264's SEI Display
> Orientation
> > message in my H.264 bitstream. (For more context, my bitstream is
> > transported over RTMP and packaged as FLV)
> >
> > I see that ffprobe can detect my Display Orientation messages as
> > av_frame_side_data of type AV_FRAME_DATA_DISPLAYMATRIX.
> >
> > However, after reading the source code of ffplay, it seems that it does
> not
> > support frame level orientation changes?.  From what I gathered, it will
> > get a display matrix using av_stream_get_side_data. And I can't find any
> > place where the stream's display matrix will be changed by a frame level
> > display matrix.
> >
> > Can someone help clarify this? Do ffplay and other popular players
> support
> > frame level rotation at all?
> >
> > Thanks!
> > Omer Iqbal
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 0/5] Add nvidia hw decode support for HEVC 4:4:4 content

2018-10-07 Thread Philip Langdale
The new video decoder hardware on Turing GPUs supports HEVC 4:4:4 content.
This patch series adds the necessary new pixel formats and implements
support in nvdec/nvenc/cuviddec.

Philip Langdale (5):
  avutil: Add YUV444P10_LSB and YUV444P12_LSB pixel formats
  avcodec/nvdec: Add support for decoding HEVC 4:4:4 content
  avcodec/nvdec: Explicitly mark codecs that support 444 output formats
  avcodec/cuviddec: Add support for decoding HEVC 4:4:4 content
  avcodec/nvenc: Accept YUV444P10_LSB and YUV444P12_LSB content

 Changelog  |  1 +
 libavcodec/cuviddec.c  | 59 ++
 libavcodec/hevcdec.c   |  3 ++
 libavcodec/nvdec.c | 46 +++--
 libavcodec/nvdec.h |  5 +++-
 libavcodec/nvdec_h264.c|  2 +-
 libavcodec/nvdec_hevc.c| 10 +--
 libavcodec/nvdec_mjpeg.c   |  2 +-
 libavcodec/nvdec_mpeg12.c  |  2 +-
 libavcodec/nvdec_mpeg4.c   |  2 +-
 libavcodec/nvdec_vc1.c |  2 +-
 libavcodec/nvdec_vp8.c |  2 +-
 libavcodec/nvdec_vp9.c |  2 +-
 libavcodec/nvenc.c | 18 
 libavcodec/version.h   |  2 +-
 libavutil/hwcontext_cuda.c |  2 ++
 libavutil/pixdesc.c| 48 +++
 libavutil/pixfmt.h |  8 ++
 libavutil/version.h|  4 +--
 19 files changed, 174 insertions(+), 46 deletions(-)

-- 
2.17.1

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


[FFmpeg-devel] [PATCH 1/5] avutil: Add YUV444P10_LSB and YUV444P12_LSB pixel formats

2018-10-07 Thread Philip Langdale
Currently, ffmpeg defines a set of YUV444P formats for use where
the bits-per-pixel are between 8 and 16 bits. In these formats,
the bits are packed in the MSBs of the 16 bits of available storage.

On the other hand, all the hardware vendors have defined their
equivalent formats with the bits packed in the LSBs, which has the
virtue of making the memory layouts compatible with being treated
as full 16 bit values (which is also why P010 is defined this way).

So, to be able to use these hardware compatible formats, we need
definitions for them in ffmpeg. Right now, I need this for nvdec,
but Vulkan also uses the same format definitions.

Signed-off-by: Philip Langdale 
---
 libavutil/pixdesc.c | 48 +
 libavutil/pixfmt.h  |  8 
 libavutil/version.h |  4 ++--
 3 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 970a83214c..c48a100907 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1629,6 +1629,54 @@ static const AVPixFmtDescriptor 
av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
 },
 .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
 },
+[AV_PIX_FMT_YUV444P10LE_LSB] = {
+.name = "yuv444p10lelsb",
+.nb_components = 3,
+.log2_chroma_w = 0,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 2, 0, 6, 10, 1, 9, 1 },/* Y */
+{ 1, 2, 0, 6, 10, 1, 9, 1 },/* U */
+{ 2, 2, 0, 6, 10, 1, 9, 1 },/* V */
+},
+.flags = AV_PIX_FMT_FLAG_PLANAR,
+},
+[AV_PIX_FMT_YUV444P10BE_LSB] = {
+.name = "yuv444p10belsb",
+.nb_components = 3,
+.log2_chroma_w = 0,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 2, 0, 6, 10, 1, 9, 1 },/* Y */
+{ 1, 2, 0, 6, 10, 1, 9, 1 },/* U */
+{ 2, 2, 0, 6, 10, 1, 9, 1 },/* V */
+},
+.flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
+},
+[AV_PIX_FMT_YUV444P12LE_LSB] = {
+.name = "yuv444p12lelsb",
+.nb_components = 3,
+.log2_chroma_w = 0,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 2, 0, 4, 12, 1, 11, 1 },/* Y */
+{ 1, 2, 0, 4, 12, 1, 11, 1 },/* U */
+{ 2, 2, 0, 4, 12, 1, 11, 1 },/* V */
+},
+.flags = AV_PIX_FMT_FLAG_PLANAR,
+},
+[AV_PIX_FMT_YUV444P12BE_LSB] = {
+.name = "yuv444p12belsb",
+.nb_components = 3,
+.log2_chroma_w = 0,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 2, 0, 4, 12, 1, 11, 1 },/* Y */
+{ 1, 2, 0, 4, 12, 1, 11, 1 },/* U */
+{ 2, 2, 0, 4, 12, 1, 11, 1 },/* V */
+},
+.flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
+},
 [AV_PIX_FMT_D3D11VA_VLD] = {
 .name = "d3d11va_vld",
 .log2_chroma_w = 1,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 6815f8dc7b..910cb0a995 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -340,6 +340,11 @@ enum AVPixelFormat {
 AV_PIX_FMT_GRAYF32BE,  ///< IEEE-754 single precision Y, 32bpp, big-endian
 AV_PIX_FMT_GRAYF32LE,  ///< IEEE-754 single precision Y, 32bpp, 
little-endian
 
+AV_PIX_FMT_YUV444P10LE_LSB,  ///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb 
sample per 1x1 Y samples), LSB packed, little-endian
+AV_PIX_FMT_YUV444P10BE_LSB,  ///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb 
sample per 1x1 Y samples), LSB packed, big-endian
+AV_PIX_FMT_YUV444P12LE_LSB,  ///< planar YUV 4:4:4, 36bpp, (1 Cr & Cb 
sample per 1x1 Y samples), LSB packed, little-endian
+AV_PIX_FMT_YUV444P12BE_LSB,  ///< planar YUV 4:4:4, 36bpp, (1 Cr & Cb 
sample per 1x1 Y samples), LSB packed, big-endian
+
 AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you 
want to link with shared libav* because the number of formats might differ 
between versions
 };
 
@@ -391,6 +396,9 @@ enum AVPixelFormat {
 #define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
 #define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
 
+#define AV_PIX_FMT_YUV444P10_LSB AV_PIX_FMT_NE(YUV444P10BE_LSB, 
YUV444P10LE_LSB)
+#define AV_PIX_FMT_YUV444P12_LSB AV_PIX_FMT_NE(YUV444P12BE_LSB, 
YUV444P12LE_LSB)
+
 #define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE ,GBRP9LE)
 #define AV_PIX_FMT_GBRP10AV_PIX_FMT_NE(GBRP10BE,GBRP10LE)
 #define AV_PIX_FMT_GBRP12AV_PIX_FMT_NE(GBRP12BE,GBRP12LE)
diff --git a/libavutil/version.h b/libavutil/version.h
index f84ec89154..377714a91e 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  19
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR  20
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_M

[FFmpeg-devel] [PATCH 4/5] avcodec/cuviddec: Add support for decoding HEVC 4:4:4 content

2018-10-07 Thread Philip Langdale
This is the equivalent change for cuviddec after the previous change
for nvdec. I made similar changes to the copying routines to handle
pixel formats in a more generic way.

Note that unlike with nvdec, there is no confusion about the ability
of a codec to output 444 formats. This is because the cuvid parser is
used, meaning that 444 JPEG content is still indicated as using a 420
output format.

Signed-off-by: Philip Langdale 
---
 libavcodec/cuviddec.c | 59 +--
 1 file changed, 40 insertions(+), 19 deletions(-)

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 4d3caf924e..595249475d 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -35,6 +35,9 @@
 #include "hwaccel.h"
 #include "internal.h"
 
+#define CUVID_FORMAT_YUV444P 2
+#define CUVID_FORMAT_YUV444P16 3
+
 typedef struct CuvidContext
 {
 AVClass *avclass;
@@ -127,6 +130,7 @@ static int CUDAAPI cuvid_handle_video_sequence(void 
*opaque, CUVIDEOFORMAT* form
 CUVIDDECODECAPS *caps = NULL;
 CUVIDDECODECREATEINFO cuinfo;
 int surface_fmt;
+int chroma_444;
 
 int old_width = avctx->width;
 int old_height = avctx->height;
@@ -169,17 +173,19 @@ static int CUDAAPI cuvid_handle_video_sequence(void 
*opaque, CUVIDEOFORMAT* form
 cuinfo.target_rect.right = cuinfo.ulTargetWidth;
 cuinfo.target_rect.bottom = cuinfo.ulTargetHeight;
 
+chroma_444 = format->chroma_format == cudaVideoChromaFormat_444;
+
 switch (format->bit_depth_luma_minus8) {
 case 0: // 8-bit
-pix_fmts[1] = AV_PIX_FMT_NV12;
+pix_fmts[1] = chroma_444 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_NV12;
 caps = &ctx->caps8;
 break;
 case 2: // 10-bit
-pix_fmts[1] = AV_PIX_FMT_P010;
+pix_fmts[1] = chroma_444 ? AV_PIX_FMT_YUV444P10_LSB : AV_PIX_FMT_P010;
 caps = &ctx->caps10;
 break;
 case 4: // 12-bit
-pix_fmts[1] = AV_PIX_FMT_P016;
+pix_fmts[1] = chroma_444 ? AV_PIX_FMT_YUV444P12_LSB : AV_PIX_FMT_P016;
 caps = &ctx->caps12;
 break;
 default:
@@ -282,12 +288,6 @@ static int CUDAAPI cuvid_handle_video_sequence(void 
*opaque, CUVIDEOFORMAT* form
 return 0;
 }
 
-if (format->chroma_format != cudaVideoChromaFormat_420) {
-av_log(avctx, AV_LOG_ERROR, "Chroma formats other than 420 are not 
supported\n");
-ctx->internal_error = AVERROR(EINVAL);
-return 0;
-}
-
 ctx->chroma_format = format->chroma_format;
 
 cuinfo.CodecType = ctx->codec_type = format->codec;
@@ -301,6 +301,14 @@ static int CUDAAPI cuvid_handle_video_sequence(void 
*opaque, CUVIDEOFORMAT* form
 case AV_PIX_FMT_P016:
 cuinfo.OutputFormat = cudaVideoSurfaceFormat_P016;
 break;
+case AV_PIX_FMT_YUV444P:
+cuinfo.OutputFormat = CUVID_FORMAT_YUV444P;
+break;
+case AV_PIX_FMT_YUV444P10_LSB:
+case AV_PIX_FMT_YUV444P12_LSB:
+case AV_PIX_FMT_YUV444P16:
+cuinfo.OutputFormat = CUVID_FORMAT_YUV444P16;
+break;
 default:
 av_log(avctx, AV_LOG_ERROR, "Output formats other than NV12, P010 or 
P016 are not supported\n");
 ctx->internal_error = AVERROR(EINVAL);
@@ -507,6 +515,7 @@ static int cuvid_output_frame(AVCodecContext *avctx, 
AVFrame *frame)
 return ret;
 
 if (av_fifo_size(ctx->frame_queue)) {
+const AVPixFmtDescriptor *pixdesc;
 CuvidParsedFrame parsed_frame;
 CUVIDPROCPARAMS params;
 unsigned int pitch = 0;
@@ -537,7 +546,10 @@ static int cuvid_output_frame(AVCodecContext *avctx, 
AVFrame *frame)
 goto error;
 }
 
-for (i = 0; i < 2; i++) {
+pixdesc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
+
+for (i = 0; i < pixdesc->nb_components; i++) {
+size_t height = avctx->height >> (i ? pixdesc->log2_chroma_h : 
0);
 CUDA_MEMCPY2D cpy = {
 .srcMemoryType = CU_MEMORYTYPE_DEVICE,
 .dstMemoryType = CU_MEMORYTYPE_DEVICE,
@@ -547,22 +559,27 @@ static int cuvid_output_frame(AVCodecContext *avctx, 
AVFrame *frame)
 .dstPitch  = frame->linesize[i],
 .srcY  = offset,
 .WidthInBytes  = FFMIN(pitch, frame->linesize[i]),
-.Height= avctx->height >> (i ? 1 : 0),
+.Height= height,
 };
 
 ret = CHECK_CU(ctx->cudl->cuMemcpy2DAsync(&cpy, 
device_hwctx->stream));
 if (ret < 0)
 goto error;
 
-offset += avctx->height;
+offset += height;
 }
 
 ret = 
CHECK_CU(ctx->cudl->cuStreamSynchronize(device_hwctx->stream));
 if (ret < 0)
 goto error;
-} else if (avctx->pix_fmt == AV_PIX_FMT_NV12 ||
-   avctx->pix_fmt == AV_PIX_FMT_P010 ||
-   avctx->p

[FFmpeg-devel] [PATCH 3/5] avcodec/nvdec: Explicitly mark codecs that support 444 output formats

2018-10-07 Thread Philip Langdale
With the introduction of HEVC 444 support, we technically have two
codecs that can handle 444 - HEVC and MJPEG. In the case of MJPEG,
it can decode, but can only output one of the semi-planar formats.

That means we need additional logic to decide whether to use a
444 output format or not.

Signed-off-by: Philip Langdale 
---
 libavcodec/nvdec.c|  7 ---
 libavcodec/nvdec.h|  5 -
 libavcodec/nvdec_h264.c   |  2 +-
 libavcodec/nvdec_hevc.c   | 10 --
 libavcodec/nvdec_mjpeg.c  |  2 +-
 libavcodec/nvdec_mpeg12.c |  2 +-
 libavcodec/nvdec_mpeg4.c  |  2 +-
 libavcodec/nvdec_vc1.c|  2 +-
 libavcodec/nvdec_vp8.c|  2 +-
 libavcodec/nvdec_vp9.c|  2 +-
 10 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index e1ac06f852..4d1f55b49a 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -295,7 +295,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
 av_log(avctx, AV_LOG_ERROR, "Unsupported chroma format\n");
 return AVERROR(ENOSYS);
 }
-chroma_444 = cuvid_chroma_format == cudaVideoChromaFormat_444;
+chroma_444 = ctx->supports_444 && cuvid_chroma_format == 
cudaVideoChromaFormat_444;
 
 if (!avctx->hw_frames_ctx) {
 ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA);
@@ -595,7 +595,8 @@ static AVBufferRef *nvdec_alloc_dummy(int size)
 
 int ff_nvdec_frame_params(AVCodecContext *avctx,
   AVBufferRef *hw_frames_ctx,
-  int dpb_size)
+  int dpb_size,
+  int supports_444)
 {
 AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data;
 const AVPixFmtDescriptor *sw_desc;
@@ -616,7 +617,7 @@ int ff_nvdec_frame_params(AVCodecContext *avctx,
 av_log(avctx, AV_LOG_VERBOSE, "Unsupported chroma format\n");
 return AVERROR(EINVAL);
 }
-chroma_444 = cuvid_chroma_format == cudaVideoChromaFormat_444;
+chroma_444 = supports_444 && cuvid_chroma_format == 
cudaVideoChromaFormat_444;
 
 frames_ctx->format= AV_PIX_FMT_CUDA;
 frames_ctx->width = (avctx->coded_width + 1) & ~1;
diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h
index 85a0fcf725..09ae8c37e6 100644
--- a/libavcodec/nvdec.h
+++ b/libavcodec/nvdec.h
@@ -61,6 +61,8 @@ typedef struct NVDECContext {
 unsigned *slice_offsets;
 int   nb_slices;
 unsigned int  slice_offsets_allocated;
+
+int   supports_444;
 } NVDECContext;
 
 int ff_nvdec_decode_init(AVCodecContext *avctx);
@@ -72,7 +74,8 @@ int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const 
uint8_t *buffer,
  uint32_t size);
 int ff_nvdec_frame_params(AVCodecContext *avctx,
   AVBufferRef *hw_frames_ctx,
-  int dpb_size);
+  int dpb_size,
+  int supports_444);
 int ff_nvdec_get_ref_idx(AVFrame *frame);
 
 #endif /* AVCODEC_NVDEC_H */
diff --git a/libavcodec/nvdec_h264.c b/libavcodec/nvdec_h264.c
index 25b30329d0..116bd4fb5d 100644
--- a/libavcodec/nvdec_h264.c
+++ b/libavcodec/nvdec_h264.c
@@ -166,7 +166,7 @@ static int nvdec_h264_frame_params(AVCodecContext *avctx,
 {
 const H264Context *h = avctx->priv_data;
 const SPS   *sps = h->ps.sps;
-return ff_nvdec_frame_params(avctx, hw_frames_ctx, sps->ref_frame_count + 
sps->num_reorder_frames);
+return ff_nvdec_frame_params(avctx, hw_frames_ctx, sps->ref_frame_count + 
sps->num_reorder_frames, 0);
 }
 
 const AVHWAccel ff_h264_nvdec_hwaccel = {
diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index e04a701f3a..9e726f708e 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -269,7 +269,13 @@ static int nvdec_hevc_frame_params(AVCodecContext *avctx,
 {
 const HEVCContext *s = avctx->priv_data;
 const HEVCSPS *sps = s->ps.sps;
-return ff_nvdec_frame_params(avctx, hw_frames_ctx, 
sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering + 1);
+return ff_nvdec_frame_params(avctx, hw_frames_ctx, 
sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering + 1, 1);
+}
+
+static int nvdec_hevc_decode_init(AVCodecContext *avctx) {
+NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
+ctx->supports_444 = 1;
+return ff_nvdec_decode_init(avctx);
 }
 
 const AVHWAccel ff_hevc_nvdec_hwaccel = {
@@ -281,7 +287,7 @@ const AVHWAccel ff_hevc_nvdec_hwaccel = {
 .end_frame= ff_nvdec_end_frame,
 .decode_slice = nvdec_hevc_decode_slice,
 .frame_params = nvdec_hevc_frame_params,
-.init = ff_nvdec_decode_init,
+.init = nvdec_hevc_decode_init,
 .uninit   = ff_nvdec_decode_uninit,
 .priv_data_size   = sizeof(NVDECContext),
 };
diff --git a/libavcodec/nvdec_mjpeg.c b/libavcodec/nvdec_mjpeg.c
index 7e404246ce.

[FFmpeg-devel] [PATCH 2/5] avcodec/nvdec: Add support for decoding HEVC 4:4:4 content

2018-10-07 Thread Philip Langdale
The latest generation video decoder on the Turing chips supports
decoding HEVC 4:4:4. Supporting this is relatively straight-forward;
we need to account for the different chroma format and pick the
right output and sw formats at the right times.

There was one bug which was the hard-coded assumption that the
first chroma plane would be half-height; I fixed this to use the
actual shift value on the plane.

The output formats ('2', and '3') are currently undocumented but
appear to be YUV444P and YUV444P16 based on how they behave.

Signed-off-by: Philip Langdale 
---
 libavcodec/hevcdec.c   |  3 +++
 libavcodec/nvdec.c | 43 +++---
 libavutil/hwcontext_cuda.c |  2 ++
 3 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index a3b5c8cb71..972f2b56b6 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -409,6 +409,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
 #endif
 break;
 case AV_PIX_FMT_YUV420P12:
+case AV_PIX_FMT_YUV444P:
+case AV_PIX_FMT_YUV444P10:
+case AV_PIX_FMT_YUV444P12:
 #if CONFIG_HEVC_NVDEC_HWACCEL
 *fmt++ = AV_PIX_FMT_CUDA;
 #endif
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index e779be3a45..e1ac06f852 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -34,6 +34,9 @@
 #include "nvdec.h"
 #include "internal.h"
 
+#define NVDEC_FORMAT_YUV444P 2
+#define NVDEC_FORMAT_YUV444P16 3
+
 typedef struct NVDECDecoder {
 CUvideodecoder decoder;
 
@@ -273,7 +276,8 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
 
 CUVIDDECODECREATEINFO params = { 0 };
 
-int cuvid_codec_type, cuvid_chroma_format;
+cudaVideoSurfaceFormat output_format;
+int cuvid_codec_type, cuvid_chroma_format, chroma_444;
 int ret = 0;
 
 sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
@@ -291,6 +295,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
 av_log(avctx, AV_LOG_ERROR, "Unsupported chroma format\n");
 return AVERROR(ENOSYS);
 }
+chroma_444 = cuvid_chroma_format == cudaVideoChromaFormat_444;
 
 if (!avctx->hw_frames_ctx) {
 ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA);
@@ -298,6 +303,21 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
 return ret;
 }
 
+switch (sw_desc->comp[0].depth) {
+case 8:
+output_format = chroma_444 ? NVDEC_FORMAT_YUV444P :
+ cudaVideoSurfaceFormat_NV12;
+break;
+case 10:
+case 12:
+output_format = chroma_444 ? NVDEC_FORMAT_YUV444P16 :
+ cudaVideoSurfaceFormat_P016;
+break;
+default:
+av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth\n");
+return AVERROR(ENOSYS);
+}
+
 frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
 
 params.ulWidth = avctx->coded_width;
@@ -305,8 +325,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
 params.ulTargetWidth   = avctx->coded_width;
 params.ulTargetHeight  = avctx->coded_height;
 params.bitDepthMinus8  = sw_desc->comp[0].depth - 8;
-params.OutputFormat= params.bitDepthMinus8 ?
- cudaVideoSurfaceFormat_P016 : 
cudaVideoSurfaceFormat_NV12;
+params.OutputFormat= output_format;
 params.CodecType   = cuvid_codec_type;
 params.ChromaFormat= cuvid_chroma_format;
 params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size;
@@ -388,6 +407,8 @@ static int nvdec_retrieve_data(void *logctx, AVFrame *frame)
 NVDECFrame*cf = (NVDECFrame*)fdd->hwaccel_priv;
 NVDECDecoder *decoder = (NVDECDecoder*)cf->decoder_ref->data;
 
+AVHWFramesContext *hwctx = (AVHWFramesContext *)frame->hw_frames_ctx->data;
+
 CUVIDPROCPARAMS vpp = { 0 };
 NVDECFrame *unmap_data = NULL;
 
@@ -397,6 +418,7 @@ static int nvdec_retrieve_data(void *logctx, AVFrame *frame)
 
 unsigned int pitch, i;
 unsigned int offset = 0;
+int shift_h = 0, shift_v = 0;
 int ret = 0;
 
 vpp.progressive_frame = 1;
@@ -433,10 +455,11 @@ static int nvdec_retrieve_data(void *logctx, AVFrame 
*frame)
 unmap_data->idx_ref = av_buffer_ref(cf->idx_ref);
 unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref);
 
+av_pix_fmt_get_chroma_sub_sample(hwctx->sw_format, &shift_h, &shift_v);
 for (i = 0; frame->linesize[i]; i++) {
 frame->data[i] = (uint8_t*)(devptr + offset);
 frame->linesize[i] = pitch;
-offset += pitch * (frame->height >> (i ? 1 : 0));
+offset += pitch * (frame->height >> (i ? shift_v : 0));
 }
 
 goto finish;
@@ -576,7 +599,7 @@ int ff_nvdec_frame_params(AVCodecContext *avctx,
 {
 AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data;
 const AVPixFmtDescriptor *sw_desc;
-int cuvid_codec_type, cuvid_chroma_format;
+int 

[FFmpeg-devel] [PATCH 5/5] avcodec/nvenc: Accept YUV444P10_LSB and YUV444P12_LSB content

2018-10-07 Thread Philip Langdale
12bit is implicitly truncated to 10bit as part of doing this, but we
already do that for P016 and YUV444P16.

I've bundled a single version bump and changelog entry in this change
to reflect the updates to all three of nvdec/nvenc/cuviddec.

Signed-off-by: Philip Langdale 
---
 Changelog|  1 +
 libavcodec/nvenc.c   | 18 +-
 libavcodec/version.h |  2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/Changelog b/Changelog
index 6c5e3c1c5d..12f600f8e6 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,7 @@ version :
 - ilbc decoder
 - audio denoiser as afftdn filter
 - AV1 parser
+- Support for HEVC 4:4:4 content in nvdec/nvenc/cuviddec
 
 
 version 4.0:
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index e180d7b993..74f3842a0b 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -41,8 +41,10 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
 AV_PIX_FMT_NV12,
 AV_PIX_FMT_P010,
 AV_PIX_FMT_YUV444P,
-AV_PIX_FMT_P016,  // Truncated to 10bits
-AV_PIX_FMT_YUV444P16, // Truncated to 10bits
+AV_PIX_FMT_P016,  // Truncated to 10bits
+AV_PIX_FMT_YUV444P10_LSB,
+AV_PIX_FMT_YUV444P12_LSB, // Truncated to 10bits
+AV_PIX_FMT_YUV444P16, // Truncated to 10bits
 AV_PIX_FMT_0RGB32,
 AV_PIX_FMT_0BGR32,
 AV_PIX_FMT_CUDA,
@@ -52,11 +54,15 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
 AV_PIX_FMT_NONE
 };
 
-#define IS_10BIT(pix_fmt)  (pix_fmt == AV_PIX_FMT_P010|| \
-pix_fmt == AV_PIX_FMT_P016|| \
+#define IS_10BIT(pix_fmt)  (pix_fmt == AV_PIX_FMT_P010  || \
+pix_fmt == AV_PIX_FMT_P016  || \
+pix_fmt == AV_PIX_FMT_YUV444P10_LSB || \
+pix_fmt == AV_PIX_FMT_YUV444P12_LSB || \
 pix_fmt == AV_PIX_FMT_YUV444P16)
 
-#define IS_YUV444(pix_fmt) (pix_fmt == AV_PIX_FMT_YUV444P || \
+#define IS_YUV444(pix_fmt) (pix_fmt == AV_PIX_FMT_YUV444P   || \
+pix_fmt == AV_PIX_FMT_YUV444P10_LSB || \
+pix_fmt == AV_PIX_FMT_YUV444P12_LSB || \
 pix_fmt == AV_PIX_FMT_YUV444P16)
 
 static const struct {
@@ -1263,6 +1269,8 @@ static NV_ENC_BUFFER_FORMAT nvenc_map_buffer_format(enum 
AVPixelFormat pix_fmt)
 return NV_ENC_BUFFER_FORMAT_YUV420_10BIT;
 case AV_PIX_FMT_YUV444P:
 return NV_ENC_BUFFER_FORMAT_YUV444_PL;
+case AV_PIX_FMT_YUV444P10_LSB:
+case AV_PIX_FMT_YUV444P12_LSB:
 case AV_PIX_FMT_YUV444P16:
 return NV_ENC_BUFFER_FORMAT_YUV444_10BIT;
 case AV_PIX_FMT_0RGB32:
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 97d134851f..7e51585661 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR  32
+#define LIBAVCODEC_VERSION_MINOR  33
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.17.1

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


Re: [FFmpeg-devel] [PATCH 4/5] avutil/tests/parseutils: add some big duration tests

2018-10-07 Thread Marton Balint



On Wed, 3 Oct 2018, Michael Niedermayer wrote:


On Sun, Sep 30, 2018 at 10:45:12PM +0200, Marton Balint wrote:

These are buggy for now...

Signed-off-by: Marton Balint 
---
 libavutil/tests/parseutils.c | 4 
 tests/ref/fate/parseutils| 4 
 2 files changed, 8 insertions(+)


This patch should only be pushed when the one fixing these issues is
otherwise we might have test failures from these buggy cases behaving
differently across platforms


Ok, pushed the series with reversed order of patch 4 and 5.

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


Re: [FFmpeg-devel] [PATCHv3 1/2] ffplay: options to specify window position

2018-10-07 Thread Marton Balint



On Thu, 4 Oct 2018, Dave Rice wrote:


From caa816d70e69f85d49556ff341addab24ebcd942 Mon Sep 17 00:00:00 2001
From: Dave Rice 
Date: Mon, 1 Oct 2018 17:07:44 -0400
Subject: [PATCH 1/2] ffplay: options to specify window position

---
doc/ffplay.texi  | 4 
fftools/ffplay.c | 6 +-
2 files changed, 9 insertions(+), 1 deletion(-)


Thanks, applied.

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


[FFmpeg-devel] [PATCH 3/5] libavfilter/ebur128: add gaugetype option

2018-10-07 Thread Daniel Molkentin
Allow to show short term instead of momentary. Useful for monitoring
whilst live mixing.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi|  9 -
 libavfilter/f_ebur128.c | 21 +++--
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index bd5154f9be..0363daffbb 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19279,7 +19279,8 @@ time graph to observe the loudness evolution. The 
graphic contains the logged
 message mentioned above, so it is not printed anymore when this option is set,
 unless the verbose logging is set. The main graphing area contains the
 short-term loudness (3 seconds of analysis), and the gauge on the right is for
-the momentary loudness (400 milliseconds).
+the momentary loudness (400 milliseconds), but can optionally be configured
+to instead display short-term loundness (see @var{gaugetype}).
 
 More information about the Loudness Recommendation EBU R128 on
 @url{http://tech.ebu.ch/loudness}.
@@ -19362,6 +19363,12 @@ Set a specific target level (in LUFS) used as relative 
zero in the visualization
 This parameter is optional and has a default value of -23LUFS as specified
 by EBU R128. However, material published online may prefer a level of -16LUFS
 (e.g. for use with podcasts or video platforms).
+
+@item gaugetype
+Set the value displayed by the gauge. Valid values are @code{momentary} and s
+@code{short-term}. By default the momentary value will be used, but in certain
+scenarios it may be more useful to observe the short term value instead (e.g.
+live mixing).
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 89bfcb0b3e..9fd4bcef0a 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -143,6 +143,7 @@ typedef struct EBUR128Context {
 int dual_mono;  ///< whether or not to treat single 
channel input files as dual-mono
 double pan_law; ///< pan law value used to calculate 
dual-mono measurements
 int target; ///< target level in LUFS used to set 
relative zero LU in visualization
+char *gauge_type;   ///< whether gauge shows momentary or short
 } EBUR128Context;
 
 enum {
@@ -151,6 +152,12 @@ enum {
 PEAK_MODE_TRUE_PEAKS= 1<<2,
 };
 
+enum {
+GAUGE_TYPE_MOMENTARY = 0,
+GAUGE_TYPE_SHORTTERM = 1,
+};
+
+
 #define OFFSET(x) offsetof(EBUR128Context, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM
 #define V AV_OPT_FLAG_VIDEO_PARAM
@@ -170,6 +177,9 @@ static const AVOption ebur128_options[] = {
 { "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F },
 { "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), 
AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F },
 { "target", "set a specific target level in LUFS (-23 to 0)", 
OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
+{ "gaugetype", "set gauge display type", OFFSET(gauge_type), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|F, "type" },
+{ "momentary",   "display momentary value",   0, AV_OPT_TYPE_CONST, 
{.i64 = GAUGE_TYPE_MOMENTARY}, INT_MIN, INT_MAX, V|F, "type" },
+{ "shortterm",   "display short-term value",  0, AV_OPT_TYPE_CONST, 
{.i64 = GAUGE_TYPE_SHORTTERM}, INT_MIN, INT_MAX, V|F, "type" },
 { NULL },
 };
 
@@ -741,9 +751,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 if (ebur128->do_video) {
 int x, y, ret;
 uint8_t *p;
+double gauge_value;
+
+if (ebur128->gauge_type == GAUGE_TYPE_MOMENTARY) {
+gauge_value = loudness_400 - ebur128->target;
+} else {
+gauge_value = loudness_3000 - ebur128->target;
+}
 
 const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 
- ebur128->target);
-const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400  
- ebur128->target);
+const int y_loudness_lu_gauge = lu_to_y(ebur128, gauge_value);
 
 /* draw the graph using the short-term loudness */
 p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + 
ebur128->graph.x*3;
@@ -755,7 +772,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 p += pic->linesize[0];
 }
 
-/* draw the gauge using the momentary loudness */
+/* draw the gauge using either momentary or short-term 
loudness */
 p = pic->data[0] + ebur128->gauge.y*pic->linesize[0] + 
ebur128->gauge.x*3;
 for (y = 0; y < ebur128->gauge.h; y++) {
 const uint8_t *c = get_graph_color(ebur128, 
y_loudness_lu_gauge, y);
-- 
2.17.1

___
ffmpe

Re: [FFmpeg-devel] [PATCH 3/5] libavfilter/ebur128: add gaugetype option

2018-10-07 Thread Paul B Mahol
On 10/7/18, Daniel Molkentin  wrote:
> Allow to show short term instead of momentary. Useful for monitoring
> whilst live mixing.
>
> Signed-off-by: Daniel Molkentin 
> Signed-off-by: Conrad Zelck 
> ---
>  doc/filters.texi|  9 -
>  libavfilter/f_ebur128.c | 21 +++--
>  2 files changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index bd5154f9be..0363daffbb 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -19279,7 +19279,8 @@ time graph to observe the loudness evolution. The
> graphic contains the logged
>  message mentioned above, so it is not printed anymore when this option is
> set,
>  unless the verbose logging is set. The main graphing area contains the
>  short-term loudness (3 seconds of analysis), and the gauge on the right is
> for
> -the momentary loudness (400 milliseconds).
> +the momentary loudness (400 milliseconds), but can optionally be configured
> +to instead display short-term loundness (see @var{gaugetype}).
>
>  More information about the Loudness Recommendation EBU R128 on
>  @url{http://tech.ebu.ch/loudness}.
> @@ -19362,6 +19363,12 @@ Set a specific target level (in LUFS) used as
> relative zero in the visualization
>  This parameter is optional and has a default value of -23LUFS as specified
>  by EBU R128. However, material published online may prefer a level of
> -16LUFS
>  (e.g. for use with podcasts or video platforms).
> +
> +@item gaugetype
> +Set the value displayed by the gauge. Valid values are @code{momentary} and
> s
> +@code{short-term}. By default the momentary value will be used, but in
> certain
> +scenarios it may be more useful to observe the short term value instead
> (e.g.
> +live mixing).
>  @end table
>
>  @subsection Examples
> diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
> index 89bfcb0b3e..9fd4bcef0a 100644
> --- a/libavfilter/f_ebur128.c
> +++ b/libavfilter/f_ebur128.c
> @@ -143,6 +143,7 @@ typedef struct EBUR128Context {
>  int dual_mono;  ///< whether or not to treat single
> channel input files as dual-mono
>  double pan_law; ///< pan law value used to calculate
> dual-mono measurements
>  int target; ///< target level in LUFS used to set
> relative zero LU in visualization
> +char *gauge_type;   ///< whether gauge shows momentary or

You forgot to change this one to int, but i can fix that when pushing.

> short
>  } EBUR128Context;
>
>  enum {
> @@ -151,6 +152,12 @@ enum {
>  PEAK_MODE_TRUE_PEAKS= 1<<2,
>  };
>
> +enum {
> +GAUGE_TYPE_MOMENTARY = 0,
> +GAUGE_TYPE_SHORTTERM = 1,
> +};
> +
> +
>  #define OFFSET(x) offsetof(EBUR128Context, x)
>  #define A AV_OPT_FLAG_AUDIO_PARAM
>  #define V AV_OPT_FLAG_VIDEO_PARAM
> @@ -170,6 +177,9 @@ static const AVOption ebur128_options[] = {
>  { "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono),
> AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F },
>  { "panlaw", "set a specific pan law for dual-mono files",
> OFFSET(pan_law), AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0,
> A|F },
>  { "target", "set a specific target level in LUFS (-23 to 0)",
> OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
> +{ "gaugetype", "set gauge display type", OFFSET(gauge_type),
> AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|F, "type" },
> +{ "momentary",   "display momentary value",   0, AV_OPT_TYPE_CONST,
> {.i64 = GAUGE_TYPE_MOMENTARY}, INT_MIN, INT_MAX, V|F, "type" },
> +{ "shortterm",   "display short-term value",  0, AV_OPT_TYPE_CONST,
> {.i64 = GAUGE_TYPE_SHORTTERM}, INT_MIN, INT_MAX, V|F, "type" },
>  { NULL },
>  };
>
> @@ -741,9 +751,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *insamples)
>  if (ebur128->do_video) {
>  int x, y, ret;
>  uint8_t *p;
> +double gauge_value;
> +
> +if (ebur128->gauge_type == GAUGE_TYPE_MOMENTARY) {
> +gauge_value = loudness_400 - ebur128->target;
> +} else {
> +gauge_value = loudness_3000 - ebur128->target;
> +}
>
>  const int y_loudness_lu_graph = lu_to_y(ebur128,
> loudness_3000 - ebur128->target);
> -const int y_loudness_lu_gauge = lu_to_y(ebur128,
> loudness_400  - ebur128->target);
> +const int y_loudness_lu_gauge = lu_to_y(ebur128,
> gauge_value);
>
>  /* draw the graph using the short-term loudness */
>  p = pic->data[0] + ebur128->graph.y*pic->linesize[0] +
> ebur128->graph.x*3;
> @@ -755,7 +772,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *insamples)
>  p += pic->linesize[0];
>  }
>
> -/* draw the gauge using the momentary loudness */
> +/* draw the gauge using either momentary or short-term
> 

Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/ebur128: add mabsolute parameter

2018-10-07 Thread Daniel Molkentin

On 07.10.2018 18:02, Daniel Molkentin wrote:
> This allows switching between absolute (LUFS) and relativ (LU) display
> in the status line.
>
> Signed-off-by: Daniel Molkentin 
> Signed-off-by: Conrad Zelck 
> ---
>  doc/filters.texi|  4 
>  libavfilter/f_ebur128.c | 34 +-
>  2 files changed, 29 insertions(+), 9 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 601cbda17c..dc01c805b2 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -19371,6 +19371,10 @@ by EBU R128. However, material published online may 
> prefer a level of -16LUFS
>  Set the value displayed by the gauge. Valid values are m (momentary) and s 
> (short-term).
>  By default the momentary value will be used, but in certain scenarios it may 
> be more useful
>  to observe the short term value instead (e.g. live mixing).
> +
> +@item mabsolute
> +Sets whether to display the loudness in LUFS (1, the default) LU relative to 
> the target (0).
> +This only affects the video output, not the summary or continous log output.
>  @end table
>
On a second thought, should this maybe be measurement=absolute|relative
or measurement=LU|LUFS? Opinions? More descriptive that way...

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


Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/ebur128: add mabsolute parameter

2018-10-07 Thread Paul B Mahol
On 10/7/18, Daniel Molkentin  wrote:
>
> On 07.10.2018 18:02, Daniel Molkentin wrote:
>> This allows switching between absolute (LUFS) and relativ (LU) display
>> in the status line.
>>
>> Signed-off-by: Daniel Molkentin 
>> Signed-off-by: Conrad Zelck 
>> ---
>>  doc/filters.texi|  4 
>>  libavfilter/f_ebur128.c | 34 +-
>>  2 files changed, 29 insertions(+), 9 deletions(-)
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 601cbda17c..dc01c805b2 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -19371,6 +19371,10 @@ by EBU R128. However, material published online
>> may prefer a level of -16LUFS
>>  Set the value displayed by the gauge. Valid values are m (momentary) and
>> s (short-term).
>>  By default the momentary value will be used, but in certain scenarios it
>> may be more useful
>>  to observe the short term value instead (e.g. live mixing).
>> +
>> +@item mabsolute
>> +Sets whether to display the loudness in LUFS (1, the default) LU relative
>> to the target (0).
>> +This only affects the video output, not the summary or continous log
>> output.
>>  @end table
>>
> On a second thought, should this maybe be measurement=absolute|relative
> or measurement=LU|LUFS? Opinions? More descriptive that way...

Yeah, that one is more descriptive, you also can have aliases so can have
both absolute/relative/LU/LUFS
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/5] avcodec/cuviddec: Add support for decoding HEVC 4:4:4 content

2018-10-07 Thread Philip Langdale
On Sun,  7 Oct 2018 10:50:56 -0700
Philip Langdale  wrote:

> This is the equivalent change for cuviddec after the previous change
> for nvdec. I made similar changes to the copying routines to handle
> pixel formats in a more generic way.
> 
> Note that unlike with nvdec, there is no confusion about the ability
> of a codec to output 444 formats. This is because the cuvid parser is
> used, meaning that 444 JPEG content is still indicated as using a 420
> output format.
> 
> Signed-off-by: Philip Langdale 
> ---
>  libavcodec/cuviddec.c | 59
> +-- 1 file changed, 40
> insertions(+), 19 deletions(-)
> 
> diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
> index 4d3caf924e..595249475d 100644
> --- a/libavcodec/cuviddec.c
> +++ b/libavcodec/cuviddec.c
> @@ -35,6 +35,9 @@
>  #include "hwaccel.h"
>  #include "internal.h"
>  
> +#define CUVID_FORMAT_YUV444P 2
> +#define CUVID_FORMAT_YUV444P16 3
> +
>  typedef struct CuvidContext
>  {
>  AVClass *avclass;
> @@ -127,6 +130,7 @@ static int CUDAAPI
> cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
> CUVIDDECODECAPS *caps = NULL; CUVIDDECODECREATEINFO cuinfo;
>  int surface_fmt;
> +int chroma_444;
>  
>  int old_width = avctx->width;
>  int old_height = avctx->height;
> @@ -169,17 +173,19 @@ static int CUDAAPI
> cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
> cuinfo.target_rect.right = cuinfo.ulTargetWidth;
> cuinfo.target_rect.bottom = cuinfo.ulTargetHeight; 
> +chroma_444 = format->chroma_format == cudaVideoChromaFormat_444;
> +
>  switch (format->bit_depth_luma_minus8) {
>  case 0: // 8-bit
> -pix_fmts[1] = AV_PIX_FMT_NV12;
> +pix_fmts[1] = chroma_444 ? AV_PIX_FMT_YUV444P :
> AV_PIX_FMT_NV12; caps = &ctx->caps8;
>  break;
>  case 2: // 10-bit
> -pix_fmts[1] = AV_PIX_FMT_P010;
> +pix_fmts[1] = chroma_444 ? AV_PIX_FMT_YUV444P10_LSB :
> AV_PIX_FMT_P010; caps = &ctx->caps10;
>  break;
>  case 4: // 12-bit
> -pix_fmts[1] = AV_PIX_FMT_P016;
> +pix_fmts[1] = chroma_444 ? AV_PIX_FMT_YUV444P12_LSB :
> AV_PIX_FMT_P016; caps = &ctx->caps12;
>  break;
>  default:
> @@ -282,12 +288,6 @@ static int CUDAAPI
> cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form return
> 0; }
>  
> -if (format->chroma_format != cudaVideoChromaFormat_420) {
> -av_log(avctx, AV_LOG_ERROR, "Chroma formats other than 420
> are not supported\n");
> -ctx->internal_error = AVERROR(EINVAL);
> -return 0;
> -}
> -
>  ctx->chroma_format = format->chroma_format;
>  
>  cuinfo.CodecType = ctx->codec_type = format->codec;
> @@ -301,6 +301,14 @@ static int CUDAAPI
> cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form case
> AV_PIX_FMT_P016: cuinfo.OutputFormat = cudaVideoSurfaceFormat_P016;
>  break;
> +case AV_PIX_FMT_YUV444P:
> +cuinfo.OutputFormat = CUVID_FORMAT_YUV444P;
> +break;
> +case AV_PIX_FMT_YUV444P10_LSB:
> +case AV_PIX_FMT_YUV444P12_LSB:
> +case AV_PIX_FMT_YUV444P16:
> +cuinfo.OutputFormat = CUVID_FORMAT_YUV444P16;
> +break;
>  default:
>  av_log(avctx, AV_LOG_ERROR, "Output formats other than NV12,
> P010 or P016 are not supported\n"); ctx->internal_error =
> AVERROR(EINVAL); @@ -507,6 +515,7 @@ static int
> cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame) return ret;
>  
>  if (av_fifo_size(ctx->frame_queue)) {
> +const AVPixFmtDescriptor *pixdesc;
>  CuvidParsedFrame parsed_frame;
>  CUVIDPROCPARAMS params;
>  unsigned int pitch = 0;
> @@ -537,7 +546,10 @@ static int cuvid_output_frame(AVCodecContext
> *avctx, AVFrame *frame) goto error;
>  }
>  
> -for (i = 0; i < 2; i++) {
> +pixdesc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
> +
> +for (i = 0; i < pixdesc->nb_components; i++) {
> +size_t height = avctx->height >> (i ?
> pixdesc->log2_chroma_h : 0); CUDA_MEMCPY2D cpy = {
>  .srcMemoryType = CU_MEMORYTYPE_DEVICE,
>  .dstMemoryType = CU_MEMORYTYPE_DEVICE,
> @@ -547,22 +559,27 @@ static int cuvid_output_frame(AVCodecContext
> *avctx, AVFrame *frame) .dstPitch  = frame->linesize[i],
>  .srcY  = offset,
>  .WidthInBytes  = FFMIN(pitch,
> frame->linesize[i]),
> -.Height= avctx->height >> (i ? 1 : 0),
> +.Height= height,
>  };
>  
>  ret = CHECK_CU(ctx->cudl->cuMemcpy2DAsync(&cpy,
> device_hwctx->stream)); if (ret < 0)
>  goto error;
>  
> -offset += avctx->height;
> +offset += height;
>  }
>  
>  ret =
> CHECK_CU(ctx->cudl->cuStreamSynchronize(device_hwctx->stream)); if
> (ret < 0) goto error;
> -} else if (avctx->pix_

Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/ebur128: add mabsolute parameter

2018-10-07 Thread Marton Balint



On Sun, 7 Oct 2018, Daniel Molkentin wrote:



On 07.10.2018 18:02, Daniel Molkentin wrote:

This allows switching between absolute (LUFS) and relativ (LU) display
in the status line.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi|  4 
 libavfilter/f_ebur128.c | 34 +-
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 601cbda17c..dc01c805b2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19371,6 +19371,10 @@ by EBU R128. However, material published online may 
prefer a level of -16LUFS
 Set the value displayed by the gauge. Valid values are m (momentary) and s 
(short-term).
 By default the momentary value will be used, but in certain scenarios it may 
be more useful
 to observe the short term value instead (e.g. live mixing).
+
+@item mabsolute
+Sets whether to display the loudness in LUFS (1, the default) LU relative to 
the target (0).
+This only affects the video output, not the summary or continous log output.
 @end table


On a second thought, should this maybe be measurement=absolute|relative
or measurement=LU|LUFS? Opinions? More descriptive that way...


scale=absolute/relative

IMHO that makes it the most descriptive.

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


Re: [FFmpeg-devel] [PATCH 1/5] avutil: Add YUV444P10_LSB and YUV444P12_LSB pixel formats

2018-10-07 Thread Timo Rothenpieler

On 07.10.2018 19:50, Philip Langdale wrote:

Currently, ffmpeg defines a set of YUV444P formats for use where
the bits-per-pixel are between 8 and 16 bits. In these formats,
the bits are packed in the MSBs of the 16 bits of available storage.

On the other hand, all the hardware vendors have defined their
equivalent formats with the bits packed in the LSBs, which has the
virtue of making the memory layouts compatible with being treated
as full 16 bit values (which is also why P010 is defined this way).

So, to be able to use these hardware compatible formats, we need
definitions for them in ffmpeg. Right now, I need this for nvdec,
but Vulkan also uses the same format definitions.


I'm very much in favor of adding those, and potentially similar other 
ones in the future.
The other option is to add a bit depth field to AVFrame, and changes in 
various places to support it, including logic for encoder to signal 
support for pix_fmt/bit_depth support.
The later approach, while it does seem cleaner, also seems very error 
prone and invasive, so I'd prefer adding the few cases we have as pixel 
formats.




smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/ebur128: add mabsolute parameter

2018-10-07 Thread Daniel Molkentin

On 07.10.2018 21:37, Marton Balint wrote:
>
>
> On Sun, 7 Oct 2018, Daniel Molkentin wrote:
>
>>
>> On 07.10.2018 18:02, Daniel Molkentin wrote:
>>> This allows switching between absolute (LUFS) and relativ (LU) display
>>> in the status line.
>>>
>>> Signed-off-by: Daniel Molkentin 
>>> Signed-off-by: Conrad Zelck 
>>> ---
>>>  doc/filters.texi    |  4 
>>>  libavfilter/f_ebur128.c | 34 +-
>>>  2 files changed, 29 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/doc/filters.texi b/doc/filters.texi
>>> index 601cbda17c..dc01c805b2 100644
>>> --- a/doc/filters.texi
>>> +++ b/doc/filters.texi
>>> @@ -19371,6 +19371,10 @@ by EBU R128. However, material published
>>> online may prefer a level of -16LUFS
>>>  Set the value displayed by the gauge. Valid values are m
>>> (momentary) and s (short-term).
>>>  By default the momentary value will be used, but in certain
>>> scenarios it may be more useful
>>>  to observe the short term value instead (e.g. live mixing).
>>> +
>>> +@item mabsolute
>>> +Sets whether to display the loudness in LUFS (1, the default) LU
>>> relative to the target (0).
>>> +This only affects the video output, not the summary or continous
>>> log output.
>>>  @end table
>>>
>> On a second thought, should this maybe be measurement=absolute|relative
>> or measurement=LU|LUFS? Opinions? More descriptive that way...
>
> scale=absolute/relative
>
> IMHO that makes it the most descriptive.
We thought about that, but the first association we thought people might
have when confronted with the word scale are the histogram labels with
the LU values on the right, (which are untouched by this option). I am
fine with either.

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


Re: [FFmpeg-devel] [PATCH 2/2] avfilter/avf_showspectrum: add fps option

2018-10-07 Thread Moritz Barsnick
On Sat, Oct 06, 2018 at 14:30:11 +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/avf_showspectrum.c | 31 +++
>  1 file changed, 23 insertions(+), 8 deletions(-)

doc/filters.texi needs to be adapted as well.

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


Re: [FFmpeg-devel] [PATCH 3/5] libavfilter/ebur128: add gaugetype option

2018-10-07 Thread Moritz Barsnick
On Sun, Oct 07, 2018 at 18:02:27 +0200, Daniel Molkentin wrote:
> +to instead display short-term loundness (see @var{gaugetype}).
 ^ loudness

> +Set the value displayed by the gauge. Valid values are m (momentary) and s 
> (short-term).
  ^ @code{m}, @code{s}

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


[FFmpeg-devel] [PATCH 1/3] avfilter/f_cue: always check the return value of ff_inlink_consume_frame

2018-10-07 Thread Marton Balint
Fixes Coverity CID 1439936.

Signed-off-by: Marton Balint 
---
 libavfilter/f_cue.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavfilter/f_cue.c b/libavfilter/f_cue.c
index 9cf710c6d2..b48dfc9d49 100644
--- a/libavfilter/f_cue.c
+++ b/libavfilter/f_cue.c
@@ -51,7 +51,9 @@ static int activate(AVFilterContext *ctx)
 }
 if (s->status == 1) {
 if (pts - s->first_pts < s->preroll) {
-ff_inlink_consume_frame(inlink, &frame);
+int ret = ff_inlink_consume_frame(inlink, &frame);
+if (ret < 0)
+return ret;
 return ff_filter_frame(outlink, frame);
 }
 s->first_pts = pts;
@@ -70,7 +72,9 @@ static int activate(AVFilterContext *ctx)
 s->status++;
 }
 if (s->status == 4) {
-ff_inlink_consume_frame(inlink, &frame);
+int ret = ff_inlink_consume_frame(inlink, &frame);
+if (ret < 0)
+return ret;
 return ff_filter_frame(outlink, frame);
 }
 }
-- 
2.16.4

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


[FFmpeg-devel] [PATCH 2/3] ffmpeg: check return value of avcodec_parameters_from_context

2018-10-07 Thread Marton Balint
Fixes Coverity CID 1427273.

Signed-off-by: Marton Balint 
---
 fftools/ffmpeg.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 934dc71a74..aa495b5d9e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3072,7 +3072,13 @@ static int init_output_stream_streamcopy(OutputStream 
*ost)
"Error setting up codec context options.\n");
 return ret;
 }
-avcodec_parameters_from_context(par_src, ost->enc_ctx);
+
+ret = avcodec_parameters_from_context(par_src, ost->enc_ctx);
+if (ret < 0) {
+av_log(NULL, AV_LOG_FATAL,
+   "Error getting reference codec parameters.\n");
+return ret;
+}
 
 if (!codec_tag) {
 unsigned int codec_tag_tmp;
-- 
2.16.4

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


[FFmpeg-devel] [PATCH 3/3] avfilter/af_asetnsamples: do not leak frame on ENOMEM

2018-10-07 Thread Marton Balint
Fixes Coverity CID 1416352.

Signed-off-by: Marton Balint 
---
 libavfilter/af_asetnsamples.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_asetnsamples.c b/libavfilter/af_asetnsamples.c
index 30fabede26..e8daec8d8f 100644
--- a/libavfilter/af_asetnsamples.c
+++ b/libavfilter/af_asetnsamples.c
@@ -71,8 +71,10 @@ static int activate(AVFilterContext *ctx)
 return ff_filter_frame(outlink, frame);
 
 pad_frame = ff_get_audio_buffer(outlink, s->nb_out_samples);
-if (!pad_frame)
+if (!pad_frame) {
+av_frame_free(&frame);
 return AVERROR(ENOMEM);
+}
 
 av_samples_copy(pad_frame->extended_data, frame->extended_data,
 0, 0, frame->nb_samples, frame->channels, 
frame->format);
-- 
2.16.4

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


Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/ebur128: add mabsolute parameter

2018-10-07 Thread Marton Balint



On Sun, 7 Oct 2018, Daniel Molkentin wrote:



On 07.10.2018 21:37, Marton Balint wrote:



On Sun, 7 Oct 2018, Daniel Molkentin wrote:



On 07.10.2018 18:02, Daniel Molkentin wrote:

This allows switching between absolute (LUFS) and relativ (LU) display
in the status line.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi    |  4 
 libavfilter/f_ebur128.c | 34 +-
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 601cbda17c..dc01c805b2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19371,6 +19371,10 @@ by EBU R128. However, material published
online may prefer a level of -16LUFS
 Set the value displayed by the gauge. Valid values are m
(momentary) and s (short-term).
 By default the momentary value will be used, but in certain
scenarios it may be more useful
 to observe the short term value instead (e.g. live mixing).
+
+@item mabsolute
+Sets whether to display the loudness in LUFS (1, the default) LU
relative to the target (0).
+This only affects the video output, not the summary or continous
log output.
 @end table


On a second thought, should this maybe be measurement=absolute|relative
or measurement=LU|LUFS? Opinions? More descriptive that way...


scale=absolute/relative

IMHO that makes it the most descriptive.

We thought about that, but the first association we thought people might
have when confronted with the word scale are the histogram labels with
the LU values on the right, (which are untouched by this option). I am
fine with either.


Ah, OK, I kind of missed that it affects the status line. IMHO the status 
line is not very useful because the text is too small for anything 
serious, so I would not put too much effort into customizing it. I have a 
patch somewhere that adds the same metadata to the video which is already added 
to the audio, so one can use the drawtext filter to present customized 
text in as big as the user needs. I can dig it up if you are interested.


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


[FFmpeg-devel] [PATCH 4/5] libavfilter/ebur128: introduce target range

2018-10-07 Thread Daniel Molkentin
This eases meeting the target level during live mixing.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi|  8 
 libavfilter/f_ebur128.c | 33 +++--
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 7f2baed9b5..875b412f41 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19284,6 +19284,9 @@ short-term loudness (3 seconds of analysis), and the 
gauge on the right is for
 the momentary loudness (400 milliseconds), but can optionally be configured
 to instead display short-term loudness (see @var{gauge}).
 
+The green area marks a  +/- 1LU target range around the target loudness
+(-23LUFS by default, unless modified through @var{target}).
+
 More information about the Loudness Recommendation EBU R128 on
 @url{http://tech.ebu.ch/loudness}.
 
@@ -19371,6 +19374,11 @@ Set the value displayed by the gauge. Valid values are 
@code{momentary} and s
 @code{shortterm}. By default the momentary value will be used, but in certain
 scenarios it may be more useful to observe the short term value instead (e.g.
 live mixing).
+
+@item mabsolute
+Sets whether to display the loudness in LUFS (1, the default) LU relative to
+the target (0). This only affects the video output, not the summary or
+continous log output.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 10dc717960..53f21c9d14 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -114,6 +114,8 @@ typedef struct EBUR128Context {
 int meter;  ///< select a EBU mode between +9 and +18
 int scale_range;///< the range of LU values according to 
the meter
 int y_zero_lu;  ///< the y value (pixel position) for 0 LU
+int y_opt_max;  ///< the y value (pixel position) for 1 LU
+int y_opt_min;  ///< the y value (pixel position) for -1 LU
 int *y_line_ref;///< y reference values for drawing the LU 
lines in the graph and the gauge
 
 /* audio */
@@ -186,22 +188,31 @@ static const AVOption ebur128_options[] = {
 AVFILTER_DEFINE_CLASS(ebur128);
 
 static const uint8_t graph_colors[] = {
-0xdd, 0x66, 0x66,   // value above 0LU non reached
-0x66, 0x66, 0xdd,   // value below 0LU non reached
-0x96, 0x33, 0x33,   // value above 0LU reached
-0x33, 0x33, 0x96,   // value below 0LU reached
-0xdd, 0x96, 0x96,   // value above 0LU line non reached
-0x96, 0x96, 0xdd,   // value below 0LU line non reached
-0xdd, 0x33, 0x33,   // value above 0LU line reached
-0x33, 0x33, 0xdd,   // value below 0LU line reached
+0xdd, 0x66, 0x66,   // value above 1LU non reached below -1LU (impossible)
+0x66, 0x66, 0xdd,   // value below 1LU non reached below -1LU
+0x96, 0x33, 0x33,   // value above 1LU reached below -1LU (impossible)
+0x33, 0x33, 0x96,   // value below 1LU reached below -1LU
+0xdd, 0x96, 0x96,   // value above 1LU line non reached below -1LU 
(impossible)
+0x96, 0x96, 0xdd,   // value below 1LU line non reached below -1LU
+0xdd, 0x33, 0x33,   // value above 1LU line reached below -1LU (impossible)
+0x33, 0x33, 0xdd,   // value below 1LU line reached below -1LU
+0xdd, 0x66, 0x66,   // value above 1LU non reached above -1LU
+0x66, 0xdd, 0x66,   // value below 1LU non reached above -1LU
+0x96, 0x33, 0x33,   // value above 1LU reached above -1LU
+0x33, 0x96, 0x33,   // value below 1LU reached above -1LU
+0xdd, 0x96, 0x96,   // value above 1LU line non reached above -1LU
+0x96, 0xdd, 0x96,   // value below 1LU line non reached above -1LU
+0xdd, 0x33, 0x33,   // value above 1LU line reached above -1LU
+0x33, 0xdd, 0x33,   // value below 1LU line reached above -1LU
 };
 
 static const uint8_t *get_graph_color(const EBUR128Context *ebur128, int v, 
int y)
 {
-const int below0  = y > ebur128->y_zero_lu;
+const int above_opt_max = y > ebur128->y_opt_max;
+const int below_opt_min = y < ebur128->y_opt_min;
 const int reached = y >= v;
 const int line= ebur128->y_line_ref[y] || y == ebur128->y_zero_lu;
-const int colorid = 4*line + 2*reached + below0;
+const int colorid = 8*below_opt_min+ 4*line + 2*reached + above_opt_max;
 return graph_colors + 3*colorid;
 }
 
@@ -335,6 +346,8 @@ static int config_video_output(AVFilterLink *outlink)
 
 /* draw graph */
 ebur128->y_zero_lu = lu_to_y(ebur128, 0);
+ebur128->y_opt_max = lu_to_y(ebur128, 1);
+ebur128->y_opt_min = lu_to_y(ebur128, -1);
 p = outpicref->data[0] + ebur128->graph.y * outpicref->linesize[0]
+ ebur128->graph.x * 3;
 for (y = 0; y < ebur128->graph.h; y++) {
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 3/5] libavfilter/ebur128: add gauge option

2018-10-07 Thread Daniel Molkentin
Allow to show short-term instead of momentary in gauge. Useful for monitoring
whilst live mixing.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi|  9 -
 libavfilter/f_ebur128.c | 21 +++--
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 86ea25bda8..7f2baed9b5 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19281,7 +19281,8 @@ time graph to observe the loudness evolution. The 
graphic contains the logged
 message mentioned above, so it is not printed anymore when this option is set,
 unless the verbose logging is set. The main graphing area contains the
 short-term loudness (3 seconds of analysis), and the gauge on the right is for
-the momentary loudness (400 milliseconds).
+the momentary loudness (400 milliseconds), but can optionally be configured
+to instead display short-term loudness (see @var{gauge}).
 
 More information about the Loudness Recommendation EBU R128 on
 @url{http://tech.ebu.ch/loudness}.
@@ -19364,6 +19365,12 @@ Set a specific target level (in LUFS) used as relative 
zero in the visualization
 This parameter is optional and has a default value of -23LUFS as specified
 by EBU R128. However, material published online may prefer a level of -16LUFS
 (e.g. for use with podcasts or video platforms).
+
+@item gauge
+Set the value displayed by the gauge. Valid values are @code{momentary} and s
+@code{shortterm}. By default the momentary value will be used, but in certain
+scenarios it may be more useful to observe the short term value instead (e.g.
+live mixing).
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 89bfcb0b3e..10dc717960 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -143,6 +143,7 @@ typedef struct EBUR128Context {
 int dual_mono;  ///< whether or not to treat single 
channel input files as dual-mono
 double pan_law; ///< pan law value used to calculate 
dual-mono measurements
 int target; ///< target level in LUFS used to set 
relative zero LU in visualization
+int gauge_type; ///< whether gauge shows momentary or short
 } EBUR128Context;
 
 enum {
@@ -151,6 +152,12 @@ enum {
 PEAK_MODE_TRUE_PEAKS= 1<<2,
 };
 
+enum {
+GAUGE_TYPE_MOMENTARY = 0,
+GAUGE_TYPE_SHORTTERM = 1,
+};
+
+
 #define OFFSET(x) offsetof(EBUR128Context, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM
 #define V AV_OPT_FLAG_VIDEO_PARAM
@@ -170,6 +177,9 @@ static const AVOption ebur128_options[] = {
 { "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F },
 { "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), 
AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F },
 { "target", "set a specific target level in LUFS (-23 to 0)", 
OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
+{ "gauge", "set gauge display type", OFFSET(gauge_type), AV_OPT_TYPE_INT, 
{.i64 = 0 }, 0, INT_MAX, V|F, "gaugetype" },
+{ "momentary",   "display momentary value",   0, AV_OPT_TYPE_CONST, 
{.i64 = GAUGE_TYPE_MOMENTARY}, INT_MIN, INT_MAX, V|F, "gaugetype" },
+{ "shortterm",   "display short-term value",  0, AV_OPT_TYPE_CONST, 
{.i64 = GAUGE_TYPE_SHORTTERM}, INT_MIN, INT_MAX, V|F, "gaugetype" },
 { NULL },
 };
 
@@ -741,9 +751,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 if (ebur128->do_video) {
 int x, y, ret;
 uint8_t *p;
+double gauge_value;
+
+if (ebur128->gauge_type == GAUGE_TYPE_MOMENTARY) {
+gauge_value = loudness_400 - ebur128->target;
+} else {
+gauge_value = loudness_3000 - ebur128->target;
+}
 
 const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 
- ebur128->target);
-const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400  
- ebur128->target);
+const int y_loudness_lu_gauge = lu_to_y(ebur128, gauge_value);
 
 /* draw the graph using the short-term loudness */
 p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + 
ebur128->graph.x*3;
@@ -755,7 +772,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 p += pic->linesize[0];
 }
 
-/* draw the gauge using the momentary loudness */
+/* draw the gauge using either momentary or short-term 
loudness */
 p = pic->data[0] + ebur128->gauge.y*pic->linesize[0] + 
ebur128->gauge.x*3;
 for (y = 0; y < ebur128->gauge.h; y++) {
 const uint8_t *c = get_graph_color(ebur128, 
y_loudness_lu_gauge, y);
-- 
2.17.1

___

[FFmpeg-devel] [PATCH 0/5] Improvements for EBU R128 plugin (second round)

2018-10-07 Thread Daniel Molkentin
Changes over first patchset:

Mainly wording. Use full words as a parameter values. Switch to constants
instead of strings for parameters. Also:

- "mabsolute" bool parameter renamed "scale" as per reviewer suggestion
- "gaugetype" parameter renamed to "gauge" for consistency with scale
- typo fixes in documentation

Cheers,
  Daniel

Daniel Molkentin (5):
  libavfilter/ebur128: add target level option for EBUR128 visualization
filter
  libavfilter/ebur128: add target value to statistics line
  libavfilter/ebur128: add gauge option
  libavfilter/ebur128: introduce target range
  libavfilter/ebur128: add scale parameter

 doc/filters.texi|  23 -
 libavfilter/f_ebur128.c | 100 +++-
 2 files changed, 100 insertions(+), 23 deletions(-)

-- 
2.17.1

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


[FFmpeg-devel] [PATCH 1/5] libavfilter/ebur128: add target level option for EBUR128 visualization filter

2018-10-07 Thread Daniel Molkentin
Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi| 6 ++
 libavfilter/f_ebur128.c | 6 --
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index b523877cf3..86ea25bda8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19358,6 +19358,12 @@ Multi-channel input files are not affected by this 
option.
 @item panlaw
 Set a specific pan law to be used for the measurement of dual mono files.
 This parameter is optional, and has a default value of -3.01dB.
+
+@item target
+Set a specific target level (in LUFS) used as relative zero in the 
visualization.
+This parameter is optional and has a default value of -23LUFS as specified
+by EBU R128. However, material published online may prefer a level of -16LUFS
+(e.g. for use with podcasts or video platforms).
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index a48d3629ce..dfccbff5ec 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -142,6 +142,7 @@ typedef struct EBUR128Context {
 int metadata;   ///< whether or not to inject loudness 
results in frames
 int dual_mono;  ///< whether or not to treat single 
channel input files as dual-mono
 double pan_law; ///< pan law value used to calculate 
dual-mono measurements
+int target; ///< target level in LUFS used to set 
relative zero LU in visualization
 } EBUR128Context;
 
 enum {
@@ -168,6 +169,7 @@ static const AVOption ebur128_options[] = {
 { "true",   "enable true-peak mode",   0, AV_OPT_TYPE_CONST, {.i64 = 
PEAK_MODE_TRUE_PEAKS},INT_MIN, INT_MAX, A|F, "mode" },
 { "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F },
 { "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), 
AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F },
+{ "target", "set a specific target level in LUFS (-23 to 0)", 
OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
 { NULL },
 };
 
@@ -740,8 +742,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 int x, y, ret;
 uint8_t *p;
 
-const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 
+ 23);
-const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400  
+ 23);
+const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 
- ebur128->target);
+const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400  
- ebur128->target);
 
 /* draw the graph using the short-term loudness */
 p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + 
ebur128->graph.x*3;
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 2/5] libavfilter/ebur128: add target value to statistics line

2018-10-07 Thread Daniel Molkentin
Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 libavfilter/f_ebur128.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index dfccbff5ec..89bfcb0b3e 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -735,7 +735,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 loudness_3000 -= ebur128->pan_law;
 }
 
-#define LOG_FMT "M:%6.1f S:%6.1f I:%6.1f LUFS LRA:%6.1f LU"
+#define LOG_FMT "TARGET:%d M:%6.1f S:%6.1f I:%6.1f LUFS LRA:%6.1f 
LU"
 
 /* push one video frame */
 if (ebur128->do_video) {
@@ -768,7 +768,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 /* draw textual info */
 drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
  LOG_FMT " ", // padding to erase trailing 
characters
- loudness_400, loudness_3000,
+ ebur128->target, loudness_400, loudness_3000,
  ebur128->integrated_loudness, 
ebur128->loudness_range);
 
 /* set pts and push frame */
@@ -811,7 +811,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 
 av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
av_ts2timestr(pts, &outlink->time_base),
-   loudness_400, loudness_3000,
+   ebur128->target, loudness_400, loudness_3000,
ebur128->integrated_loudness, ebur128->loudness_range);
 
 #define PRINT_PEAKS(str, sp, ptype) do {\
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 5/5] libavfilter/ebur128: add scale parameter

2018-10-07 Thread Daniel Molkentin
This allows switching between absolute (LUFS) and relativ (LU) display
in the status line.

Signed-off-by: Daniel Molkentin 
Signed-off-by: Conrad Zelck 
---
 doc/filters.texi|  8 
 libavfilter/f_ebur128.c | 42 -
 2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 875b412f41..df957fda0f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19375,10 +19375,10 @@ Set the value displayed by the gauge. Valid values 
are @code{momentary} and s
 scenarios it may be more useful to observe the short term value instead (e.g.
 live mixing).
 
-@item mabsolute
-Sets whether to display the loudness in LUFS (1, the default) LU relative to
-the target (0). This only affects the video output, not the summary or
-continous log output.
+@item scale
+Sets the display scale for the loudness. Valid parameters are @code{absolute}
+(in LUFS) or @code{relative} (LU) relative to the target. This only affects the
+video output, not the summary or continous log output.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 53f21c9d14..259d2036fc 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -146,6 +146,7 @@ typedef struct EBUR128Context {
 double pan_law; ///< pan law value used to calculate 
dual-mono measurements
 int target; ///< target level in LUFS used to set 
relative zero LU in visualization
 int gauge_type; ///< whether gauge shows momentary or short
+int scale;  ///< display scale type of statistics
 } EBUR128Context;
 
 enum {
@@ -159,6 +160,10 @@ enum {
 GAUGE_TYPE_SHORTTERM = 1,
 };
 
+enum {
+SCALE_TYPE_ABSOLUTE = 0,
+SCALE_TYPE_RELATIVE = 1,
+};
 
 #define OFFSET(x) offsetof(EBUR128Context, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM
@@ -182,6 +187,11 @@ static const AVOption ebur128_options[] = {
 { "gauge", "set gauge display type", OFFSET(gauge_type), AV_OPT_TYPE_INT, 
{.i64 = 0 }, 0, INT_MAX, V|F, "gaugetype" },
 { "momentary",   "display momentary value",   0, AV_OPT_TYPE_CONST, 
{.i64 = GAUGE_TYPE_MOMENTARY}, INT_MIN, INT_MAX, V|F, "gaugetype" },
 { "shortterm",   "display short-term value",  0, AV_OPT_TYPE_CONST, 
{.i64 = GAUGE_TYPE_SHORTTERM}, INT_MIN, INT_MAX, V|F, "gaugetype" },
+{ "scale", "sets display method for the stats", OFFSET(scale), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, V|F, "scaletype" },
+{ "absolute",   "display absolute values (LUFS)",  0, 
AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_ABSOLUTE}, INT_MIN, INT_MAX, V|F, 
"scaletype" },
+{ "LUFS",   "display absolute values (LUFS)",  0, 
AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_ABSOLUTE}, INT_MIN, INT_MAX, V|F, 
"scaletype" },
+{ "relative",   "display values relative to target (LU)",  0, 
AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_RELATIVE}, INT_MIN, INT_MAX, V|F, 
"scaletype" },
+{ "LU", "display values relative to target (LU)",  0, 
AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_RELATIVE}, INT_MIN, INT_MAX, V|F, 
"scaletype" },
 { NULL },
 };
 
@@ -758,7 +768,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 loudness_3000 -= ebur128->pan_law;
 }
 
-#define LOG_FMT "TARGET:%d M:%6.1f S:%6.1f I:%6.1f LUFS LRA:%6.1f 
LU"
+#define LOG_FMT "TARGET:%d LUFSM:%6.1f S:%6.1f I:%6.1f %s   
LRA:%6.1f LU"
 
 /* push one video frame */
 if (ebur128->do_video) {
@@ -796,10 +806,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 }
 
 /* draw textual info */
-drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
- LOG_FMT " ", // padding to erase trailing 
characters
- ebur128->target, loudness_400, loudness_3000,
- ebur128->integrated_loudness, 
ebur128->loudness_range);
+if (ebur128->scale == SCALE_TYPE_ABSOLUTE) {
+drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
+ LOG_FMT " ", // padding to erase trailing 
characters
+ ebur128->target, loudness_400, loudness_3000,
+ ebur128->integrated_loudness, "LUFS", 
ebur128->loudness_range);
+} else {
+drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors,
+ LOG_FMT " ", // padding to erase trailing 
characters
+ ebur128->target, loudness_400-ebur128->target, 
loudness_3000-ebur128->target,
+ ebur128->integrated_loudness-ebur128->target, 
"LU", ebur128->loudness_range);
+}
 
 /* set pts and push frame */
 pic->pts = pts;
@@ -839,10 +856,17 @@

Re: [FFmpeg-devel] [PATCH 1/3] avfilter/f_cue: always check the return value of ff_inlink_consume_frame

2018-10-07 Thread Nicolas George
Marton Balint (2018-10-07):
> Fixes Coverity CID 1439936.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavfilter/f_cue.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

LGTM, sorry for having missed it.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] Mentoring project: music test source

2018-10-07 Thread Mina



On 10/04/2018 11:40 AM, Nicolas George wrote:

Hi.

No need to Cc people who are on the list.


Actually replied only to you initially, sorry about that.



Mina (2018-09-30):

Do you mean by "look like music" to just follow music theory rules or
actually sound like real music.
Just curious.

In my mind, the purpose is to have a signal that can exercise filters
and codecs, trigger as many code paths as possible, without requiring an
external sample.

Therefore, it must "look like music" from the point of view of analysis
done by filters and codecs. And since some of the have quite subtle
psychoacoustic models tweaked for music, following music theory rules is
probably a requirement.

Sounding like real music seems much more difficult, and possibly not
that useful. But I think that if the code is clean, if somebody comes up
with a better algorithm to sound more catchy, it can be added in the
same filter as an option.

And, to answer Carl Eugen's question: No, I do not have a student lined
for this project.

Regards,



I think I can start on that, I was already searching for my next 
contribution. Pedro's reply seems pretty useful.

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


Re: [FFmpeg-devel] [PATCH 2/2] avdevice/sdl2 : add option to set window position

2018-10-07 Thread Gyan
On Thu, Oct 4, 2018 at 2:33 AM Dave Rice  wrote:

>
>
> I attempted to add an error message but am uncertain how to access the
> width and height of the canvas used. Any advice?
>

I believe you need to call SDL_GetCurrentDisplayMode.

See https://wiki.libsdl.org/SDL_GetCurrentDisplayMode

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


Re: [FFmpeg-devel] H.264 SEI Display Orientation Message support in ffplay

2018-10-07 Thread Kirill Gavrilov
Omer Iqbal  wrote:

> I'm curious, does anyone know why this is not implemented in video players?
> Considering it is part of the H.264 specification, and ffmpeg supports
> decoding it?
>

I believe that changing frame orientation within a stream is very awkward
and rare situation, which should be avoided.
So that there is almost nobody interested in handling use case which never
actually happen.

sView video player actually handles AV_FRAME_DATA_DISPLAYMATRIX in source
code, but I never had any video sample to test.
https://github.com/gkv311/sview/blob/master/StMoviePlayer/StVideo/StVideoQueue.cpp#L939
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/5] avutil: Add YUV444P10_LSB and YUV444P12_LSB pixel formats

2018-10-07 Thread Hendrik Leppkes
On Sun, Oct 7, 2018 at 7:51 PM Philip Langdale  wrote:
>
> Currently, ffmpeg defines a set of YUV444P formats for use where
> the bits-per-pixel are between 8 and 16 bits. In these formats,
> the bits are packed in the MSBs of the 16 bits of available storage.
>
> On the other hand, all the hardware vendors have defined their
> equivalent formats with the bits packed in the LSBs, which has the
> virtue of making the memory layouts compatible with being treated
> as full 16 bit values (which is also why P010 is defined this way).
>

Don't you have that flipped around?
In our default formats, the data is in LSB, padding in MSB. In these
hardware formats, data is in MSB, padding in LSB.

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