[FFmpeg-devel] [PATCH] Fix bad ID3v2 tag length

2020-01-08 Thread misc
(this time with the attached git-format patch !)

The Id3v2 tag is set to a wrong size (14 bytes too large), when a CTOC
frame is included. It makes decoders believe the first MP3 frame is inside
the ID3v2 tag, and hence mungle the first mp3 frame.
The code source uses a hardcoded "16" magic value that is incorrect. (it
should be "2")

This patch fixes this bug *without* using magic values.

See:
https://github.com/gbouthenot/mp3splitter-js/issues/2
https://github.com/openaudible/openaudible/issues/258

Thank you !


0001-Fix-bad-ID3v2-tag-length.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] Fix bad ID3v2 tag length

2020-01-08 Thread Gyan



On 09-01-2020 12:09 pm, m...@atomas.com wrote:

  The Id3v2 tag is set to a wrong size, when a CTOC frame is written.
The code source uses a hardcoded "16" magic value that is incorrect. (it
should be "2")

This patch fixes this bug *without* using magic values.

See:
https://github.com/gbouthenot/mp3splitter-js/issues/2
https://github.com/openaudible/openaudible/issues/258


For review, patches should be formatted with git format-patch and sent 
inline or attached to the mail.


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

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

[FFmpeg-devel] [PATCH] Fix bad ID3v2 tag length

2020-01-08 Thread misc
 The Id3v2 tag is set to a wrong size, when a CTOC frame is written.
The code source uses a hardcoded "16" magic value that is incorrect. (it
should be "2")

This patch fixes this bug *without* using magic values.

See:
https://github.com/gbouthenot/mp3splitter-js/issues/2
https://github.com/openaudible/openaudible/issues/258

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

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

Re: [FFmpeg-devel] [PATCH v2 3/5] avfilter/scale: separate exprs parse and eval

2020-01-08 Thread Gyan

Barring further reviews, I'll retest and push the patchset on Monday.

On 06-01-2020 11:44 am, Gyan wrote:
Ping for the remainder of patchset.  Expression parsing and backup has 
been factorized so code duplication is minimized.


On 01-01-2020 01:12 am, Gyan Doshi wrote:

Retains parsed expressions which allows for better
error-checking and adding animation support.
---

First version was rebased incorrectly in scale_eval_dimensions

  libavfilter/scale_eval.c |  69 +-
  libavfilter/vf_scale.c   | 264 +++
  2 files changed, 246 insertions(+), 87 deletions(-)

diff --git a/libavfilter/scale_eval.c b/libavfilter/scale_eval.c
index 6c526a97af..dfec081e15 100644
--- a/libavfilter/scale_eval.c
+++ b/libavfilter/scale_eval.c
@@ -54,46 +54,6 @@ enum var_name {
  VARS_NB
  };
  -/**
- * This must be kept in sync with var_names so that it is always a
- * complete list of var_names with the scale2ref specific names
- * appended. scale2ref values must appear in the order they appear
- * in the var_name_scale2ref enum but also be below all of the
- * non-scale2ref specific values.
- */
-static const char *const var_names_scale2ref[] = {
-    "in_w",   "iw",
-    "in_h",   "ih",
-    "out_w",  "ow",
-    "out_h",  "oh",
-    "a",
-    "sar",
-    "dar",
-    "hsub",
-    "vsub",
-    "ohsub",
-    "ovsub",
-    "main_w",
-    "main_h",
-    "main_a",
-    "main_sar",
-    "main_dar", "mdar",
-    "main_hsub",
-    "main_vsub",
-    NULL
-};
-
-enum var_name_scale2ref {
-    VAR_S2R_MAIN_W,
-    VAR_S2R_MAIN_H,
-    VAR_S2R_MAIN_A,
-    VAR_S2R_MAIN_SAR,
-    VAR_S2R_MAIN_DAR, VAR_S2R_MDAR,
-    VAR_S2R_MAIN_HSUB,
-    VAR_S2R_MAIN_VSUB,
-    VARS_S2R_NB
-};
-
  int ff_scale_eval_dimensions(void *log_ctx,
  const char *w_expr, const char *h_expr,
  AVFilterLink *inlink, AVFilterLink *outlink,
@@ -104,16 +64,7 @@ int ff_scale_eval_dimensions(void *log_ctx,
  const char *expr;
  int eval_w, eval_h;
  int ret;
-    const char scale2ref = outlink->src->nb_inputs == 2 && 
outlink->src->inputs[1] == inlink;

-    double var_values[VARS_NB + VARS_S2R_NB], res;
-    const AVPixFmtDescriptor *main_desc;
-    const AVFilterLink *main_link;
-    const char *const *names = scale2ref ? var_names_scale2ref : 
var_names;

-
-    if (scale2ref) {
-    main_link = outlink->src->inputs[0];
-    main_desc = av_pix_fmt_desc_get(main_link->format);
-    }
+    double var_values[VARS_NB], res;
    var_values[VAR_IN_W]  = var_values[VAR_IW] = inlink->w;
  var_values[VAR_IN_H]  = var_values[VAR_IH] = inlink->h;
@@ -128,32 +79,20 @@ int ff_scale_eval_dimensions(void *log_ctx,
  var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w;
  var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h;
  -    if (scale2ref) {
-    var_values[VARS_NB + VAR_S2R_MAIN_W] = main_link->w;
-    var_values[VARS_NB + VAR_S2R_MAIN_H] = main_link->h;
-    var_values[VARS_NB + VAR_S2R_MAIN_A] = (double) main_link->w 
/ main_link->h;
-    var_values[VARS_NB + VAR_S2R_MAIN_SAR] = 
main_link->sample_aspect_ratio.num ?
-    (double) main_link->sample_aspect_ratio.num / 
main_link->sample_aspect_ratio.den : 1;
-    var_values[VARS_NB + VAR_S2R_MAIN_DAR] = var_values[VARS_NB 
+ VAR_S2R_MDAR] =
-    var_values[VARS_NB + VAR_S2R_MAIN_A] * 
var_values[VARS_NB + VAR_S2R_MAIN_SAR];
-    var_values[VARS_NB + VAR_S2R_MAIN_HSUB] = 1 << 
main_desc->log2_chroma_w;
-    var_values[VARS_NB + VAR_S2R_MAIN_VSUB] = 1 << 
main_desc->log2_chroma_h;

-    }
-
  /* evaluate width and height */
  av_expr_parse_and_eval(, (expr = w_expr),
-   names, var_values,
+   var_names, var_values,
 NULL, NULL, NULL, NULL, NULL, 0, log_ctx);
  eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = (int) res 
== 0 ? inlink->w : (int) res;

    if ((ret = av_expr_parse_and_eval(, (expr = h_expr),
-  names, var_values,
+  var_names, var_values,
    NULL, NULL, NULL, NULL, NULL, 
0, log_ctx)) < 0)

  goto fail;
  eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = (int) res 
== 0 ? inlink->h : (int) res;
  /* evaluate again the width, as it may depend on the output 
height */

  if ((ret = av_expr_parse_and_eval(, (expr = w_expr),
-  names, var_values,
+  var_names, var_values,
    NULL, NULL, NULL, NULL, NULL, 
0, log_ctx)) < 0)

  goto fail;
  eval_w = (int) res == 0 ? inlink->w : (int) res;
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 5a375fac5d..582b34ce09 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -32,6 +32,7 @@
  #include "scale_eval.h"
  #include "video.h"
  #include "libavutil/avstring.h"

Re: [FFmpeg-devel] [PATCH 2/2] avformat/dashenc: use ff_rename instead of avpriv_io_move

2020-01-08 Thread Jeyapal, Karthick

On 1/8/20 5:53 AM, Marton Balint wrote:
> ff_rename always logs the error message.
>
> Signed-off-by: Marton Balint 
> ---
>  libavformat/dashenc.c | 10 --
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index b84736881f..6b82ca9450 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -540,9 +540,7 @@ static void write_hls_media_playlist(OutputStream *os, 
> AVFormatContext *s,
>  dashenc_io_close(s, >m3u8_out, temp_filename_hls);
>  
>  if (use_rename)
> -if (avpriv_io_move(temp_filename_hls, filename_hls) < 0) {
> -av_log(os->ctx, AV_LOG_WARNING, "renaming file %s to %s 
> failed\n\n", temp_filename_hls, filename_hls);
> -}
> +ff_rename(temp_filename_hls, filename_hls, os->ctx);
>  }
>  
>  static int flush_init_segment(AVFormatContext *s, OutputStream *os)
> @@ -1037,7 +1035,7 @@ static int write_manifest(AVFormatContext *s, int final)
>  dashenc_io_close(s, >mpd_out, temp_filename);
>  
>  if (use_rename) {
> -if ((ret = avpriv_io_move(temp_filename, s->url)) < 0)
> +if ((ret = ff_rename(temp_filename, s->url, s)) < 0)
>  return ret;
>  }
>  
> @@ -1119,7 +1117,7 @@ static int write_manifest(AVFormatContext *s, int final)
>  }
>  dashenc_io_close(s, >m3u8_out, temp_filename);
>  if (use_rename)
> -if ((ret = avpriv_io_move(temp_filename, filename_hls)) < 0)
> +if ((ret = ff_rename(temp_filename, filename_hls, s)) < 0)
>  return ret;
>  c->master_playlist_created = 1;
>  }
> @@ -1619,7 +1617,7 @@ static int dash_flush(AVFormatContext *s, int final, 
> int stream)
>  dashenc_io_close(s, >out, os->temp_path);
>  
>  if (use_rename) {
> -ret = avpriv_io_move(os->temp_path, os->full_path);
> +ret = ff_rename(os->temp_path, os->full_path, os->ctx);
>  if (ret < 0)
>  break;
>  }
LGTM

Regards,
Karthick

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

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

[FFmpeg-devel] [PATCH] avcodec/mlpdec: filter invalid block size

2020-01-08 Thread Xingwen.Fang
From: Xingwen Fang 

When the block size is illegal, we don't need to read the
block data. Otherwise, there will be abnormal memory access
in dsp.mlp_filter_channel.

Signed-off-by: Xingwen Fang 
---
 libavcodec/mlpdec.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 39c4091..198d3c0 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -1263,6 +1263,11 @@ static int read_access_unit(AVCodecContext *avctx, void* 
data,
 if (!s->restart_seen)
 goto next_substr;
 
+if (s->blocksize < 8) {
+av_log(m->avctx, AV_LOG_ERROR, "Block size is too small.\n");
+goto next_substr;
+}
+
 if ((ret = read_block_data(m, , substr)) < 0)
 return ret;
 
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH v1] avfilter/vf_showinfo: fix the integer handling issues

2020-01-08 Thread lance . lmwang
From: Limin Wang 

Fixes CID 1457606 and 1457607
Signed-off-by: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_showinfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 5fff123..79b79db 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -221,10 +221,10 @@ static void update_sample_stats_16(int be, const uint8_t 
*src, int len, int64_t
 for (i = 0; i < len / 2; i++) {
 if ((HAVE_BIGENDIAN && !be) || (!HAVE_BIGENDIAN && be)) {
 *sum += av_bswap16(src1[i]);
-*sum2 += av_bswap16(src1[i]) * av_bswap16(src1[i]);
+*sum2 += (uint32_t)av_bswap16(src1[i]) * 
(uint32_t)av_bswap16(src1[i]);
 } else {
 *sum += src1[i];
-*sum2 += src1[i] * src1[i];
+*sum2 += (uint32_t)src1[i] * (uint32_t)src1[i];
 }
 }
 }
-- 
2.9.5

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

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

[FFmpeg-devel] [PATCH v1] avcodec/utils: replace avctx->internal with avci for better readability

2020-01-08 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/utils.c | 63 --
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index fd5565a..ab48754 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -551,6 +551,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 int codec_init_ok = 0;
 AVDictionary *tmp = NULL;
 const AVPixFmtDescriptor *pixdesc;
+AVCodecInternal *avci;
 
 if (avcodec_is_open(avctx))
 return 0;
@@ -575,55 +576,56 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 
 ff_lock_avcodec(avctx, codec);
 
-avctx->internal = av_mallocz(sizeof(*avctx->internal));
-if (!avctx->internal) {
+avci = av_mallocz(sizeof(*avci));
+if (!avci) {
 ret = AVERROR(ENOMEM);
 goto end;
 }
+avctx->internal = avci;
 
-avctx->internal->pool = av_mallocz(sizeof(*avctx->internal->pool));
-if (!avctx->internal->pool) {
+avci->pool = av_mallocz(sizeof(*avci->pool));
+if (!avci->pool) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
 
-avctx->internal->to_free = av_frame_alloc();
-if (!avctx->internal->to_free) {
+avci->to_free = av_frame_alloc();
+if (!avci->to_free) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
 
-avctx->internal->compat_decode_frame = av_frame_alloc();
-if (!avctx->internal->compat_decode_frame) {
+avci->compat_decode_frame = av_frame_alloc();
+if (!avci->compat_decode_frame) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
 
-avctx->internal->buffer_frame = av_frame_alloc();
-if (!avctx->internal->buffer_frame) {
+avci->buffer_frame = av_frame_alloc();
+if (!avci->buffer_frame) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
 
-avctx->internal->buffer_pkt = av_packet_alloc();
-if (!avctx->internal->buffer_pkt) {
+avci->buffer_pkt = av_packet_alloc();
+if (!avci->buffer_pkt) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
 
-avctx->internal->ds.in_pkt = av_packet_alloc();
-if (!avctx->internal->ds.in_pkt) {
+avci->ds.in_pkt = av_packet_alloc();
+if (!avci->ds.in_pkt) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
 
-avctx->internal->last_pkt_props = av_packet_alloc();
-if (!avctx->internal->last_pkt_props) {
+avci->last_pkt_props = av_packet_alloc();
+if (!avci->last_pkt_props) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
 
-avctx->internal->skip_samples_multiplier = 1;
+avci->skip_samples_multiplier = 1;
 
 if (codec->priv_data_size > 0) {
 if (!avctx->priv_data) {
@@ -755,7 +757,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 }
 
 if (HAVE_THREADS
-&& !(avctx->internal->frame_thread_encoder && 
(avctx->active_thread_type_THREAD_FRAME))) {
+&& !(avci->frame_thread_encoder && 
(avctx->active_thread_type_THREAD_FRAME))) {
 ret = ff_thread_init(avctx);
 if (ret < 0) {
 goto free_and_end;
@@ -947,7 +949,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
"gray decoding requested but not enabled at configuration 
time\n");
 
 if (   avctx->codec->init && (!(avctx->active_thread_type_THREAD_FRAME)
-|| avctx->internal->frame_thread_encoder)) {
+|| avci->frame_thread_encoder)) {
 ret = avctx->codec->init(avctx);
 if (ret < 0) {
 goto free_and_end;
@@ -1045,7 +1047,7 @@ free_and_end:
  (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)))
 avctx->codec->close(avctx);
 
-if (HAVE_THREADS && avctx->internal->thread_ctx)
+if (HAVE_THREADS && avci->thread_ctx)
 ff_thread_free(avctx);
 
 if (codec->priv_class && codec->priv_data_size)
@@ -1061,19 +1063,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_dict_free();
 av_freep(>priv_data);
 av_freep(>subtitle_header);
-if (avctx->internal) {
-av_frame_free(>internal->to_free);
-av_frame_free(>internal->compat_decode_frame);
-av_frame_free(>internal->buffer_frame);
-av_packet_free(>internal->buffer_pkt);
-av_packet_free(>internal->last_pkt_props);
-
-av_packet_free(>internal->ds.in_pkt);
+if (avci) {
+av_frame_free(>to_free);
+av_frame_free(>compat_decode_frame);
+av_frame_free(>buffer_frame);
+av_packet_free(>buffer_pkt);
+av_packet_free(>last_pkt_props);
+
+av_packet_free(>ds.in_pkt);
 ff_decode_bsfs_uninit(avctx);
 
-av_freep(>internal->pool);
+av_freep(>pool);
 }
-av_freep(>internal);
+av_freep();
+avctx->internal = NULL;
 avctx->codec = NULL;
 goto end;
 }
-- 
2.9.5


Re: [FFmpeg-devel] [PATCH v3 1/3] avcodec/libvpxenc: add VP9 temporal scalability encoding option

2020-01-08 Thread Wonkap Jang
On Wed, Jan 8, 2020 at 3:00 PM Wonkap Jang  wrote:

> This commit reuses the configuration options for VP8 that enables
> temporal scalability for VP9. It also adds a way to enable three
> preset temporal structures (refer to the documentation for more
> detail) that can be used in offline encoding.
> ---
>  libavcodec/libvpxenc.c | 251 +
>  1 file changed, 228 insertions(+), 23 deletions(-)
>
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 0b8a070304..14cc1e7158 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -100,7 +100,9 @@ typedef struct VPxEncoderContext {
>  int rc_undershoot_pct;
>  int rc_overshoot_pct;
>
> -AVDictionary *vp8_ts_parameters;
> +AVDictionary *vpx_ts_parameters;
> +int *ts_layer_flags;
> +int current_temporal_idx;
>
>  // VP9-only
>  int lossless;
> @@ -137,6 +139,7 @@ static const char *const ctlidstr[] = {
>  [VP8E_SET_CQ_LEVEL]  = "VP8E_SET_CQ_LEVEL",
>  [VP8E_SET_MAX_INTRA_BITRATE_PCT] = "VP8E_SET_MAX_INTRA_BITRATE_PCT",
>  [VP8E_SET_SHARPNESS]   = "VP8E_SET_SHARPNESS",
> +[VP8E_SET_TEMPORAL_LAYER_ID]   = "VP8E_SET_TEMPORAL_LAYER_ID",
>  #if CONFIG_LIBVPX_VP9_ENCODER
>  [VP9E_SET_LOSSLESS]= "VP9E_SET_LOSSLESS",
>  [VP9E_SET_TILE_COLUMNS]= "VP9E_SET_TILE_COLUMNS",
> @@ -144,6 +147,11 @@ static const char *const ctlidstr[] = {
>  [VP9E_SET_FRAME_PARALLEL_DECODING] =
> "VP9E_SET_FRAME_PARALLEL_DECODING",
>  [VP9E_SET_AQ_MODE] = "VP9E_SET_AQ_MODE",
>  [VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE",
> +[VP9E_SET_SVC_LAYER_ID]= "VP9E_SET_SVC_LAYER_ID",
> +#if VPX_ENCODER_ABI_VERSION >= 12
> +[VP9E_SET_SVC_PARAMETERS]  = "VP9E_SET_SVC_PARAMETERS",
> +#endif
> +[VP9E_SET_SVC] = "VP9E_SET_SVC",
>  #if VPX_ENCODER_ABI_VERSION >= 11
>  [VP9E_SET_COLOR_RANGE] = "VP9E_SET_COLOR_RANGE",
>  #endif
> @@ -223,8 +231,16 @@ static av_cold void dump_enc_cfg(AVCodecContext
> *avctx,
> "  %*s%u\n", width, "ts_number_layers:",
> cfg->ts_number_layers);
>  av_log(avctx, level,
> "\n  %*s", width, "ts_target_bitrate:");
> -for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
> -av_log(avctx, level, "%u ", cfg->ts_target_bitrate[i]);
> +if (avctx->codec_id == AV_CODEC_ID_VP8) {
> +for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
> +av_log(avctx, level, "%u ", cfg->ts_target_bitrate[i]);
> +}
> +#if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
> +if (avctx->codec_id == AV_CODEC_ID_VP9) {
> +for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
> +av_log(avctx, level, "%u ", cfg->layer_target_bitrate[i]);
> +}
> +#endif
>  av_log(avctx, level, "\n");
>  av_log(avctx, level,
> "\n  %*s", width, "ts_rate_decimator:");
> @@ -346,6 +362,8 @@ static av_cold int vpx_free(AVCodecContext *avctx)
>  }
>  #endif
>
> +av_freep(>ts_layer_flags);
> +
>  vpx_codec_destroy(>encoder);
>  if (ctx->is_alpha) {
>  vpx_codec_destroy(>encoder_alpha);
> @@ -370,23 +388,154 @@ static void vp8_ts_parse_int_array(int *dest, char
> *value, size_t value_len, int
>  }
>  }
>
> -static int vp8_ts_param_parse(struct vpx_codec_enc_cfg *enccfg, char
> *key, char *value)
> +static void set_temporal_layer_pattern(int layering_mode,
> +   vpx_codec_enc_cfg_t *cfg,
> +   int *layer_flags,
> +   int *flag_periodicity)
> +{
> +switch (layering_mode) {
> +case 2: {
> +/**
> + * 2-layers, 2-frame period.
> + */
> +int ids[2] = { 0, 1 };
> +cfg->ts_periodicity = 2;
> +*flag_periodicity = 2;
> +cfg->ts_number_layers = 2;
> +cfg->ts_rate_decimator[0] = 2;
> +cfg->ts_rate_decimator[1] = 1;
> +memcpy(cfg->ts_layer_id, ids, sizeof(ids));
> +
> +layer_flags[0] =
> + VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
> + VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
> +
> +layer_flags[1] =
> +VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF |
> +VP8_EFLAG_NO_UPD_LAST |
> +VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF;
> +break;
> +}
> +case 3: {
> +/**
> + * 3-layers structure with one reference frame.
> + *  This works same as temporal_layering_mode 3.
> + *
> + * 3-layers, 4-frame period.
> + */
> +int ids[4] = { 0, 2, 1, 2 };
> +cfg->ts_periodicity = 4;
> +*flag_periodicity = 4;
> +cfg->ts_number_layers = 3;
> +cfg->ts_rate_decimator[0] = 4;
> +cfg->ts_rate_decimator[1] = 2;
> +cfg->ts_rate_decimator[2] = 1;
> +memcpy(cfg->ts_layer_id, ids, sizeof(ids));

Re: [FFmpeg-devel] [PATCH] lavc/qsv: adding DX11 support

2020-01-08 Thread Hendrik Leppkes
On Thu, Jan 9, 2020 at 12:32 AM Max Dmitrichenko  wrote:
> > Historically, QSV failed at accepting the array-textures that are used
> > by a D3D11 decoder, which is why this was not included.
> >
> >
>
> right but not anymore,
> therefore this patch.
>

Cool. Whats the requirement on that? New MFX library? Certain driver versions?

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

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

Re: [FFmpeg-devel] [PATCHv2 1/3] avutil/eval: separate AVExpr state to a new AVExprState struct

2020-01-08 Thread Marton Balint



On Wed, 1 Jan 2020, Marton Balint wrote:




On Wed, 1 Jan 2020, Michael Niedermayer wrote:


On Mon, Dec 30, 2019 at 11:23:40PM +0100, Marton Balint wrote:

Also add helper functions to allocate and free such a struct, and make it
usable by providing a new av_eval_expr2 function for which you can specify 

a

custom AVExprState.

Signed-off-by: Marton Balint 
---
 doc/APIchanges  |  4 
 libavutil/eval.c| 36 +---
 libavutil/eval.h| 41 +
 libavutil/version.h |  2 +-
 4 files changed, 71 insertions(+), 12 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 3c24dc6fbc..d0b33bda02 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21

 API changes, most recent first:

+2020-01-xx - xx - lavu 56.39.100 - eval.h
+  Add AVExprState struct and av_expr_eval2, av_expr_state_alloc,
+  av_expr_state_free functions
+
 2019-12-27 - xx - lavu 56.38.100 - eval.h
   Add av_expr_count_func().

diff --git a/libavutil/eval.c b/libavutil/eval.c
index d527f6a9d0..4619d0fba0 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -53,7 +53,6 @@ typedef struct Parser {
 void *opaque;
 int log_offset;
 void *log_ctx;
-#define VARS 10
 double *var;
 } Parser;

@@ -173,7 +172,7 @@ struct AVExpr {
 double (*func2)(void *, double, double);
 } a;
 struct AVExpr *param[3];
-double *var;
+AVExprState *state;
 };

 static double etime(double v)
@@ -191,7 +190,7 @@ static double eval_expr(Parser *p, AVExpr *e)
 case e_func2:  return e->value * e->a.func2(p->opaque, 

eval_expr(p, e->param[0]), eval_expr(p, e->param[1]));

 case e_squish: return 1/(1+exp(4*eval_expr(p, e->param[0])));
 case e_gauss: { double d = eval_expr(p, e->param[0]); return 

exp(-d*d/2)/sqrt(2*M_PI); }
-case e_ld: return e->value * p->var[av_clip(eval_expr(p, 

e->param[0]), 0, VARS-1)];
+case e_ld: return e->value * p->var[av_clip(eval_expr(p, 

e->param[0]), 0, AV_EXPR_STATE_NB_VARS-1)];
 case e_isnan:  return e->value * !!isnan(eval_expr(p, 

e->param[0]));
 case e_isinf:  return e->value * !!isinf(eval_expr(p, 

e->param[0]));
 case e_floor:  return e->value * floor(eval_expr(p, 

e->param[0]));

@@ -230,7 +229,7 @@ static double eval_expr(Parser *p, AVExpr *e)
 return x;
 }
 case e_random:{
-int idx= av_clip(eval_expr(p, e->param[0]), 0, VARS-1);
+int idx= av_clip(eval_expr(p, e->param[0]), 0, 

AV_EXPR_STATE_NB_VARS-1);

 uint64_t r= isnan(p->var[idx]) ? 0 : p->var[idx];
 r= r*1664525+1013904223;
 p->var[idx]= r;
@@ -245,7 +244,7 @@ static double eval_expr(Parser *p, AVExpr *e)
 case e_taylor: {
 double t = 1, d = 0, v;
 double x = eval_expr(p, e->param[1]);
-int id = e->param[2] ? av_clip(eval_expr(p, e->param[2]), 0, 

VARS-1) : 0;
+int id = e->param[2] ? av_clip(eval_expr(p, e->param[2]), 0, 

AV_EXPR_STATE_NB_VARS-1) : 0;

 int i;
 double var0 = p->var[id];
 for(i=0; i<1000; i++) {
@@ -320,7 +319,7 @@ static double eval_expr(Parser *p, AVExpr *e)
 case e_div: return e->value * ((!CONFIG_FTRAPV || d2 ) ? 

(d / d2) : d * INFINITY);

 case e_add: return e->value * (d + d2);
 case e_last:return e->value * d2;
-case e_st : return e->value * (p->var[av_clip(d, 0, 

VARS-1)]= d2);
+case e_st : return e->value * (p->var[av_clip(d, 0, 

AV_EXPR_STATE_NB_VARS-1)]= d2);

 case e_hypot:return e->value * hypot(d, d2);
 case e_atan2:return e->value * atan2(d, d2);
 case e_bitand: return isnan(d) || isnan(d2) ? NAN : 

e->value * ((long int)d & (long int)d2);

@@ -333,13 +332,23 @@ static double eval_expr(Parser *p, AVExpr *e)

 static int parse_expr(AVExpr **e, Parser *p);

+AVExprState *av_expr_state_alloc(void)
+{
+return av_mallocz(sizeof(AVExprState));
+}
+
+void av_expr_state_free(AVExprState **ps)
+{
+av_freep(ps);
+}
+
 void av_expr_free(AVExpr *e)
 {
 if (!e) return;
 av_expr_free(e->param[0]);
 av_expr_free(e->param[1]);
 av_expr_free(e->param[2]);
-av_freep(>var);
+av_expr_state_free(>state);
 av_freep();
 }

@@ -724,8 +733,8 @@ int av_expr_parse(AVExpr **expr, const char *s,
 ret = AVERROR(EINVAL);
 goto end;
 }
-e->var= av_mallocz(sizeof(double) *VARS);
-if (!e->var) {
+e->state = av_expr_state_alloc();
+if (!e->state) {
 ret = AVERROR(ENOMEM);
 goto end;
 }
@@ -763,16 +772,21 @@ int av_expr_count_func(AVExpr *e, unsigned *counter, 

int size, int arg)
 return expr_count(e, counter, size, ((int[]){e_const, e_func1, 

e_func2})[arg]);

 }

-double av_expr_eval(AVExpr *e, const double 

[FFmpeg-devel] [PATCH v2 1/3] avformat/avio: move ff_rename implementation from internal.h to avio.c

2020-01-08 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/avio.c | 15 +++
 libavformat/internal.h | 14 +-
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 2dd2312296..8c2c85f171 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -26,6 +26,7 @@
 #include "libavutil/avassert.h"
 #include "os_support.h"
 #include "avformat.h"
+#include "internal.h"
 #if CONFIG_NETWORK
 #include "network.h"
 #endif
@@ -665,3 +666,17 @@ int ff_check_interrupt(AVIOInterruptCB *cb)
 return cb->callback(cb->opaque);
 return 0;
 }
+
+int ff_rename(const char *oldpath, const char *newpath, void *logctx)
+{
+int ret = 0;
+if (rename(oldpath, newpath) == -1) {
+ret = AVERROR(errno);
+if (logctx) {
+char err[AV_ERROR_MAX_STRING_SIZE] = {0};
+av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, ret);
+av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s: 
%s\n", oldpath, newpath, err);
+}
+}
+return ret;
+}
diff --git a/libavformat/internal.h b/libavformat/internal.h
index ec9a29907a..da09983083 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -586,19 +586,7 @@ int ff_stream_encode_params_copy(AVStream *dst, const 
AVStream *src);
  * @param newpath destination path
  * @return0 or AVERROR on failure
  */
-static inline int ff_rename(const char *oldpath, const char *newpath, void 
*logctx)
-{
-int ret = 0;
-if (rename(oldpath, newpath) == -1) {
-ret = AVERROR(errno);
-if (logctx) {
-char err[AV_ERROR_MAX_STRING_SIZE] = {0};
-av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, ret);
-av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s: 
%s\n", oldpath, newpath, err);
-}
-}
-return ret;
-}
+int ff_rename(const char *oldpath, const char *newpath, void *logctx);
 
 /**
  * Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH v2 3/3] avformat/dashenc: use ff_rename instead of avpriv_io_move

2020-01-08 Thread Marton Balint
ff_rename always logs the error message.

Signed-off-by: Marton Balint 
---
 libavformat/dashenc.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index b84736881f..6b82ca9450 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -540,9 +540,7 @@ static void write_hls_media_playlist(OutputStream *os, 
AVFormatContext *s,
 dashenc_io_close(s, >m3u8_out, temp_filename_hls);
 
 if (use_rename)
-if (avpriv_io_move(temp_filename_hls, filename_hls) < 0) {
-av_log(os->ctx, AV_LOG_WARNING, "renaming file %s to %s 
failed\n\n", temp_filename_hls, filename_hls);
-}
+ff_rename(temp_filename_hls, filename_hls, os->ctx);
 }
 
 static int flush_init_segment(AVFormatContext *s, OutputStream *os)
@@ -1037,7 +1035,7 @@ static int write_manifest(AVFormatContext *s, int final)
 dashenc_io_close(s, >mpd_out, temp_filename);
 
 if (use_rename) {
-if ((ret = avpriv_io_move(temp_filename, s->url)) < 0)
+if ((ret = ff_rename(temp_filename, s->url, s)) < 0)
 return ret;
 }
 
@@ -1119,7 +1117,7 @@ static int write_manifest(AVFormatContext *s, int final)
 }
 dashenc_io_close(s, >m3u8_out, temp_filename);
 if (use_rename)
-if ((ret = avpriv_io_move(temp_filename, filename_hls)) < 0)
+if ((ret = ff_rename(temp_filename, filename_hls, s)) < 0)
 return ret;
 c->master_playlist_created = 1;
 }
@@ -1619,7 +1617,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 dashenc_io_close(s, >out, os->temp_path);
 
 if (use_rename) {
-ret = avpriv_io_move(os->temp_path, os->full_path);
+ret = ff_rename(os->temp_path, os->full_path, os->ctx);
 if (ret < 0)
 break;
 }
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH v2 2/3] avformat/avio: fix ff_rename to respect used protocol

2020-01-08 Thread Marton Balint
Also simplify it and make it always log the error.

This fixes for example the image2 muxer when used with an URL which also
contains the protocol:

ffmpeg -f lavfi -i testsrc -vframes 10 -atomic_writing 1 file:out%d.png

Signed-off-by: Marton Balint 
---
 libavformat/avio.c | 14 --
 libavformat/internal.h |  8 
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 8c2c85f171..65cfc0f4bb 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -667,16 +667,10 @@ int ff_check_interrupt(AVIOInterruptCB *cb)
 return 0;
 }
 
-int ff_rename(const char *oldpath, const char *newpath, void *logctx)
+int ff_rename(const char *url_src, const char *url_dst, void *logctx)
 {
-int ret = 0;
-if (rename(oldpath, newpath) == -1) {
-ret = AVERROR(errno);
-if (logctx) {
-char err[AV_ERROR_MAX_STRING_SIZE] = {0};
-av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, ret);
-av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s: 
%s\n", oldpath, newpath, err);
-}
-}
+int ret = avpriv_io_move(url_src, url_dst);
+if (ret < 0)
+av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s: %s\n", 
url_src, url_dst, av_err2str(ret));
 return ret;
 }
diff --git a/libavformat/internal.h b/libavformat/internal.h
index da09983083..332477a532 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -580,13 +580,13 @@ int ff_stream_add_bitstream_filter(AVStream *st, const 
char *name, const char *a
 int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
 
 /**
- * Wrap errno on rename() error.
+ * Wrap avpriv_io_move and log if error happens.
  *
- * @param oldpath source path
- * @param newpath destination path
+ * @param url_src source path
+ * @param url_dst destination path
  * @return0 or AVERROR on failure
  */
-int ff_rename(const char *oldpath, const char *newpath, void *logctx);
+int ff_rename(const char *url_src, const char *url_dst, void *logctx);
 
 /**
  * Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end
-- 
2.16.4

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

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

Re: [FFmpeg-devel] [PATCH] lavc/qsv: adding DX11 support

2020-01-08 Thread Max Dmitrichenko
On Mon, Dec 23, 2019 at 8:24 PM Hendrik Leppkes  wrote:

> On Mon, Dec 23, 2019 at 7:40 PM Artem Galin  wrote:
> >
> > This enables DX11 support for QSV with higher priority than DX9.
> > In case of multiple GPUs configuration, DX9 API does not allow to get
> > access to QSV device in some cases - headless.
> > Implementation based on DX11 resolves that restriction by enumerating
> list of available GPUs and finding device with QSV support.
> >
> > Signed-off-by: Artem Galin 
>
> Did you test this in combination of D3D11VA decoding and QSV encoding?
>


yes, it has been tested


> Historically, QSV failed at accepting the array-textures that are used
> by a D3D11 decoder, which is why this was not included.
>
>

right but not anymore,
therefore this patch.


> - Hendrik
>


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

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

[FFmpeg-devel] [PATCH v3 2/3] avcodec/libvpxenc: add a way to explicitly set temporal layer id

2020-01-08 Thread Wonkap Jang
In order for rate control to correctly allocate bitrate to each temporal
layer, correct temporal layer id has to be set to each frame. This
commit provides the ability to set correct temporal layer id for each
frame.
---
 libavcodec/libvpxenc.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 14cc1e7158..8d24e96241 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1520,11 +1520,22 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 #endif
 if (frame->pict_type == AV_PICTURE_TYPE_I)
 flags |= VPX_EFLAG_FORCE_KF;
-if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8 && 
frame->metadata) {
+if (frame->metadata) {
 AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", 
NULL, 0);
 if (en) {
 flags |= strtoul(en->value, NULL, 10);
 }
+
+memset(_id, 0, sizeof(layer_id));
+
+en = av_dict_get(frame->metadata, "temporal_id", NULL, 0);
+if (en) {
+layer_id.temporal_layer_id = strtoul(en->value, NULL, 10);
+#ifdef VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT
+layer_id.temporal_layer_id_per_spatial[0] = 
layer_id.temporal_layer_id;
+#endif
+layer_id_valid = 1;
+}
 }
 
 if (sd) {
-- 
2.25.0.rc1.283.g88dfdc4193-goog

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

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

[FFmpeg-devel] [PATCH v3 1/3] avcodec/libvpxenc: add VP9 temporal scalability encoding option

2020-01-08 Thread Wonkap Jang
This commit reuses the configuration options for VP8 that enables
temporal scalability for VP9. It also adds a way to enable three
preset temporal structures (refer to the documentation for more
detail) that can be used in offline encoding.
---
 libavcodec/libvpxenc.c | 251 +
 1 file changed, 228 insertions(+), 23 deletions(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 0b8a070304..14cc1e7158 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -100,7 +100,9 @@ typedef struct VPxEncoderContext {
 int rc_undershoot_pct;
 int rc_overshoot_pct;
 
-AVDictionary *vp8_ts_parameters;
+AVDictionary *vpx_ts_parameters;
+int *ts_layer_flags;
+int current_temporal_idx;
 
 // VP9-only
 int lossless;
@@ -137,6 +139,7 @@ static const char *const ctlidstr[] = {
 [VP8E_SET_CQ_LEVEL]  = "VP8E_SET_CQ_LEVEL",
 [VP8E_SET_MAX_INTRA_BITRATE_PCT] = "VP8E_SET_MAX_INTRA_BITRATE_PCT",
 [VP8E_SET_SHARPNESS]   = "VP8E_SET_SHARPNESS",
+[VP8E_SET_TEMPORAL_LAYER_ID]   = "VP8E_SET_TEMPORAL_LAYER_ID",
 #if CONFIG_LIBVPX_VP9_ENCODER
 [VP9E_SET_LOSSLESS]= "VP9E_SET_LOSSLESS",
 [VP9E_SET_TILE_COLUMNS]= "VP9E_SET_TILE_COLUMNS",
@@ -144,6 +147,11 @@ static const char *const ctlidstr[] = {
 [VP9E_SET_FRAME_PARALLEL_DECODING] = "VP9E_SET_FRAME_PARALLEL_DECODING",
 [VP9E_SET_AQ_MODE] = "VP9E_SET_AQ_MODE",
 [VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE",
+[VP9E_SET_SVC_LAYER_ID]= "VP9E_SET_SVC_LAYER_ID",
+#if VPX_ENCODER_ABI_VERSION >= 12
+[VP9E_SET_SVC_PARAMETERS]  = "VP9E_SET_SVC_PARAMETERS",
+#endif
+[VP9E_SET_SVC] = "VP9E_SET_SVC",
 #if VPX_ENCODER_ABI_VERSION >= 11
 [VP9E_SET_COLOR_RANGE] = "VP9E_SET_COLOR_RANGE",
 #endif
@@ -223,8 +231,16 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
"  %*s%u\n", width, "ts_number_layers:", cfg->ts_number_layers);
 av_log(avctx, level,
"\n  %*s", width, "ts_target_bitrate:");
-for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
-av_log(avctx, level, "%u ", cfg->ts_target_bitrate[i]);
+if (avctx->codec_id == AV_CODEC_ID_VP8) {
+for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
+av_log(avctx, level, "%u ", cfg->ts_target_bitrate[i]);
+}
+#if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER
+if (avctx->codec_id == AV_CODEC_ID_VP9) {
+for (i = 0; i < VPX_TS_MAX_LAYERS; i++)
+av_log(avctx, level, "%u ", cfg->layer_target_bitrate[i]);
+}
+#endif
 av_log(avctx, level, "\n");
 av_log(avctx, level,
"\n  %*s", width, "ts_rate_decimator:");
@@ -346,6 +362,8 @@ static av_cold int vpx_free(AVCodecContext *avctx)
 }
 #endif
 
+av_freep(>ts_layer_flags);
+
 vpx_codec_destroy(>encoder);
 if (ctx->is_alpha) {
 vpx_codec_destroy(>encoder_alpha);
@@ -370,23 +388,154 @@ static void vp8_ts_parse_int_array(int *dest, char 
*value, size_t value_len, int
 }
 }
 
-static int vp8_ts_param_parse(struct vpx_codec_enc_cfg *enccfg, char *key, 
char *value)
+static void set_temporal_layer_pattern(int layering_mode,
+   vpx_codec_enc_cfg_t *cfg,
+   int *layer_flags,
+   int *flag_periodicity)
+{
+switch (layering_mode) {
+case 2: {
+/**
+ * 2-layers, 2-frame period.
+ */
+int ids[2] = { 0, 1 };
+cfg->ts_periodicity = 2;
+*flag_periodicity = 2;
+cfg->ts_number_layers = 2;
+cfg->ts_rate_decimator[0] = 2;
+cfg->ts_rate_decimator[1] = 1;
+memcpy(cfg->ts_layer_id, ids, sizeof(ids));
+
+layer_flags[0] =
+ VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
+ VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
+
+layer_flags[1] =
+VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF |
+VP8_EFLAG_NO_UPD_LAST |
+VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF;
+break;
+}
+case 3: {
+/**
+ * 3-layers structure with one reference frame.
+ *  This works same as temporal_layering_mode 3.
+ *
+ * 3-layers, 4-frame period.
+ */
+int ids[4] = { 0, 2, 1, 2 };
+cfg->ts_periodicity = 4;
+*flag_periodicity = 4;
+cfg->ts_number_layers = 3;
+cfg->ts_rate_decimator[0] = 4;
+cfg->ts_rate_decimator[1] = 2;
+cfg->ts_rate_decimator[2] = 1;
+memcpy(cfg->ts_layer_id, ids, sizeof(ids));
+
+/**
+ * 0=L, 1=GF, 2=ARF,
+ * Intra-layer prediction disabled.
+ */
+layer_flags[0] =
+VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
+VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
+layer_flags[2] =
+

[FFmpeg-devel] [PATCH v3 3/3] doc/encoders: add VP9 temporal scalability encoding option

2020-01-08 Thread Wonkap Jang
Documentation change for adding support for encoding
with temporal scalability in VP9.
---
 doc/encoders.texi | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 61e674cf96..88429aed4c 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1885,8 +1885,6 @@ Enable error resiliency features.
 Increase sharpness at the expense of lower PSNR.
 The valid range is [0, 7].
 
-@item VP8-specific options
-@table @option
 @item ts-parameters
 Sets the temporal scalability configuration using a :-separated list of
 key=value pairs. For example, to specify temporal scalability parameters
@@ -1894,7 +1892,7 @@ with @code{ffmpeg}:
 @example
 ffmpeg -i INPUT -c:v libvpx -ts-parameters ts_number_layers=3:\
 ts_target_bitrate=250,500,1000:ts_rate_decimator=4,2,1:\
-ts_periodicity=4:ts_layer_id=0,2,1,2 OUTPUT
+ts_periodicity=4:ts_layer_id=0,2,1,2:ts_layering_mode=3 OUTPUT
 @end example
 Below is a brief explanation of each of the parameters, please
 refer to @code{struct vpx_codec_enc_cfg} in @code{vpx/vpx_encoder.h} for more
@@ -1911,6 +1909,20 @@ Frame rate decimation factor for each temporal layer.
 Length of the sequence defining frame temporal layer membership.
 @item ts_layer_id
 Template defining the membership of frames to temporal layers.
+@item ts_layering_mode
+(optional) Selecting the temporal structure from a set of pre-defined temporal 
layering modes.
+Currently supports the following options.
+@table @option
+@item 0
+No temporal layering flags are provided internally,
+relies on flags being passed in using metadata in AVFrame.
+@item 2
+Two temporal layers. 0-1...
+@item 3
+Three temporal layers. 0-2-1-2...; with single reference frame.
+@item 4
+Same as option "3", except there is a dependency between
+the two temporal layer 2 frames within the temporal period.
 @end table
 @end table
 
-- 
2.25.0.rc1.283.g88dfdc4193-goog

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

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

Re: [FFmpeg-devel] [PATCH] nvenc: implement flush to help allow an encoder to be re-used

2020-01-08 Thread Josh Allmann
On Mon, 30 Dec 2019 at 16:40, Philip Langdale  wrote:
>
> On Sat, 21 Dec 2019 14:54:38 -0800
> Philip Langdale  wrote:
>
> > On Fri, 20 Dec 2019 16:07:18 -0800
> > Josh Allmann  wrote:
> >
> > > One concern I had was about the long-term stability of this
> > > behavior. Right now, it works, but perhaps only coincidentally?
> > > Being flushable and resumable like this isn't explicitly part of
> > > the "contract" for nvenc, as far as I can see. Could future changes
> > > inadvertently introduce state that isn't reset in between flushes,
> > > breaking the resumable behavior? If so, is there a way to safeguard
> > > against that?
> > >
> > > Josh
> >
> > So, the behaviour at the ffmpeg level is something you can view as
> > stable. If it was to break, I'd expect us to fix it. For nvenc itself,
> > that's harder to make any statements about. I wouldn't expect the
> > nvidia folks to change thing casually, but until they document a
> > specific flush behaviour, there's always going to be a risk -
> > ultimately we just have to react if they change something.
> >

Hi Phil,

Flushing and resumption is documented/supported in nvenc via
NV_ENC_FLAGS_EOS, but I wasn't sure if this was a feature that
ffmpeg's integration was intentionally designed for. But if you
confirm we can expect this behavior to be supported going forward,
then that's great news.

> > In an ideal world, you'd have a test running for this, but we're not
> > set up to exercise any hwaccels in our automated fate executions.
> >

We do have internal tests [1]  that should catch the issue if anything
changes, so that might be of some help as well, although we currently
only update ffmpeg on an as-needed basis.

[1] https://github.com/livepeer/lpms/blob/master/ffmpeg/nvidia_test.go

> > Did this form of the patch work for you?
> >
>
> Hi Josh,
>
> Did you get a chance to try it?
>
> --phil

Was delayed on testing this due to the holidays, my apologies.

Can confirm that this patch works very nicely in conjunction with
avcodec_flush_buffers . Thanks so much!

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

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

Re: [FFmpeg-devel] [PATCHv2 8/8] avformat/img2enc: add support for specifying protocol options

2020-01-08 Thread Marton Balint



On Wed, 1 Jan 2020, Marton Balint wrote:



On Tue, 31 Dec 2019, Michael Niedermayer wrote:


On Tue, Dec 31, 2019 at 12:37:02PM +0100, Nicolas George wrote:

Marton Balint (12019-12-28):

v2: simplified example

Signed-off-by: Marton Balint 
---
 doc/muxers.texi   | 11 +++
 libavformat/img2enc.c | 13 -
 2 files changed, 23 insertions(+), 1 deletion(-)


image2 is not the only demuxer that opens new streams. I think a generic
solution would be preferable.


i also had a slightly ungood feeling about the patch but didnt
had time to think more about it. a more generic solution like with
child AVClasses or something would be interresting but as said i didnt
had time to think about this ...


It looks like a big can of worms.

In the AVFMT_NOFILE case there is no IO context, so options can only be 
passed using avformat_write_header/avformat_init_output.


There is no way to determine which options the protocols will use 
without actually opening an IO context (protocol options are passed to the 
url_open method of each protocol), so we have to store all remaining 
options passed to avformat_write_header/avformat_init_output for possible 
nested IO use.


In the normal case (non AVFMT_NOFILE) muxers can use nested contexts too, 
so avio_open should also store the original options, all of them, because 
the nested contexts might use different protocols. This alone is 
problematic, because avio_open should return the unrecognized options...


Also it might make sense to specify different IO options for nested 
contexts than main contexts (or different options for some of the nested 
contexts)


IMHO being able to specify the nested options separately is a 
clean solution, admittedly less user friendly, but I don't see how this 
can work automagically without some major redesign.


Ping for this.

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

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

Re: [FFmpeg-devel] [PATCH 7/8] lavc/vaapi_decode: add profile_parser and format map support for HEVC REXT

2020-01-08 Thread Mark Thompson
On 29/12/2019 16:30, Linjie Fu wrote:
> Add function pointer field in vaapi_profile_map[], set profile_parser
> for HEVC_REXT to find the exact va_profile.
> 
> Also add format map support.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/vaapi_decode.c | 77 
> +--
>  1 file changed, 47 insertions(+), 30 deletions(-)
> 
> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> index 69512e1..658f26c 100644
> --- a/libavcodec/vaapi_decode.c
> +++ b/libavcodec/vaapi_decode.c
> @@ -24,7 +24,7 @@
>  #include "decode.h"
>  #include "internal.h"
>  #include "vaapi_decode.h"
> -
> +#include "vaapi_hevc.h"
>  
>  int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
>VAAPIDecodePicture *pic,
> @@ -256,6 +256,12 @@ static const struct {
>  #ifdef VA_FOURCC_YV16
>  MAP(YV16, YUV422P),
>  #endif
> +#ifdef VA_FOURCC_YUY2
> +MAP(YUY2, YUYV422),
> +#endif

Is YUY2 really more recent than the oldest supported VAAPI version?

> +#ifdef VA_FOURCC_Y210
> +MAP(Y210,Y210),
> +#endif
>  // 4:4:0
>  MAP(422V, YUV440P),
>  // 4:4:4
> @@ -364,39 +370,44 @@ static const struct {
>  enum AVCodecID codec_id;
>  int codec_profile;
>  VAProfile va_profile;
> +VAProfile (*profile_parser)(AVCodecContext *avctx);
>  } vaapi_profile_map[] = {
> -#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v }
> -MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2Simple ),
> -MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2Main   ),
> -MAP(H263,UNKNOWN, H263Baseline),
> -MAP(MPEG4,   MPEG4_SIMPLE,MPEG4Simple ),
> +#define MAP(c, p, v, f) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## 
> v, f}

Maybe something like:

#define MAP(c, p, v, ...) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## 
v, __VA_ARGS__ }

would let you avoid making the table more complex with all the NULL entries.

> +MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2Simple , NULL ),
> +MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2Main   , NULL ),
> +MAP(H263,UNKNOWN, H263Baseline, NULL ),
> +MAP(MPEG4,   MPEG4_SIMPLE,MPEG4Simple , NULL ),
>  MAP(MPEG4,   MPEG4_ADVANCED_SIMPLE,
> -   MPEG4AdvancedSimple),
> -MAP(MPEG4,   MPEG4_MAIN,  MPEG4Main   ),
> +   MPEG4AdvancedSimple, NULL ),
> +MAP(MPEG4,   MPEG4_MAIN,  MPEG4Main   , NULL ),
>  MAP(H264,H264_CONSTRAINED_BASELINE,
> -   H264ConstrainedBaseline),
> -MAP(H264,H264_MAIN,   H264Main),
> -MAP(H264,H264_HIGH,   H264High),
> +   H264ConstrainedBaseline, NULL ),
> +MAP(H264,H264_MAIN,   H264Main, NULL ),
> +MAP(H264,H264_HIGH,   H264High, NULL ),
>  #if VA_CHECK_VERSION(0, 37, 0)
> -MAP(HEVC,HEVC_MAIN,   HEVCMain),
> -MAP(HEVC,HEVC_MAIN_10,HEVCMain10  ),
> +MAP(HEVC,HEVC_MAIN,   HEVCMain, NULL ),
> +MAP(HEVC,HEVC_MAIN_10,HEVCMain10  , NULL ),
> +#endif
> +#if VA_CHECK_VERSION(1, 2, 0)
> +MAP(HEVC,HEVC_REXT,   None,
> +  ff_vaapi_parse_rext_profile),
>  #endif
>  MAP(MJPEG,   MJPEG_HUFFMAN_BASELINE_DCT,
> -  JPEGBaseline),
> -MAP(WMV3,VC1_SIMPLE,  VC1Simple   ),
> -MAP(WMV3,VC1_MAIN,VC1Main ),
> -MAP(WMV3,VC1_COMPLEX, VC1Advanced ),
> -MAP(WMV3,VC1_ADVANCED,VC1Advanced ),
> -MAP(VC1, VC1_SIMPLE,  VC1Simple   ),
> -MAP(VC1, VC1_MAIN,VC1Main ),
> -MAP(VC1, VC1_COMPLEX, VC1Advanced ),
> -MAP(VC1, VC1_ADVANCED,VC1Advanced ),
> -MAP(VP8, UNKNOWN,   VP8Version0_3 ),
> +  JPEGBaseline, NULL ),
> +MAP(WMV3,VC1_SIMPLE,  VC1Simple   , NULL ),
> +MAP(WMV3,VC1_MAIN,VC1Main , NULL ),
> +MAP(WMV3,VC1_COMPLEX, VC1Advanced , NULL ),
> +MAP(WMV3,VC1_ADVANCED,VC1Advanced , NULL ),
> +MAP(VC1, VC1_SIMPLE,  VC1Simple   , NULL ),
> +MAP(VC1, VC1_MAIN,VC1Main , NULL ),
> +MAP(VC1, VC1_COMPLEX, VC1Advanced , NULL ),
> +MAP(VC1, VC1_ADVANCED,VC1Advanced , NULL ),
> +MAP(VP8, UNKNOWN,   VP8Version0_3 , NULL ),
>  #if VA_CHECK_VERSION(0, 38, 0)
> -MAP(VP9, VP9_0,   VP9Profile0 ),
> +MAP(VP9, VP9_0,   VP9Profile0 , NULL ),
>  #endif
>  #if VA_CHECK_VERSION(0, 39, 0)
> -MAP(VP9, VP9_2,   VP9Profile2 ),
> +MAP(VP9, VP9_2,   VP9Profile2 , NULL ),
>  #endif
>  #undef MAP
>  };
> @@ -415,8 +426,8 @@ static int 

Re: [FFmpeg-devel] [PATCH 6/8] lavc/vaapi_hevc: add function to find exact va_profile for REXT

2020-01-08 Thread Mark Thompson
On 29/12/2019 16:30, Linjie Fu wrote:
> Add vaapi_parse_rext_profile and use profile constraint flags to
> determine the exact va_profile for HEVC_REXT.
> 
> Add build object in Makefile for h265_profile_level dependency.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/Makefile |  2 +-
>  libavcodec/vaapi_hevc.c | 69 
> +
>  libavcodec/vaapi_hevc.h | 24 +
>  3 files changed, 94 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/vaapi_hevc.h
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index c1f35b4..7cb914d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -884,7 +884,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   += dxva2_hevc.o
>  OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
>  OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
>  OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
> -OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
> +OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o 
> h265_profile_level.o
>  OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
>  OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o
>  OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)+= vaapi_mjpeg.o
> diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> index ab48b73..0604e23 100644
> --- a/libavcodec/vaapi_hevc.c
> +++ b/libavcodec/vaapi_hevc.c
> @@ -27,6 +27,8 @@
>  #include "hevcdec.h"
>  #include "hwaccel.h"
>  #include "vaapi_decode.h"
> +#include "vaapi_hevc.h"
> +#include "h265_profile_level.h"
>  
>  typedef struct VAAPIDecodePictureHEVC {
>  VAPictureParameterBufferHEVC pic_param;
> @@ -494,6 +496,73 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
>  return 0;
>  }
>  
> +static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel 
> *h265_raw_ptl)
> +{
> +h265_raw_ptl->general_profile_space = general_ptl->profile_space;
> +h265_raw_ptl->general_tier_flag = general_ptl->tier_flag;
> +h265_raw_ptl->general_profile_idc   = general_ptl->profile_idc;
> +
> +memcpy(h265_raw_ptl->general_profile_compatibility_flag,
> +  general_ptl->profile_compatibility_flag, 
> 32 * sizeof(int));

Not int!

> +
> +h265_raw_ptl->general_progressive_source_flag  = 
> general_ptl->progressive_source_flag;
> +h265_raw_ptl->general_interlaced_source_flag   = 
> general_ptl->interlaced_source_flag;
> +h265_raw_ptl->general_non_packed_constraint_flag   = 
> general_ptl->non_packed_constraint_flag;
> +h265_raw_ptl->general_frame_only_constraint_flag   = 
> general_ptl->frame_only_constraint_flag;
> +h265_raw_ptl->general_max_12bit_constraint_flag= 
> general_ptl->max_12bit_constraint_flag;
> +h265_raw_ptl->general_max_10bit_constraint_flag= 
> general_ptl->max_10bit_constraint_flag;
> +h265_raw_ptl->general_max_8bit_constraint_flag = 
> general_ptl->max_8bit_constraint_flag;
> +h265_raw_ptl->general_max_422chroma_constraint_flag= 
> general_ptl->max_422chroma_constraint_flag;
> +h265_raw_ptl->general_max_420chroma_constraint_flag= 
> general_ptl->max_420chroma_constraint_flag;
> +h265_raw_ptl->general_max_monochrome_constraint_flag   = 
> general_ptl->max_monochrome_constraint_flag;
> +h265_raw_ptl->general_intra_constraint_flag= 
> general_ptl->intra_constraint_flag;
> +h265_raw_ptl->general_one_picture_only_constraint_flag = 
> general_ptl->one_picture_only_constraint_flag;
> +h265_raw_ptl->general_lower_bit_rate_constraint_flag   = 
> general_ptl->lower_bit_rate_constraint_flag;
> +h265_raw_ptl->general_max_14bit_constraint_flag= 
> general_ptl->max_14bit_constraint_flag;
> +h265_raw_ptl->general_inbld_flag   = 
> general_ptl->inbld_flag;
> +h265_raw_ptl->general_level_idc= 
> general_ptl->level_idc;

The names are all identical, so a little macroing could make this look a little 
less horrible.

#define copy_field(name) h265_raw_ptl->general_ ## name = general_ptl->name

> +
> +return 0;
> +}
> +
> +/*
> + * Find exact va_profile for HEVC Range Extension
> + */
> +VAProfile ff_vaapi_parse_rext_profile(AVCodecContext *avctx)

Put hevc in the name as well.

> +{
> +const HEVCContext *h = avctx->priv_data;
> +const HEVCSPS *sps = h->ps.sps;
> +const PTL *ptl = &(sps->ptl);
> +const PTLCommon *general_ptl = &(ptl->general_ptl);
> +const H265ProfileDescriptor *profile = NULL;
> +
> +H265RawProfileTierLevel *h265_raw_ptl = 
> av_mallocz(sizeof(H265RawProfileTierLevel));

This structure isn't huge, it could be on the stack.

> +/* convert PTLCommon to H265RawProfileTierLevel */
> +ptl_convert(general_ptl, h265_raw_ptl);
> +
> +profile = ff_h265_get_profile(h265_raw_ptl);
> +av_freep(_raw_ptl);
> +
> +if (!profile)
> +return VAProfileNone;


Re: [FFmpeg-devel] [PATCH 3/4] avformat/utils: Remove redundant save+restore

2020-01-08 Thread Michael Niedermayer
On Tue, Oct 08, 2019 at 07:41:15AM +0200, Andreas Rheinhardt wrote:
> If the size of the input packet is zero, av_grow_packet() used to call
> av_new_packet() which would initialize the packet and (in particular)
> reset the pos field. This behaviour (which was never documented and
> arguably always contradicted the documented behaviour) was changed in
> 2fe04630. This means that it is unnecessary to save and restore the
> packet's position in append_packet_chunked().
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/utils.c | 2 --
>  1 file changed, 2 deletions(-)

will apply

thx

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/proresenc_anatoliy: Fix invalid left shift of negative number

2020-01-08 Thread Michael Niedermayer
On Wed, Jan 08, 2020 at 07:29:13PM +0100, Andreas Rheinhardt wrote:
> This fixes ticket #7997 as well as the vsynth*-prores_# FATE-tests
> (where * ranges over { 1, 2, 3, _lena } and # over { , _int, _444,
> _444_int }).
> 
> (Given that prev_dc is in the range -0xC000..0x3FFF, no overflow can
> happen upon multiplication with 2.)
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> Actually, #7997 ran into the same issue as #7979 and so it is no longer
> reproducible with the given commandline since aef24efb (which fixed
> #7979). But it is still reproducible with e.g. the null muxer.
> 
>  libavcodec/proresenc_anatoliy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates


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

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

Re: [FFmpeg-devel] [PATCH 5/8] lavc/hevc_ps: parse constraint flags for HEVC REXT

2020-01-08 Thread Mark Thompson
On 29/12/2019 16:30, Linjie Fu wrote:
> Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018).
> 
> They have to be passed to hw decoders to determine the exact profile for Range
> Extension HEVC.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/hevc_ps.c | 44 
>  libavcodec/hevc_ps.h | 13 -
>  2 files changed, 52 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index a30b8b8..87a1da1 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -267,7 +267,7 @@ static int decode_profile_tier_level(GetBitContext *gb, 
> AVCodecContext *avctx,
>  {
>  int i;
>  
> -if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12)
> +if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 43 + 1)
>  return -1;
>  
>  ptl->profile_space = get_bits(gb, 2);
> @@ -295,9 +295,45 @@ static int decode_profile_tier_level(GetBitContext *gb, 
> AVCodecContext *avctx,
>  ptl->non_packed_constraint_flag = get_bits1(gb);
>  ptl->frame_only_constraint_flag = get_bits1(gb);
>  
> -skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
> -skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
> -skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
> +#define check_profile_idc(idc) \
> +ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
> +
> +if (check_profile_idc(4) || check_profile_idc(5) || check_profile_idc(6) 
> ||
> +check_profile_idc(7) || check_profile_idc(8) || check_profile_idc(9) 
> ||
> +check_profile_idc(10)) {
> +
> +ptl->max_12bit_constraint_flag= get_bits1(gb);
> +ptl->max_10bit_constraint_flag= get_bits1(gb);
> +ptl->max_8bit_constraint_flag = get_bits1(gb);
> +ptl->max_422chroma_constraint_flag= get_bits1(gb);
> +ptl->max_420chroma_constraint_flag= get_bits1(gb);
> +ptl->max_monochrome_constraint_flag   = get_bits1(gb);
> +ptl->intra_constraint_flag= get_bits1(gb);
> +ptl->one_picture_only_constraint_flag = get_bits1(gb);
> +ptl->lower_bit_rate_constraint_flag   = get_bits1(gb);
> +
> +if (check_profile_idc(5) || check_profile_idc(9) || 
> check_profile_idc(10)) {
> +ptl->max_14bit_constraint_flag= get_bits1(gb);
> +skip_bits_long(gb, 33); // XXX_reserved_zero_33bits[0..32]
> +} else {
> +skip_bits_long(gb, 34); // XXX_reserved_zero_34bits[0..33]
> +}
> +} else if (check_profile_idc(2)) {
> +skip_bits(gb, 7);
> +ptl->one_picture_only_constraint_flag = get_bits1(gb);
> +skip_bits_long(gb, 35); // XXX_reserved_zero_35bits[0..34]
> +} else {
> +skip_bits_long(gb, 43); // XXX_reserved_zero_43bits[0..42]
> +}
> +
> +if ((ptl->profile_idc >=1 && ptl->profile_idc <= 5) || ptl->profile_idc 
> == 9 ||
> +ptl->profile_compatibility_flag[1] || 
> ptl->profile_compatibility_flag[2] ||
> +ptl->profile_compatibility_flag[3] || 
> ptl->profile_compatibility_flag[4] ||
> +ptl->profile_compatibility_flag[5] || 
> ptl->profile_compatibility_flag[9])

Your check_profile_idc() macro from above would make this test slightly clearer.

> +ptl->inbld_flag = get_bits1(gb);
> +else
> +skip_bits1(gb);
> +#undef check_profile_idc
>  
>  return 0;
>  }
> diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
> index 2840dc4..8e1bccd 100644
> --- a/libavcodec/hevc_ps.h
> +++ b/libavcodec/hevc_ps.h
> @@ -177,11 +177,22 @@ typedef struct PTLCommon {
>  uint8_t tier_flag;
>  uint8_t profile_idc;
>  uint8_t profile_compatibility_flag[32];
> -uint8_t level_idc;
>  uint8_t progressive_source_flag;
>  uint8_t interlaced_source_flag;
>  uint8_t non_packed_constraint_flag;
>  uint8_t frame_only_constraint_flag;
> +uint8_t max_12bit_constraint_flag;
> +uint8_t max_10bit_constraint_flag;
> +uint8_t max_8bit_constraint_flag;
> +uint8_t max_422chroma_constraint_flag;
> +uint8_t max_420chroma_constraint_flag;
> +uint8_t max_monochrome_constraint_flag;
> +uint8_t intra_constraint_flag;
> +uint8_t one_picture_only_constraint_flag;
> +uint8_t lower_bit_rate_constraint_flag;
> +uint8_t max_14bit_constraint_flag;
> +uint8_t inbld_flag;
> +uint8_t level_idc;
>  } PTLCommon;
>  
>  typedef struct PTL {
> 
- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] configure: Increase minimum libx265 version

2020-01-08 Thread Andriy Gelman
From: Andriy Gelman 

libx265.c references a member x265_picture.quantOffsets (for ROI
support) which was added in X265_BUILD 70. Increase the minimum libx265
version to fix compilation.

Signed-off-by: Andriy Gelman 
---

ubuntu 16.04 LTS is using X265_BUILD 79

 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 46f20386273..1f3d0fdd4bc 100755
--- a/configure
+++ b/configure
@@ -6361,7 +6361,7 @@ enabled libx264   && { check_pkg_config libx264 
x264 "stdint.h x264.h" x
  require_cpp_condition libx264 x264.h "X264_BUILD 
>= 118" &&
  check_cpp_condition libx262 x264.h "X264_MPEG2"
 enabled libx265   && require_pkg_config libx265 x265 x265.h 
x265_api_get &&
- require_cpp_condition libx265 x265.h "X265_BUILD 
>= 68"
+ require_cpp_condition libx265 x265.h "X265_BUILD 
>= 70"
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
 enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.3.0" 
"stdint.h xavs2.h" xavs2_api_get
 enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
-- 
2.24.0

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avformat/avio: fix ff_rename to respect used protocol

2020-01-08 Thread Michael Niedermayer
On Wed, Jan 08, 2020 at 01:23:39AM +0100, Marton Balint wrote:
> Also simplify it, move it to avio.c and make it always log the error.

I think at least moving and changing should be seperate so the diff shows
what is changed

thx

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

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato


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

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

Re: [FFmpeg-devel] [PATCH 4/8] lavc/vaapi_hevc: Add HEVC Rext parameter for VAPicture and VASlice

2020-01-08 Thread Mark Thompson
On 29/12/2019 16:29, Linjie Fu wrote:
> Add VAPictureParameterBufferHEVCRext and VASliceParameterBufferHEVCRext.
> 
> Pass Range Extension flags to support the decode for HEVC REXT.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/vaapi_hevc.c | 79 
> +++--
>  1 file changed, 76 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> index c69d63d..ab48b73 100644
> --- a/libavcodec/vaapi_hevc.c
> +++ b/libavcodec/vaapi_hevc.c
> @@ -30,7 +30,13 @@
>  
>  typedef struct VAAPIDecodePictureHEVC {
>  VAPictureParameterBufferHEVC pic_param;
> +#if VA_CHECK_VERSION(1, 2, 0)
> +VAPictureParameterBufferHEVCRext pic_rext_param;
> +#endif
>  VASliceParameterBufferHEVC last_slice_param;
> +#if VA_CHECK_VERSION(1, 2, 0)
> +VASliceParameterBufferHEVCRext slice_rext_param;
> +#endif

I would feel happier if this wasn't playing games with concatenated structures 
and sizing.  Can you have a single VAPictureParameterBufferHEVCExtension here, 
and then use either just the first element of it for Main / Main 10, or the 
whole thing for extension profiles?

>  const uint8_t *last_buffer;
>  size_t last_size;
>  
> @@ -119,6 +125,11 @@ static int vaapi_hevc_start_frame(AVCodecContext 
>  *avctx,
>  const ScalingList *scaling_list = NULL;
>  int err, i;
>  
> +int pic_param_size = sizeof(pic->pic_param);
> +#if VA_CHECK_VERSION(1, 2, 0)
> +pic_param_size += sizeof(pic->pic_rext_param);

But only if in an extension profile?  (Or replace with sizeof the extension 
structure.)

> +#endif
> +
>  pic->pic.output_surface = ff_vaapi_get_surface_id(h->ref->frame);
>  
>  pic->pic_param = (VAPictureParameterBufferHEVC) {
> @@ -208,9 +219,38 @@ static int vaapi_hevc_start_frame(AVCodecContext 
>  *avctx,
>  pic->pic_param.st_rps_bits = 0;
>  }
>  
> +#if VA_CHECK_VERSION(1, 2, 0)
> +if (sps->sps_range_extension_flag) {
> +pic->pic_rext_param = (VAPictureParameterBufferHEVCRext) {
> +.range_extension_pic_fields.bits  = {
> +.transform_skip_rotation_enabled_flag   = 
> sps->transform_skip_rotation_enabled_flag,
> +.transform_skip_context_enabled_flag= 
> sps->transform_skip_context_enabled_flag,
> +.implicit_rdpcm_enabled_flag= 
> sps->implicit_rdpcm_enabled_flag,
> +.explicit_rdpcm_enabled_flag= 
> sps->explicit_rdpcm_enabled_flag,
> +.extended_precision_processing_flag = 
> sps->extended_precision_processing_flag,
> +.intra_smoothing_disabled_flag  = 
> sps->intra_smoothing_disabled_flag,
> +.high_precision_offsets_enabled_flag= 
> sps->high_precision_offsets_enabled_flag,
> +.persistent_rice_adaptation_enabled_flag= 
> sps->persistent_rice_adaptation_enabled_flag,
> +.cabac_bypass_alignment_enabled_flag= 
> sps->cabac_bypass_alignment_enabled_flag,
> +.cross_component_prediction_enabled_flag= 
> pps->cross_component_prediction_enabled_flag,
> +.chroma_qp_offset_list_enabled_flag = 
> pps->chroma_qp_offset_list_enabled_flag,
> +},
> +.diff_cu_chroma_qp_offset_depth = 
> pps->diff_cu_chroma_qp_offset_depth,
> +.chroma_qp_offset_list_len_minus1   = 
> pps->chroma_qp_offset_list_len_minus1,
> +.log2_sao_offset_scale_luma = 
> pps->log2_sao_offset_scale_luma,
> +.log2_sao_offset_scale_chroma   = 
> pps->log2_sao_offset_scale_chroma,
> +.log2_max_transform_skip_block_size_minus2  = 
> pps->log2_max_transform_skip_block_size - 2,
> +};
> +
> +for (i = 0; i < 6; i++)
> +pic->pic_rext_param.cb_qp_offset_list[i]= 
> pps->cb_qp_offset_list[i];
> +for (i = 0; i < 6; i++)
> +pic->pic_rext_param.cr_qp_offset_list[i]= 
> pps->cr_qp_offset_list[i];
> +}

Do inferred values do the right thing if pps_range_extension_flag is not set?  
What if sps_r_e_f is not set but pps_r_e_f is?

> +#endif
>  err = ff_vaapi_decode_make_param_buffer(avctx, >pic,
>  VAPictureParameterBufferType,
> ->pic_param, 
> sizeof(pic->pic_param));
> +>pic_param, pic_param_size);
>  if (err < 0)
>  goto fail;
>  
> @@ -255,12 +295,19 @@ static int vaapi_hevc_end_frame(AVCodecContext *avctx)
>  {
>  const HEVCContext*h = avctx->priv_data;
>  VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
> +const HEVCSPS  *sps = h->ps.sps;
>  int ret;
>  
> +int slice_param_size = sizeof(pic->last_slice_param);
> +#if VA_CHECK_VERSION(1, 

Re: [FFmpeg-devel] [PATCH V6 2/2] libswscale/x86/yuv2rgb: add ssse3 version

2020-01-08 Thread Michael Niedermayer
On Wed, Jan 08, 2020 at 10:25:59AM +0800, Ting Fu wrote:
> Tested using this command:
> /ffmpeg -pix_fmt yuv420p -s 1920*1080 -i ArashRawYuv420.yuv \
> -vcodec rawvideo -s 1920*1080 -pix_fmt rgb24 -f null /dev/null
> 
> The fps increase from 389 to 640 on Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
> 
> Signed-off-by: Ting Fu 
> ---
>  libswscale/x86/yuv2rgb.c  |   7 +-
>  libswscale/x86/yuv2rgb_template.c |  58 +++-
>  libswscale/x86/yuv_2_rgb.asm  | 145 ++
>  3 files changed, 191 insertions(+), 19 deletions(-)
> 
> diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c
> index f3d2bb526e..7015266a7e 100644
> --- a/libswscale/x86/yuv2rgb.c
> +++ b/libswscale/x86/yuv2rgb.c
> @@ -61,13 +61,18 @@ DECLARE_ASM_CONST(8, uint64_t, pb_07) = 
> 0x0707070707070707ULL;
>  #define COMPILE_TEMPLATE_MMXEXT 1
>  #endif /* HAVE_MMXEXT */
>  
> +//SSSE3 versions
> +#if HAVE_SSSE3
> +#define COMPILE_TEMPLATE_SSSE3 1
> +#endif
> +
>  #include "yuv2rgb_template.c"
>  
>  av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
>  {
>  int cpu_flags = av_get_cpu_flags();
>  
> -if (EXTERNAL_MMX(cpu_flags)) {
> +if (EXTERNAL_MMX(cpu_flags) || EXTERNAL_SSSE3(cpu_flags)) {

I would expect that EXTERNAL_SSSE3 implies EXTERNAL_MMX

thx

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

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk



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

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

Re: [FFmpeg-devel] [PATCH v5 3/7] avformat: Add av_stream_add_coded_side_data()

2020-01-08 Thread Michael Niedermayer
On Mon, Dec 30, 2019 at 11:31:24AM +0100, Nicolas Gaullier wrote:
> This will allow avformat_find_stream_info() get side data from the codec 
> context.
> ---
>  doc/APIchanges |  3 +++
>  libavformat/avformat.h | 11 +++
>  libavformat/utils.c| 15 +++
>  libavformat/version.h  |  4 ++--
>  4 files changed, 31 insertions(+), 2 deletions(-)

Its a bit difficult to review this because its not immedeatly
clear which other patches this depends on
Maybe you can post the patch either as reply to the previous version
or repost the whole related set

Thanks

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

No great genius has ever existed without some touch of madness. -- Aristotle


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

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

Re: [FFmpeg-devel] [PATCH 1/8] lavu/pix_fmt: add new pixel format y210

2020-01-08 Thread Mark Thompson
On 29/12/2019 16:28, Linjie Fu wrote:
> Add some packed 4:2:2 10-bit pixel formats for hardware decode support
> in VAAPI and QSV.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/pixdesc.c  | 23 +++
>  libavutil/pixfmt.h   |  5 +
>  libavutil/version.h  |  2 +-
>  tests/ref/fate/sws-pixdesc-query |  7 +++
>  4 files changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> index 05dd4a1..1e118ef 100644
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -205,6 +205,29 @@ static const AVPixFmtDescriptor 
> av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
>  { 0, 4, 1, 0, 8, 3, 7, 2 },/* V */
>  },
>  },
> +[AV_PIX_FMT_Y210LE] = {
> +.name = "y210le",
> +.nb_components = 3,
> +.log2_chroma_w = 1,
> +.log2_chroma_h = 0,
> +.comp = {
> +{ 0, 4, 0, 6, 10, 3, 9, 1 },/* Y */
> +{ 0, 8, 2, 6, 10, 7, 9, 3 },/* U */
> +{ 0, 8, 6, 6, 10, 7, 9, 7 },/* V */
> +},
> +},
> +[AV_PIX_FMT_Y210BE] = {
> +.name = "y210be",
> +.nb_components = 3,
> +.log2_chroma_w = 1,
> +.log2_chroma_h = 0,
> +.comp = {
> +{ 0, 4, 0, 6, 10, 3, 9, 1 },/* Y */
> +{ 0, 8, 2, 6, 10, 7, 9, 3 },/* U */
> +{ 0, 8, 6, 6, 10, 7, 9, 7 },/* V */
> +},
> +.flags = AV_PIX_FMT_FLAG_BE,
> +},
>  [AV_PIX_FMT_RGB24] = {
>  .name = "rgb24",
>  .nb_components = 3,
> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> index 37ecebd..7ffa5a0 100644
> --- a/libavutil/pixfmt.h
> +++ b/libavutil/pixfmt.h
> @@ -348,6 +348,9 @@ enum AVPixelFormat {
>  AV_PIX_FMT_NV24,  ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 
> plane for the UV components, which are interleaved (first byte U and the 
> following byte V)
>  AV_PIX_FMT_NV42,  ///< as above, but U and V bytes are swapped
>  
> +AV_PIX_FMT_Y210BE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, 
> big-endian
> +AV_PIX_FMT_Y210LE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, 
> little-endian

These comments should be clear that the data are in the high bits (like P010), 
rather than in the low bits (like most formats used by software codecs).

Being consistent with other comments would write 20bpp rather than 32bpp, 
though I'm not sure how much information that number is really adding.

> +
>  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
>  };
>  
> @@ -436,6 +439,8 @@ enum AVPixelFormat {
>  #define AV_PIX_FMT_P010   AV_PIX_FMT_NE(P010BE,  P010LE)
>  #define AV_PIX_FMT_P016   AV_PIX_FMT_NE(P016BE,  P016LE)
>  
> +#define AV_PIX_FMT_Y210   AV_PIX_FMT_NE(Y210BE,  Y210LE)
> +
>  /**
>* Chromaticity coordinates of the source primaries.
>* These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1.
> ...

Thanks,

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/h265_metadata_bsf: Add vps/sps/pps id offset

2020-01-08 Thread Mark Thompson
On 08/01/2020 16:47, Eran Gonen wrote:
> ---
>  doc/bitstream_filters.texi |   5 ++
>  libavcodec/h265_metadata_bsf.c | 106 +++--
>  2 files changed, 105 insertions(+), 6 deletions(-)

To repeat my previous comment, I don't think this belongs in h265_metadata 
since it's editing something which isn't really metadata.  A separate BSF for 
doing this sort of thing would make more sense (particularly if it then 
implemented some user-facing feature which you are using this transformation to 
enable).

Also note that you need to edit various SEI structures which refer to parameter 
set IDs as well (buffering_period most importantly, since that is very commonly 
used).

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

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

Re: [FFmpeg-devel] [PATCHv2] movenc: Write durations based on pts into mvhd/mdhd/tkhd/elst

2020-01-08 Thread Martin Storsjö

On Fri, 20 Dec 2019, Michael Niedermayer wrote:


On Tue, Dec 17, 2019 at 03:15:09PM +0200, Martin Storsjö wrote:

Keep all the existing data fields as they are (there's lots and
lots of nontrivial calculation and heuristics based on them in
their current form), but derive the duration as the difference
between the pts of the first packet to the maximum pts+duration
(not necessarily the last packet); use this duration in any box
where the actual presentation duration is supposed to be.

Fixes: 8420
---
Fixed to fetch the duration for tmcd tracks from their designated
source track.
---
 libavformat/movenc.c | 35 ---
 1 file changed, 28 insertions(+), 7 deletions(-)


I found another case that changes, again dont know which is more correct

make -j12 && ./ffmpeg -i ~/tickets/3453/mov_with_tmcd.mov -y  -bitexact -codec 
copy -map 0 -t 2 file.mov ; ./ffprobe -v 0 file.mov -show_packets -print_format compact 
> /tmp/before

--- /tmp/before 2019-12-20 23:28:04.009327038 +0100
+++ /tmp/after  2019-12-20 23:27:17.213326052 +0100
@@ -188,7 +188,7 @@
packet|codec_type=audio|stream_index=1|pts=88320|pts_time=1.84|dts=88320|dts_time=1.84|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=4096|pos=408905|flags=K_
packet|codec_type=data|stream_index=2|pts=46|pts_time=1.84|dts=46|dts_time=1.84|duration=1|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=4|pos=413001|flags=K_
packet|codec_type=audio|stream_index=1|pts=89344|pts_time=1.861333|dts=89344|dts_time=1.861333|duration=896|duration_time=0.018667|convergence_duration=N/A|convergence_duration_time=N/A|size=3584|pos=413005|flags=K_
-packet|codec_type=video|stream_index=0|pts=26624|pts_time=2.08|dts=24064|dts_time=1.88|duration=512|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=776|pos=416589|flags=_D
+packet|codec_type=video|stream_index=0|pts=26624|pts_time=2.08|dts=24064|dts_time=1.88|duration=512|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=776|pos=416589|flags=__
packet|codec_type=audio|stream_index=1|pts=90240|pts_time=1.88|dts=90240|dts_time=1.88|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=4096|pos=417365|flags=K_
packet|codec_type=data|stream_index=2|pts=47|pts_time=1.88|dts=47|dts_time=1.88|duration=1|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=4|pos=421461|flags=K_
packet|codec_type=audio|stream_index=1|pts=91264|pts_time=1.901333|dts=91264|dts_time=1.901333|duration=896|duration_time=0.018667|convergence_duration=N/A|convergence_duration_time=N/A|size=3584|pos=421465|flags=K_


I would say the new behaviour is more correct here.

This command writes a truncated sequence; the sequence of muxed packets 
is this:


pts=0|pts_time=0.00|dts=-1024|dts_time=-0.08|duration=512|duration_time=0.04
...
pts=26624|pts_time=2.08|dts=24064|dts_time=1.88|duration=512|duration_time=0.04
pts=25600|pts_time=2.00|dts=24576|dts_time=1.92|duration=512|duration_time=0.04
pts=25088|pts_time=1.96|dts=25088|dts_time=1.96|duration=512|duration_time=0.04

Based on DTS, this previously wrote a total duration of 1.96 + 0.04 - 
(-0.08) = 2.08.


This duration also was set in the edit list, which then made the last 
frame (in presentation order) with a pts of 2.08 to be outside of the edit 
list, and thus be marked discardable.


With the patch, the duration of the file gets written as 2.08 + 0.04 - 
0.00 = 2.12, and thus the last frame no longer is marked as discardable.



If the reordering sequene wasn't truncated, if the following packet also 
would be included, the duration would end up calculated the same with both 
DTS and PTS:


pts=26112|pts_time=2.04|dts=25600|dts_time=2.00|duration=512|duration_time=0.04


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

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

Re: [FFmpeg-devel] [PATCH] avfilter/mpegaudiodec_template: Fix wrong decision of illegal

2020-01-08 Thread Michael Niedermayer
On Wed, Jan 08, 2020 at 04:32:39PM +0900, Ted Lee wrote:
> Dear FFmpeg developers,
> 
> I'm glad to have a chance to contribute to FFmpeg.
> 
> Since this is the first time for me, please give feedback if I missed
> something. I will reflect on that.
> 
> *Summary:*
> 
>- Test signal: 790_pomnyun_taebaek2.mp3
>   - MP3 file with the same left channel and right channel except for
>   the first 7 seconds and the last 10 seconds.
>   (download:
>   
> 
>   https://www.dropbox.com/s/sivz18sixvhoo66/790_pomnyun_taebaek2.mp3?dl=0
>   )
>- When decoding the test signal using FFmpeg as below, a difference
>occurs in the same part of L and R.
>   - $ffmpeg -i 790_pomnyun_taebaek2.mp3 -acodec pcm_s16le
>   790_pomnyun_taebaek2.wav
> 
> 
> Expected result (Adobe Audition or Core Audio):
> 
> Decoded PCM
> [image: image.png]
> (L-R)
> [image: image.png]
> (You can reproduce it using Adobe Audition or CoreAudio of MacOS)
> 
> Actual result (FFmpeg):
> 
> Decoded PCM
> [image: image.png]
> 
> (L-R)
> [image: image.png]
> 
> *Why it happens?:*
> 
>- In MPEG-1 Layer 3 (MP3), the illegal position of intensity stereo is
>defined as the maximum value of scale factor. Since intensity stereo
>positions (scale factor of the right channel) are always allocated to 3
>bits, intensity stereo positions are limited from 0 to 6 and 7 is treated
>as the illegal position.
>- In MPEG-2 LSF, the illegal position is also defined as the maximum
>value of scale factor, but the number of bits of the scale factor is not
>fixed. So the number of bits needs to be calculated (slen[]) and the
>illegal stereo position should be changed as the maximum value. However, in
>the current implementation, the illegal position is defined as fixed value
>16.
> 
> *How to fix this?:*
> 
>- The maximum value of scale factor (the illegal position) should be
>store to sf_max_table[] and an illegal position is determined when the
>scale factor is sf_max_table[](sf_max).
> 
> 
> From 754545f6c675aede07abd912992f9ed4a17d4ddc Mon Sep 17 00:00:00 2001
> From: Ted 
> Date: Wed, 8 Jan 2020 11:53:56 +0900
> Subject: [PATCH] avfilter/mpegaudiodec_template: Fix wrong decision of
> illegal
>  intensity stereo position for MPEG-2 LSF
> 
> Signed-off-by: Ted 
> ---
>  libavcodec/mpegaudiodec_template.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/mpegaudiodec_template.c
> b/libavcodec/mpegaudiodec_template.c
> index 3f1674e827..d6d7cd5ad0 100644
> --- a/libavcodec/mpegaudiodec_template.c
> +++ b/libavcodec/mpegaudiodec_template.c
> @@ -115,6 +115,7 @@ static uint16_t band_index_long[9][23];
>  static INTFLOAT is_table[2][16];
>  static INTFLOAT is_table_lsf[2][2][16];
>  static INTFLOAT csa_table[8][4];
> +static uint8_t sf_max_table[40];

[...]


>  v1 = is_tab[0][sf];
> @@ -1523,11 +1527,15 @@ static int mp_decode_layer3(MPADecodeContext *s)
>  n  = lsf_nsf_table[tindex2][tindex][k];
>  sl = slen[k];
>  if (sl) {
> -for (i = 0; i < n; i++)
> +for (i = 0; i < n; i++) {

> +sf_max_table[j] = (uint8_t) exp2(sl) - 1;

non constant statics do not work because there can be more than one mp3
decoder instance
also the exp2() very likely should be a simple shift

Thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Never trust a computer, one day, it may think you are the virus. -- Compn


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

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

[FFmpeg-devel] [PATCH] avcodec/proresenc_anatoliy: Fix invalid left shift of negative number

2020-01-08 Thread Andreas Rheinhardt
This fixes ticket #7997 as well as the vsynth*-prores_# FATE-tests
(where * ranges over { 1, 2, 3, _lena } and # over { , _int, _444,
_444_int }).

(Given that prev_dc is in the range -0xC000..0x3FFF, no overflow can
happen upon multiplication with 2.)

Signed-off-by: Andreas Rheinhardt 
---
Actually, #7997 ran into the same issue as #7979 and so it is no longer
reproducible with the given commandline since aef24efb (which fixed
#7979). But it is still reproducible with e.g. the null muxer.

 libavcodec/proresenc_anatoliy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 0fc79fc1de..1fcb0ae913 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -224,7 +224,7 @@ static void encode_codeword(PutBitContext *pb, int val, int 
codebook)
 }
 
 #define QSCALE(qmat,ind,val) ((val) / ((qmat)[ind]))
-#define TO_GOLOMB(val) (((val) << 1) ^ ((val) >> 31))
+#define TO_GOLOMB(val) (((val) * 2) ^ ((val) >> 31))
 #define DIFF_SIGN(val, sign) (((val) >> 31) ^ (sign))
 #define IS_NEGATIVE(val) val) >> 31) ^ -1) + 1)
 #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH] avcodec/h265_metadata_bsf: Add vps/sps/pps id offset

2020-01-08 Thread Eran Gonen
---
 doc/bitstream_filters.texi |   5 ++
 libavcodec/h265_metadata_bsf.c | 106 +++--
 2 files changed, 105 insertions(+), 6 deletions(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 8fe5b3ad75..2e874bf6ff 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -357,6 +357,11 @@ Set poc_proportional_to_timing_flag in VPS and VUI and use 
this value
 to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
 E.3.1).  Ignored if @option{tick_rate} is not also set.
 
+@item vps_id_offset
+@item sps_id_offset
+@item pps_id_offset
+Replace the original VPS/SPS/PPS identifier by increasing its value by an 
offset.
+
 @item crop_left
 @item crop_right
 @item crop_top
diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index b3a1fda144..7aeb1bffd1 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -68,6 +68,10 @@ typedef struct H265MetadataContext {
 int level;
 int level_guess;
 int level_warned;
+
+int vps_id_offset;
+int sps_id_offset;
+int pps_id_offset;
 } H265MetadataContext;
 
 
@@ -168,6 +172,8 @@ static int h265_metadata_update_vps(AVBSFContext *bsf,
 {
 H265MetadataContext *ctx = bsf->priv_data;
 
+vps->vps_video_parameter_set_id = (vps->vps_video_parameter_set_id + 
ctx->vps_id_offset) % HEVC_MAX_VPS_COUNT;
+
 if (ctx->tick_rate.num && ctx->tick_rate.den) {
 int num, den;
 
@@ -200,6 +206,9 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
 int need_vui = 0;
 int crop_unit_x, crop_unit_y;
 
+sps->sps_video_parameter_set_id = (sps->sps_video_parameter_set_id + 
ctx->vps_id_offset) % HEVC_MAX_VPS_COUNT;
+sps->sps_seq_parameter_set_id = (sps->sps_seq_parameter_set_id + 
ctx->sps_id_offset) % HEVC_MAX_SPS_COUNT;
+
 if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
 // Table E-1.
 static const AVRational sar_idc[] = {
@@ -336,6 +345,27 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
 return 0;
 }
 
+static int h265_metadata_update_pps(AVBSFContext *bsf,
+H265RawPPS *pps)
+{
+H265MetadataContext *ctx = bsf->priv_data;
+
+pps->pps_seq_parameter_set_id = (pps->pps_seq_parameter_set_id + 
ctx->sps_id_offset) % HEVC_MAX_SPS_COUNT;
+pps->pps_pic_parameter_set_id = (pps->pps_pic_parameter_set_id + 
ctx->pps_id_offset) % HEVC_MAX_PPS_COUNT;
+
+return 0;
+}
+
+static int h265_metadata_update_slice_header(AVBSFContext *bsf,
+H265RawSliceHeader *slice)
+{
+H265MetadataContext *ctx = bsf->priv_data;
+
+slice->slice_pic_parameter_set_id = (slice->slice_pic_parameter_set_id + 
ctx->pps_id_offset) % HEVC_MAX_PPS_COUNT;
+
+return 0;
+}
+
 static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
 {
 H265MetadataContext *ctx = bsf->priv_data;
@@ -406,15 +436,42 @@ static int h265_metadata_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 h265_metadata_guess_level(bsf, au);
 
 for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == HEVC_NAL_VPS) {
+switch (au->units[i].type) {
+case HEVC_NAL_VPS:
 err = h265_metadata_update_vps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
-}
-if (au->units[i].type == HEVC_NAL_SPS) {
+break;
+case HEVC_NAL_SPS:
 err = h265_metadata_update_sps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
+break;
+case HEVC_NAL_PPS:
+err = h265_metadata_update_pps(bsf, au->units[i].content);
+if (err < 0)
+goto fail;
+break;
+case HEVC_NAL_TRAIL_N:
+case HEVC_NAL_TRAIL_R:
+case HEVC_NAL_TSA_N:
+case HEVC_NAL_TSA_R:
+case HEVC_NAL_STSA_N:
+case HEVC_NAL_STSA_R:
+case HEVC_NAL_BLA_W_LP:
+case HEVC_NAL_BLA_W_RADL:
+case HEVC_NAL_BLA_N_LP:
+case HEVC_NAL_IDR_W_RADL:
+case HEVC_NAL_IDR_N_LP:
+case HEVC_NAL_CRA_NUT:
+case HEVC_NAL_RADL_N:
+case HEVC_NAL_RADL_R:
+case HEVC_NAL_RASL_N:
+case HEVC_NAL_RASL_R:
+err = h265_metadata_update_slice_header(bsf, au->units[i].content);
+if (err < 0)
+goto fail;
+break;
 }
 }
 
@@ -455,15 +512,42 @@ static int h265_metadata_init(AVBSFContext *bsf)
 h265_metadata_guess_level(bsf, au);
 
 for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == HEVC_NAL_VPS) {
+switch (au->units[i].type) {
+case HEVC_NAL_VPS:
 err = h265_metadata_update_vps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
-}
-if (au->units[i].type == HEVC_NAL_SPS) {
+break;
+   

Re: [FFmpeg-devel] [PATCH] Add vps/sps/pps id offset to hevc_metadata bsf

2020-01-08 Thread Eran Gonen
Yes. Fixing the identifier misprint

On Wed, Jan 8, 2020 at 5:52 PM Limin Wang  wrote:

> On Wed, Jan 08, 2020 at 05:20:07PM +0200, Eran Gonen wrote:
> > ---
> >  doc/bitstream_filters.texi |   5 ++
> >  libavcodec/h265_metadata_bsf.c | 106 +++--
> >  2 files changed, 105 insertions(+), 6 deletions(-)
> >
> > diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> > index 8fe5b3ad75..abd20e19d5 100644
> > --- a/doc/bitstream_filters.texi
> > +++ b/doc/bitstream_filters.texi
> > @@ -357,6 +357,11 @@ Set poc_proportional_to_timing_flag in VPS and VUI
> and use this value
> >  to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
> >  E.3.1).  Ignored if @option{tick_rate} is not also set.
> >
> > +@item vps_id_offset
> > +@item sps_id_offset
> > +@item pps_id_offset
> > +Replace the original VPS/SPS/PPS idenfier by increasing its value by
> the offset.
>
> idenfier -> identifier?
>
> > +
> >  @item crop_left
> >  @item crop_right
> >  @item crop_top
> > diff --git a/libavcodec/h265_metadata_bsf.c
> b/libavcodec/h265_metadata_bsf.c
> > index b3a1fda144..7aeb1bffd1 100644
> > --- a/libavcodec/h265_metadata_bsf.c
> > +++ b/libavcodec/h265_metadata_bsf.c
> > @@ -68,6 +68,10 @@ typedef struct H265MetadataContext {
> >  int level;
> >  int level_guess;
> >  int level_warned;
> > +
> > +int vps_id_offset;
> > +int sps_id_offset;
> > +int pps_id_offset;
> >  } H265MetadataContext;
> >
> >
> > @@ -168,6 +172,8 @@ static int h265_metadata_update_vps(AVBSFContext
> *bsf,
> >  {
> >  H265MetadataContext *ctx = bsf->priv_data;
> >
> > +vps->vps_video_parameter_set_id = (vps->vps_video_parameter_set_id
> + ctx->vps_id_offset) % HEVC_MAX_VPS_COUNT;
> > +
> >  if (ctx->tick_rate.num && ctx->tick_rate.den) {
> >  int num, den;
> >
> > @@ -200,6 +206,9 @@ static int h265_metadata_update_sps(AVBSFContext
> *bsf,
> >  int need_vui = 0;
> >  int crop_unit_x, crop_unit_y;
> >
> > +sps->sps_video_parameter_set_id = (sps->sps_video_parameter_set_id
> + ctx->vps_id_offset) % HEVC_MAX_VPS_COUNT;
> > +sps->sps_seq_parameter_set_id = (sps->sps_seq_parameter_set_id +
> ctx->sps_id_offset) % HEVC_MAX_SPS_COUNT;
> > +
> >  if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
> >  // Table E-1.
> >  static const AVRational sar_idc[] = {
> > @@ -336,6 +345,27 @@ static int h265_metadata_update_sps(AVBSFContext
> *bsf,
> >  return 0;
> >  }
> >
> > +static int h265_metadata_update_pps(AVBSFContext *bsf,
> > +H265RawPPS *pps)
> > +{
> > +H265MetadataContext *ctx = bsf->priv_data;
> > +
> > +pps->pps_seq_parameter_set_id = (pps->pps_seq_parameter_set_id +
> ctx->sps_id_offset) % HEVC_MAX_SPS_COUNT;
> > +pps->pps_pic_parameter_set_id = (pps->pps_pic_parameter_set_id +
> ctx->pps_id_offset) % HEVC_MAX_PPS_COUNT;
> > +
> > +return 0;
> > +}
> > +
> > +static int h265_metadata_update_slice_header(AVBSFContext *bsf,
> > +H265RawSliceHeader *slice)
> > +{
> > +H265MetadataContext *ctx = bsf->priv_data;
> > +
> > +slice->slice_pic_parameter_set_id =
> (slice->slice_pic_parameter_set_id + ctx->pps_id_offset) %
> HEVC_MAX_PPS_COUNT;
> > +
> > +return 0;
> > +}
> > +
> >  static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
> >  {
> >  H265MetadataContext *ctx = bsf->priv_data;
> > @@ -406,15 +436,42 @@ static int h265_metadata_filter(AVBSFContext *bsf,
> AVPacket *pkt)
> >  h265_metadata_guess_level(bsf, au);
> >
> >  for (i = 0; i < au->nb_units; i++) {
> > -if (au->units[i].type == HEVC_NAL_VPS) {
> > +switch (au->units[i].type) {
> > +case HEVC_NAL_VPS:
> >  err = h265_metadata_update_vps(bsf, au->units[i].content);
> >  if (err < 0)
> >  goto fail;
> > -}
> > -if (au->units[i].type == HEVC_NAL_SPS) {
> > +break;
> > +case HEVC_NAL_SPS:
> >  err = h265_metadata_update_sps(bsf, au->units[i].content);
> >  if (err < 0)
> >  goto fail;
> > +break;
> > +case HEVC_NAL_PPS:
> > +err = h265_metadata_update_pps(bsf, au->units[i].content);
> > +if (err < 0)
> > +goto fail;
> > +break;
> > +case HEVC_NAL_TRAIL_N:
> > +case HEVC_NAL_TRAIL_R:
> > +case HEVC_NAL_TSA_N:
> > +case HEVC_NAL_TSA_R:
> > +case HEVC_NAL_STSA_N:
> > +case HEVC_NAL_STSA_R:
> > +case HEVC_NAL_BLA_W_LP:
> > +case HEVC_NAL_BLA_W_RADL:
> > +case HEVC_NAL_BLA_N_LP:
> > +case HEVC_NAL_IDR_W_RADL:
> > +case HEVC_NAL_IDR_N_LP:
> > +case HEVC_NAL_CRA_NUT:
> > +case HEVC_NAL_RADL_N:
> > +case HEVC_NAL_RADL_R:
> > +case HEVC_NAL_RASL_N:
> > +case HEVC_NAL_RASL_R:
> > +err = 

[FFmpeg-devel] [PATCH v8 3/4] avfilter/vf_showinfo: display H.26[45] user data unregistered sei message

2020-01-08 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_showinfo.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 5fff123..fc24e29 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -23,6 +23,7 @@
  */
 
 #include 
+#include 
 
 #include "libavutil/bswap.h"
 #include "libavutil/adler32.h"
@@ -170,6 +171,39 @@ static void dump_content_light_metadata(AVFilterContext 
*ctx, AVFrameSideData *s
metadata->MaxCLL, metadata->MaxFALL);
 }
 
+static int string_is_print(const uint8_t *str)
+{
+while (isprint(*str)) str++;
+return !*str;
+}
+
+static void dump_sei_unregistered_metadata(AVFilterContext *ctx, 
AVFrameSideData *sd)
+{
+const int uuid_size = 16;
+uint8_t *user_data = sd->data;
+
+if (sd->size < uuid_size) {
+av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", 
sd->size, uuid_size);
+return;
+}
+
+av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
+av_log(ctx, AV_LOG_INFO, "UUID=");
+for (int i = 0; i < uuid_size; i++) {
+av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
+if (i == 3 || i == 5 || i == 7 || i == 9)
+av_log(ctx, AV_LOG_INFO, "-");
+}
+av_log(ctx, AV_LOG_INFO, "\n");
+
+user_data += uuid_size;
+/* Only print the user data details if it's string */
+if (string_is_print(user_data)) {
+av_log(ctx, AV_LOG_INFO, "User Data=");
+av_log(ctx, AV_LOG_INFO, "%s", user_data);
+}
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
 const char *color_range_str = av_color_range_name(frame->color_range);
@@ -347,6 +381,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 av_log(ctx, AV_LOG_INFO, "GOP timecode - %s", tcbuf);
 break;
 }
+case AV_FRAME_DATA_SEI_UNREGISTERED:
+dump_sei_unregistered_metadata(ctx, sd);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
sd->type, sd->size);
-- 
2.9.5

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

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

[FFmpeg-devel] [PATCH v8 2/4] avcodec/hevc_sei: add support for user data unregistered SEI message

2020-01-08 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/hevc_sei.c   | 31 +++
 libavcodec/hevc_sei.h   |  6 ++
 libavcodec/hevcdec.c| 14 ++
 tests/ref/fate/hevc-monochrome-crop |  3 +++
 4 files changed, 54 insertions(+)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 562ce8b..a7c49ce 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -207,6 +207,30 @@ static int 
decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetB
 return 0;
 }
 
+static int decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, 
GetBitContext *gb,
+  int size)
+{
+AVBufferRef *buf_ref, **tmp;
+
+if (size < 16)
+   return AVERROR(EINVAL);
+
+tmp = av_realloc_array(s->buf_ref, s->nb_buf_ref + 1, sizeof(*s->buf_ref));
+if (!tmp)
+return AVERROR(ENOMEM);
+s->buf_ref = tmp;
+
+buf_ref = av_buffer_alloc(size);
+if (!buf_ref)
+return AVERROR(ENOMEM);
+
+for (int i = 0; i < size; i++)
+buf_ref->data[i] = get_bits(gb, 8);
+s->buf_ref[s->nb_buf_ref++] = buf_ref;
+
+return 0;
+}
+
 static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, 
GetBitContext *gb,
  int size)
 {
@@ -294,6 +318,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void 
*logctx, HEVCSEI *s,
 return decode_nal_sei_active_parameter_sets(s, gb, logctx);
 case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
 return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, size);
+case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED:
+return decode_nal_sei_user_data_unregistered(>unregistered, gb, 
size);
 case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
 return decode_nal_sei_alternative_transfer(>alternative_transfer, 
gb);
 default:
@@ -365,4 +391,9 @@ int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, 
HEVCSEI *s,
 void ff_hevc_reset_sei(HEVCSEI *s)
 {
 av_buffer_unref(>a53_caption.buf_ref);
+
+for (int i = 0; i < s->unregistered.nb_buf_ref; i++)
+av_buffer_unref(>unregistered.buf_ref[i]);
+s->unregistered.nb_buf_ref = 0;
+av_freep(>unregistered.buf_ref);
 }
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 2769d41..a8a2ab7 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -86,6 +86,11 @@ typedef struct HEVCSEIA53Caption {
 AVBufferRef *buf_ref;
 } HEVCSEIA53Caption;
 
+typedef struct HEVCSEIUnregistered {
+AVBufferRef **buf_ref;
+int nb_buf_ref;
+} HEVCSEIUnregistered;
+
 typedef struct HEVCSEIMasteringDisplay {
 int present;
 uint16_t display_primaries[3][2];
@@ -111,6 +116,7 @@ typedef struct HEVCSEI {
 HEVCSEIDisplayOrientation display_orientation;
 HEVCSEIPictureTiming picture_timing;
 HEVCSEIA53Caption a53_caption;
+HEVCSEIUnregistered unregistered;
 HEVCSEIMasteringDisplay mastering_display;
 HEVCSEIContentLight content_light;
 int active_seq_parameter_set_id;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 19b0cd8..9d00c20 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2789,6 +2789,20 @@ static int set_side_data(HEVCContext *s)
 s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 }
 
+for (int i = 0; i < s->sei.unregistered.nb_buf_ref; i++) {
+HEVCSEIUnregistered *unreg = >sei.unregistered;
+
+if (unreg->buf_ref[i]) {
+AVFrameSideData *sd = av_frame_new_side_data_from_buf(out,
+AV_FRAME_DATA_SEI_UNREGISTERED,
+unreg->buf_ref[i]);
+if (!sd)
+av_buffer_unref(>buf_ref[i]);
+unreg->buf_ref[i] = NULL;
+}
+}
+s->sei.unregistered.nb_buf_ref = 0;
+
 return 0;
 }
 
diff --git a/tests/ref/fate/hevc-monochrome-crop 
b/tests/ref/fate/hevc-monochrome-crop
index 4e45412..384404d 100644
--- a/tests/ref/fate/hevc-monochrome-crop
+++ b/tests/ref/fate/hevc-monochrome-crop
@@ -1,6 +1,9 @@
 [FRAME]
 width=384
 height=240
+[SIDE_DATA]
+side_data_type=H.26[45] User Data Unregistered SEI message
+[/SIDE_DATA]
 [/FRAME]
 [STREAM]
 width=384
-- 
2.9.5

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

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

Re: [FFmpeg-devel] [PATCH] Add vps/sps/pps id offset to hevc_metadata bsf

2020-01-08 Thread Limin Wang
On Wed, Jan 08, 2020 at 05:20:07PM +0200, Eran Gonen wrote:
> ---
>  doc/bitstream_filters.texi |   5 ++
>  libavcodec/h265_metadata_bsf.c | 106 +++--
>  2 files changed, 105 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> index 8fe5b3ad75..abd20e19d5 100644
> --- a/doc/bitstream_filters.texi
> +++ b/doc/bitstream_filters.texi
> @@ -357,6 +357,11 @@ Set poc_proportional_to_timing_flag in VPS and VUI and 
> use this value
>  to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
>  E.3.1).  Ignored if @option{tick_rate} is not also set.
>  
> +@item vps_id_offset
> +@item sps_id_offset
> +@item pps_id_offset
> +Replace the original VPS/SPS/PPS idenfier by increasing its value by the 
> offset.

idenfier -> identifier?

> +
>  @item crop_left
>  @item crop_right
>  @item crop_top
> diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
> index b3a1fda144..7aeb1bffd1 100644
> --- a/libavcodec/h265_metadata_bsf.c
> +++ b/libavcodec/h265_metadata_bsf.c
> @@ -68,6 +68,10 @@ typedef struct H265MetadataContext {
>  int level;
>  int level_guess;
>  int level_warned;
> +
> +int vps_id_offset;
> +int sps_id_offset;
> +int pps_id_offset;
>  } H265MetadataContext;
>  
>  
> @@ -168,6 +172,8 @@ static int h265_metadata_update_vps(AVBSFContext *bsf,
>  {
>  H265MetadataContext *ctx = bsf->priv_data;
>  
> +vps->vps_video_parameter_set_id = (vps->vps_video_parameter_set_id + 
> ctx->vps_id_offset) % HEVC_MAX_VPS_COUNT;
> +
>  if (ctx->tick_rate.num && ctx->tick_rate.den) {
>  int num, den;
>  
> @@ -200,6 +206,9 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
>  int need_vui = 0;
>  int crop_unit_x, crop_unit_y;
>  
> +sps->sps_video_parameter_set_id = (sps->sps_video_parameter_set_id + 
> ctx->vps_id_offset) % HEVC_MAX_VPS_COUNT;
> +sps->sps_seq_parameter_set_id = (sps->sps_seq_parameter_set_id + 
> ctx->sps_id_offset) % HEVC_MAX_SPS_COUNT;
> +
>  if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
>  // Table E-1.
>  static const AVRational sar_idc[] = {
> @@ -336,6 +345,27 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
>  return 0;
>  }
>  
> +static int h265_metadata_update_pps(AVBSFContext *bsf,
> +H265RawPPS *pps)
> +{
> +H265MetadataContext *ctx = bsf->priv_data;
> +
> +pps->pps_seq_parameter_set_id = (pps->pps_seq_parameter_set_id + 
> ctx->sps_id_offset) % HEVC_MAX_SPS_COUNT;
> +pps->pps_pic_parameter_set_id = (pps->pps_pic_parameter_set_id + 
> ctx->pps_id_offset) % HEVC_MAX_PPS_COUNT;
> +
> +return 0;
> +}
> +
> +static int h265_metadata_update_slice_header(AVBSFContext *bsf,
> +H265RawSliceHeader *slice)
> +{
> +H265MetadataContext *ctx = bsf->priv_data;
> +
> +slice->slice_pic_parameter_set_id = (slice->slice_pic_parameter_set_id + 
> ctx->pps_id_offset) % HEVC_MAX_PPS_COUNT;
> +
> +return 0;
> +}
> +
>  static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
>  {
>  H265MetadataContext *ctx = bsf->priv_data;
> @@ -406,15 +436,42 @@ static int h265_metadata_filter(AVBSFContext *bsf, 
> AVPacket *pkt)
>  h265_metadata_guess_level(bsf, au);
>  
>  for (i = 0; i < au->nb_units; i++) {
> -if (au->units[i].type == HEVC_NAL_VPS) {
> +switch (au->units[i].type) {
> +case HEVC_NAL_VPS:
>  err = h265_metadata_update_vps(bsf, au->units[i].content);
>  if (err < 0)
>  goto fail;
> -}
> -if (au->units[i].type == HEVC_NAL_SPS) {
> +break;
> +case HEVC_NAL_SPS:
>  err = h265_metadata_update_sps(bsf, au->units[i].content);
>  if (err < 0)
>  goto fail;
> +break;
> +case HEVC_NAL_PPS:
> +err = h265_metadata_update_pps(bsf, au->units[i].content);
> +if (err < 0)
> +goto fail;
> +break;
> +case HEVC_NAL_TRAIL_N:
> +case HEVC_NAL_TRAIL_R:
> +case HEVC_NAL_TSA_N:
> +case HEVC_NAL_TSA_R:
> +case HEVC_NAL_STSA_N:
> +case HEVC_NAL_STSA_R:
> +case HEVC_NAL_BLA_W_LP:
> +case HEVC_NAL_BLA_W_RADL:
> +case HEVC_NAL_BLA_N_LP:
> +case HEVC_NAL_IDR_W_RADL:
> +case HEVC_NAL_IDR_N_LP:
> +case HEVC_NAL_CRA_NUT:
> +case HEVC_NAL_RADL_N:
> +case HEVC_NAL_RADL_R:
> +case HEVC_NAL_RASL_N:
> +case HEVC_NAL_RASL_R:
> +err = h265_metadata_update_slice_header(bsf, 
> au->units[i].content);
> +if (err < 0)
> +goto fail;
> +break;
>  }
>  }
>  
> @@ -455,15 +512,42 @@ static int h265_metadata_init(AVBSFContext *bsf)
>  h265_metadata_guess_level(bsf, au);
>  
>  for (i = 0; i < au->nb_units; i++) 

[FFmpeg-devel] [PATCH v8 4/4] avcodec/h264: create user data unregistered SEI side data for H.264

2020-01-08 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/h264_sei.c |  30 +--
 libavcodec/h264_sei.h |   2 +
 libavcodec/h264_slice.c   |  14 
 tests/ref/fate/mov-zombie | 195 ++
 4 files changed, 171 insertions(+), 70 deletions(-)

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index a565fea..f72c48c 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -24,6 +24,7 @@
  * H.264 / AVC / MPEG-4 part10 SEI decoding.
  * @author Michael Niedermayer 
  */
+#include 
 
 #include "avcodec.h"
 #include "get_bits.h"
@@ -52,6 +53,10 @@ void ff_h264_sei_uninit(H264SEIContext *h)
 h->afd.present =  0;
 
 av_buffer_unref(>a53_caption.buf_ref);
+for (int i = 0; i < h->unregistered.nb_buf_ref; i++)
+av_buffer_unref(>unregistered.buf_ref[i]);
+h->unregistered.nb_buf_ref = 0;
+av_freep(>unregistered.buf_ref);
 }
 
 static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext *gb,
@@ -241,30 +246,45 @@ static int decode_registered_user_data(H264SEIContext *h, 
GetBitContext *gb,
 return 0;
 }
 
+static int string_is_print(const uint8_t *str)
+{
+while (isprint(*str)) str++;
+return !*str;
+}
+
 static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext 
*gb,
  void *logctx, int size)
 {
 uint8_t *user_data;
 int e, build, i;
+AVBufferRef *buf_ref, **tmp;
 
-if (size < 16 || size >= INT_MAX - 1)
+if (size < 16)
 return AVERROR_INVALIDDATA;
 
-user_data = av_malloc(size + 1);
-if (!user_data)
+tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref));
+if (!tmp)
 return AVERROR(ENOMEM);
+h->buf_ref = tmp;
+
+buf_ref = av_buffer_alloc(size);
+if (!buf_ref)
+return AVERROR(ENOMEM);
+user_data = buf_ref->data;
 
 for (i = 0; i < size; i++)
 user_data[i] = get_bits(gb, 8);
+h->buf_ref[h->nb_buf_ref++] = buf_ref;
+
+if (!string_is_print(user_data + 16))
+return 0;
 
-user_data[i] = 0;
 e = sscanf(user_data + 16, "x264 - core %d", );
 if (e == 1 && build > 0)
 h->x264_build = build;
 if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core ", 16))
 h->x264_build = 67;
 
-av_free(user_data);
 return 0;
 }
 
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index a75c3aa..aa4595f 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -121,6 +121,8 @@ typedef struct H264SEIA53Caption {
 
 typedef struct H264SEIUnregistered {
 int x264_build;
+AVBufferRef **buf_ref;
+int nb_buf_ref;
 } H264SEIUnregistered;
 
 typedef struct H264SEIRecoveryPoint {
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index e24d41c..ac4b11e 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1285,6 +1285,20 @@ static int h264_export_frame_props(H264Context *h)
 h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 }
 
+for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) {
+H264SEIUnregistered *unreg = >sei.unregistered;
+
+if (unreg->buf_ref[i]) {
+AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f,
+AV_FRAME_DATA_SEI_UNREGISTERED,
+unreg->buf_ref[i]);
+if (!sd)
+av_buffer_unref(>buf_ref[i]);
+unreg->buf_ref[i] = NULL;
+}
+}
+h->sei.unregistered.nb_buf_ref = 0;
+
 if (h->sei.picture_timing.timecode_cnt > 0) {
 uint32_t tc = 0;
 uint32_t *tc_sd;
diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie
index f45fa59..5c58246 100644
--- a/tests/ref/fate/mov-zombie
+++ b/tests/ref/fate/mov-zombie
@@ -1,133 +1,198 @@
 
packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4133|pos=11309|flags=K_
 
packet|codec_type=video|stream_index=0|pts=5440|pts_time=0.060444|dts=-567|dts_time=-0.006300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1077|pos=15442|flags=__
-frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.00|pkt_dts=-567|pkt_dts_time=-0.006300|best_effort_timestamp=0|best_effort_timestamp_time=0.00|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=11309|pkt_size=4133|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleft

[FFmpeg-devel] [PATCH v8 1/4] avutil: add AV_FRAME_DATA_SEI_UNREGISTERED side data type

2020-01-08 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/APIchanges  | 3 +++
 libavutil/frame.c   | 1 +
 libavutil/frame.h   | 8 
 libavutil/version.h | 2 +-
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 3c24dc6..8af9005 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-01-xx - xx - lavu 56.39.100 - frame.h
+  Add AV_FRAME_DATA_SEI_UNREGISTERED.
+
 2019-12-27 - xx - lavu 56.38.100 - eval.h
   Add av_expr_count_func().
 
diff --git a/libavutil/frame.c b/libavutil/frame.c
index e403809..ce5ff8e 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -842,6 +842,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 #endif
 case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata 
SMPTE2094-40 (HDR10+)";
 case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest";
+case AV_FRAME_DATA_SEI_UNREGISTERED: return "H.26[45] User Data 
Unregistered SEI message";
 }
 return NULL;
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index b5afb58..c16d040 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -179,6 +179,14 @@ enum AVFrameSideDataType {
  * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.
  */
 AV_FRAME_DATA_REGIONS_OF_INTEREST,
+
+/**
+ * User data unregistered metadata associated with a video frame.
+ * This is the H.26[45] UDU SEI message, and shouldn't be used for any 
other purpose
+ * The data is stored as uint8_t in AVFrameSideData.data which is 16 bytes 
of
+ * uuid_iso_iec_11578 followed by AVFrameSideData.size-16 bytes of 
user_data_payload_byte.
+ */
+AV_FRAME_DATA_SEI_UNREGISTERED,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/version.h b/libavutil/version.h
index af8f614..2bc1b98 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  38
+#define LIBAVUTIL_VERSION_MINOR  39
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.9.5

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

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

[FFmpeg-devel] [PATCH] Add vps/sps/pps id offset to hevc_metadata bsf

2020-01-08 Thread Eran Gonen
---
 doc/bitstream_filters.texi |   5 ++
 libavcodec/h265_metadata_bsf.c | 106 +++--
 2 files changed, 105 insertions(+), 6 deletions(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 8fe5b3ad75..abd20e19d5 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -357,6 +357,11 @@ Set poc_proportional_to_timing_flag in VPS and VUI and use 
this value
 to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
 E.3.1).  Ignored if @option{tick_rate} is not also set.
 
+@item vps_id_offset
+@item sps_id_offset
+@item pps_id_offset
+Replace the original VPS/SPS/PPS idenfier by increasing its value by the 
offset.
+
 @item crop_left
 @item crop_right
 @item crop_top
diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index b3a1fda144..7aeb1bffd1 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -68,6 +68,10 @@ typedef struct H265MetadataContext {
 int level;
 int level_guess;
 int level_warned;
+
+int vps_id_offset;
+int sps_id_offset;
+int pps_id_offset;
 } H265MetadataContext;
 
 
@@ -168,6 +172,8 @@ static int h265_metadata_update_vps(AVBSFContext *bsf,
 {
 H265MetadataContext *ctx = bsf->priv_data;
 
+vps->vps_video_parameter_set_id = (vps->vps_video_parameter_set_id + 
ctx->vps_id_offset) % HEVC_MAX_VPS_COUNT;
+
 if (ctx->tick_rate.num && ctx->tick_rate.den) {
 int num, den;
 
@@ -200,6 +206,9 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
 int need_vui = 0;
 int crop_unit_x, crop_unit_y;
 
+sps->sps_video_parameter_set_id = (sps->sps_video_parameter_set_id + 
ctx->vps_id_offset) % HEVC_MAX_VPS_COUNT;
+sps->sps_seq_parameter_set_id = (sps->sps_seq_parameter_set_id + 
ctx->sps_id_offset) % HEVC_MAX_SPS_COUNT;
+
 if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
 // Table E-1.
 static const AVRational sar_idc[] = {
@@ -336,6 +345,27 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
 return 0;
 }
 
+static int h265_metadata_update_pps(AVBSFContext *bsf,
+H265RawPPS *pps)
+{
+H265MetadataContext *ctx = bsf->priv_data;
+
+pps->pps_seq_parameter_set_id = (pps->pps_seq_parameter_set_id + 
ctx->sps_id_offset) % HEVC_MAX_SPS_COUNT;
+pps->pps_pic_parameter_set_id = (pps->pps_pic_parameter_set_id + 
ctx->pps_id_offset) % HEVC_MAX_PPS_COUNT;
+
+return 0;
+}
+
+static int h265_metadata_update_slice_header(AVBSFContext *bsf,
+H265RawSliceHeader *slice)
+{
+H265MetadataContext *ctx = bsf->priv_data;
+
+slice->slice_pic_parameter_set_id = (slice->slice_pic_parameter_set_id + 
ctx->pps_id_offset) % HEVC_MAX_PPS_COUNT;
+
+return 0;
+}
+
 static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
 {
 H265MetadataContext *ctx = bsf->priv_data;
@@ -406,15 +436,42 @@ static int h265_metadata_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 h265_metadata_guess_level(bsf, au);
 
 for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == HEVC_NAL_VPS) {
+switch (au->units[i].type) {
+case HEVC_NAL_VPS:
 err = h265_metadata_update_vps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
-}
-if (au->units[i].type == HEVC_NAL_SPS) {
+break;
+case HEVC_NAL_SPS:
 err = h265_metadata_update_sps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
+break;
+case HEVC_NAL_PPS:
+err = h265_metadata_update_pps(bsf, au->units[i].content);
+if (err < 0)
+goto fail;
+break;
+case HEVC_NAL_TRAIL_N:
+case HEVC_NAL_TRAIL_R:
+case HEVC_NAL_TSA_N:
+case HEVC_NAL_TSA_R:
+case HEVC_NAL_STSA_N:
+case HEVC_NAL_STSA_R:
+case HEVC_NAL_BLA_W_LP:
+case HEVC_NAL_BLA_W_RADL:
+case HEVC_NAL_BLA_N_LP:
+case HEVC_NAL_IDR_W_RADL:
+case HEVC_NAL_IDR_N_LP:
+case HEVC_NAL_CRA_NUT:
+case HEVC_NAL_RADL_N:
+case HEVC_NAL_RADL_R:
+case HEVC_NAL_RASL_N:
+case HEVC_NAL_RASL_R:
+err = h265_metadata_update_slice_header(bsf, au->units[i].content);
+if (err < 0)
+goto fail;
+break;
 }
 }
 
@@ -455,15 +512,42 @@ static int h265_metadata_init(AVBSFContext *bsf)
 h265_metadata_guess_level(bsf, au);
 
 for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == HEVC_NAL_VPS) {
+switch (au->units[i].type) {
+case HEVC_NAL_VPS:
 err = h265_metadata_update_vps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
-}
-if (au->units[i].type == HEVC_NAL_SPS) {
+break;
+

Re: [FFmpeg-devel] [PATCH] avfilter/mpegaudiodec_template: Fix wrong decision of illegal

2020-01-08 Thread Moritz Barsnick
On Wed, Jan 08, 2020 at 16:32:39 +0900, Ted Lee wrote:
> Dear FFmpeg developers,
> I'm glad to have a chance to contribute to FFmpeg.

Welcome.

> *Summary:*
>
>- Test signal: 790_pomnyun_taebaek2.mp3
>   - MP3 file with the same left channel and right channel except for
>   the first 7 seconds and the last 10 seconds.
>   (download:
>   
> 
>   https://www.dropbox.com/s/sivz18sixvhoo66/790_pomnyun_taebaek2.mp3?dl=0
>   )
>- When decoding the test signal using FFmpeg as below, a difference
>occurs in the same part of L and R.
>   - $ffmpeg -i 790_pomnyun_taebaek2.mp3 -acodec pcm_s16le
>   790_pomnyun_taebaek2.wav
>
>
> Expected result (Adobe Audition or Core Audio):
>
> Decoded PCM
> [image: image.png]
> (L-R)
> [image: image.png]
> (You can reproduce it using Adobe Audition or CoreAudio of MacOS)
>
> Actual result (FFmpeg):
>
> Decoded PCM
> [image: image.png]
>
> (L-R)
> [image: image.png]

To put it in other words:
You expect the monoaural section of this file to be decoded with
identical left and right channels. ffmpeg does not achieve this. In
fact, there seem to be ~50 dB too much "noise".

[See mean/max_volume results below, before and after subtraction.]

Original ffmpeg:
barsnick@sunshine:/usr/new/tools/video/ffmpeg/ffmpeg-snapshot-2020-01-05 > 
../ffmpeg-build-2020-01-05/ffmpeg_g -ss 10 -t 10:00 -i 
~/tmp/790_pomnyun_taebaek2.mp3 -af 
volumedetect,"pan=mono|c0=c0-c1",volumedetect -f null -
[...]
[Parsed_volumedetect_0 @ 0xa5bb380] n_samples: 2646
[Parsed_volumedetect_0 @ 0xa5bb380] mean_volume: -25.1 dB
[Parsed_volumedetect_0 @ 0xa5bb380] max_volume: 0.0 dB
[Parsed_volumedetect_0 @ 0xa5bb380] histogram_0db: 594
[Parsed_volumedetect_0 @ 0xa5bb380] histogram_1db: 671
[Parsed_volumedetect_0 @ 0xa5bb380] histogram_2db: 1033
[Parsed_volumedetect_0 @ 0xa5bb380] histogram_3db: 1794
[Parsed_volumedetect_0 @ 0xa5bb380] histogram_4db: 3067
[Parsed_volumedetect_0 @ 0xa5bb380] histogram_5db: 4940
[Parsed_volumedetect_0 @ 0xa5bb380] histogram_6db: 7871
[Parsed_volumedetect_0 @ 0xa5bb380] histogram_7db: 12062
[Parsed_volumedetect_2 @ 0xa5c3b40] n_samples: 1323
[Parsed_volumedetect_2 @ 0xa5c3b40] mean_volume: -41.2 dB
[Parsed_volumedetect_2 @ 0xa5c3b40] max_volume: -15.5 dB
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_15db: 29
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_16db: 154
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_17db: 159
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_18db: 308
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_19db: 627
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_20db: 1130
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_21db: 1932
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_22db: 3433
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_23db: 5099
[Parsed_volumedetect_2 @ 0xa5c3b40] histogram_24db: 8002

I can at least confirm that other decoders achieve a better equality.
Using mpg321 with libmad-0.15.1b (to convert to wav and analyze with
ffmpeg), I get:

[Parsed_volumedetect_0 @ 0xbe50d00] n_samples: 2646
[Parsed_volumedetect_0 @ 0xbe50d00] mean_volume: -26.9 dB
[Parsed_volumedetect_0 @ 0xbe50d00] max_volume: -0.1 dB
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_0db: 186
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_1db: 310
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_2db: 556
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_3db: 866
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_4db: 1354
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_5db: 2158
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_6db: 3680
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_7db: 6260
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_8db: 8990
[Parsed_volumedetect_0 @ 0xbe50d00] histogram_9db: 13236
[Parsed_volumedetect_2 @ 0xbe4c180] n_samples: 1323
[Parsed_volumedetect_2 @ 0xbe4c180] mean_volume: -85.5 dB
[Parsed_volumedetect_2 @ 0xbe4c180] max_volume: -62.7 dB
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_62db: 1
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_63db: 9
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_64db: 13
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_65db: 26
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_66db: 37
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_67db: 35
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_68db: 68
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_69db: 54
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_70db: 73
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_71db: 86
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_72db: 118
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_73db: 340
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_74db: 9490
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_75db: 0
[Parsed_volumedetect_2 @ 0xbe4c180] histogram_76db: 105618

With your patch, ffmpeg achieves this (very similar for both mp3 and
mp3float), which is even closer to identity:

[Parsed_volumedetect_0 @ 0xa6e3380] n_samples: 2646
[Parsed_volumedetect_0 @ 0xa6e3380] 

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Eran Gonen
Thanks for your feedback.

@item vps_id_offset
@item sps_id_offset
@item pps_id_offset
Replace the original VPS/SPS/PPS identifier by adding an offset.

Offset sounds just as good to me. Is this clear?

On Wed, Jan 8, 2020 at 4:46 PM Moritz Barsnick  wrote:

> On Wed, Jan 08, 2020 at 15:42:09 +0100, Anton Khirnov wrote:
> > If negative values are allowed, then 'offset' would be more accurate.
>
> That's the word I was looking for, nice. Even valid if only positive
> offsets are allowed. (I understand you implemented wrap-around. Perhaps
> sufficient to write that in the documentation. Or implement both
> directions. ;-))
>
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v6] avformat/mov: Memory optimization with QuickTime/MP4

2020-01-08 Thread Jörg Beckmann
> -Ursprüngliche Nachricht-
> Von: ffmpeg-devel  Im Auftrag von Moritz
> Barsnick
> Gesendet: Mittwoch, 8. Januar 2020 15:25
> An: FFmpeg development discussions and patches 
> Betreff: [SCISYS Possible Spam] Re: [FFmpeg-devel] [PATCH v6] avformat/mov:
> Memory optimization with QuickTime/MP4
> 
> On Wed, Jan 08, 2020 at 13:26:35 +, Jörg Beckmann wrote:
> > Invents a new option "discard_fragments" for the MP4/Quicktime/MOV decoder.
> 
> Strictly speaking, it's a demuxer and not a decoder. ;-)
> 
> > If this option is set to "on", old fragments are discarded as far as
> > possible on each call to switch_root(). If set to "off", nothing
> > changes at all. If set to "auto" (the default), this function is
> > turned on for streams containing only audio.
> 
> Since it's new option, and possibly even a behavioral change, I suggest 
> bumping
> libavformat's MICRO version with the same commit.
> 
> > +{ "discard_fragments", "Discard fragments after they have been read to
> support live streams.", OFFSET(discard_fragments),
> > +AV_OPT_TYPE_INT, { .i64 = MOV_DISCARD_AUTO },
> MOV_DISCARD_AUTO, MOV_DISCARD_ON, FLAGS, "discard_fragments"},
> > +{ "auto", "Switch on for audio only streams", 0, AV_OPT_TYPE_CONST,
> {.i64 = MOV_DISCARD_AUTO}, INT_MIN, INT_MAX, FLAGS, "discard_fragments"
> },
> > +{ "off",  "Switch off",   0, 
> > AV_OPT_TYPE_CONST, {.i64 =
> MOV_DISCARD_OFF},  INT_MIN, INT_MAX, FLAGS, "discard_fragments" },
> > +{ "on",   "Switch on",0, 
> > AV_OPT_TYPE_CONST, {.i64 =
> MOV_DISCARD_ON},   INT_MIN, INT_MAX, FLAGS, "discard_fragments" },
> >  { NULL },
> 
> I would have suggest you add documentation to doc/demuxers.texi, but since
> most of mov's options don't seem to be documented there...
> *sigh*.

I'll write some documentation when the patch is applied eventually. I just 
don't want to write it more than once. And this version of the patch changed 
the options as suggested by Carl Eugen.

> Moritz

Jörg

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

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Moritz Barsnick
On Wed, Jan 08, 2020 at 15:42:09 +0100, Anton Khirnov wrote:
> If negative values are allowed, then 'offset' would be more accurate.

That's the word I was looking for, nice. Even valid if only positive
offsets are allowed. (I understand you implemented wrap-around. Perhaps
sufficient to write that in the documentation. Or implement both
directions. ;-))

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

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Eran Gonen
It's limited to [0 - 16] (positive)

On Wed, Jan 8, 2020 at 4:42 PM Anton Khirnov  wrote:

> Quoting Eran Gonen (2020-01-08 15:25:20)
> > I will fix the style and documentation and resubmit.
> > { "increase_vps_id", "Increase the vps id",
> > Is this naming more clear to you?
>
> If negative values are allowed, then 'offset' would be more accurate.
>
> --
> Anton Khirnov
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Moritz Barsnick
On Wed, Jan 08, 2020 at 16:25:20 +0200, Eran Gonen wrote:
> { "increase_vps_id", "Increase the vps id",
> Is this naming more clear to you?

If that's what it does, then this is indeed clearer to me.

But since it's not boolean, it's a number, it should perhaps reflect
that. I can't come up with something good, but perhaps: "amount to
increase the VPS ID by" or something like this.

Sorry for nitpicking,Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Anton Khirnov
Quoting Eran Gonen (2020-01-08 15:25:20)
> I will fix the style and documentation and resubmit.
> { "increase_vps_id", "Increase the vps id",
> Is this naming more clear to you?

If negative values are allowed, then 'offset' would be more accurate.

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

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

Re: [FFmpeg-devel] [PATCH v6] avformat/mov: Memory optimization with QuickTime/MP4

2020-01-08 Thread Moritz Barsnick
On Wed, Jan 08, 2020 at 13:26:35 +, Jörg Beckmann wrote:
> Invents a new option "discard_fragments" for the MP4/Quicktime/MOV decoder.

Strictly speaking, it's a demuxer and not a decoder. ;-)

> If this option is set to "on", old fragments are discarded as far as possible
> on each call to switch_root(). If set to "off", nothing changes at all. If set
> to "auto" (the default), this function is turned on for streams containing
> only audio.

Since it's new option, and possibly even a behavioral change, I suggest
bumping libavformat's MICRO version with the same commit.

> +{ "discard_fragments", "Discard fragments after they have been read to 
> support live streams.", OFFSET(discard_fragments),
> +AV_OPT_TYPE_INT, { .i64 = MOV_DISCARD_AUTO }, MOV_DISCARD_AUTO, 
> MOV_DISCARD_ON, FLAGS, "discard_fragments"},
> +{ "auto", "Switch on for audio only streams", 0, AV_OPT_TYPE_CONST, 
> {.i64 = MOV_DISCARD_AUTO}, INT_MIN, INT_MAX, FLAGS, "discard_fragments" },
> +{ "off",  "Switch off",   0, AV_OPT_TYPE_CONST, 
> {.i64 = MOV_DISCARD_OFF},  INT_MIN, INT_MAX, FLAGS, "discard_fragments" },
> +{ "on",   "Switch on",0, AV_OPT_TYPE_CONST, 
> {.i64 = MOV_DISCARD_ON},   INT_MIN, INT_MAX, FLAGS, "discard_fragments" },
>  { NULL },

I would have suggest you add documentation to doc/demuxers.texi, but
since most of mov's options don't seem to be documented there...
*sigh*.

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

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Eran Gonen
I will fix the style and documentation and resubmit.
{ "increase_vps_id", "Increase the vps id",
Is this naming more clear to you?

On Wed, Jan 8, 2020 at 4:18 PM Moritz Barsnick  wrote:

> On Wed, Jan 08, 2020 at 16:10:12 +0200, Eran Gonen wrote:
> > Advance pps id means advance pps id. What would you suggest?
>
> You mean, mathematically speaking, "increase"?
>
> You didn't fix the "if(" -> "if (" style isse.
>
> And as Hendrik mentioned (I missed that originally): The
> "hevc_metadata" section in doc/bitstream_filters.texi needs to be
> amended.
>
> Cheers,
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Moritz Barsnick
On Wed, Jan 08, 2020 at 16:10:12 +0200, Eran Gonen wrote:
> Advance pps id means advance pps id. What would you suggest?

You mean, mathematically speaking, "increase"?

You didn't fix the "if(" -> "if (" style isse.

And as Hendrik mentioned (I missed that originally): The
"hevc_metadata" section in doc/bitstream_filters.texi needs to be
amended.

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

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Eran Gonen
It would, I'll change it.

Thanks,
Eran

On Wed, Jan 8, 2020 at 3:32 PM Andreas Rheinhardt <
andreas.rheinha...@gmail.com> wrote:

> On Wed, Jan 8, 2020 at 2:18 PM Eran Gonen 
> wrote:
>
> > ---
> >  libavcodec/h265_metadata_bsf.c | 117 +++--
> >  1 file changed, 111 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavcodec/h265_metadata_bsf.c
> > b/libavcodec/h265_metadata_bsf.c
> > index b3a1fda144..796046ac7f 100644
> > --- a/libavcodec/h265_metadata_bsf.c
> > +++ b/libavcodec/h265_metadata_bsf.c
> > @@ -68,6 +68,10 @@ typedef struct H265MetadataContext {
> >  int level;
> >  int level_guess;
> >  int level_warned;
> > +
> > +int advance_vps_id;
> > +int advance_sps_id;
> > +int advance_pps_id;
> >  } H265MetadataContext;
> >
> >
> > @@ -168,6 +172,10 @@ static int h265_metadata_update_vps(AVBSFContext
> *bsf,
> >  {
> >  H265MetadataContext *ctx = bsf->priv_data;
> >
> > +if(ctx->advance_vps_id > -1) {
> > +vps->vps_video_parameter_set_id =
> > (vps->vps_video_parameter_set_id + ctx->advance_vps_id) %
> > HEVC_MAX_VPS_COUNT;
> > +}
> > +
> >  if (ctx->tick_rate.num && ctx->tick_rate.den) {
> >  int num, den;
> >
> > @@ -200,6 +208,13 @@ static int h265_metadata_update_sps(AVBSFContext
> *bsf,
> >  int need_vui = 0;
> >  int crop_unit_x, crop_unit_y;
> >
> > +if(ctx->advance_vps_id > -1) {
> > +sps->sps_video_parameter_set_id =
> > (sps->sps_video_parameter_set_id + ctx->advance_vps_id) %
> > HEVC_MAX_VPS_COUNT;
> > +}
> > +if(ctx->advance_sps_id > -1) {
> > +sps->sps_seq_parameter_set_id = (sps->sps_seq_parameter_set_id +
> > ctx->advance_sps_id) % HEVC_MAX_SPS_COUNT;
> > +}
> > +
> >  if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
> >  // Table E-1.
> >  static const AVRational sar_idc[] = {
> > @@ -336,6 +351,32 @@ static int h265_metadata_update_sps(AVBSFContext
> *bsf,
> >  return 0;
> >  }
> >
> > +static int h265_metadata_update_pps(AVBSFContext *bsf,
> > +H265RawPPS *pps)
> > +{
> > +H265MetadataContext *ctx = bsf->priv_data;
> > +
> > +if(ctx->advance_sps_id > -1) {
> > +pps->pps_seq_parameter_set_id = (pps->pps_seq_parameter_set_id +
> > ctx->advance_sps_id) % HEVC_MAX_SPS_COUNT;
> > +}
> > +if(ctx->advance_pps_id > -1) {
> > +pps->pps_pic_parameter_set_id = (pps->pps_pic_parameter_set_id +
> > ctx->advance_pps_id) % HEVC_MAX_PPS_COUNT;
> > +}
> > +
> > +return 0;
> > +}
> > +
> > +static int h265_metadata_update_slice_header(AVBSFContext *bsf,
> > +H265RawSliceHeader *slice)
> > +{
> > +H265MetadataContext *ctx = bsf->priv_data;
> > +
> > +if(ctx->advance_pps_id > -1) {
> > +slice->slice_pic_parameter_set_id =
> > (slice->slice_pic_parameter_set_id + ctx->advance_pps_id) %
> > HEVC_MAX_PPS_COUNT;
> > +}
> > +return 0;
> > +}
> > +
> >  static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
> >  {
> >  H265MetadataContext *ctx = bsf->priv_data;
> > @@ -406,15 +447,42 @@ static int h265_metadata_filter(AVBSFContext *bsf,
> > AVPacket *pkt)
> >  h265_metadata_guess_level(bsf, au);
> >
> >  for (i = 0; i < au->nb_units; i++) {
> > -if (au->units[i].type == HEVC_NAL_VPS) {
> > +switch (au->units[i].type) {
> > +case HEVC_NAL_VPS:
> >  err = h265_metadata_update_vps(bsf, au->units[i].content);
> >  if (err < 0)
> >  goto fail;
> > -}
> > -if (au->units[i].type == HEVC_NAL_SPS) {
> > +break;
> > +case HEVC_NAL_SPS:
> >  err = h265_metadata_update_sps(bsf, au->units[i].content);
> >  if (err < 0)
> >  goto fail;
> > +break;
> > +case HEVC_NAL_PPS:
> > +err = h265_metadata_update_pps(bsf, au->units[i].content);
> > +if (err < 0)
> > +goto fail;
> > +break;
> > +case HEVC_NAL_TRAIL_N:
> > +case HEVC_NAL_TRAIL_R:
> > +case HEVC_NAL_TSA_N:
> > +case HEVC_NAL_TSA_R:
> > +case HEVC_NAL_STSA_N:
> > +case HEVC_NAL_STSA_R:
> > +case HEVC_NAL_BLA_W_LP:
> > +case HEVC_NAL_BLA_W_RADL:
> > +case HEVC_NAL_BLA_N_LP:
> > +case HEVC_NAL_IDR_W_RADL:
> > +case HEVC_NAL_IDR_N_LP:
> > +case HEVC_NAL_CRA_NUT:
> > +case HEVC_NAL_RADL_N:
> > +case HEVC_NAL_RADL_R:
> > +case HEVC_NAL_RASL_N:
> > +case HEVC_NAL_RASL_R:
> > +err = h265_metadata_update_slice_header(bsf,
> > au->units[i].content);
> > +if (err < 0)
> > +goto fail;
> > +break;
> >  }
> >  }
> >
> > @@ -455,15 +523,42 @@ static int h265_metadata_init(AVBSFContext *bsf)
> >  h265_metadata_guess_level(bsf, au);
> >
> >  for (i = 0; i < 

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Eran Gonen
Advance pps id means advance pps id. What would you suggest?

On Wed, Jan 8, 2020 at 4:04 PM Hendrik Leppkes  wrote:

> On Wed, Jan 8, 2020 at 2:18 PM Eran Gonen 
> wrote:
> > @@ -547,6 +642,16 @@ static const AVOption h265_metadata_options[] = {
> >  OFFSET(crop_bottom), AV_OPT_TYPE_INT,
> >  { .i64 = -1 }, -1, HEVC_MAX_HEIGHT, FLAGS },
> >
> > +{ "advance_vps_id", "Advance the vps id",
> > +OFFSET(advance_vps_id), AV_OPT_TYPE_INT,
> > +{ .i64 = -1 }, -1, HEVC_MAX_VPS_COUNT, FLAGS },
> > +{  "advance_sps_id", "Advance the sps id",
> > +OFFSET(advance_sps_id), AV_OPT_TYPE_INT,
> > +{ .i64 = -1 }, -1, HEVC_MAX_SPS_COUNT, FLAGS },
> > +{  "advance_pps_id", "Advance the pps id",
> > +OFFSET(advance_pps_id), AV_OPT_TYPE_INT,
> > +{ .i64 = -1 }, -1, HEVC_MAX_PPS_COUNT, FLAGS },
> > +
>
> I think these could use some better wording and/or documentation, I'm
> not sure many people would understand whats going to happen here.
>
> - Hendrik
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Hendrik Leppkes
On Wed, Jan 8, 2020 at 2:18 PM Eran Gonen  wrote:
> @@ -547,6 +642,16 @@ static const AVOption h265_metadata_options[] = {
>  OFFSET(crop_bottom), AV_OPT_TYPE_INT,
>  { .i64 = -1 }, -1, HEVC_MAX_HEIGHT, FLAGS },
>
> +{ "advance_vps_id", "Advance the vps id",
> +OFFSET(advance_vps_id), AV_OPT_TYPE_INT,
> +{ .i64 = -1 }, -1, HEVC_MAX_VPS_COUNT, FLAGS },
> +{  "advance_sps_id", "Advance the sps id",
> +OFFSET(advance_sps_id), AV_OPT_TYPE_INT,
> +{ .i64 = -1 }, -1, HEVC_MAX_SPS_COUNT, FLAGS },
> +{  "advance_pps_id", "Advance the pps id",
> +OFFSET(advance_pps_id), AV_OPT_TYPE_INT,
> +{ .i64 = -1 }, -1, HEVC_MAX_PPS_COUNT, FLAGS },
> +

I think these could use some better wording and/or documentation, I'm
not sure many people would understand whats going to happen here.

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

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

Re: [FFmpeg-devel] [PATCH v7 1/8] avutil: add AV_FRAME_DATA_USER_DATA_UNREGISTERED side data type

2020-01-08 Thread Limin Wang
On Wed, Jan 08, 2020 at 06:07:29AM +0100, Anton Khirnov wrote:
> Quoting lance.lmw...@gmail.com (2020-01-07 06:03:48)
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  doc/APIchanges  | 3 +++
> >  libavutil/frame.c   | 1 +
> >  libavutil/frame.h   | 8 
> >  libavutil/version.h | 2 +-
> >  4 files changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index 3c24dc6fbc..6e1673e25e 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -15,6 +15,9 @@ libavutil: 2017-10-21
> >  
> >  API changes, most recent first:
> >  
> > +2020-01-xx - xx - lavu 56.39.100 - frame.h
> > +  Add AV_FRAME_DATA_USER_DATA_UNREGISTERED.
> > +
> >  2019-12-27 - xx - lavu 56.38.100 - eval.h
> >Add av_expr_count_func().
> >  
> > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > index e4038096c2..1d0faec687 100644
> > --- a/libavutil/frame.c
> > +++ b/libavutil/frame.c
> > @@ -842,6 +842,7 @@ const char *av_frame_side_data_name(enum 
> > AVFrameSideDataType type)
> >  #endif
> >  case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata 
> > SMPTE2094-40 (HDR10+)";
> >  case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest";
> > +case AV_FRAME_DATA_USER_DATA_UNREGISTERED: return "User Data 
> > Unregistered";
> >  }
> >  return NULL;
> >  }
> > diff --git a/libavutil/frame.h b/libavutil/frame.h
> > index b5afb58634..54863c86ce 100644
> > --- a/libavutil/frame.h
> > +++ b/libavutil/frame.h
> > @@ -179,6 +179,14 @@ enum AVFrameSideDataType {
> >   * array element is implied by AVFrameSideData.size / 
> > AVRegionOfInterest.self_size.
> >   */
> >  AV_FRAME_DATA_REGIONS_OF_INTEREST,
> > +
> > +/**
> > + * User data unregistered metadata associated with a video frame.
> > + * This is the H.26[45] UDU SEI message, and shouldn't be used for any 
> > other purpose
> > + * The data is stored as uint8_t in AVFrameSideData.data which is 16 
> > bytes of
> > + * uuid_iso_iec_11578 followed by AVFrameSideData.size-16 bytes of 
> > user_data_payload_byte.
> > + */
> > +AV_FRAME_DATA_USER_DATA_UNREGISTERED,
> 
> This naming is too generic IMO. Something like
> AV_FRAME_DATA_SEI_UNREGISTERED would make it clearer that it refers to
> the H.26x concept rather than any other kind of "registration" or "user
> data".

Sure, I'll change to AV_FRAME_DATA_SEI_UNREGISTERED.


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

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

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

[FFmpeg-devel] [PATCH] lavc/h265_profile_level: Fix the default profile in ff_h265_guess_level

2020-01-08 Thread Linjie Fu
Default to use multiplication factors for Main profile.

Introduced since cd3578a8e4e11e0ba021e621367a7974d6de5da0.

Fixed the notation at the same time.

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

diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c
index 70db1a5..a5347f6 100644
--- a/libavcodec/h265_profile_level.c
+++ b/libavcodec/h265_profile_level.c
@@ -187,8 +187,8 @@ const H265LevelDescriptor *ff_h265_guess_level(const 
H265RawProfileTierLevel *pt
 else
 profile = NULL;
 if (!profile) {
-// Default to using multiplication factors for Main profile.
-profile = _profiles[3];
+// Default to use multiplication factors for Main profile.
+profile = _profiles[4];
 }
 
 pic_size = width * height;
-- 
2.7.4

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

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

Re: [FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Andreas Rheinhardt
On Wed, Jan 8, 2020 at 2:18 PM Eran Gonen  wrote:

> ---
>  libavcodec/h265_metadata_bsf.c | 117 +++--
>  1 file changed, 111 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/h265_metadata_bsf.c
> b/libavcodec/h265_metadata_bsf.c
> index b3a1fda144..796046ac7f 100644
> --- a/libavcodec/h265_metadata_bsf.c
> +++ b/libavcodec/h265_metadata_bsf.c
> @@ -68,6 +68,10 @@ typedef struct H265MetadataContext {
>  int level;
>  int level_guess;
>  int level_warned;
> +
> +int advance_vps_id;
> +int advance_sps_id;
> +int advance_pps_id;
>  } H265MetadataContext;
>
>
> @@ -168,6 +172,10 @@ static int h265_metadata_update_vps(AVBSFContext *bsf,
>  {
>  H265MetadataContext *ctx = bsf->priv_data;
>
> +if(ctx->advance_vps_id > -1) {
> +vps->vps_video_parameter_set_id =
> (vps->vps_video_parameter_set_id + ctx->advance_vps_id) %
> HEVC_MAX_VPS_COUNT;
> +}
> +
>  if (ctx->tick_rate.num && ctx->tick_rate.den) {
>  int num, den;
>
> @@ -200,6 +208,13 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
>  int need_vui = 0;
>  int crop_unit_x, crop_unit_y;
>
> +if(ctx->advance_vps_id > -1) {
> +sps->sps_video_parameter_set_id =
> (sps->sps_video_parameter_set_id + ctx->advance_vps_id) %
> HEVC_MAX_VPS_COUNT;
> +}
> +if(ctx->advance_sps_id > -1) {
> +sps->sps_seq_parameter_set_id = (sps->sps_seq_parameter_set_id +
> ctx->advance_sps_id) % HEVC_MAX_SPS_COUNT;
> +}
> +
>  if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
>  // Table E-1.
>  static const AVRational sar_idc[] = {
> @@ -336,6 +351,32 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
>  return 0;
>  }
>
> +static int h265_metadata_update_pps(AVBSFContext *bsf,
> +H265RawPPS *pps)
> +{
> +H265MetadataContext *ctx = bsf->priv_data;
> +
> +if(ctx->advance_sps_id > -1) {
> +pps->pps_seq_parameter_set_id = (pps->pps_seq_parameter_set_id +
> ctx->advance_sps_id) % HEVC_MAX_SPS_COUNT;
> +}
> +if(ctx->advance_pps_id > -1) {
> +pps->pps_pic_parameter_set_id = (pps->pps_pic_parameter_set_id +
> ctx->advance_pps_id) % HEVC_MAX_PPS_COUNT;
> +}
> +
> +return 0;
> +}
> +
> +static int h265_metadata_update_slice_header(AVBSFContext *bsf,
> +H265RawSliceHeader *slice)
> +{
> +H265MetadataContext *ctx = bsf->priv_data;
> +
> +if(ctx->advance_pps_id > -1) {
> +slice->slice_pic_parameter_set_id =
> (slice->slice_pic_parameter_set_id + ctx->advance_pps_id) %
> HEVC_MAX_PPS_COUNT;
> +}
> +return 0;
> +}
> +
>  static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
>  {
>  H265MetadataContext *ctx = bsf->priv_data;
> @@ -406,15 +447,42 @@ static int h265_metadata_filter(AVBSFContext *bsf,
> AVPacket *pkt)
>  h265_metadata_guess_level(bsf, au);
>
>  for (i = 0; i < au->nb_units; i++) {
> -if (au->units[i].type == HEVC_NAL_VPS) {
> +switch (au->units[i].type) {
> +case HEVC_NAL_VPS:
>  err = h265_metadata_update_vps(bsf, au->units[i].content);
>  if (err < 0)
>  goto fail;
> -}
> -if (au->units[i].type == HEVC_NAL_SPS) {
> +break;
> +case HEVC_NAL_SPS:
>  err = h265_metadata_update_sps(bsf, au->units[i].content);
>  if (err < 0)
>  goto fail;
> +break;
> +case HEVC_NAL_PPS:
> +err = h265_metadata_update_pps(bsf, au->units[i].content);
> +if (err < 0)
> +goto fail;
> +break;
> +case HEVC_NAL_TRAIL_N:
> +case HEVC_NAL_TRAIL_R:
> +case HEVC_NAL_TSA_N:
> +case HEVC_NAL_TSA_R:
> +case HEVC_NAL_STSA_N:
> +case HEVC_NAL_STSA_R:
> +case HEVC_NAL_BLA_W_LP:
> +case HEVC_NAL_BLA_W_RADL:
> +case HEVC_NAL_BLA_N_LP:
> +case HEVC_NAL_IDR_W_RADL:
> +case HEVC_NAL_IDR_N_LP:
> +case HEVC_NAL_CRA_NUT:
> +case HEVC_NAL_RADL_N:
> +case HEVC_NAL_RADL_R:
> +case HEVC_NAL_RASL_N:
> +case HEVC_NAL_RASL_R:
> +err = h265_metadata_update_slice_header(bsf,
> au->units[i].content);
> +if (err < 0)
> +goto fail;
> +break;
>  }
>  }
>
> @@ -455,15 +523,42 @@ static int h265_metadata_init(AVBSFContext *bsf)
>  h265_metadata_guess_level(bsf, au);
>
>  for (i = 0; i < au->nb_units; i++) {
> -if (au->units[i].type == HEVC_NAL_VPS) {
> +switch (au->units[i].type) {
> +case HEVC_NAL_VPS:
>  err = h265_metadata_update_vps(bsf, au->units[i].content);
>  if (err < 0)
>  goto fail;
> -}
> -if (au->units[i].type == HEVC_NAL_SPS) {
> +break;
> +case HEVC_NAL_SPS:

[FFmpeg-devel] [PATCH v6] avformat/mov: Memory optimization with QuickTime/MP4

2020-01-08 Thread Jörg Beckmann
Invents a new option "discard_fragments" for the MP4/Quicktime/MOV decoder.

If this option is set to "on", old fragments are discarded as far as possible
on each call to switch_root(). If set to "off", nothing changes at all. If set
to "auto" (the default), this function is turned on for streams containing
only audio.

For pure audio streams, the memory usage is now constant. For video streams,
the memory usage is reduced. It's tested with audio streams received from a
professional DAB+ receiver and with video streams created on my own with
"ffmpeg -i .m4v -c:a:0 copy -c:v copy -c:s copy -f ismv -movflags \
frag_keyframe -movflags faststart tcp://localhost:1234?listen" and
"ffmpeg -i tcp://localhost:1234 -c:a copy -c:v copy -c:s copy -y ".

For pure audio streams, this function is intensively tested and in production
use for several weeks. For video streams, it is tested with some examples, but 
is
more or less experimental. Therefore "auto" turns it on for pure audio streams
only.

Signed-off-by: Jörg Beckmann mailto:joerg.beckm...@scisys.com
---
 libavformat/isom.h |  1 +
 libavformat/mov.c  | 60 --
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 4943b80ccf..9b4753f4d7 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -268,6 +268,7 @@ typedef struct MOVContext {
 int advanced_editlist;
 int ignore_chapters;
 int seek_individually;
+int discard_fragments;
 int64_t next_root_atom; ///< offset of the next root atom
 int export_all;
 int export_xmp;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 890c6e85b8..a3289dda20 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -66,6 +66,10 @@
 
 #include "qtpalette.h"
 
+#define MOV_DISCARD_AUTO (-1)
+#define MOV_DISCARD_OFF   0
+#define MOV_DISCARD_ON1
+
 /* those functions parse an atom */
 /* links atom IDs to parse functions */
 typedef struct MOVParseTableEntry {
@@ -7454,6 +7458,7 @@ static int mov_read_header(AVFormatContext *s)
 int j, err;
 MOVAtom atom = { AV_RL32("root") };
 int i;
+int audio_only = 1;
 
 if (mov->decryption_key_len != 0 && mov->decryption_key_len != 
AES_CTR_KEY_SIZE) {
 av_log(s, AV_LOG_ERROR, "Invalid decryption key len %d expected %d\n",
@@ -7522,6 +7527,9 @@ static int mov_read_header(AVFormatContext *s)
 AVStream *st = s->streams[i];
 MOVStreamContext *sc = st->priv_data;
 fix_timescale(mov, sc);
+if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
+audio_only = 0;
+}
 if(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && 
st->codecpar->codec_id == AV_CODEC_ID_AAC) {
 st->skip_samples = sc->start_pad;
 }
@@ -7547,6 +7555,10 @@ static int mov_read_header(AVFormatContext *s)
 }
 }
 
+if (mov->discard_fragments == MOV_DISCARD_AUTO) {
+mov->discard_fragments = audio_only;
+}
+
 if (mov->trex_data) {
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
@@ -7692,8 +7704,11 @@ static int should_retry(AVIOContext *pb, int error_code) 
{
 
 static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
 {
-int ret;
+int ret, i;
 MOVContext *mov = s->priv_data;
+AVStream *st = NULL;
+MOVStreamContext *sc;
+MOVFragment *frag;
 
 if (index >= 0 && index < mov->frag_index.nb_items)
 target = mov->frag_index.item[index].moof_offset;
@@ -7715,6 +7730,43 @@ static int mov_switch_root(AVFormatContext *s, int64_t 
target, int index)
 
 mov->found_mdat = 0;
 
+if (mov->discard_fragments) {
+frag = >fragment;
+
+for (i = 0; i < mov->fc->nb_streams; i++) {
+if (mov->fc->streams[i]->id == frag->track_id) {
+st = mov->fc->streams[i];
+break;
+}
+}
+
+av_assert0(st);
+
+sc = st->priv_data;
+
+switch (st->codecpar->codec_type) {
+case AVMEDIA_TYPE_AUDIO:
+case AVMEDIA_TYPE_SUBTITLE:
+/* Freeing VIDEO tables leads to corrupted video when writing 
to eg. MKV */
+av_freep(>index_entries);
+st->nb_index_entries = 0;
+st->index_entries_allocated_size = 0;
+
+sc->current_index = 0;
+sc->current_sample = 0;
+
+av_freep(>ctts_data);
+sc->ctts_allocated_size = 0;
+sc->ctts_count = 0;
+break;
+}
+
+av_free(mov->frag_index.item->stream_info);
+av_freep(>frag_index.item);
+mov->frag_index.allocated_size = 0;
+mov->frag_index.nb_items = 0;
+}
+
 ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX 
});
 if (ret < 0)
 return ret;
@@ -8057,7 +8109,11 @@ static const AVOption mov_options[] = {
 { 

[FFmpeg-devel] [PATCH] Add advance vps/sps/pps id to hevc_metadata bsf

2020-01-08 Thread Eran Gonen
---
 libavcodec/h265_metadata_bsf.c | 117 +++--
 1 file changed, 111 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index b3a1fda144..796046ac7f 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -68,6 +68,10 @@ typedef struct H265MetadataContext {
 int level;
 int level_guess;
 int level_warned;
+
+int advance_vps_id;
+int advance_sps_id;
+int advance_pps_id;
 } H265MetadataContext;
 
 
@@ -168,6 +172,10 @@ static int h265_metadata_update_vps(AVBSFContext *bsf,
 {
 H265MetadataContext *ctx = bsf->priv_data;
 
+if(ctx->advance_vps_id > -1) {
+vps->vps_video_parameter_set_id = (vps->vps_video_parameter_set_id + 
ctx->advance_vps_id) % HEVC_MAX_VPS_COUNT;
+}
+
 if (ctx->tick_rate.num && ctx->tick_rate.den) {
 int num, den;
 
@@ -200,6 +208,13 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
 int need_vui = 0;
 int crop_unit_x, crop_unit_y;
 
+if(ctx->advance_vps_id > -1) {
+sps->sps_video_parameter_set_id = (sps->sps_video_parameter_set_id + 
ctx->advance_vps_id) % HEVC_MAX_VPS_COUNT;
+}
+if(ctx->advance_sps_id > -1) {
+sps->sps_seq_parameter_set_id = (sps->sps_seq_parameter_set_id + 
ctx->advance_sps_id) % HEVC_MAX_SPS_COUNT;
+}
+
 if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
 // Table E-1.
 static const AVRational sar_idc[] = {
@@ -336,6 +351,32 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
 return 0;
 }
 
+static int h265_metadata_update_pps(AVBSFContext *bsf,
+H265RawPPS *pps)
+{
+H265MetadataContext *ctx = bsf->priv_data;
+
+if(ctx->advance_sps_id > -1) {
+pps->pps_seq_parameter_set_id = (pps->pps_seq_parameter_set_id + 
ctx->advance_sps_id) % HEVC_MAX_SPS_COUNT;
+}
+if(ctx->advance_pps_id > -1) {
+pps->pps_pic_parameter_set_id = (pps->pps_pic_parameter_set_id + 
ctx->advance_pps_id) % HEVC_MAX_PPS_COUNT;
+}
+
+return 0;
+}
+
+static int h265_metadata_update_slice_header(AVBSFContext *bsf,
+H265RawSliceHeader *slice)
+{
+H265MetadataContext *ctx = bsf->priv_data;
+
+if(ctx->advance_pps_id > -1) {
+slice->slice_pic_parameter_set_id = (slice->slice_pic_parameter_set_id 
+ ctx->advance_pps_id) % HEVC_MAX_PPS_COUNT;
+}
+return 0;
+}
+
 static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
 {
 H265MetadataContext *ctx = bsf->priv_data;
@@ -406,15 +447,42 @@ static int h265_metadata_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 h265_metadata_guess_level(bsf, au);
 
 for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == HEVC_NAL_VPS) {
+switch (au->units[i].type) {
+case HEVC_NAL_VPS:
 err = h265_metadata_update_vps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
-}
-if (au->units[i].type == HEVC_NAL_SPS) {
+break;
+case HEVC_NAL_SPS:
 err = h265_metadata_update_sps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
+break;
+case HEVC_NAL_PPS:
+err = h265_metadata_update_pps(bsf, au->units[i].content);
+if (err < 0)
+goto fail;
+break;
+case HEVC_NAL_TRAIL_N:
+case HEVC_NAL_TRAIL_R:
+case HEVC_NAL_TSA_N:
+case HEVC_NAL_TSA_R:
+case HEVC_NAL_STSA_N:
+case HEVC_NAL_STSA_R:
+case HEVC_NAL_BLA_W_LP:
+case HEVC_NAL_BLA_W_RADL:
+case HEVC_NAL_BLA_N_LP:
+case HEVC_NAL_IDR_W_RADL:
+case HEVC_NAL_IDR_N_LP:
+case HEVC_NAL_CRA_NUT:
+case HEVC_NAL_RADL_N:
+case HEVC_NAL_RADL_R:
+case HEVC_NAL_RASL_N:
+case HEVC_NAL_RASL_R:
+err = h265_metadata_update_slice_header(bsf, au->units[i].content);
+if (err < 0)
+goto fail;
+break;
 }
 }
 
@@ -455,15 +523,42 @@ static int h265_metadata_init(AVBSFContext *bsf)
 h265_metadata_guess_level(bsf, au);
 
 for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == HEVC_NAL_VPS) {
+switch (au->units[i].type) {
+case HEVC_NAL_VPS:
 err = h265_metadata_update_vps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
-}
-if (au->units[i].type == HEVC_NAL_SPS) {
+break;
+case HEVC_NAL_SPS:
 err = h265_metadata_update_sps(bsf, au->units[i].content);
 if (err < 0)
 goto fail;
+break;
+case HEVC_NAL_PPS:
+err = h265_metadata_update_pps(bsf, au->units[i].content);
+if (err < 0)
+

Re: [FFmpeg-devel] [PATCH v2 1/2] configure: Change the configure check for tonemap_vaapi

2020-01-08 Thread Sun, Xinpeng

> -Original Message-
> From: ffmpeg-devel  On Behalf Of Mark
> Thompson
> Sent: Tuesday, January 7, 2020 8:07 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] configure: Change the configure
> check for tonemap_vaapi
> 
> On 30/12/2019 07:32, Xinpeng Sun wrote:
> > "VAProcFilterParameterBufferHDRToneMapping" was defined in libva
> > 2.4.1, which will lead to build failure for the filter tonemap_vaapi
> > for libva 2.3.0 with current check. This patch is to fix this build error.
> >
> > Signed-off-by: Xinpeng Sun 
> > ---
> >  configure | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/configure b/configure
> > index 43dc409fe6..01b4acd77e 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3579,7 +3579,7 @@ tinterlace_filter_deps="gpl"
> >  tinterlace_merge_test_deps="tinterlace_filter"
> >  tinterlace_pad_test_deps="tinterlace_filter"
> >  tonemap_filter_deps="const_nan"
> > -tonemap_vaapi_filter_deps="vaapi
> VAProcPipelineParameterBuffer_output_hdr_metadata"
> > +tonemap_vaapi_filter_deps="vaapi
> VAProcFilterParameterBufferHDRToneMapping"
> >  tonemap_opencl_filter_deps="opencl const_nan"
> >  transpose_opencl_filter_deps="opencl"
> >  transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
> > @@ -6584,7 +6584,7 @@ if enabled vaapi; then
> >
> >  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
> >  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
> > -check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer"
> output_hdr_metadata
> > +check_type   "va/va.h va/va_vpp.h"
> "VAProcFilterParameterBufferHDRToneMapping"
> >  check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
> >  check_type "va/va.h va/va_enc_hevc.h"
> "VAEncPictureParameterBufferHEVC"
> >  check_type "va/va.h va/va_enc_jpeg.h"
> "VAEncPictureParameterBufferJPEG"
> >
> 
> Thanks, applied.
> 
> Relatedly: can you explain how to get this filter to work?
> 
> So far the only non-identity transformation I have managed to achieve is to
> make the output entirely black (which happens if the set the output colour
> matrix to anything other than the same as the input).
> 
> E.g. given an input which is:
> 
> Stream #0:0[0x101]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024),
> yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9],
> 25 fps, 25 tbr, 90k tbn, 25 tbc
> [Parsed_showinfo_0 @ 0x5609cc1a6d00]   side data - mastering display:
> has_primaries:1 has_luminance:1 r(0.6800,0.3200) g(0.2650,0.6900) b(0.1500
> 0.0600) wp(0.3127, 0.3290) min_luminance=0.05,
> max_luminance=1200.00
> 
> then doing:
> 
> -vf tonemap_vaapi=format=nv12
> 
> gives identical output to:
> 
> -vf scale_vaapi=format=nv12
> 
> while:
> 
> -vf tonemap_vaapi=format=nv12:t=bt709:p=bt709:m=bt709
> 
> gives output which is entirely black.
> 
> (Hardware is Icelake 1065G7.)
> 
> - Mark

Hi Mark,

For your first test(tonemap_vaapi has the same output with scale_vaapi), I am 
working with others to investigate the root-cause in iHD driver.

And for your second test(the output is black), scale_vaapi also has similar 
issue when performing bt2020 to bt709/bt601 on the color matrix for 4K 
resolution. 
It’s a driver issue and I think they may share the same root-cause.
The issue link is:  https://github.com/intel/media-driver/issues/760
Same issue from gstreamer-vaapi side: 
https://github.com/intel/media-driver/issues/763

I'm so sorry for forgetting to test the bt709-color-matrix for output when 
developing the patch.

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

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

Re: [FFmpeg-devel] Patch "configure: Check for the SetDllDirectory and GetModuleHandle functions" by Martin Storsjö

2020-01-08 Thread Martin Storsjö

On Wed, 8 Jan 2020, Jörg Beckmann wrote:


-Ursprüngliche Nachricht-
Von: ffmpeg-devel  Im Auftrag von Martin
Storsjö
Gesendet: Mittwoch, 8. Januar 2020 12:39
An: FFmpeg development discussions and patches 
Betreff: Re: [FFmpeg-devel] Patch "configure: Check for the SetDllDirectory and
GetModuleHandle functions" by Martin Storsjö

On Wed, 8 Jan 2020, Jörg Beckmann wrote:


Hi,

with this patch, FFmpeg does not compile for me on Cygwin anymore:

---
fftools/cmdutils.c: In function 'get_preset_file':
fftools/cmdutils.c:2043:22: error: 'MAX_PATH' undeclared (first use in this

function); did you mean '_CS_PATH'?

char datadir[MAX_PATH], *ls;
 ^~~~


I just sent an untested patch which I believe should fix this. Can you test it?


Thank you very much for your fast response. You're new patch is working 
and it compiles again. 


Thanks, I pushed this patch then.

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

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

Re: [FFmpeg-devel] Patch "configure: Check for the SetDllDirectory and GetModuleHandle functions" by Martin Storsjö

2020-01-08 Thread Jörg Beckmann
> -Ursprüngliche Nachricht-
> Von: ffmpeg-devel  Im Auftrag von Martin
> Storsjö
> Gesendet: Mittwoch, 8. Januar 2020 12:39
> An: FFmpeg development discussions and patches 
> Betreff: Re: [FFmpeg-devel] Patch "configure: Check for the SetDllDirectory 
> and
> GetModuleHandle functions" by Martin Storsjö
> 
> On Wed, 8 Jan 2020, Jörg Beckmann wrote:
> 
> > Hi,
> >
> > with this patch, FFmpeg does not compile for me on Cygwin anymore:
> >
> > ---
> > fftools/cmdutils.c: In function 'get_preset_file':
> > fftools/cmdutils.c:2043:22: error: 'MAX_PATH' undeclared (first use in this
> function); did you mean '_CS_PATH'?
> > char datadir[MAX_PATH], *ls;
> >  ^~~~
> 
> I just sent an untested patch which I believe should fix this. Can you test 
> it?

Thank you very much for your fast response. You're new patch is working and it 
compiles again. 

> 
> // Martin

Jörg


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

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

Re: [FFmpeg-devel] Patch "configure: Check for the SetDllDirectory and GetModuleHandle functions" by Martin Storsjö

2020-01-08 Thread Martin Storsjö

On Wed, 8 Jan 2020, Jörg Beckmann wrote:


Hi,

with this patch, FFmpeg does not compile for me on Cygwin anymore:

---
fftools/cmdutils.c: In function 'get_preset_file':
fftools/cmdutils.c:2043:22: error: 'MAX_PATH' undeclared (first use in this 
function); did you mean '_CS_PATH'?
char datadir[MAX_PATH], *ls;
 ^~~~


I just sent an untested patch which I believe should fix this. Can you 
test it?


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

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

[FFmpeg-devel] [PATCH] cmdutils: Fix compilation on cygwin wrt SetDllDirectory and GetModuleHandle

2020-01-08 Thread Martin Storsjö
After 06ec9c4746ebc1d3b613c1847e434bbd0b4407b4 we check for these
functions in configure (which will succeed in cygwin), but cmdutils.c
only includes windows.h if _WIN32 is defined (which it isn't in cygwin).

Retain the old intent from before 06ec9c4746ebc1d3b613c1847e434bbd0b4407b4,
that these functions only would be used when _WIN32 is defined, while
only using them if configure has agreed that they do exist.
---
 fftools/cmdutils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index e4f4861d66..7954f23430 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -119,7 +119,7 @@ static void log_callback_report(void *ptr, int level, const 
char *fmt, va_list v
 
 void init_dynload(void)
 {
-#if HAVE_SETDLLDIRECTORY
+#if HAVE_SETDLLDIRECTORY && defined(_WIN32)
 /* Calling SetDllDirectory with the empty string (but not NULL) removes the
  * current working directory from the DLL search path as a security 
pre-caution. */
 SetDllDirectory("");
@@ -2039,7 +2039,7 @@ FILE *get_preset_file(char *filename, size_t 
filename_size,
 av_strlcpy(filename, preset_name, filename_size);
 f = fopen(filename, "r");
 } else {
-#if HAVE_GETMODULEHANDLE
+#if HAVE_GETMODULEHANDLE && defined(_WIN32)
 char datadir[MAX_PATH], *ls;
 base[2] = NULL;
 
-- 
2.21.0 (Apple Git-122.2)

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

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

Re: [FFmpeg-devel] [PATCH] Add vps/sps/pps id set to hevc_metadata bsf

2020-01-08 Thread Moritz Barsnick
On Tue, Jan 07, 2020 at 15:24:53 +0200, Eran Gonen wrote:
> Thanks, I will fix that. What's the formatter parameters for that? (AStyle
> or other)

See https://www.ffmpeg.org/developer.html#Coding-Rules-1
$ indent -i4 -kr -nut
(approximately)

I haven't used astyle so much (only trial-and-error), but perhaps
others have.

Also check other files in the source code for inspiration, though some
don't comply.

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

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

Re: [FFmpeg-devel] [PATCH] HEVC: Export motion vectors to frame side data.

2020-01-08 Thread Asaf Kave
On Tue, Jan 7, 2020 at 4:49 AM Zhong Li  wrote:

> Haven't tested but patch LGTM
>

Thanks Li for the feedback.


>
> Asaf Kave  于2019年12月29日周日 下午10:08写道:
> >
> > ---
> >  libavcodec/hevc_refs.c |  15 
> >  libavcodec/hevcdec.c   | 173 -
> >  libavcodec/hevcdec.h   |  13 
> >  3 files changed, 200 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
> > index 7870a72fd6..20f028fa73 100644
> > --- a/libavcodec/hevc_refs.c
> > +++ b/libavcodec/hevc_refs.c
> > @@ -42,6 +42,9 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame
> *frame, int flags)
> >  av_buffer_unref(>tab_mvf_buf);
> >  frame->tab_mvf = NULL;
> >
> > +av_buffer_unref(>cuh_buf);
> > +frame->cuh = NULL;
> > +
> >  av_buffer_unref(>rpl_buf);
> >  av_buffer_unref(>rpl_tab_buf);
> >  frame->rpl_tab= NULL;
> > @@ -101,11 +104,17 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
> >  goto fail;
> >  frame->tab_mvf = (MvField *)frame->tab_mvf_buf->data;
> >
> > +frame->cuh_buf = av_buffer_pool_get(s->cuh_pool);
> > +if (!frame->cuh_buf)
> > +goto fail;
> > +frame->cuh = (CodingUnitHelper *)frame->cuh_buf->data;
> > +
> >  frame->rpl_tab_buf = av_buffer_pool_get(s->rpl_tab_pool);
> >  if (!frame->rpl_tab_buf)
> >  goto fail;
> >  frame->rpl_tab   = (RefPicListTab **)frame->rpl_tab_buf->data;
> >  frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height;
> > +frame->cu_count = 0;
> >  for (j = 0; j < frame->ctb_count; j++)
> >  frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data;
> >
> > @@ -161,6 +170,10 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame
> **frame, int poc)
> >  else
> >  ref->flags = HEVC_FRAME_FLAG_SHORT_REF;
> >
> > +if (s->avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) {
> > +ref->flags |= HEVC_FRAME_FLAG_MV;
> > +}
> > +
> >  ref->poc  = poc;
> >  ref->sequence = s->seq_decode;
> >  ref->frame->crop_left   = s->ps.sps->output_window.left_offset;
> > @@ -216,6 +229,8 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame
> *out, int flush)
> >  if (ret < 0)
> >  return ret;
> >
> > +s->output_frame_poc = frame->poc;
> > +
> >  av_log(s->avctx, AV_LOG_DEBUG,
> > "Output frame with POC %d.\n", frame->poc);
> >  return 1;
> > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> > index 19b0cd815d..aedc559283 100644
> > --- a/libavcodec/hevcdec.c
> > +++ b/libavcodec/hevcdec.c
> > @@ -32,6 +32,7 @@
> >  #include "libavutil/opt.h"
> >  #include "libavutil/pixdesc.h"
> >  #include "libavutil/stereo3d.h"
> > +#include "libavutil/motion_vector.h"
> >
> >  #include "bswapdsp.h"
> >  #include "bytestream.h"
> > @@ -80,6 +81,7 @@ static void pic_arrays_free(HEVCContext *s)
> >  av_freep(>sh.offset);
> >
> >  av_buffer_pool_uninit(>tab_mvf_pool);
> > +av_buffer_pool_uninit(>cuh_pool);
> >  av_buffer_pool_uninit(>rpl_tab_pool);
> >  }
> >
> > @@ -128,9 +130,11 @@ static int pic_arrays_init(HEVCContext *s, const
> HEVCSPS *sps)
> >
> >  s->tab_mvf_pool = av_buffer_pool_init(min_pu_size * sizeof(MvField),
> >av_buffer_allocz);
> > +s->cuh_pool = av_buffer_pool_init(min_pu_size *
> sizeof(CodingUnitHelper),
> > +  av_buffer_allocz);
> >  s->rpl_tab_pool = av_buffer_pool_init(ctb_count *
> sizeof(RefPicListTab),
> >av_buffer_allocz);
> > -if (!s->tab_mvf_pool || !s->rpl_tab_pool)
> > +if (!s->tab_mvf_pool || !s->rpl_tab_pool || !s->cuh_pool)
> >  goto fail;
> >
> >  return 0;
> > @@ -1806,6 +1810,7 @@ static void hls_prediction_unit(HEVCContext *s,
> int x0, int y0,
> >  int min_pu_width = s->ps.sps->min_pu_width;
> >
> >  MvField *tab_mvf = s->ref->tab_mvf;
> > +CodingUnitHelper *cuh = s->ref->cuh;
> >  RefPicList  *refPicList = s->ref->refPicList;
> >  HEVCFrame *ref0 = NULL, *ref1 = NULL;
> >  uint8_t *dst0 = POS(0, x0, y0);
> > @@ -1843,6 +1848,9 @@ static void hls_prediction_unit(HEVCContext *s,
> int x0, int y0,
> >  for (i = 0; i < nPbW >> s->ps.sps->log2_min_pu_size; i++)
> >  tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
> >
> > +struct CodingUnitHelper cuh_ = {lc->cu, log2_cb_size };
> > +cuh[s->ref->cu_count++] = cuh_;
> > +
> >  if (current_mv.pred_flag & PF_L0) {
> >  ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
> >  if (!ref0)
> > @@ -3192,6 +3200,160 @@ static int hevc_decode_extradata(HEVCContext *s,
> uint8_t *buf, int length, int f
> >  return 0;
> >  }
> >
> > +static int set_mv(AVMotionVector *mv, int puW, int puH,
> > +  int dst_x, 

Re: [FFmpeg-devel] setting vps/sps/pps id via hevc_metadata

2020-01-08 Thread Andreas Rheinhardt
On Wed, Jan 8, 2020 at 9:12 AM Eran Gonen  wrote:

> Would it make more sense if I'll change it to advance sps id? offering no
> risk for multiple ps
>
>
That would be safe (if you reduce the id modulo the number of allowed
values afterwards).

- Andreas

PS: Avoid top-posting on this list.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] setting vps/sps/pps id via hevc_metadata

2020-01-08 Thread Eran Gonen
Would it make more sense if I'll change it to advance sps id? offering no
risk for multiple ps

On Tue, Jan 7, 2020 at 3:54 PM Eran Gonen  wrote:

> Hi,
> This filter allows editing hevc headers and change metadata. Most
> modifications doesn't make sense for all multiple PS streams (even if they
> are decodable): same crop for different resolutions, the same tick_rate for
> different FR. Changing the PS id allows a wide range of stream compositions
> and offer no decoding risk for most streams.
>
> On Mon, Jan 6, 2020 at 11:48 PM Mark Thompson  wrote:
>
>> On 06/01/2020 19:24, Eran Gonen wrote:> On Mon, Jan 6, 2020 at 9:05 PM
>> Andreas Rheinhardt <
>> > andreas.rheinha...@gmail.com> wrote:
>> >
>> >> On Mon, Jan 6, 2020 at 7:54 PM Eran Gonen 
>> >> wrote:
>> >>
>> >>> Hi,
>> >>>
>> >>> The attached patch allows setting vps/sps/pps id
>> >>>
>> >>> Usage:
>> >>> /ffmpeg -i source -c:v libx265 -bsf:v
>> >>> hevc_metadata=sps_id=8:pps_id=12:vps_id=3 output
>> >>>
>> >>>
>> >> There is a problem with this: Input files with parameter sets of the
>> same
>> >> kind with different ids can be broken by this (because they would all
>> share
>> >> the same id in the output and hence overwrite each other upon
>> decoding).
>> >>
>> >> - Andreas
>> >>
>> > Thanks Andreas. I also thought about this point.
>> > I guess the same goes to the rest of parameters in hevc_metadata.
>> > They all affect all sets in the file. Maybe that's the intention of the
>> > user for such files.
>>
>> I'm not sure that comparison is really right, because the existing
>> elements which can be modified are the metadata which don't affect the
>> decoding process.  Changing the PS IDs will break most streams with
>> multiple parameter sets (try PPS_A_qualcomm_7.bit from the conformance test
>> suite).
>>
>> What is your actual use-case here?  If it's fixing some particular set of
>> broken streams then perhaps it could be a separate BSF like
>> h264_redundant_pps.
>>
>> - Mark
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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