Re: [FFmpeg-devel] [PATCH 7/7] hwcontext_qsv: Try to select a matching VAAPI device by default

2019-05-20 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Monday, May 6, 2019 10:49 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 7/7] hwcontext_qsv: Try to select a
> matching VAAPI device by default
> 
> Tries to find a device backed by the i915 kernel driver and loads the iHD
> VAAPI driver to use with it.  This reduces confusion on machines with
> multiple DRM devices and removes the surprising requirement to set the
> LIBVA_DRIVER_NAME environment variable to use libmfx at all.
> ---
>  libavutil/hwcontext_qsv.c | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> 49b5952cef..59e4ed9157 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -1206,6 +1206,7 @@ static int qsv_device_create(AVHWDeviceContext
> *ctx, const char *device,
>  QSVDevicePriv *priv;
>  enum AVHWDeviceType child_device_type;
>  AVHWDeviceContext *child_device;
> +AVDictionary *child_device_opts;
>  AVDictionaryEntry *e;
> 
>  mfxIMPL impl;
> @@ -1220,9 +1221,17 @@ static int
> qsv_device_create(AVHWDeviceContext *ctx, const char *device,
> 
>  e = av_dict_get(opts, "child_device", NULL, 0);
> 
> -if (CONFIG_VAAPI)
> +child_device_opts = NULL;
> +if (CONFIG_VAAPI) {
>  child_device_type = AV_HWDEVICE_TYPE_VAAPI;
> -else if (CONFIG_DXVA2)
> +// libmfx does not actually implement VAAPI properly, rather it
> +// depends on the specific behaviour of a matching iHD driver
> when
> +// used on recent Intel hardware.  Set options to the VAAPI
> device
> +// creation so that we should pick a usable setup by default if
> +// possible, even when multiple devices and drivers are available.
> +av_dict_set(&child_device_opts, "kernel_driver", "i915", 0);
> +av_dict_set(&child_device_opts, "driver","iHD",  0);
> +} else if (CONFIG_DXVA2)
>  child_device_type = AV_HWDEVICE_TYPE_DXVA2;
>  else {
>  av_log(ctx, AV_LOG_ERROR, "No supported child device type is
> enabled\n"); @@ -1230,7 +1239,7 @@ static int
> qsv_device_create(AVHWDeviceContext *ctx, const char *device,
>  }
> 
>  ret = av_hwdevice_ctx_create(&priv->child_device_ctx,
> child_device_type,
> - e ? e->value : NULL, NULL, 0);
> + e ? e->value : NULL,
> + child_device_opts, 0);
>  if (ret < 0)
>  return ret;
> 
> --
> 2.20.1

LGTM and tested. Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 5/7] hwcontext_vaapi: Add option to set driver name

2019-05-20 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Monday, May 6, 2019 10:49 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 5/7] hwcontext_vaapi: Add option to set
> driver name
> 
> For example: -init_hw_device vaapi:/dev/dri/renderD128,driver=foo
> 
> This may be more convenient that using the environment variable, and
> allows loading different drivers for different devices in the same process.
> ---
>  libavutil/hwcontext_vaapi.c | 19 +++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index
> c151f8da93..35883d7855 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -1598,6 +1598,25 @@ static int
> vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
>  return AVERROR(EINVAL);
>  }
> 
> +ent = av_dict_get(opts, "driver", NULL, 0);
> +if (ent) {
> +#if VA_CHECK_VERSION(0, 38, 0)
> +VAStatus vas;
> +vas = vaSetDriverName(display, ent->value);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(ctx, AV_LOG_ERROR, "Failed to set driver name to "
> +   "%s: %d (%s).\n", ent->value, vas, vaErrorStr(vas));
> +vaTerminate(display);
> +return AVERROR_EXTERNAL;
> +}
> +#else
> +av_log(ctx, AV_LOG_WARNING, "Driver name setting is not "
> +   "supported with this VAAPI version.\n");
> +vaTerminate(display);
> +return AVERROR(ENOSYS);

Giving a warning message should be enough?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] libavfilter/dnn_native: Add multiple padding methods in dnn native

2019-05-20 Thread Steven Liu
Guo, Yejun  于2019年5月21日周二 上午10:25写道:
>
>
>
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> > Xuewei Meng
> > Sent: Saturday, May 18, 2019 3:19 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Xuewei Meng 
> > Subject: [FFmpeg-devel] [PATCH v3] libavfilter/dnn_native: Add multiple 
> > padding
> > methods in dnn native
> >
> > Add another two padding methods "VALID" and "SAME" as tensorflow, and
> > keep the existing "SAME_CLAMP_TO_EDGE" method suggested by sr filter.
> > As "SAME_CLAMP_TO_EDGE"can keep the output with the same size as
> > original input, and gives a slight better result as mentioned by sr filter.
> >
> > Signed-off-by: Xuewei Meng 
> > ---
> >  libavfilter/dnn_backend_native.c | 52 
> >  libavfilter/dnn_backend_native.h |  3 ++
> >  2 files changed, 43 insertions(+), 12 deletions(-)
>
> looks good to me, except some trailing whitespaces.
Fixed trailing whitespaces, fixed code style and pushed.


Thanks
>
> >
> > diff --git a/libavfilter/dnn_backend_native.c 
> > b/libavfilter/dnn_backend_native.c
> > index 06fbdf368b..171a756385 100644
> > --- a/libavfilter/dnn_backend_native.c
> > +++ b/libavfilter/dnn_backend_native.c
> > @@ -61,6 +61,12 @@ static DNNReturnType set_input_output_native(void
> > *model, DNNInputData *input, c
> >  return DNN_ERROR;
> >  }
> >  cur_channels = conv_params->output_num;
> > +
> > +if(conv_params->padding_method == VALID){
> > +int pad_size = conv_params->kernel_size - 1;
> > +cur_height -= pad_size;
> > +cur_width -= pad_size;
> > +}
> >  break;
> >  case DEPTH_TO_SPACE:
> >  depth_to_space_params = (DepthToSpaceParams
> > *)network->layers[layer].params;
> > @@ -77,6 +83,10 @@ static DNNReturnType set_input_output_native(void
> > *model, DNNInputData *input, c
> >  if (network->layers[layer].output){
> >  av_freep(&network->layers[layer].output);
> >  }
> > +
> > +if(cur_height <= 0 || cur_width <= 0)
> > +return DNN_ERROR;
> > +
> >  network->layers[layer].output = av_malloc(cur_height * cur_width *
> > cur_channels * sizeof(float));
> >  if (!network->layers[layer].output){
> >  return DNN_ERROR;
> > @@ -154,13 +164,14 @@ DNNModel *ff_dnn_load_model_native(const char
> > *model_filename)
> >  ff_dnn_free_model_native(&model);
> >  return NULL;
> >  }
> > +conv_params->padding_method =
> > (int32_t)avio_rl32(model_file_context);
> >  conv_params->activation =
> > (int32_t)avio_rl32(model_file_context);
> >  conv_params->input_num =
> > (int32_t)avio_rl32(model_file_context);
> >  conv_params->output_num =
> > (int32_t)avio_rl32(model_file_context);
> >  conv_params->kernel_size =
> > (int32_t)avio_rl32(model_file_context);
> >  kernel_size = conv_params->input_num *
> > conv_params->output_num *
> >conv_params->kernel_size *
> > conv_params->kernel_size;
> > -dnn_size += 16 + (kernel_size + conv_params->output_num <<
> > 2);
> > +dnn_size += 20 + (kernel_size + conv_params->output_num <<
> > 2);
> >  if (dnn_size > file_size || conv_params->input_num <= 0 ||
> >  conv_params->output_num <= 0 ||
> > conv_params->kernel_size <= 0){
> >  avio_closep(&model_file_context);
> > @@ -218,23 +229,35 @@ DNNModel *ff_dnn_load_model_native(const char
> > *model_filename)
> >
> >  static void convolve(const float *input, float *output, const
> > ConvolutionalParams *conv_params, int width, int height)
> >  {
> > -int y, x, n_filter, ch, kernel_y, kernel_x;
> >  int radius = conv_params->kernel_size >> 1;
> >  int src_linesize = width * conv_params->input_num;
> >  int filter_linesize = conv_params->kernel_size *
> > conv_params->input_num;
> >  int filter_size = conv_params->kernel_size * filter_linesize;
> > +int pad_size = (conv_params->padding_method == VALID) ?
> > (conv_params->kernel_size - 1) / 2 : 0;
> >
> > -for (y = 0; y < height; ++y){
> > -for (x = 0; x < width; ++x){
> > -for (n_filter = 0; n_filter < conv_params->output_num;
> > ++n_filter){
> > +for (int y = pad_size; y < height - pad_size; ++y){
> > +for (int x = pad_size; x < width - pad_size; ++x){
> > +for (int n_filter = 0; n_filter < conv_params->output_num;
> > ++n_filter){
> >  output[n_filter] = conv_params->biases[n_filter];
> > -for (ch = 0; ch < conv_params->input_num; ++ch){
> > -for (kernel_y = 0; kernel_y <
> > conv_params->kernel_size; ++kernel_y){
> > -for (kernel_x = 0; kernel_x <
> > conv_params->kernel_size; ++kernel_x){
> > - 

Re: [FFmpeg-devel] [PATCH v2 01/11] cbs: Mention all codecs in unit type comment

2019-05-20 Thread James Almer
On 5/20/2019 8:02 PM, Mark Thompson wrote:
> ---
>  libavcodec/cbs.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index 967dcd1468..e8b2d41ecb 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -49,6 +49,8 @@ struct CodedBitstreamType;
>   * H.265 / HEVC: nal_unit_type
>   * MPEG-2: start code value (without prefix)
>   * VP9: unused, set to zero (every unit is a frame)
> + * JPEG: marker value (without 0xff prefix)
> + * AV1: obu_type

Nit: Before this patch the list was in alphabetical order.

LGTM with or without addressing that.

>   */
>  typedef uint32_t CodedBitstreamUnitType;
>  
> 

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

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

Re: [FFmpeg-devel] [PATCH V3] lavfi/opencl: add nlmeans_opencl filter

2019-05-20 Thread Song, Ruiling


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Tuesday, May 21, 2019 6:16 AM
> To: 'FFmpeg development discussions and patches'  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH V3] lavfi/opencl: add nlmeans_opencl
> filter
> 
> On 20/05/2019 02:18, Song, Ruiling wrote:
> >> -Original Message-
> >> From: Song, Ruiling
> >> Sent: Monday, May 13, 2019 10:18 AM
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>; 'Mark Thompson' 
> >> Subject: RE: [FFmpeg-devel] [PATCH V3] lavfi/opencl: add
> nlmeans_opencl
> >> filter
> >>
> >>> -Original Message-
> >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >> Behalf
> >>> Of Ruiling Song
> >>> Sent: Tuesday, May 7, 2019 10:45 AM
> >>> To: ffmpeg-devel@ffmpeg.org
> >>> Cc: Song, Ruiling 
> >>> Subject: [FFmpeg-devel] [PATCH V3] lavfi/opencl: add nlmeans_opencl
> >> filter
> >>>
> >>> Signed-off-by: Ruiling Song 
> >>> ---
> >>>  configure   |   1 +
> >>>  doc/filters.texi|   4 +
> >>>  libavfilter/Makefile|   1 +
> >>>  libavfilter/allfilters.c|   1 +
> >>>  libavfilter/opencl/nlmeans.cl   | 115 +
> >>>  libavfilter/opencl_source.h |   1 +
> >>>  libavfilter/vf_nlmeans_opencl.c | 443
> >>> 
> >>>  7 files changed, 566 insertions(+)
> >>>  create mode 100644 libavfilter/opencl/nlmeans.cl
> >>>  create mode 100644 libavfilter/vf_nlmeans_opencl.c
> >> Hi Mark,
> >>
> >> Do you have further comment on v3?
> > Will apply if no further comments.
> 
> No more from me.  I also did some testing of this on Mali, all good.
Thanks Mark for your valuable comments on the patch, will apply.

> 
> 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".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] libavfilter/dnn_native: Add multiple padding methods in dnn native

2019-05-20 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Xuewei Meng
> Sent: Saturday, May 18, 2019 3:19 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Xuewei Meng 
> Subject: [FFmpeg-devel] [PATCH v3] libavfilter/dnn_native: Add multiple 
> padding
> methods in dnn native
> 
> Add another two padding methods "VALID" and "SAME" as tensorflow, and
> keep the existing "SAME_CLAMP_TO_EDGE" method suggested by sr filter.
> As "SAME_CLAMP_TO_EDGE"can keep the output with the same size as
> original input, and gives a slight better result as mentioned by sr filter.
> 
> Signed-off-by: Xuewei Meng 
> ---
>  libavfilter/dnn_backend_native.c | 52 
>  libavfilter/dnn_backend_native.h |  3 ++
>  2 files changed, 43 insertions(+), 12 deletions(-)

looks good to me, except some trailing whitespaces.

> 
> diff --git a/libavfilter/dnn_backend_native.c 
> b/libavfilter/dnn_backend_native.c
> index 06fbdf368b..171a756385 100644
> --- a/libavfilter/dnn_backend_native.c
> +++ b/libavfilter/dnn_backend_native.c
> @@ -61,6 +61,12 @@ static DNNReturnType set_input_output_native(void
> *model, DNNInputData *input, c
>  return DNN_ERROR;
>  }
>  cur_channels = conv_params->output_num;
> +
> +if(conv_params->padding_method == VALID){
> +int pad_size = conv_params->kernel_size - 1;
> +cur_height -= pad_size;
> +cur_width -= pad_size;
> +}
>  break;
>  case DEPTH_TO_SPACE:
>  depth_to_space_params = (DepthToSpaceParams
> *)network->layers[layer].params;
> @@ -77,6 +83,10 @@ static DNNReturnType set_input_output_native(void
> *model, DNNInputData *input, c
>  if (network->layers[layer].output){
>  av_freep(&network->layers[layer].output);
>  }
> +
> +if(cur_height <= 0 || cur_width <= 0)
> +return DNN_ERROR;
> +
>  network->layers[layer].output = av_malloc(cur_height * cur_width *
> cur_channels * sizeof(float));
>  if (!network->layers[layer].output){
>  return DNN_ERROR;
> @@ -154,13 +164,14 @@ DNNModel *ff_dnn_load_model_native(const char
> *model_filename)
>  ff_dnn_free_model_native(&model);
>  return NULL;
>  }
> +conv_params->padding_method =
> (int32_t)avio_rl32(model_file_context);
>  conv_params->activation =
> (int32_t)avio_rl32(model_file_context);
>  conv_params->input_num =
> (int32_t)avio_rl32(model_file_context);
>  conv_params->output_num =
> (int32_t)avio_rl32(model_file_context);
>  conv_params->kernel_size =
> (int32_t)avio_rl32(model_file_context);
>  kernel_size = conv_params->input_num *
> conv_params->output_num *
>conv_params->kernel_size *
> conv_params->kernel_size;
> -dnn_size += 16 + (kernel_size + conv_params->output_num <<
> 2);
> +dnn_size += 20 + (kernel_size + conv_params->output_num <<
> 2);
>  if (dnn_size > file_size || conv_params->input_num <= 0 ||
>  conv_params->output_num <= 0 ||
> conv_params->kernel_size <= 0){
>  avio_closep(&model_file_context);
> @@ -218,23 +229,35 @@ DNNModel *ff_dnn_load_model_native(const char
> *model_filename)
> 
>  static void convolve(const float *input, float *output, const
> ConvolutionalParams *conv_params, int width, int height)
>  {
> -int y, x, n_filter, ch, kernel_y, kernel_x;
>  int radius = conv_params->kernel_size >> 1;
>  int src_linesize = width * conv_params->input_num;
>  int filter_linesize = conv_params->kernel_size *
> conv_params->input_num;
>  int filter_size = conv_params->kernel_size * filter_linesize;
> +int pad_size = (conv_params->padding_method == VALID) ?
> (conv_params->kernel_size - 1) / 2 : 0;
> 
> -for (y = 0; y < height; ++y){
> -for (x = 0; x < width; ++x){
> -for (n_filter = 0; n_filter < conv_params->output_num;
> ++n_filter){
> +for (int y = pad_size; y < height - pad_size; ++y){
> +for (int x = pad_size; x < width - pad_size; ++x){
> +for (int n_filter = 0; n_filter < conv_params->output_num;
> ++n_filter){
>  output[n_filter] = conv_params->biases[n_filter];
> -for (ch = 0; ch < conv_params->input_num; ++ch){
> -for (kernel_y = 0; kernel_y <
> conv_params->kernel_size; ++kernel_y){
> -for (kernel_x = 0; kernel_x <
> conv_params->kernel_size; ++kernel_x){
> -output[n_filter] +=
> input[CLAMP_TO_EDGE(y + kernel_y - radius, height) * src_linesize +
> -
> CLAMP_TO_EDGE(x + kernel_x - radius, width) * conv_params->input_num + ch]
> *
> -
> conv_params->kernel[n_filter * filter_size + kernel_y * filter_linesize +
> -
> kernel_x * conv_params->input_num + ch];
> +

Re: [FFmpeg-devel] [PATCH v2 02/11] cbs: Ensure that reference fields always follow the associated pointer

2019-05-20 Thread myp...@gmail.com
On Tue, May 21, 2019 at 7:08 AM Mark Thompson  wrote:
>
> Hvaing these together allows us to find both pointers given the address
> of only one of them.
> ---
>  libavcodec/cbs_av1.h   |  6 +++---
>  libavcodec/cbs_h264.h  | 18 +-
>  libavcodec/cbs_h265.h  | 16 
>  libavcodec/cbs_jpeg.h  |  2 +-
>  libavcodec/cbs_mpeg2.h | 10 +-
>  libavcodec/cbs_vp9.h   |  2 +-
>  6 files changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
> index 1fb668ada4..a87cbc030b 100644
> --- a/libavcodec/cbs_av1.h
> +++ b/libavcodec/cbs_av1.h
> @@ -284,8 +284,8 @@ typedef struct AV1RawFrameHeader {
>
>  typedef struct AV1RawTileData {
>  uint8_t *data;
> -size_t   data_size;
>  AVBufferRef *data_ref;
> +size_t   data_size;
>  } AV1RawTileData;
>
>  typedef struct AV1RawTileGroup {
> @@ -346,8 +346,8 @@ typedef struct AV1RawMetadataITUTT35 {
>  uint8_t itu_t_t35_country_code_extension_byte;
>
>  uint8_t *payload;
> -size_t   payload_size;
>  AVBufferRef *payload_ref;
> +size_t   payload_size;
>  } AV1RawMetadataITUTT35;
>
>  typedef struct AV1RawMetadataTimecode {
> @@ -379,8 +379,8 @@ typedef struct AV1RawMetadata {
>
>  typedef struct AV1RawPadding {
>  uint8_t *payload;
> -size_t   payload_size;
>  AVBufferRef *payload_ref;
> +size_t   payload_size;
>  } AV1RawPadding;
>
>
> diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
> index cc46eeb3b0..57a9782cc9 100644
> --- a/libavcodec/cbs_h264.h
> +++ b/libavcodec/cbs_h264.h
> @@ -277,16 +277,16 @@ typedef struct H264RawSEIPanScanRect {
>  typedef struct H264RawSEIUserDataRegistered {
>  uint8_t itu_t_t35_country_code;
>  uint8_t itu_t_t35_country_code_extension_byte;
> -uint8_t *data;
> -size_t data_length;
> +uint8_t *data;
>  AVBufferRef *data_ref;
> +size_t   data_length;
>  } H264RawSEIUserDataRegistered;
>
>  typedef struct H264RawSEIUserDataUnregistered {
>  uint8_t uuid_iso_iec_11578[16];
> -uint8_t *data;
> -size_t data_length;
> +uint8_t *data;
>  AVBufferRef *data_ref;
> +size_t   data_length;
>  } H264RawSEIUserDataUnregistered;
>
>  typedef struct H264RawSEIRecoveryPoint {
> @@ -328,9 +328,9 @@ typedef struct H264RawSEIPayload {
>  H264RawSEIDisplayOrientation display_orientation;
>  H264RawSEIMasteringDisplayColourVolume 
> mastering_display_colour_volume;
>  struct {
> -uint8_t *data;
> -size_t data_length;
> +uint8_t *data;
>  AVBufferRef *data_ref;
> +size_t   data_length;
>  } other;
>  } payload;
>  } H264RawSEIPayload;
> @@ -423,10 +423,10 @@ typedef struct H264RawSliceHeader {
>  typedef struct H264RawSlice {
>  H264RawSliceHeader header;
>
> -uint8_t *data;
> -size_t   data_size;
> -int  data_bit_start;
> +uint8_t *data;
>  AVBufferRef *data_ref;
> +size_t   data_size;
> +int  data_bit_start;
>  } H264RawSlice;
>
>  typedef struct H264RawFiller {
> diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
> index c9bc90187b..5cab93c828 100644
> --- a/libavcodec/cbs_h265.h
> +++ b/libavcodec/cbs_h265.h
> @@ -184,8 +184,8 @@ typedef struct H265RawVUI {
>
>  typedef struct H265RawPSExtensionData {
>  uint8_t *data;
> -size_t bit_length;
>  AVBufferRef *data_ref;
> +size_t bit_length;
>  } H265RawPSExtensionData;
>
>  typedef struct H265RawVPS {
> @@ -541,10 +541,10 @@ typedef struct  H265RawSliceHeader {
>  typedef struct H265RawSlice {
>  H265RawSliceHeader header;
>
> -uint8_t *data;
> -size_t   data_size;
> -int  data_bit_start;
> +uint8_t *data;
>  AVBufferRef *data_ref;
> +size_t   data_size;
> +int  data_bit_start;
>  } H265RawSlice;
>
>
> @@ -600,15 +600,15 @@ typedef struct H265RawSEIUserDataRegistered {
>  uint8_t itu_t_t35_country_code;
>  uint8_t itu_t_t35_country_code_extension_byte;
>  uint8_t *data;
> -size_t   data_length;
>  AVBufferRef *data_ref;
> +size_t   data_length;
>  } H265RawSEIUserDataRegistered;
>
>  typedef struct H265RawSEIUserDataUnregistered {
>  uint8_t uuid_iso_iec_11578[16];
>  uint8_t *data;
> -size_t   data_length;
>  AVBufferRef *data_ref;
> +size_t   data_length;
>  } H265RawSEIUserDataUnregistered;
>
>  typedef struct H265RawSEIRecoveryPoint {
> @@ -698,9 +698,9 @@ typedef struct H265RawSEIPayload {
>  H265RawSEIAlternativeTransferCharacteristics
>  alternative_transfer_characteristics;
>  struct {
> -uint8_t *data;
> -size_t data_length;
> +uint8_t *data;
>  AVBufferRef *data_ref;
> +size_t   data_length;
>  } other;
>  } payload;
>  } H265RawSEIPayload;
> diff --git a/libavcodec/

Re: [FFmpeg-devel] [PATCH v2 01/11] cbs: Mention all codecs in unit type comment

2019-05-20 Thread myp...@gmail.com
On Tue, May 21, 2019 at 7:02 AM Mark Thompson  wrote:
>
> ---
>  libavcodec/cbs.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index 967dcd1468..e8b2d41ecb 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -49,6 +49,8 @@ struct CodedBitstreamType;
>   * H.265 / HEVC: nal_unit_type
>   * MPEG-2: start code value (without prefix)
>   * VP9: unused, set to zero (every unit is a frame)
> + * JPEG: marker value (without 0xff prefix)
> + * AV1: obu_type
>   */
>  typedef uint32_t CodedBitstreamUnitType;
>

LGTM
___
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] lavfi/colorlevels: Add slice threading support

2019-05-20 Thread Jun Zhao
From: Jun Zhao 

Add slice threading support, use the command like:

./ffmpeg -i input -vf colorlevel with 1080p h264 clip, the fps
from 39 fps to 79 fps in the local

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_colorlevels.c |  125 +++--
 1 files changed, 106 insertions(+), 19 deletions(-)

diff --git a/libavfilter/vf_colorlevels.c b/libavfilter/vf_colorlevels.c
index 5385a5e..68668e7 100644
--- a/libavfilter/vf_colorlevels.c
+++ b/libavfilter/vf_colorlevels.c
@@ -105,6 +105,83 @@ static int config_input(AVFilterLink *inlink)
 return 0;
 }
 
+struct thread_data {
+const uint8_t *srcrow;
+uint8_t *dstrow;
+int dst_linesize;
+int src_linesize;
+
+double coeff;
+uint8_t offset;
+
+int h;
+
+int imin;
+int omin;
+};
+
+static int colorlevel_slice_8(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+ColorLevelsContext *s = ctx->priv;
+const struct thread_data *td = arg;
+
+int process_h = td->h;
+const int slice_start = (process_h *  jobnr   ) / nb_jobs;
+const int slice_end   = (process_h * (jobnr+1)) / nb_jobs;
+int x, y;
+const uint8_t *srcrow = td->srcrow;
+uint8_t *dstrow = td->dstrow;
+const int step = s->step;
+const uint8_t offset = td->offset;
+
+int imin = td->imin;
+int omin = td->omin;
+double coeff = td->coeff;
+
+for (y = slice_start; y < slice_end; y++) {
+const uint8_t *src = srcrow;
+uint8_t *dst = dstrow;
+
+for (x = 0; x < s->linesize; x += step)
+dst[x + offset] = av_clip_uint8((src[x + offset] - imin) * coeff + 
omin);
+dstrow += td->dst_linesize;
+srcrow += td->src_linesize;
+}
+
+return 0;
+}
+
+static int colorlevel_slice_16(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+ColorLevelsContext *s = ctx->priv;
+const struct thread_data *td = arg;
+
+int process_h = td->h;
+const int slice_start = (process_h *  jobnr   ) / nb_jobs;
+const int slice_end   = (process_h * (jobnr+1)) / nb_jobs;
+int x, y;
+const uint8_t *srcrow = td->srcrow;
+uint8_t *dstrow = td->dstrow;
+const int step = s->step;
+const uint8_t offset = td->offset;
+
+int imin = td->imin;
+int omin = td->omin;
+double coeff = td->coeff;
+
+for (y = slice_start; y < slice_end; y++) {
+const uint16_t *src = (const uint16_t *)srcrow;
+uint16_t *dst = (uint16_t *)dstrow;
+
+for (x = 0; x < s->linesize; x += step)
+dst[x + offset] = av_clip_uint8((src[x + offset] - imin) * coeff + 
omin);
+dstrow += td->dst_linesize;
+srcrow += td->src_linesize;
+}
+
+return 0;
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
@@ -137,6 +214,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 int omin = lrint(r->out_min * UINT8_MAX);
 int omax = lrint(r->out_max * UINT8_MAX);
 double coeff;
+struct thread_data td;
 
 if (imin < 0) {
 imin = UINT8_MAX;
@@ -162,15 +240,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
 srcrow = in->data[0];
 coeff = (omax - omin) / (double)(imax - imin);
-for (y = 0; y < inlink->h; y++) {
-const uint8_t *src = srcrow;
-uint8_t *dst = dstrow;
-
-for (x = 0; x < s->linesize; x += step)
-dst[x + offset] = av_clip_uint8((src[x + offset] - imin) * 
coeff + omin);
-dstrow += out->linesize[0];
-srcrow += in->linesize[0];
-}
+
+td.srcrow= srcrow;
+td.dstrow= dstrow;
+td.dst_linesize  = out->linesize[0];
+td.src_linesize  = in->linesize[0];
+td.coeff = coeff;
+td.offset= offset;
+td.h = inlink->h;
+td.imin  = imin;
+td.omin  = omin;
+
+ctx->internal->execute(ctx, colorlevel_slice_8, &td, NULL,
+   FFMIN(inlink->h, 
ff_filter_get_nb_threads(ctx)));
 }
 break;
 case 2:
@@ -184,6 +266,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 int omin = lrint(r->out_min * UINT16_MAX);
 int omax = lrint(r->out_max * UINT16_MAX);
 double coeff;
+struct thread_data td;
 
 if (imin < 0) {
 imin = UINT16_MAX;
@@ -209,15 +292,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
 srcrow = in->data[0];
 coeff = (omax - omin) / (double)(imax - imin);
-for (y = 0; y < inlink->h; y++) {
-const uint16_t *src = (const uint16_t*)srcrow;
-uint16_t *dst = (uint16_t *)dstrow;
-
-for (x = 0; x < s->linesize;

[FFmpeg-devel] [PATCH] avcodec/dxv: Check op_offset in dxv_decompress_cocg()

2019-05-20 Thread Michael Niedermayer
Fixes: signed integer overflow: -2147483648 - 12 cannot be represented in type 
'int'
Fixes: 
14732/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_fuzzer-5735273129836544

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

diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index 6fe5516505..5fd1844094 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -745,6 +745,9 @@ static int dxv_decompress_cocg(DXVContext *ctx, 
GetByteContext *gb,
 int skip0, skip1, oi0 = 0, oi1 = 0;
 int ret, state0 = 0, state1 = 0;
 
+if (op_offset < 12)
+return AVERROR_INVALIDDATA;
+
 dst = tex_data;
 bytestream2_skip(gb, op_offset - 12);
 if (op_size0 > max_op_size0)
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH] lavc/vp9_superframe_bsf: avoid error messages in one line

2019-05-20 Thread Mark Thompson
On 16/05/2019 16:04, Fu Linjie wrote:
> Add "\n" to avoid continuous error messages in one line.
> 
> Signed-off-by: Fu Linjie 
> ---
>  libavcodec/vp9_superframe_bsf.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vp9_superframe_bsf.c b/libavcodec/vp9_superframe_bsf.c
> index ea67507..23933d4 100644
> --- a/libavcodec/vp9_superframe_bsf.c
> +++ b/libavcodec/vp9_superframe_bsf.c
> @@ -133,7 +133,7 @@ static int vp9_superframe_filter(AVBSFContext *ctx, 
> AVPacket *out)
>  
>  if (uses_superframe_syntax && s->n_cache > 0) {
>  av_log(ctx, AV_LOG_ERROR,
> -   "Mixing of superframe syntax and naked VP9 frames not 
> supported");
> +   "Mixing of superframe syntax and naked VP9 frames not 
> supported\n");
>  res = AVERROR(ENOSYS);
>  goto done;
>  } else if ((!invisible || uses_superframe_syntax) && !s->n_cache) {
> @@ -142,7 +142,7 @@ static int vp9_superframe_filter(AVBSFContext *ctx, 
> AVPacket *out)
>  goto done;
>  } else if (s->n_cache + 1 >= MAX_CACHE) {
>  av_log(ctx, AV_LOG_ERROR,
> -   "Too many invisible frames");
> +   "Too many invisible frames\n");
>  res = AVERROR_INVALIDDATA;
>  goto done;
>  }
> 

Yep, applied.

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

[FFmpeg-devel] [PATCH v2 08/11] h264_redundant_pps: Make it reference-compatible

2019-05-20 Thread Mark Thompson
From: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/h264_redundant_pps_bsf.c 
b/libavcodec/h264_redundant_pps_bsf.c
index db8717d69a..b98c344058 100644
--- a/libavcodec/h264_redundant_pps_bsf.c
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -40,8 +40,19 @@ typedef struct H264RedundantPPSContext {
 
 
 static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx,
-H264RawPPS *pps)
+CodedBitstreamUnit *unit)
 {
+H264RawPPS *pps;
+int err;
+
+// The changes we are about to perform affect the parsing process,
+// so we must make sure that the PPS is writable, otherwise the
+// parsing of future slices will be incorrect and even raise errors.
+err = ff_cbs_make_unit_writable(ctx->input, unit);
+if (err < 0)
+return err;
+pps = unit->content;
+
 // Record the current value of pic_init_qp in order to fix up
 // following slices, then overwrite with the global value.
 ctx->current_pic_init_qp = pps->pic_init_qp_minus26 + 26;
@@ -89,7 +100,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, 
AVPacket *out)
 if (nal->type == H264_NAL_SPS)
 au_has_sps = 1;
 if (nal->type == H264_NAL_PPS) {
-err = h264_redundant_pps_fixup_pps(ctx, nal->content);
+err = h264_redundant_pps_fixup_pps(ctx, nal);
 if (err < 0)
 goto fail;
 if (!au_has_sps) {
@@ -151,7 +162,7 @@ static int h264_redundant_pps_init(AVBSFContext *bsf)
 
 for (i = 0; i < au->nb_units; i++) {
 if (au->units[i].type == H264_NAL_PPS) {
-err = h264_redundant_pps_fixup_pps(ctx, au->units[i].content);
+err = h264_redundant_pps_fixup_pps(ctx, &au->units[i]);
 if (err < 0)
 goto fail;
 }
-- 
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 v2 03/11] cbs: Describe allocate/free methods in tabular form

2019-05-20 Thread Mark Thompson
Unit types are split into three categories, depending on how their
content is managed:
* POD structure - these require no special treatment.
* Structure containing references to refcounted buffers - these can use
  a common free function when the offsets of all the internal references
  are known.
* More complex structures - these still require ad-hoc treatment.

For each codec we can then maintain a table of descriptors for each unit
type, defining the mechanism needed to allocate/free that unit content.
This is not required to be used immediately - a new alloc function
supports this, but does not replace the old one which works without
referring to these tables.
---
 libavcodec/cbs.c  | 62 +++
 libavcodec/cbs.h  | 16 ++
 libavcodec/cbs_internal.h | 36 +++
 3 files changed, 114 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 0260ba6f67..1963d86133 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -754,3 +754,65 @@ int ff_cbs_delete_unit(CodedBitstreamContext *ctx,
 
 return 0;
 }
+
+static void cbs_default_free_unit_content(void *opaque, uint8_t *data)
+{
+const CodedBitstreamUnitTypeDescriptor *desc = opaque;
+if (desc->content_type == CBS_CONTENT_TYPE_INTERNAL_REFS) {
+int i;
+for (i = 0; i < desc->nb_ref_offsets; i++) {
+void **ptr = (void**)(data + desc->ref_offsets[i]);
+av_buffer_unref((AVBufferRef**)(ptr + 1));
+*ptr = NULL;
+}
+}
+av_free(data);
+}
+
+static const CodedBitstreamUnitTypeDescriptor
+*cbs_find_unit_type_desc(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit)
+{
+const CodedBitstreamUnitTypeDescriptor *desc;
+int i;
+
+if (!ctx->codec->unit_types)
+return NULL;
+
+for (i = 0;; i++) {
+desc = &ctx->codec->unit_types[i];
+if (desc->unit_type == CBS_INVALID_UNIT_TYPE)
+break;
+if (desc->unit_type == unit->type)
+return desc;
+}
+return NULL;
+}
+
+int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
+   CodedBitstreamUnit *unit)
+{
+const CodedBitstreamUnitTypeDescriptor *desc;
+
+av_assert0(!unit->content && !unit->content_ref);
+
+desc = cbs_find_unit_type_desc(ctx, unit);
+if (!desc)
+return AVERROR(ENOSYS);
+
+unit->content = av_mallocz(desc->content_size);
+if (!unit->content)
+return AVERROR(ENOMEM);
+
+unit->content_ref =
+av_buffer_create(unit->content, desc->content_size,
+ desc->content_free ? desc->content_free
+: cbs_default_free_unit_content,
+ (void*)desc, 0);
+if (!unit->content_ref) {
+av_freep(&unit->content);
+return AVERROR(ENOMEM);
+}
+
+return 0;
+}
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index e8b2d41ecb..8f764905bd 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -54,6 +54,13 @@ struct CodedBitstreamType;
  */
 typedef uint32_t CodedBitstreamUnitType;
 
+/**
+ * Value which is never valid as a unit type.
+ *
+ * This can be used as a sentinel.
+ */
+#define CBS_INVALID_UNIT_TYPE (UINT32_MAX)
+
 /**
  * Coded bitstream unit structure.
  *
@@ -337,6 +344,15 @@ int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,
   size_t size,
   void (*free)(void *unit, uint8_t *content));
 
+/**
+ * Allocate a new internal content buffer matching the type of the unit.
+ *
+ * The content will be zeroed.
+ */
+int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
+   CodedBitstreamUnit *unit);
+
+
 /**
  * Allocate a new internal data buffer of the given size in the unit.
  *
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index dd4babf092..06a8f9b979 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -25,11 +25,47 @@
 #include "put_bits.h"
 
 
+enum {
+// Unit content is a simple structure.
+CBS_CONTENT_TYPE_POD,
+// Unit content contains some references to other structures, but all
+// managed via buffer reference counting.  The descriptor defines the
+// structure offsets of every buffer reference.
+CBS_CONTENT_TYPE_INTERNAL_REFS,
+// Unit content is something more complex.  The descriptor defines
+// special functions to manage the content.
+CBS_CONTENT_TYPE_COMPLEX,
+};
+
+// Maximum number of reference buffer offsets in any one unit.
+#define CBS_MAX_REF_OFFSETS 1
+
+typedef struct CodedBitstreamUnitTypeDescriptor {
+CodedBitstreamUnitType unit_type;
+
+intcontent_type;
+size_t content_size;
+
+int nb_ref_offsets;
+// The structure must contain two adjacent elements:
+//   type*field;
+//   AVBufferRef *field_ref;
+// where field points to somethi

[FFmpeg-devel] [PATCH v2 05/11] cbs_h264: Use table-based alloc/free

2019-05-20 Thread Mark Thompson
---
 libavcodec/cbs_h2645.c | 156 +
 1 file changed, 64 insertions(+), 92 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 319202fc48..e10bb2c62b 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -442,51 +442,6 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 #undef allocate
 
 
-static void cbs_h264_free_pps(void *unit, uint8_t *content)
-{
-H264RawPPS *pps = (H264RawPPS*)content;
-av_buffer_unref(&pps->slice_group_id_ref);
-av_freep(&content);
-}
-
-static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload)
-{
-switch (payload->payload_type) {
-case H264_SEI_TYPE_BUFFERING_PERIOD:
-case H264_SEI_TYPE_PIC_TIMING:
-case H264_SEI_TYPE_PAN_SCAN_RECT:
-case H264_SEI_TYPE_RECOVERY_POINT:
-case H264_SEI_TYPE_DISPLAY_ORIENTATION:
-case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
-break;
-case H264_SEI_TYPE_USER_DATA_REGISTERED:
-av_buffer_unref(&payload->payload.user_data_registered.data_ref);
-break;
-case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
-av_buffer_unref(&payload->payload.user_data_unregistered.data_ref);
-break;
-default:
-av_buffer_unref(&payload->payload.other.data_ref);
-break;
-}
-}
-
-static void cbs_h264_free_sei(void *unit, uint8_t *content)
-{
-H264RawSEI *sei = (H264RawSEI*)content;
-int i;
-for (i = 0; i < sei->payload_count; i++)
-cbs_h264_free_sei_payload(&sei->payload[i]);
-av_freep(&content);
-}
-
-static void cbs_h264_free_slice(void *unit, uint8_t *content)
-{
-H264RawSlice *slice = (H264RawSlice*)content;
-av_buffer_unref(&slice->data_ref);
-av_freep(&content);
-}
-
 static void cbs_h265_free_vps(void *unit, uint8_t *content)
 {
 H265RawVPS *vps = (H265RawVPS*)content;
@@ -781,15 +736,14 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 if (err < 0)
 return err;
 
+err = ff_cbs_alloc_unit_content2(ctx, unit);
+if (err < 0)
+return err;
+
 switch (unit->type) {
 case H264_NAL_SPS:
 {
-H264RawSPS *sps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*sps), NULL);
-if (err < 0)
-return err;
-sps = unit->content;
+H264RawSPS *sps = unit->content;
 
 err = cbs_h264_read_sps(ctx, &gbc, sps);
 if (err < 0)
@@ -803,12 +757,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_SPS_EXT:
 {
-err = ff_cbs_alloc_unit_content(ctx, unit,
-sizeof(H264RawSPSExtension),
-NULL);
-if (err < 0)
-return err;
-
 err = cbs_h264_read_sps_extension(ctx, &gbc, unit->content);
 if (err < 0)
 return err;
@@ -817,13 +765,7 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_PPS:
 {
-H264RawPPS *pps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*pps),
-&cbs_h264_free_pps);
-if (err < 0)
-return err;
-pps = unit->content;
+H264RawPPS *pps = unit->content;
 
 err = cbs_h264_read_pps(ctx, &gbc, pps);
 if (err < 0)
@@ -839,15 +781,9 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 case H264_NAL_IDR_SLICE:
 case H264_NAL_AUXILIARY_SLICE:
 {
-H264RawSlice *slice;
+H264RawSlice *slice = unit->content;
 int pos, len;
 
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*slice),
-&cbs_h264_free_slice);
-if (err < 0)
-return err;
-slice = unit->content;
-
 err = cbs_h264_read_slice_header(ctx, &gbc, &slice->header);
 if (err < 0)
 return err;
@@ -873,11 +809,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_AUD:
 {
-err = ff_cbs_alloc_unit_content(ctx, unit,
-sizeof(H264RawAUD), NULL);
-if (err < 0)
-return err;
-
 err = cbs_h264_read_aud(ctx, &gbc, unit->content);
 if (err < 0)
 return err;
@@ -886,11 +817,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_SEI:
 {
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(H264RawSEI),
-&cbs_h264_free_sei);
-if (err < 0)
-return err;
-
 err = cbs_h264_read_sei(ctx, &gbc, unit->content);
 if (err < 0)
 return err;
@@ -899,11 

[FFmpeg-devel] [PATCH v2 11/11] cbs_av1: Use table-based alloc/free

2019-05-20 Thread Mark Thompson
---
 libavcodec/cbs_av1.c | 85 
 1 file changed, 39 insertions(+), 46 deletions(-)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index eb2d03ef43..c497ddc352 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -811,50 +811,6 @@ fail:
 return err;
 }
 
-static void cbs_av1_free_tile_data(AV1RawTileData *td)
-{
-av_buffer_unref(&td->data_ref);
-}
-
-static void cbs_av1_free_padding(AV1RawPadding *pd)
-{
-av_buffer_unref(&pd->payload_ref);
-}
-
-static void cbs_av1_free_metadata(AV1RawMetadata *md)
-{
-switch (md->metadata_type) {
-case AV1_METADATA_TYPE_ITUT_T35:
-av_buffer_unref(&md->metadata.itut_t35.payload_ref);
-break;
-}
-}
-
-static void cbs_av1_free_obu(void *unit, uint8_t *content)
-{
-AV1RawOBU *obu = (AV1RawOBU*)content;
-
-switch (obu->header.obu_type) {
-case AV1_OBU_TILE_GROUP:
-cbs_av1_free_tile_data(&obu->obu.tile_group.tile_data);
-break;
-case AV1_OBU_FRAME:
-cbs_av1_free_tile_data(&obu->obu.frame.tile_group.tile_data);
-break;
-case AV1_OBU_TILE_LIST:
-cbs_av1_free_tile_data(&obu->obu.tile_list.tile_data);
-break;
-case AV1_OBU_METADATA:
-cbs_av1_free_metadata(&obu->obu.metadata);
-break;
-case AV1_OBU_PADDING:
-cbs_av1_free_padding(&obu->obu.padding);
-break;
-}
-
-av_freep(&obu);
-}
-
 static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx,
  CodedBitstreamUnit *unit,
  GetBitContext *gbc,
@@ -889,8 +845,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
 GetBitContext gbc;
 int err, start_pos, end_pos;
 
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*obu),
-&cbs_av1_free_obu);
+err = ff_cbs_alloc_unit_content2(ctx, unit);
 if (err < 0)
 return err;
 obu = unit->content;
@@ -1303,11 +1258,49 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
 av_freep(&priv->write_buffer);
 }
 
+static void cbs_av1_free_metadata(void *unit, uint8_t *content)
+{
+AV1RawOBU *obu = (AV1RawOBU*)content;
+AV1RawMetadata *md;
+
+av_assert0(obu->header.obu_type == AV1_OBU_METADATA);
+md = &obu->obu.metadata;
+
+switch (md->metadata_type) {
+case AV1_METADATA_TYPE_ITUT_T35:
+av_buffer_unref(&md->metadata.itut_t35.payload_ref);
+break;
+}
+}
+
+static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = {
+CBS_UNIT_TYPE_POD(AV1_OBU_SEQUENCE_HEADER,AV1RawOBU),
+CBS_UNIT_TYPE_POD(AV1_OBU_TEMPORAL_DELIMITER, AV1RawOBU),
+CBS_UNIT_TYPE_POD(AV1_OBU_FRAME_HEADER,   AV1RawOBU),
+CBS_UNIT_TYPE_POD(AV1_OBU_REDUNDANT_FRAME_HEADER, AV1RawOBU),
+
+CBS_UNIT_TYPE_INTERNAL_REFS(AV1_OBU_TILE_GROUP, AV1RawOBU, 1,
+{ offsetof(AV1RawOBU, 
obu.tile_group.tile_data.data) }),
+CBS_UNIT_TYPE_INTERNAL_REFS(AV1_OBU_FRAME,  AV1RawOBU, 1,
+{ offsetof(AV1RawOBU, 
obu.frame.tile_group.tile_data.data) }),
+CBS_UNIT_TYPE_INTERNAL_REFS(AV1_OBU_TILE_LIST,  AV1RawOBU, 1,
+{ offsetof(AV1RawOBU, 
obu.tile_list.tile_data.data) }),
+CBS_UNIT_TYPE_INTERNAL_REFS(AV1_OBU_PADDING,AV1RawOBU, 1,
+{ offsetof(AV1RawOBU, obu.padding.payload) }),
+
+CBS_UNIT_TYPE_COMPLEX(AV1_OBU_METADATA, AV1RawOBU,
+  &cbs_av1_free_metadata),
+
+CBS_UNIT_TYPE_END_OF_LIST
+};
+
 const CodedBitstreamType ff_cbs_type_av1 = {
 .codec_id  = AV_CODEC_ID_AV1,
 
 .priv_data_size= sizeof(CodedBitstreamAV1Context),
 
+.unit_types= cbs_av1_unit_types,
+
 .split_fragment= &cbs_av1_split_fragment,
 .read_unit = &cbs_av1_read_unit,
 .write_unit= &cbs_av1_write_unit,
-- 
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 v2 06/11] cbs: Add support functions for handling unit content references

2019-05-20 Thread Mark Thompson
Use the unit type table to determine what we need to do to clone the
internals of the unit content when making copies for refcounting or
writeability.  (This will still fail for units with complex content
if they do not have a defined clone function.)

Setup and naming from a patch by Andreas Rheinhardt
, but with the implementation
changed to use the unit type information if possible rather than
requiring a codec-specific function.
---
 libavcodec/cbs.c  | 168 ++
 libavcodec/cbs.h  |  23 ++
 libavcodec/cbs_internal.h |   1 +
 3 files changed, 192 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 1963d86133..9fc8e1eb47 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -816,3 +816,171 @@ int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
 
 return 0;
 }
+
+static int cbs_clone_unit_content(AVBufferRef **clone_ref,
+  CodedBitstreamUnit *unit,
+  const CodedBitstreamUnitTypeDescriptor *desc)
+{
+uint8_t *src, *copy;
+void **src_ptr, **copy_ptr;
+AVBufferRef **src_buf, **copy_buf;
+int err, i;
+
+av_assert0(unit->type == desc->unit_type);
+av_assert0(unit->content);
+src = unit->content;
+
+copy = av_malloc(desc->content_size);
+if (!copy) {
+err = AVERROR(ENOMEM);
+goto fail;
+}
+memcpy(copy, src, desc->content_size);
+
+for (i = 0; i < desc->nb_ref_offsets; i++) {
+src_ptr  = (void**)(src + desc->ref_offsets[i]);
+src_buf  = (AVBufferRef**)(src_ptr + 1);
+copy_ptr = (void**)(copy + desc->ref_offsets[i]);
+copy_buf = (AVBufferRef**)(copy_ptr + 1);
+
+if (!*src_ptr) {
+av_assert0(!*src_buf);
+continue;
+}
+if (!*src_buf) {
+// We can't handle a non-refcounted pointer here - we don't
+// have enough information to handle whatever structure lies
+// at the other end of it.
+err = AVERROR(EINVAL);
+goto fail;
+}
+
+// src_ptr is required to point somewhere inside src_buf.  If it
+// doesn't, there is a bug somewhere.
+av_assert0((uint8_t*)*src_ptr >= (*src_buf)->data &&
+   (uint8_t*)*src_ptr <  (*src_buf)->data + (*src_buf)->size);
+
+*copy_buf = av_buffer_ref(*src_buf);
+if (!*copy_buf) {
+err = AVERROR(ENOMEM);
+goto fail;
+}
+
+err = av_buffer_make_writable(copy_buf);
+if (err < 0) {
+av_buffer_unref(copy_buf);
+goto fail;
+}
+
+*copy_ptr = (*copy_buf)->data +
+((uint8_t*)*src_ptr - (*src_buf)->data);
+}
+
+*clone_ref = av_buffer_create(copy, desc->content_size,
+  desc->content_free ? desc->content_free :
+  cbs_default_free_unit_content,
+  (void*)desc, 0);
+if (!*clone_ref)
+goto fail;
+
+return 0;
+
+fail:
+for (--i; i >= 0; i--)
+av_buffer_unref((AVBufferRef**)(copy + desc->ref_offsets[i]));
+av_freep(©);
+*clone_ref = NULL;
+return err;
+}
+
+int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,
+CodedBitstreamUnit *unit)
+{
+const CodedBitstreamUnitTypeDescriptor *desc;
+AVBufferRef *ref;
+int err;
+
+if (unit->content_ref)
+return 0;
+
+desc = cbs_find_unit_type_desc(ctx, unit);
+if (!desc)
+return AVERROR(ENOSYS);
+
+switch (desc->content_type) {
+case CBS_CONTENT_TYPE_POD:
+ref = av_buffer_alloc(desc->content_size);
+if (!ref)
+return AVERROR(ENOMEM);
+memcpy(ref->data, unit->content, desc->content_size);
+err = 0;
+break;
+
+case CBS_CONTENT_TYPE_INTERNAL_REFS:
+err = cbs_clone_unit_content(&ref, unit, desc);
+break;
+
+case CBS_CONTENT_TYPE_COMPLEX:
+if (!desc->content_clone)
+return AVERROR_PATCHWELCOME;
+err = desc->content_clone(&ref, unit);
+break;
+
+default:
+av_assert0(0 && "Invalid content type.");
+}
+
+if (err < 0)
+return err;
+
+av_buffer_unref(&unit->content_ref);
+unit->content_ref = ref;
+unit->content = ref->data;
+return 0;
+}
+
+int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
+  CodedBitstreamUnit *unit)
+{
+const CodedBitstreamUnitTypeDescriptor *desc;
+AVBufferRef *ref;
+int err;
+
+// This can only be applied to refcounted units.
+err = ff_cbs_make_unit_refcounted(ctx, unit);
+if (err < 0)
+return err;
+av_assert0(unit->content && unit->content_ref);
+
+if (av_buffer_is_writable(unit->content_ref))
+return 0;
+
+desc = cbs_find_unit_type_desc(ctx, unit);
+if (!desc)
+return AVE

[FFmpeg-devel] [PATCH v2 02/11] cbs: Ensure that reference fields always follow the associated pointer

2019-05-20 Thread Mark Thompson
Hvaing these together allows us to find both pointers given the address
of only one of them.
---
 libavcodec/cbs_av1.h   |  6 +++---
 libavcodec/cbs_h264.h  | 18 +-
 libavcodec/cbs_h265.h  | 16 
 libavcodec/cbs_jpeg.h  |  2 +-
 libavcodec/cbs_mpeg2.h | 10 +-
 libavcodec/cbs_vp9.h   |  2 +-
 6 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 1fb668ada4..a87cbc030b 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -284,8 +284,8 @@ typedef struct AV1RawFrameHeader {
 
 typedef struct AV1RawTileData {
 uint8_t *data;
-size_t   data_size;
 AVBufferRef *data_ref;
+size_t   data_size;
 } AV1RawTileData;
 
 typedef struct AV1RawTileGroup {
@@ -346,8 +346,8 @@ typedef struct AV1RawMetadataITUTT35 {
 uint8_t itu_t_t35_country_code_extension_byte;
 
 uint8_t *payload;
-size_t   payload_size;
 AVBufferRef *payload_ref;
+size_t   payload_size;
 } AV1RawMetadataITUTT35;
 
 typedef struct AV1RawMetadataTimecode {
@@ -379,8 +379,8 @@ typedef struct AV1RawMetadata {
 
 typedef struct AV1RawPadding {
 uint8_t *payload;
-size_t   payload_size;
 AVBufferRef *payload_ref;
+size_t   payload_size;
 } AV1RawPadding;
 
 
diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index cc46eeb3b0..57a9782cc9 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -277,16 +277,16 @@ typedef struct H264RawSEIPanScanRect {
 typedef struct H264RawSEIUserDataRegistered {
 uint8_t itu_t_t35_country_code;
 uint8_t itu_t_t35_country_code_extension_byte;
-uint8_t *data;
-size_t data_length;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_length;
 } H264RawSEIUserDataRegistered;
 
 typedef struct H264RawSEIUserDataUnregistered {
 uint8_t uuid_iso_iec_11578[16];
-uint8_t *data;
-size_t data_length;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_length;
 } H264RawSEIUserDataUnregistered;
 
 typedef struct H264RawSEIRecoveryPoint {
@@ -328,9 +328,9 @@ typedef struct H264RawSEIPayload {
 H264RawSEIDisplayOrientation display_orientation;
 H264RawSEIMasteringDisplayColourVolume mastering_display_colour_volume;
 struct {
-uint8_t *data;
-size_t data_length;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_length;
 } other;
 } payload;
 } H264RawSEIPayload;
@@ -423,10 +423,10 @@ typedef struct H264RawSliceHeader {
 typedef struct H264RawSlice {
 H264RawSliceHeader header;
 
-uint8_t *data;
-size_t   data_size;
-int  data_bit_start;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_size;
+int  data_bit_start;
 } H264RawSlice;
 
 typedef struct H264RawFiller {
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index c9bc90187b..5cab93c828 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -184,8 +184,8 @@ typedef struct H265RawVUI {
 
 typedef struct H265RawPSExtensionData {
 uint8_t *data;
-size_t bit_length;
 AVBufferRef *data_ref;
+size_t bit_length;
 } H265RawPSExtensionData;
 
 typedef struct H265RawVPS {
@@ -541,10 +541,10 @@ typedef struct  H265RawSliceHeader {
 typedef struct H265RawSlice {
 H265RawSliceHeader header;
 
-uint8_t *data;
-size_t   data_size;
-int  data_bit_start;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_size;
+int  data_bit_start;
 } H265RawSlice;
 
 
@@ -600,15 +600,15 @@ typedef struct H265RawSEIUserDataRegistered {
 uint8_t itu_t_t35_country_code;
 uint8_t itu_t_t35_country_code_extension_byte;
 uint8_t *data;
-size_t   data_length;
 AVBufferRef *data_ref;
+size_t   data_length;
 } H265RawSEIUserDataRegistered;
 
 typedef struct H265RawSEIUserDataUnregistered {
 uint8_t uuid_iso_iec_11578[16];
 uint8_t *data;
-size_t   data_length;
 AVBufferRef *data_ref;
+size_t   data_length;
 } H265RawSEIUserDataUnregistered;
 
 typedef struct H265RawSEIRecoveryPoint {
@@ -698,9 +698,9 @@ typedef struct H265RawSEIPayload {
 H265RawSEIAlternativeTransferCharacteristics
 alternative_transfer_characteristics;
 struct {
-uint8_t *data;
-size_t data_length;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_length;
 } other;
 } payload;
 } H265RawSEIPayload;
diff --git a/libavcodec/cbs_jpeg.h b/libavcodec/cbs_jpeg.h
index 913d3f90f6..d51c83845b 100644
--- a/libavcodec/cbs_jpeg.h
+++ b/libavcodec/cbs_jpeg.h
@@ -80,8 +80,8 @@ typedef struct JPEGRawScanHeader {
 typedef struct JPEGRawScan {
 JPEGRawScanHeader header;
 uint8_t  *data;
-size_tdata_size;
 AVBufferRef  *data_

[FFmpeg-devel] [PATCH v2 07/11] cbs_h2645: Ensure that non-refcounted parameter sets are fully copied

2019-05-20 Thread Mark Thompson
Only copying the main structure is not necessarily sufficient - there
could be references to substructures.
---
 libavcodec/cbs_h2645.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index e10bb2c62b..0b0996829c 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -700,18 +700,20 @@ static int cbs_h26 ## h26n ## _replace_ ## 
ps_var(CodedBitstreamContext *ctx, \
 CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
 H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
 unsigned int id = ps_var->id_element; \
+int err; \
 if (id > FF_ARRAY_ELEMS(priv->ps_var)) { \
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid " #ps_name \
" id : %d.\n", id); \
 return AVERROR_INVALIDDATA; \
 } \
+err = ff_cbs_make_unit_refcounted(ctx, unit); \
+if (err < 0) \
+return err; \
 if (priv->ps_var[id] == priv->active_ ## ps_var) \
 priv->active_ ## ps_var = NULL ; \
 av_buffer_unref(&priv->ps_var ## _ref[id]); \
-if (unit->content_ref) \
-priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
-else \
-priv->ps_var ## _ref[id] = av_buffer_alloc(sizeof(*ps_var)); \
+av_assert0(unit->content_ref); \
+priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
 if (!priv->ps_var ## _ref[id]) \
 return AVERROR(ENOMEM); \
 priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## 
_ref[id]->data; \
-- 
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 v2 09/11] cbs_h265: Use table-based alloc/free

2019-05-20 Thread Mark Thompson
---
 libavcodec/cbs_h2645.c | 186 ++---
 1 file changed, 83 insertions(+), 103 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 0b0996829c..9d19577980 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -442,70 +442,6 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 #undef allocate
 
 
-static void cbs_h265_free_vps(void *unit, uint8_t *content)
-{
-H265RawVPS *vps = (H265RawVPS*)content;
-av_buffer_unref(&vps->extension_data.data_ref);
-av_freep(&content);
-}
-
-static void cbs_h265_free_sps(void *unit, uint8_t *content)
-{
-H265RawSPS *sps = (H265RawSPS*)content;
-av_buffer_unref(&sps->extension_data.data_ref);
-av_freep(&content);
-}
-
-static void cbs_h265_free_pps(void *unit, uint8_t *content)
-{
-H265RawPPS *pps = (H265RawPPS*)content;
-av_buffer_unref(&pps->extension_data.data_ref);
-av_freep(&content);
-}
-
-static void cbs_h265_free_slice(void *unit, uint8_t *content)
-{
-H265RawSlice *slice = (H265RawSlice*)content;
-av_buffer_unref(&slice->data_ref);
-av_freep(&content);
-}
-
-static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload)
-{
-switch (payload->payload_type) {
-case HEVC_SEI_TYPE_BUFFERING_PERIOD:
-case HEVC_SEI_TYPE_PICTURE_TIMING:
-case HEVC_SEI_TYPE_PAN_SCAN_RECT:
-case HEVC_SEI_TYPE_RECOVERY_POINT:
-case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
-case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
-case HEVC_SEI_TYPE_DECODED_PICTURE_HASH:
-case HEVC_SEI_TYPE_TIME_CODE:
-case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
-case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
-case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
-break;
-case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
-av_buffer_unref(&payload->payload.user_data_registered.data_ref);
-break;
-case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED:
-av_buffer_unref(&payload->payload.user_data_unregistered.data_ref);
-break;
-default:
-av_buffer_unref(&payload->payload.other.data_ref);
-break;
-}
-}
-
-static void cbs_h265_free_sei(void *unit, uint8_t *content)
-{
-H265RawSEI *sei = (H265RawSEI*)content;
-int i;
-for (i = 0; i < sei->payload_count; i++)
-cbs_h265_free_sei_payload(&sei->payload[i]);
-av_freep(&content);
-}
-
 static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag,
const H2645Packet *packet)
@@ -861,16 +797,14 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 if (err < 0)
 return err;
 
+err = ff_cbs_alloc_unit_content2(ctx, unit);
+if (err < 0)
+return err;
+
 switch (unit->type) {
 case HEVC_NAL_VPS:
 {
-H265RawVPS *vps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*vps),
-&cbs_h265_free_vps);
-if (err < 0)
-return err;
-vps = unit->content;
+H265RawVPS *vps = unit->content;
 
 err = cbs_h265_read_vps(ctx, &gbc, vps);
 if (err < 0)
@@ -883,13 +817,7 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 break;
 case HEVC_NAL_SPS:
 {
-H265RawSPS *sps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*sps),
-&cbs_h265_free_sps);
-if (err < 0)
-return err;
-sps = unit->content;
+H265RawSPS *sps = unit->content;
 
 err = cbs_h265_read_sps(ctx, &gbc, sps);
 if (err < 0)
@@ -903,13 +831,7 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case HEVC_NAL_PPS:
 {
-H265RawPPS *pps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*pps),
-&cbs_h265_free_pps);
-if (err < 0)
-return err;
-pps = unit->content;
+H265RawPPS *pps = unit->content;
 
 err = cbs_h265_read_pps(ctx, &gbc, pps);
 if (err < 0)
@@ -938,15 +860,9 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 case HEVC_NAL_IDR_N_LP:
 case HEVC_NAL_CRA_NUT:
 {
-H265RawSlice *slice;
+H265RawSlice *slice = unit->content;
 int pos, len;
 
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*slice),
-&cbs_h265_free_slice);
-if (err < 0)
-return err;
-slice = unit->content;
-
 err = cbs_h265_read_slice_segment_header(ctx, &gbc, 
&slice->header);
 if (err < 0)
 return err;
@@ -972,11 +888,6 @@ static int cbs_h265_read_nal_unit(Cod

[FFmpeg-devel] [PATCH v2 04/11] cbs: Add macros to support defining unit type tables

2019-05-20 Thread Mark Thompson
---
 libavcodec/cbs_internal.h | 21 +
 1 file changed, 21 insertions(+)

diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index 06a8f9b979..439fa7934b 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -140,6 +140,27 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
 #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
 
 
+#define CBS_UNIT_TYPE_POD(type, structure) { \
+.unit_type= type, \
+.content_type = CBS_CONTENT_TYPE_POD, \
+.content_size = sizeof(structure), \
+}
+#define CBS_UNIT_TYPE_INTERNAL_REFS(type, structure, nb_offsets, offsets) { \
+.unit_type  = type, \
+.content_type   = CBS_CONTENT_TYPE_INTERNAL_REFS, \
+.content_size   = sizeof(structure), \
+.nb_ref_offsets = nb_offsets, \
+.ref_offsets= offsets, \
+}
+#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) { \
+.unit_type = type, \
+.content_type  = CBS_CONTENT_TYPE_COMPLEX, \
+.content_size  = sizeof(structure), \
+.content_free  = free_func, \
+}
+#define CBS_UNIT_TYPE_END_OF_LIST { CBS_INVALID_UNIT_TYPE }
+
+
 extern const CodedBitstreamType ff_cbs_type_av1;
 extern const CodedBitstreamType ff_cbs_type_h264;
 extern const CodedBitstreamType ff_cbs_type_h265;
-- 
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 v2 01/11] cbs: Mention all codecs in unit type comment

2019-05-20 Thread Mark Thompson
---
 libavcodec/cbs.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 967dcd1468..e8b2d41ecb 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -49,6 +49,8 @@ struct CodedBitstreamType;
  * H.265 / HEVC: nal_unit_type
  * MPEG-2: start code value (without prefix)
  * VP9: unused, set to zero (every unit is a frame)
+ * JPEG: marker value (without 0xff prefix)
+ * AV1: obu_type
  */
 typedef uint32_t CodedBitstreamUnitType;
 
-- 
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 v2 10/11] cbs_vp9: Use table-based alloc/free

2019-05-20 Thread Mark Thompson
---
 libavcodec/cbs_vp9.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c
index 0b5f137ed8..71c1b38032 100644
--- a/libavcodec/cbs_vp9.c
+++ b/libavcodec/cbs_vp9.c
@@ -474,13 +474,6 @@ static int cbs_vp9_split_fragment(CodedBitstreamContext 
*ctx,
 return 0;
 }
 
-static void cbs_vp9_free_frame(void *unit, uint8_t *content)
-{
-VP9RawFrame *frame = (VP9RawFrame*)content;
-av_buffer_unref(&frame->data_ref);
-av_freep(&frame);
-}
-
 static int cbs_vp9_read_unit(CodedBitstreamContext *ctx,
  CodedBitstreamUnit *unit)
 {
@@ -492,8 +485,7 @@ static int cbs_vp9_read_unit(CodedBitstreamContext *ctx,
 if (err < 0)
 return err;
 
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*frame),
-&cbs_vp9_free_frame);
+err = ff_cbs_alloc_unit_content2(ctx, unit);
 if (err < 0)
 return err;
 frame = unit->content;
@@ -678,11 +670,19 @@ static void cbs_vp9_close(CodedBitstreamContext *ctx)
 av_freep(&priv->write_buffer);
 }
 
+static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[] = {
+CBS_UNIT_TYPE_INTERNAL_REFS(0, VP9RawFrame, 1,
+{ offsetof(VP9RawFrame, data) }),
+CBS_UNIT_TYPE_END_OF_LIST
+};
+
 const CodedBitstreamType ff_cbs_type_vp9 = {
 .codec_id  = AV_CODEC_ID_VP9,
 
 .priv_data_size= sizeof(CodedBitstreamVP9Context),
 
+.unit_types= cbs_vp9_unit_types,
+
 .split_fragment= &cbs_vp9_split_fragment,
 .read_unit = &cbs_vp9_read_unit,
 .write_unit= &cbs_vp9_write_unit,
-- 
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".

Re: [FFmpeg-devel] [PATCH 0/4] Add AVDRMFrameDescriptor.format field

2019-05-20 Thread Mark Thompson
On 20/05/2019 23:33, Mark Thompson wrote:
> On 12/05/2019 20:00, Jonas Karlman wrote:
>> From what I understand support for composed layers wont be added to AMD as 
>> it technically are multiple objects. I am not even sure if AMD have support 
>> for NV12 as a drm plane format.
> 
> Yeah.  Mesa decodes to multiple objects, which can then be handled separately 
> by all the normal graphics APIs (OpenGL / Vulkan).  On the AMD systems I've 
> seen KMS supports only packed 8- and 10-bit RGB planes, so I don't think 
> there is anything in AMD-land which would ever want the single-layer 
> representation.

Or apparently I'm out of date - 
.
   I guess that must work as NV12 with two separate objects.

- 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 0/4] Add AVDRMFrameDescriptor.format field

2019-05-20 Thread Mark Thompson
On 12/05/2019 20:00, Jonas Karlman wrote:
> On 2019-05-12 19:28, Mark Thompson wrote:
>> On 09/05/2019 20:38, Jonas Karlman wrote:
>>> Hello,
>>>
>>> When a multi-layer AVDRMFrameDescriptor is used to describe a frame the 
>>> overall
>>> frame format is missing and applications need to deduce the frame 
>>> DRM_FORMAT_*
>>> based on sw_format or the layers format.
>>>
>>> This patchset adds a AVDRMFrameDescriptor.format field to remove any 
>>> ambiguity
>>> of what frame format a multi-layer descriptor may have.
>>>
>>> Kodi has up until now only supported single layer AVDRMFrameDescriptor,
>>> when trying to add support for multi-layer frame descriptors [1],
>>> we did not want to try and deduce the frame format, hence this patchset.
>>>
>>> [1] https://github.com/xbmc/xbmc/pull/16102
>>>
>>> Patch 1 adds a new field, format, to the AVDRMFrameDescriptor struct.
>>> Patch 2-4 adds code to set the new format field.
>>>
>>> Regards,
>>> Jonas
>>>
>>> ---
>>>
>>> Jonas Karlman (4):
>>>   hwcontext_drm: Add AVDRMFrameDescriptor.format field
>>>   hwcontext_vaapi: Set AVDRMFrameDescriptor.format in map_from
>>>   rkmppdec: Set AVDRMFrameDescriptor.format
>>>   kmsgrab: Set AVDRMFrameDescriptor.format
>>>
>>>  doc/APIchanges  |  3 +++
>>>  libavcodec/rkmppdec.c   |  1 +
>>>  libavdevice/kmsgrab.c   |  1 +
>>>  libavutil/hwcontext_drm.h   |  4 
>>>  libavutil/hwcontext_vaapi.c | 38 +
>>>  libavutil/version.h |  4 ++--
>>>  6 files changed, 49 insertions(+), 2 deletions(-)
>> Can you argue why this case should be put in FFmpeg rather than constructing 
>> the format you want in the client code?
>>
>> The intent of the existing format information is that each layer is 
>> definitely usable as the specific format stated if the device supports that 
>> format and format modifier.  That isn't true for the top-level format - some 
>> devices enforce additional constraints which aren't visible.  For example, 
>> if you take an R8 + GR88 frame from an AMD device, it probably won't work as 
>> NV12 with Intel video hardware because there the whole frame is required to 
>> be in one object (well, not quite - actually the offset from the luma plane 
>> to the chroma plane just has some relatively small limit; in practice this 
>> gets enforced as single-object, though), but it will work perfectly well as 
>> R8 and GR88 planes.
> 
> The reason why I wanted to offload this to FFmpeg is that the top-level 
> format is already known while the application would have to guess/calculate 
> correct format to use when importing the video buffer into a drm plane.
> 
> The main issue we are facing is that kernel api do not have a distinction 
> between single/multi layer/object when importing a video buffer into a 
> framebuffer, drmModeAddFB2WithModifiers is expecting the top-level format 
> regardless if the planes come from multiple objects or not.
> (Kernel driver may still enforce additional constraints, e.g. on Rockchip the 
> luma plane must be contiguous after chroma plane, and Allwinner have similar 
> limits as Intel, chorma and luma plane must be in close proximity)
> 
> In order to support HDR video using a framebuffer tied to a drm plane on 
> Intel, the top-level format passed to drmModeAddFB2WithModifiers must be P010 
> even if vaExportSurfaceHandle exports the video buffer as two layers, R16 + 
> RG1616.

That makes sense, so I agree it's useful to add it at this level if the format 
is meaningful.

> Changing vaapi_map_to_drm_esh in hwcontext_vaapi to try and use 
> VA_EXPORT_SURFACE_COMPOSED_LAYERS and fallback to 
> VA_EXPORT_SURFACE_SEPARATE_LAYERS could also work for our use case, the Intel 
> vaapi driver support both export methods and AMD only the separate layers 
> method.

Hmm.  The separate case is definitely wanted elsewhere (if importing to OpenGL 
or OpenCL, say), so the default can't change.  I guess it could be switched by 
an extra option to av_hwframe_map(), but that would be a special API-specific 
option in the generic API so not really desirable.  Given that, I definitely 
prefer your first answer to this one.

> From what I understand support for composed layers wont be added to AMD as it 
> technically are multiple objects. I am not even sure if AMD have support for 
> NV12 as a drm plane format.

Yeah.  Mesa decodes to multiple objects, which can then be handled separately 
by all the normal graphics APIs (OpenGL / Vulkan).  On the AMD systems I've 
seen KMS supports only packed 8- and 10-bit RGB planes, so I don't think there 
is anything in AMD-land which would ever want the single-layer representation.

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 V3] lavfi/opencl: add nlmeans_opencl filter

2019-05-20 Thread Mark Thompson
On 20/05/2019 02:18, Song, Ruiling wrote:
>> -Original Message-
>> From: Song, Ruiling
>> Sent: Monday, May 13, 2019 10:18 AM
>> To: FFmpeg development discussions and patches > de...@ffmpeg.org>; 'Mark Thompson' 
>> Subject: RE: [FFmpeg-devel] [PATCH V3] lavfi/opencl: add nlmeans_opencl
>> filter
>>
>>> -Original Message-
>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
>> Behalf
>>> Of Ruiling Song
>>> Sent: Tuesday, May 7, 2019 10:45 AM
>>> To: ffmpeg-devel@ffmpeg.org
>>> Cc: Song, Ruiling 
>>> Subject: [FFmpeg-devel] [PATCH V3] lavfi/opencl: add nlmeans_opencl
>> filter
>>>
>>> Signed-off-by: Ruiling Song 
>>> ---
>>>  configure   |   1 +
>>>  doc/filters.texi|   4 +
>>>  libavfilter/Makefile|   1 +
>>>  libavfilter/allfilters.c|   1 +
>>>  libavfilter/opencl/nlmeans.cl   | 115 +
>>>  libavfilter/opencl_source.h |   1 +
>>>  libavfilter/vf_nlmeans_opencl.c | 443
>>> 
>>>  7 files changed, 566 insertions(+)
>>>  create mode 100644 libavfilter/opencl/nlmeans.cl
>>>  create mode 100644 libavfilter/vf_nlmeans_opencl.c
>> Hi Mark,
>>
>> Do you have further comment on v3?
> Will apply if no further comments.

No more from me.  I also did some testing of this on Mali, all good.

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 v3] libavformat/mpegtsenc: Add minimal support for ATSC PSIP tables

2019-05-20 Thread Phil Burr
I've found some fields that aren't being set correctly.  I've corrected
those and I'll push a new patch after I've done proper testing.

Phil

On Mon, May 20, 2019 at 11:03 AM Thomas Volkert  wrote:

>
> On 20.05.2019 18:56, Phil Burr wrote:
> > Besides passing `make fate` locally, I have manually inspected data
> streams
> > to look at my packets
>
> Okay, that is standard.
>
>
> >  and I've used SDR software to transmit to various TV
> > sets I own and have verified correct virtual channel and channel name on
> > those receivers.
>
> That is what I wanted to know - that is really good!
> Thanks for your efforts.
>
> Best regards,
> Thomas.
> ___
> 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".

[FFmpeg-devel] [PATCH] avformat/matroskadec: request frame header parsing for HEVC

2019-05-20 Thread James Almer
HEVC parsing was forcefully disabled six years ago in commit 16b6839de6, when
the hevc parser had no frame header parsing capabilites whatsoever, and enabling
it would have been a no-op overhead in the demuxing process.

This hasn't been the case for a very long while, so revert it.

Signed-off-by: James Almer 
---
 libavformat/matroskadec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index cba2b3d1f8..e282c01fc1 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2525,8 +2525,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
   st->codecpar->width  * track->video.display_height * 
display_height_mul,
   255);
 }
-if (st->codecpar->codec_id != AV_CODEC_ID_HEVC)
-st->need_parsing = AVSTREAM_PARSE_HEADERS;
+st->need_parsing = AVSTREAM_PARSE_HEADERS;
 
 if (track->default_duration) {
 av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH] ffplay: added option always on top for video window

2019-05-20 Thread James Almer
On 5/20/2019 5:43 PM, Daniel Kučera wrote:
> po 20. 5. 2019 o 21:12 James Almer  napísal(a):
>>
>> On 5/20/2019 4:01 PM, Marton Balint wrote:
>>>
>>> On Mon, 20 May 2019, Carl Eugen Hoyos wrote:
>>>
 Marton,

 Am Mo., 13. Mai 2019 um 13:42 Uhr schrieb Daniel Kucera
 :
>
> From: Daniel Kucera 
>
> Signed-off-by: Daniel Kucera 
> ---
>  doc/ffplay.texi  | 2 ++
>  fftools/ffplay.c | 8 
>  2 files changed, 10 insertions(+)
>
> diff --git a/doc/ffplay.texi b/doc/ffplay.texi
> index c305465078..a487c0de8d 100644
> --- a/doc/ffplay.texi
> +++ b/doc/ffplay.texi
> @@ -66,6 +66,8 @@ Set custom interval, in seconds, for seeking using
> left/right keys. Default is 1
>  Disable graphical display.
>  @item -noborder
>  Borderless window.
> +@item -alwaysontop
> +Window always on top. Available on: X11 with SDL >= 2.0.5, Windows
> SDL >= 2.0.6.
>  @item -volume
>  Set the startup volume. 0 means silence, 100 means no volume
> reduction or
>  amplification. Negative values are treated as 0, values above 100
> are treated
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index 8f050e16e6..8fb8faeb06 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -324,6 +324,7 @@ static int seek_by_bytes = -1;
>  static float seek_interval = 10;
>  static int display_disable;
>  static int borderless;
> +static int alwaysontop;
>  static int startup_volume = 100;
>  static int show_status = 1;
>  static int av_sync_type = AV_SYNC_AUDIO_MASTER;
> @@ -3581,6 +3582,7 @@ static const OptionDef options[] = {
>  { "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set
> seek interval for left/right keys, in seconds", "seconds" },
>  { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical
> display" },
>  { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
> +{ "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on
> top" },
>  { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup
> volume 0=min 100=max", "volume" },
>  { "f", HAS_ARG, { .func_arg = opt_format }, "force format",
> "fmt" },
>  { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg =
> opt_frame_pix_fmt }, "set pixel format", "format" },
> @@ -3722,6 +3724,12 @@ int main(int argc, char **argv)
>
>  if (!display_disable) {
>  int flags = SDL_WINDOW_HIDDEN;
> +if (alwaysontop)
> +#if SDL_VERSION_ATLEAST(2,0,5)
> +flags |= SDL_WINDOW_ALWAYS_ON_TOP;
> +#else
> +av_log(NULL, AV_LOG_WARNING, "Your SDL version doesn't
> support SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
> +#endif

 Is there any reason you are against this patch?
>>>
>>> I am not against it, it looks good to me.
>>
>> Is the flag available in 2.0.5 for Windows, or only since 2.0.6 as the
>> doxy addition mentions?
> 
> The flag is available generally in the library since 2.0.5, but the
> windows implementation is there since 2.0.6 only.
> 
> https://github.com/SDL-mirror/SDL/commit/a60edd403816eb8d7f77f18320b76d27c1db2973
> 
> https://github.com/SDL-mirror/SDL/commit/76adc80cafd9f83dcfb36ada4b2b028487f7e1d8

Alright, pushed then. Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] ffplay: added option always on top for video window

2019-05-20 Thread Daniel Kučera
po 20. 5. 2019 o 21:12 James Almer  napísal(a):
>
> On 5/20/2019 4:01 PM, Marton Balint wrote:
> >
> > On Mon, 20 May 2019, Carl Eugen Hoyos wrote:
> >
> >> Marton,
> >>
> >> Am Mo., 13. Mai 2019 um 13:42 Uhr schrieb Daniel Kucera
> >> :
> >>>
> >>> From: Daniel Kucera 
> >>>
> >>> Signed-off-by: Daniel Kucera 
> >>> ---
> >>>  doc/ffplay.texi  | 2 ++
> >>>  fftools/ffplay.c | 8 
> >>>  2 files changed, 10 insertions(+)
> >>>
> >>> diff --git a/doc/ffplay.texi b/doc/ffplay.texi
> >>> index c305465078..a487c0de8d 100644
> >>> --- a/doc/ffplay.texi
> >>> +++ b/doc/ffplay.texi
> >>> @@ -66,6 +66,8 @@ Set custom interval, in seconds, for seeking using
> >>> left/right keys. Default is 1
> >>>  Disable graphical display.
> >>>  @item -noborder
> >>>  Borderless window.
> >>> +@item -alwaysontop
> >>> +Window always on top. Available on: X11 with SDL >= 2.0.5, Windows
> >>> SDL >= 2.0.6.
> >>>  @item -volume
> >>>  Set the startup volume. 0 means silence, 100 means no volume
> >>> reduction or
> >>>  amplification. Negative values are treated as 0, values above 100
> >>> are treated
> >>> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> >>> index 8f050e16e6..8fb8faeb06 100644
> >>> --- a/fftools/ffplay.c
> >>> +++ b/fftools/ffplay.c
> >>> @@ -324,6 +324,7 @@ static int seek_by_bytes = -1;
> >>>  static float seek_interval = 10;
> >>>  static int display_disable;
> >>>  static int borderless;
> >>> +static int alwaysontop;
> >>>  static int startup_volume = 100;
> >>>  static int show_status = 1;
> >>>  static int av_sync_type = AV_SYNC_AUDIO_MASTER;
> >>> @@ -3581,6 +3582,7 @@ static const OptionDef options[] = {
> >>>  { "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set
> >>> seek interval for left/right keys, in seconds", "seconds" },
> >>>  { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical
> >>> display" },
> >>>  { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
> >>> +{ "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on
> >>> top" },
> >>>  { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup
> >>> volume 0=min 100=max", "volume" },
> >>>  { "f", HAS_ARG, { .func_arg = opt_format }, "force format",
> >>> "fmt" },
> >>>  { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg =
> >>> opt_frame_pix_fmt }, "set pixel format", "format" },
> >>> @@ -3722,6 +3724,12 @@ int main(int argc, char **argv)
> >>>
> >>>  if (!display_disable) {
> >>>  int flags = SDL_WINDOW_HIDDEN;
> >>> +if (alwaysontop)
> >>> +#if SDL_VERSION_ATLEAST(2,0,5)
> >>> +flags |= SDL_WINDOW_ALWAYS_ON_TOP;
> >>> +#else
> >>> +av_log(NULL, AV_LOG_WARNING, "Your SDL version doesn't
> >>> support SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
> >>> +#endif
> >>
> >> Is there any reason you are against this patch?
> >
> > I am not against it, it looks good to me.
>
> Is the flag available in 2.0.5 for Windows, or only since 2.0.6 as the
> doxy addition mentions?

The flag is available generally in the library since 2.0.5, but the
windows implementation is there since 2.0.6 only.

https://github.com/SDL-mirror/SDL/commit/a60edd403816eb8d7f77f18320b76d27c1db2973

https://github.com/SDL-mirror/SDL/commit/76adc80cafd9f83dcfb36ada4b2b028487f7e1d8



-- 

S pozdravom / Best regards
Daniel Kucera.
___
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/libdav1d: fine tune thread distribution

2019-05-20 Thread James Almer
On 5/13/2019 11:31 AM, James Almer wrote:
> As suggested by Ronald, don't map auto threads to frame threads only, and
> instead distribute them between frame and tile more efficiently.
> Add a new framethreads override option, similar to the tilethreads one.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/libdav1d.c | 16 +---
>  libavcodec/version.h  |  2 +-
>  2 files changed, 14 insertions(+), 4 deletions(-)

Pushed.
___
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] ffplay: added option always on top for video window

2019-05-20 Thread James Almer
On 5/20/2019 4:01 PM, Marton Balint wrote:
> 
> On Mon, 20 May 2019, Carl Eugen Hoyos wrote:
> 
>> Marton,
>>
>> Am Mo., 13. Mai 2019 um 13:42 Uhr schrieb Daniel Kucera
>> :
>>>
>>> From: Daniel Kucera 
>>>
>>> Signed-off-by: Daniel Kucera 
>>> ---
>>>  doc/ffplay.texi  | 2 ++
>>>  fftools/ffplay.c | 8 
>>>  2 files changed, 10 insertions(+)
>>>
>>> diff --git a/doc/ffplay.texi b/doc/ffplay.texi
>>> index c305465078..a487c0de8d 100644
>>> --- a/doc/ffplay.texi
>>> +++ b/doc/ffplay.texi
>>> @@ -66,6 +66,8 @@ Set custom interval, in seconds, for seeking using
>>> left/right keys. Default is 1
>>>  Disable graphical display.
>>>  @item -noborder
>>>  Borderless window.
>>> +@item -alwaysontop
>>> +Window always on top. Available on: X11 with SDL >= 2.0.5, Windows
>>> SDL >= 2.0.6.
>>>  @item -volume
>>>  Set the startup volume. 0 means silence, 100 means no volume
>>> reduction or
>>>  amplification. Negative values are treated as 0, values above 100
>>> are treated
>>> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
>>> index 8f050e16e6..8fb8faeb06 100644
>>> --- a/fftools/ffplay.c
>>> +++ b/fftools/ffplay.c
>>> @@ -324,6 +324,7 @@ static int seek_by_bytes = -1;
>>>  static float seek_interval = 10;
>>>  static int display_disable;
>>>  static int borderless;
>>> +static int alwaysontop;
>>>  static int startup_volume = 100;
>>>  static int show_status = 1;
>>>  static int av_sync_type = AV_SYNC_AUDIO_MASTER;
>>> @@ -3581,6 +3582,7 @@ static const OptionDef options[] = {
>>>  { "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set
>>> seek interval for left/right keys, in seconds", "seconds" },
>>>  { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical
>>> display" },
>>>  { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
>>> +    { "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on
>>> top" },
>>>  { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup
>>> volume 0=min 100=max", "volume" },
>>>  { "f", HAS_ARG, { .func_arg = opt_format }, "force format",
>>> "fmt" },
>>>  { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg =
>>> opt_frame_pix_fmt }, "set pixel format", "format" },
>>> @@ -3722,6 +3724,12 @@ int main(int argc, char **argv)
>>>
>>>  if (!display_disable) {
>>>  int flags = SDL_WINDOW_HIDDEN;
>>> +    if (alwaysontop)
>>> +#if SDL_VERSION_ATLEAST(2,0,5)
>>> +    flags |= SDL_WINDOW_ALWAYS_ON_TOP;
>>> +#else
>>> +    av_log(NULL, AV_LOG_WARNING, "Your SDL version doesn't
>>> support SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
>>> +#endif
>>
>> Is there any reason you are against this patch?
> 
> I am not against it, it looks good to me.

Is the flag available in 2.0.5 for Windows, or only since 2.0.6 as the
doxy addition mentions?
___
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] web/download: set realistic release schedule

2019-05-20 Thread Thomas Volkert

On 20.05.2019 21:00, Lou Logan wrote:
> Major releases have been every 6 months approximately; not every 3 months.
>
> Signed-off-by: Lou Logan 
> ---
>  src/download | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/download b/src/download
> index 07f4439..9544de2 100644
> --- a/src/download
> +++ b/src/download
> @@ -258,7 +258,7 @@
>  Releases
>
>
> -Approximately every 3 months the FFmpeg project makes a new major 
> release.
> +Approximately every 6 months the FFmpeg project makes a new major 
> release.
>  Between major releases point releases
>  will appear that add important bug fixes but no new features.
>  Note that these releases are intended for distributors and system 
> integrators.

Good idea

Best regards,
Thomas.

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

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

Re: [FFmpeg-devel] [PATCH v3] avformat/ifv: added support for ifv cctv files

2019-05-20 Thread Swaraj Hota
On Thu 16 May, 2019, 2:19 AM Swaraj Hota,  wrote:

> Fixes ticket #2956.
>
> Signed-off-by: Swaraj Hota 
> ---
> Revised patch based on previous discussions.
> Some of the changes are:
> - using AVIndexEntry now
> - demuxer is totally index based (removed linear search)
> - added seeking functionality with timestamps
>
> There are some timing issues though, due to which seeking does not
> work in the files with audio (works fine for files without audio).
> I tried a lot but couldn't figure it out, maybe I don't understand
> timing stuff clearly. Any suggestions regarding this will be really
> helpful. Thanks in advance!
>
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/ifv.c| 316 +++
>  libavformat/version.h|   4 +-
>  5 files changed, 321 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/ifv.c


Ping!
___
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] web/download: set realistic release schedule

2019-05-20 Thread James Almer
On 5/20/2019 4:00 PM, Lou Logan wrote:
> Major releases have been every 6 months approximately; not every 3 months.
> 
> Signed-off-by: Lou Logan 
> ---
>  src/download | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/download b/src/download
> index 07f4439..9544de2 100644
> --- a/src/download
> +++ b/src/download
> @@ -258,7 +258,7 @@
>  Releases
>  
>
> -Approximately every 3 months the FFmpeg project makes a new major 
> release.
> +Approximately every 6 months the FFmpeg project makes a new major 
> release.
>  Between major releases point releases
>  will appear that add important bug fixes but no new features.
>  Note that these releases are intended for distributors and system 
> integrators.
> 

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

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

Re: [FFmpeg-devel] [PATCH] ffplay: added option always on top for video window

2019-05-20 Thread Marton Balint


On Mon, 20 May 2019, Carl Eugen Hoyos wrote:


Marton,

Am Mo., 13. Mai 2019 um 13:42 Uhr schrieb Daniel Kucera
:


From: Daniel Kucera 

Signed-off-by: Daniel Kucera 
---
 doc/ffplay.texi  | 2 ++
 fftools/ffplay.c | 8 
 2 files changed, 10 insertions(+)

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index c305465078..a487c0de8d 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -66,6 +66,8 @@ Set custom interval, in seconds, for seeking using left/right 
keys. Default is 1
 Disable graphical display.
 @item -noborder
 Borderless window.
+@item -alwaysontop
+Window always on top. Available on: X11 with SDL >= 2.0.5, Windows SDL >= 
2.0.6.
 @item -volume
 Set the startup volume. 0 means silence, 100 means no volume reduction or
 amplification. Negative values are treated as 0, values above 100 are treated
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 8f050e16e6..8fb8faeb06 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -324,6 +324,7 @@ static int seek_by_bytes = -1;
 static float seek_interval = 10;
 static int display_disable;
 static int borderless;
+static int alwaysontop;
 static int startup_volume = 100;
 static int show_status = 1;
 static int av_sync_type = AV_SYNC_AUDIO_MASTER;
@@ -3581,6 +3582,7 @@ static const OptionDef options[] = {
 { "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set seek interval for 
left/right keys, in seconds", "seconds" },
 { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" },
 { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
+{ "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on top" },
 { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 
100=max", "volume" },
 { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" },
 { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set 
pixel format", "format" },
@@ -3722,6 +3724,12 @@ int main(int argc, char **argv)

 if (!display_disable) {
 int flags = SDL_WINDOW_HIDDEN;
+if (alwaysontop)
+#if SDL_VERSION_ATLEAST(2,0,5)
+flags |= SDL_WINDOW_ALWAYS_ON_TOP;
+#else
+av_log(NULL, AV_LOG_WARNING, "Your SDL version doesn't support 
SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
+#endif


Is there any reason you are against this patch?


I am not against it, it looks good to me.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/mxfenc: support XAVC long gop

2019-05-20 Thread Baptiste Coudurier
> On May 17, 2019, at 12:07 PM, Baptiste Coudurier 
>  wrote:
> 
> Hi Thomas,
> 
>> On May 14, 2019, at 2:54 PM, Thomas Mundt > > wrote:
>> 
>> Hi Baptiste,
>> 
>> Am Di., 14. Mai 2019 um 18:59 Uhr schrieb Baptiste Coudurier 
>> mailto:baptiste.coudur...@gmail.com>>:
>> ---
>>  libavformat/Makefile |   2 +-
>>  libavformat/avc.c| 186 +
>>  libavformat/avc.h|  15 +++
>>  libavformat/hevc.c   |  36 +---
>>  libavformat/mxf.h|   1 +
>>  libavformat/mxfenc.c | 213 ++-
>>  6 files changed, 372 insertions(+), 81 deletions(-)
>> 
>> diff --git a/libavformat/Makefile b/libavformat/Makefile
>> index 99be60d184..df87c54a58 100644
>> --- a/libavformat/Makefile
>> +++ b/libavformat/Makefile
>> @@ -339,7 +339,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER)  += musx.o
>>  OBJS-$(CONFIG_MV_DEMUXER)+= mvdec.o
>>  OBJS-$(CONFIG_MVI_DEMUXER)   += mvi.o
>>  OBJS-$(CONFIG_MXF_DEMUXER)   += mxfdec.o mxf.o
>> -OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o audiointerleave.o
>> +OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o 
>> audiointerleave.o avc.o
>>  OBJS-$(CONFIG_MXG_DEMUXER)   += mxg.o
>>  OBJS-$(CONFIG_NC_DEMUXER)+= ncdec.o
>>  OBJS-$(CONFIG_NISTSPHERE_DEMUXER)+= nistspheredec.o pcm.o
>> diff --git a/libavformat/avc.c b/libavformat/avc.c
>> index ec50033a04..a041e84357 100644
>> --- a/libavformat/avc.c
>> +++ b/libavformat/avc.c
>> @@ -21,6 +21,7 @@
>> 
>>  #include "libavutil/intreadwrite.h"
>>  #include "libavcodec/h264.h"
>> +#include "libavcodec/get_bits.h"
>>  #include "avformat.h"
>>  #include "avio.h"
>>  #include "avc.h"
>> @@ -241,3 +242,188 @@ const uint8_t *ff_avc_mp4_find_startcode(const uint8_t 
>> *start,
>> 
>>  return start + res;
>>  }
>> +
>> +uint8_t *ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len,
>> +  uint32_t *dst_len, int header_len)
>> +{
>> +uint8_t *dst;
>> +uint32_t i, len;
>> +
>> +dst = av_malloc(src_len + AV_INPUT_BUFFER_PADDING_SIZE);
>> +if (!dst)
>> +return NULL;
>> +
>> +/* NAL unit header */
>> +i = len = 0;
>> +while (i < header_len && i < src_len)
>> +dst[len++] = src[i++];
>> +
>> +while (i + 2 < src_len)
>> +if (!src[i] && !src[i + 1] && src[i + 2] == 3) {
>> +dst[len++] = src[i++];
>> +dst[len++] = src[i++];
>> +i++; // remove emulation_prevention_three_byte
>> +} else
>> +dst[len++] = src[i++];
>> +
>> +while (i < src_len)
>> +dst[len++] = src[i++];
>> +
>> +memset(dst + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>> +
>> +*dst_len = len;
>> +return dst;
>> +}
>> +
>> +static const AVRational avc_sample_aspect_ratio[17] = {
>> +{   0,  1 },
>> +{   1,  1 },
>> +{  12, 11 },
>> +{  10, 11 },
>> +{  16, 11 },
>> +{  40, 33 },
>> +{  24, 11 },
>> +{  20, 11 },
>> +{  32, 11 },
>> +{  80, 33 },
>> +{  18, 11 },
>> +{  15, 11 },
>> +{  64, 33 },
>> +{ 160, 99 },
>> +{   4,  3 },
>> +{   3,  2 },
>> +{   2,  1 },
>> +};
>> +
>> +static inline int get_ue_golomb(GetBitContext *gb) {
>> +int i;
>> +for (i = 0; i < 32 && !get_bits1(gb); i++)
>> +;
>> +return get_bitsz(gb, i) + (1 << i) - 1;
>> +}
>> +
>> +static inline int get_se_golomb(GetBitContext *gb) {
>> +int v = get_ue_golomb(gb) + 1;
>> +int sign = -(v & 1);
>> +return ((v >> 1) ^ sign) - sign;
>> +}
>> +
>> +H264SequenceParameterSet *ff_avc_decode_sps(const uint8_t *buf, int 
>> buf_size)
>> +{
>> +int i, j, ret, rbsp_size, aspect_ratio_idc, pic_order_cnt_type;
>> +int num_ref_frames_in_pic_order_cnt_cycle;
>> +int delta_scale, lastScale = 8, nextScale = 8;
>> +int sizeOfScalingList;
>> +H264SequenceParameterSet *sps = NULL;
>> +GetBitContext gb;
>> +uint8_t *rbsp_buf;
>> +
>> +rbsp_buf = ff_nal_unit_extract_rbsp(buf, buf_size, &rbsp_size, 0);
>> +if (!rbsp_buf)
>> +return NULL;
>> +
>> +ret = init_get_bits8(&gb, rbsp_buf, rbsp_size);
>> +if (ret < 0)
>> +goto end;
>> +
>> +sps = av_mallocz(sizeof(*sps));
>> +if (!sps)
>> +goto end;
>> +
>> +sps->profile_idc = get_bits(&gb, 8);
>> +sps->constraint_set_flags |= get_bits1(&gb) << 0; // 
>> constraint_set0_flag
>> +sps->constraint_set_flags |= get_bits1(&gb) << 1; // 
>> constraint_set1_flag
>> +sps->constraint_set_flags |= get_bits1(&gb) << 2; // 
>> constraint_set2_flag
>> +sps->constraint_set_flags |= get_bits1(&gb) << 3; // 
>> constraint_set3_flag
>> +sps->constraint_set_flags |= get_bits1(&gb) << 4; // 
>> constraint_set4_flag
>> +sps->constraint_set_flags |= get_bits1(&gb) << 5; // 
>> constraint_set5_flag
>> +skip_bits(&gb, 2); // reserved_zero_2bits
>> +sps->level_idc = get_b

[FFmpeg-devel] [PATCH] web/download: set realistic release schedule

2019-05-20 Thread Lou Logan
Major releases have been every 6 months approximately; not every 3 months.

Signed-off-by: Lou Logan 
---
 src/download | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/download b/src/download
index 07f4439..9544de2 100644
--- a/src/download
+++ b/src/download
@@ -258,7 +258,7 @@
 Releases
 
   
-Approximately every 3 months the FFmpeg project makes a new major release.
+Approximately every 6 months the FFmpeg project makes a new major release.
 Between major releases point releases
 will appear that add important bug fixes but no new features.
 Note that these releases are intended for distributors and system 
integrators.
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH] avfilter/f_loop: do not loop if loop size is 0

2019-05-20 Thread Marton Balint



On Mon, 20 May 2019, Gyan wrote:




On 20-05-2019 02:18 AM, Marton Balint wrote:



On Sun, 19 May 2019, Paul B Mahol wrote:


On 5/19/19, Marton Balint  wrote:



On Sun, 19 May 2019, Paul B Mahol wrote:


On 5/19/19, Marton Balint  wrote:

Fixes infinte loop with -vf loop=loop=1.

Possible regression since ef1aadffc785b48ed62c45d954289e754f43ef46.

Signed-off-by: Marton Balint 
---
 libavfilter/f_loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index d9d55f9837..3da753dd1e 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -343,7 +343,7 @@ static int activate(AVFilterContext *ctx)

 FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);

-    if (!s->eof && (s->nb_frames < s->size || !s->loop)) {
+    if (!s->eof && (s->nb_frames < s->size || !s->loop || 
!s->size)) {

 ret = ff_inlink_consume_frame(inlink, &frame);
 if (ret < 0)
 return ret;
--
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".


I think better fix is to change default and minimal allowed loop 
size to

1.
Does that sounds ok to you?


Well, looping the whole length of the input would be more intuitive 
to me

as the default.


That would require infinite memory.


So as the reverse filter. As long as it is properly documented that 
the looped stuff is kept in memory so the user should not use this for 
long clips, then I think it is fine.


I disagree. Yes, for loop with only loop specified, it would be 
intuitive to loop the whole stream, but relying on users to exercise due 
diligence can't be counted upon. We're talking about a scenario where 
the user hasn't bothered to specify the size variable because they don't 
know or don't care or are sloppy. They won't take heed of the 
documentation until the command fails. The defaults should be robust 
against lax use.


Fair enough, although I never liked the idea that we make the tool less 
handy because we target unexperienced users.


Anyway, I don't have strong feelings about this, maybe my patch has the 
benefit of keeping existing behaviour (which is similar to how aloop 
works) in contrast to what paul suggested, but I don't really mind Paul's 
or Bela's solution either.


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

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

[FFmpeg-devel] FFmpeg 4.2

2019-05-20 Thread Michael Niedermayer
Hi

Its quite some time since 4.1 so its probably getting time to branch
4.2.

If there are any bugs you want fixed in 4.2 its probably a good idea to
fix them soon.

Are there any suggestions for a name ?
If not ill pick something from unused past suggestions.

If there are no objections i will likely make that release in the next weeks

Thanks

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


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/cpia: Check input size also against linesizes and EOL

2019-05-20 Thread Michael Niedermayer
On Mon, May 20, 2019 at 10:14:46AM +0200, Carl Eugen Hoyos wrote:
> Am So., 19. Mai 2019 um 17:43 Uhr schrieb Michael Niedermayer
> :
> >
> > Fixes: Timeout (14sec -> 29ms)
> > Fixes: 
> > 14733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CPIA_fuzzer-5707022445576192
> >
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/cpia.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c
> > index 119969389e..2e78fcff7a 100644
> > --- a/libavcodec/cpia.c
> > +++ b/libavcodec/cpia.c
> > @@ -63,7 +63,7 @@ static int cpia_decode_frame(AVCodecContext *avctx,
> >  uint8_t *y, *u, *v;
> >
> >  // Check header
> > -if ( avpkt->size < FRAME_HEADER_SIZE
> > +if ( avpkt->size < FRAME_HEADER_SIZE + avctx->height*3
> 
> lgtm except for the missing whitespace that is constantly present in the file.

add whitespace, will apply

thx

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

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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] mpeg12enc: Use all Closed Captions side data

2019-05-20 Thread Reimar Döffinger
On Mon, May 20, 2019 at 10:05:49AM +0200, Hendrik Leppkes wrote:
> On Mon, May 20, 2019 at 9:44 AM Reimar Döffinger
>  wrote:
> > On 20.05.2019, at 09:23, Mathieu Duponchelle  
> > wrote:
> > > On 5/19/19 7:00 PM, Devin Heitmueller wrote:
> > >> Are you suggesting he should make a patch which results in the
> > >> indentation being wrong, and then submit a second patch which fixes
> > >> the incorrect indentation introduced by the first patch?
> >
> > I think it should probably be up to the maintainer, but possibly yes.
> > A lot of review still happens primarily by email, and if you re-indent code
> > it becomes impossible to see what, if anything, you changed in that block.
> > Enabling reviews of the patch via email means not re-indenting even if
> > it becomes "wrong".
> > Not everyone does reviews that way though, so some maintainers nowadays 
> > might prefer it differently?
>
> My main concern with such requests is that its added effort to even
> make these patches, since many developers will just automatically
> indent where appropriate (as it should be), or even have tooling to do
> it for them.
> Personally, I would have to use another editor to "un-indent" the
> code, since my main editor automatically corrects this stuff for me in
> newly written code. As such, I'll personally never comply with such
> requests, because I think its silly, and it would be extraordinary
> effort to even do it, first restoring original indent with a second
> editor.

There's many ways to do it, but the reviewability issue is already
solved by e.g. sending the patch as generated by diff -w (have not
tried, but git send-email seems to accept that option), so I
think you are overstating the effort a bit :)
There is also the point that this should not be an issue normally:
- It doesn't matter if it's just a small block of code.
- If it's a large block of code, many times it means the code
should have been refactored long ago and put into a separate function.
So there often is the option of "volunteering" for some code cleanup
first :)

> I don't think its that much to ask for a reviewer to also use a tool
> that can ignore whitespace. Maybe we can teach patchwork to offer a
> button to view diffs without whitespace, if people don't want to use a
> simple tool.

FFmpeg used to have far too few reviewers.
If that is still the case, I think it's reasonable to put reviewer
convenience over submitter convenience.
I don't see how patchwork is really useful: finding the patch
there is already a pain, and we don't use it for reviews AT ALL,
we use email.
Now there might be an argument if we should have alternative/additional
review tools to email, but it's a bit of a separate question.
Personally, my suggestion would be that if you re-indented a lot
and unless you know the most likely potential reviewers do not care,
send a patch without whitespace changes at least in addition.
I mean, I don't have a super-strong opinion, but if I have to
dig through whitespace changes I'll probably just not review a
patch, because far too often all I have at hand to do them is
an email client...

Best regards,
Reimar Döffinger
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] libavformat/mpegtsenc: Add minimal support for ATSC PSIP tables

2019-05-20 Thread Thomas Volkert

On 20.05.2019 18:56, Phil Burr wrote:
> Besides passing `make fate` locally, I have manually inspected data streams
> to look at my packets

Okay, that is standard.


>  and I've used SDR software to transmit to various TV
> sets I own and have verified correct virtual channel and channel name on
> those receivers.

That is what I wanted to know - that is really good!
Thanks for your efforts.

Best regards,
Thomas.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] libavformat/mpegtsenc: Add minimal support for ATSC PSIP tables

2019-05-20 Thread Phil Burr
Besides passing `make fate` locally, I have manually inspected data streams
to look at my packets and I've used SDR software to transmit to various TV
sets I own and have verified correct virtual channel and channel name on
those receivers.

On Mon, May 20, 2019 at 10:44 AM Thomas Volkert  wrote:

>
> On 20.05.2019 18:09, Phillip Burr wrote:
> > Minimal support for ATSC PSIP tables.  Does not support STT or
> > EIT tables and so is not compliant with terrestrial ATSC.
> > ATSC tables are not created by default, and will only be transmitted
> > if either "atsc_name" or "atsc_channel" metadata is supplied.
> >
> > [..]
>
>
> Good work!
> How have you verified your patch?
>
>
> Best regards,
> Thomas.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] libavformat/mpegtsenc: Add minimal support for ATSC PSIP tables

2019-05-20 Thread Thomas Volkert

On 20.05.2019 18:09, Phillip Burr wrote:
> Minimal support for ATSC PSIP tables.  Does not support STT or
> EIT tables and so is not compliant with terrestrial ATSC.
> ATSC tables are not created by default, and will only be transmitted
> if either "atsc_name" or "atsc_channel" metadata is supplied.
>
> [..]


Good work!
How have you verified your patch?


Best regards,
Thomas.
___
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] libavformat/mpegtsenc: Add minimal support for ATSC PSIP tables

2019-05-20 Thread Phillip Burr
Minimal support for ATSC PSIP tables.  Does not support STT or
EIT tables and so is not compliant with terrestrial ATSC.
ATSC tables are not created by default, and will only be transmitted
if either "atsc_name" or "atsc_channel" metadata is supplied.

Signed-off-by: Phillip Burr 
---
 doc/muxers.texi |  33 +++-
 libavformat/mpegts.h|   8 +
 libavformat/mpegtsenc.c | 412 
 3 files changed, 372 insertions(+), 81 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 83ae017d6c..dd68eec362 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1500,10 +1500,35 @@ MPEG transport stream muxer.
 
 This muxer implements ISO 13818-1 and part of ETSI EN 300 468.
 
-The recognized metadata settings in mpegts muxer are @code{service_provider}
-and @code{service_name}. If they are not set the default for
-@code{service_provider} is @samp{FFmpeg} and the default for
-@code{service_name} is @samp{Service01}.
+@subsection Metadata
+
+The recognized metadata settings in this muxer are:
+
+@table @option
+@item service_name @var{string}
+Set the @code{service_provider}.  Default is @samp{FFmpeg}.
+
+@item service_name @var{string}
+Set the @code{service_name}. Default is @samp{Service01}.
+
+@item atsc_name @var{string}
+Set the @code{atsc_name} for the stream.  This is the ATSC short
+channel name for the stream.
+
+@item atsc_channel @var{string}
+Set the @code{atsc_channel} virtual channel for the stream.  This
+is parsed as @samp{Channel[.SubChannel]} format where the subchannel
+is optional and defaults to @code{1}.
+
+@end table
+
+ATSC tables will @emph{not} be generated unless either @code{atsc_name}
+or @code{atsc_channel} are provided @emph{and} @code{muxrate} is provided.
+In the event that either @code{atsc_name} or @code{atsc_channel} is provided
+but not both, the default for @code{atsc_name} is @samp{FFmpeg}
+and the default for @code{atsc_channel} is @samp{1.1}.
+ATSC tables generated include @code{MGT} and @code{TVCT} tables but are 
lacking the mandatory
+@code{STT}, @code{EIT0}, @code{EIT1}, @code{EIT2} and @code{EIT3} tables 
needed for terrestrial ATC compliance.
 
 @subsection Options
 
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 272e2be4f7..ca6943b1ba 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -35,12 +35,20 @@
 /* pids */
 #define PAT_PID 0x
 #define SDT_PID 0x0011
+#define ATSC_PID0x1ffb
 
 /* table ids */
 #define PAT_TID   0x00
 #define PMT_TID   0x02
 #define M4OD_TID  0x05
 #define SDT_TID   0x42
+#define MGT_TID   0xc7
+#define TVCT_TID  0xc8
+#define CVCT_TID  0xc9
+#define RRT_TID   0xca
+#define EIT_TID   0xcb
+#define ETT_TID   0xcc
+#define STT_TID   0xcd
 
 #define STREAM_TYPE_VIDEO_MPEG1 0x01
 #define STREAM_TYPE_VIDEO_MPEG2 0x02
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..cd3460e5f3 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -56,6 +56,11 @@ typedef struct MpegTSService {
 int sid;   /* service ID */
 uint8_t name[256];
 uint8_t provider_name[256];
+
+uint16_t atsc_name[7]; /* ATSC VCT fields */
+int atsc_mj_channel;
+int atsc_mn_channel;
+
 int pcr_pid;
 int pcr_packet_count;
 int pcr_packet_period;
@@ -77,11 +82,16 @@ typedef struct MpegTSWrite {
 const AVClass *av_class;
 MpegTSSection pat; /* MPEG-2 PAT table */
 MpegTSSection sdt; /* MPEG-2 SDT table context */
+MpegTSSection atsc; /* ATSC tables */
 MpegTSService **services;
 int sdt_packet_count;
 int sdt_packet_period;
 int pat_packet_count;
 int pat_packet_period;
+int mgt_packet_count;
+int mgt_packet_period;
+int tvct_packet_count;
+int tvct_packet_period;
 int nb_services;
 int onid;
 int tsid;
@@ -113,6 +123,9 @@ typedef struct MpegTSWrite {
 double sdt_period;
 int64_t last_pat_ts;
 int64_t last_sdt_ts;
+int64_t last_mgt_ts;
+int64_t last_tvct_ts;
+int xmit_atsc;
 
 int omit_video_pes_length;
 } MpegTSWrite;
@@ -189,14 +202,24 @@ static inline void put16(uint8_t **q_ptr, int val)
 *q_ptr = q;
 }
 
+static inline void put32(uint8_t **q_ptr, int val)
+{
+uint8_t *q;
+q  = *q_ptr;
+*q++   = val >> 24;
+*q++   = val >> 16;
+*q++   = val >> 8;
+*q++   = val;
+*q_ptr = q;
+}
+
 static int mpegts_write_section1(MpegTSSection *s, int tid, int id,
  int version, int sec_num, int last_sec_num,
- uint8_t *buf, int len)
+ int private, uint8_t *buf, int len)
 {
 uint8_t section[1024], *q;
 unsigned int tot_len;
-/* reserved_future_use field must be set to 1 for SDT */
-unsigned int flags = tid == SDT_TID ? 0xf000 : 0xb000;
+unsigned int flags = private ? 0xf000 : 0xb000;
 
 tot_len = 3 + 5 + len + 4;
 /* check if not too 

Re: [FFmpeg-devel] [PATCH v2] libavformat/mpegtsenc: Add minimal support for ATSC PSIP tables

2019-05-20 Thread Phil Burr
Thank you for your suggestions.  I will push an update to the patch with
documentation and will hold off on STT and EIT[0-3] tables for a later
patch.

On Mon, May 20, 2019 at 7:24 AM Devin Heitmueller <
dheitmuel...@kernellabs.com> wrote:

> On Mon, May 20, 2019 at 8:36 AM Phil Burr  wrote:
> >
> > Thank you for the feedback.  I will look into adding documentation for
> the
> > atsc metadata.  ATSC requires in addition to the tables I've added, the
> STT
> > and EIT0-EIT3 tables.  I'm thinking of adding support for STT and at
> least
> > producing empty EIT tables so that the stream would be minimally
> compliant.
>
> I would have no problem with them being excluded in a first version of
> the patch, as long as it's documented that they are not expected to be
> present in the resulting streams.
>
> Your patch is already a huge improvement over the current state of
> affairs, and I don't want to see your patch not get merged because it
> lacks two features that I think the vast majority of people won't care
> about.
>
> Devin
>
> --
> Devin J. Heitmueller - Kernel Labs
> http://www.kernellabs.com
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat/movenc: use unspecified language by default

2019-05-20 Thread James Almer
On 5/20/2019 6:58 AM, Carl Eugen Hoyos wrote:
> Am So., 19. Mai 2019 um 20:10 Uhr schrieb Marton Balint :
> 
>> English was used before.
> 
> A version bump is necessary.
> 
> I would also like a Changelog entry, most people prefer an entry to
> apichanges though.

No API is being changed or added, so this doesn't belong in APIChanges.

Also, i personally don't consider changing a default value for a
metadata field on a single muxer something worth mentioning in
Changelog, but if you think it's worth it then i won't oppose.

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

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

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

Re: [FFmpeg-devel] [PATCH v2] libavformat/mpegtsenc: Add minimal support for ATSC PSIP tables

2019-05-20 Thread Devin Heitmueller
On Mon, May 20, 2019 at 8:36 AM Phil Burr  wrote:
>
> Thank you for the feedback.  I will look into adding documentation for the
> atsc metadata.  ATSC requires in addition to the tables I've added, the STT
> and EIT0-EIT3 tables.  I'm thinking of adding support for STT and at least
> producing empty EIT tables so that the stream would be minimally compliant.

I would have no problem with them being excluded in a first version of
the patch, as long as it's documented that they are not expected to be
present in the resulting streams.

Your patch is already a huge improvement over the current state of
affairs, and I don't want to see your patch not get merged because it
lacks two features that I think the vast majority of people won't care
about.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
___
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] avfilter/avf_aphasemeter: Add out-of-phase and mono detection

2019-05-20 Thread Romane Lafon
I have updated the patch that extends aphasemeter filter.
It allows to get metadata for out-of-phase or mono sequences of stereo
streams.
It displays start, end and duration as for silencedetect filter.
From 08daf8a0394da0d482ee09f29d7cefa14b5c5440 Mon Sep 17 00:00:00 2001
From: Romane Lafon 
Date: Mon, 20 May 2019 13:28:21 +0200
Subject: [PATCH] avfilter/avf_aphasemeter: Add out of phase and mono detection

Signed-off-by: Romane Lafon 
---
 libavfilter/avf_aphasemeter.c | 124 --
 1 file changed, 120 insertions(+), 4 deletions(-)

diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c
index ed837059ea..daa15b46a9 100644
--- a/libavfilter/avf_aphasemeter.c
+++ b/libavfilter/avf_aphasemeter.c
@@ -28,26 +28,42 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
+#include "libavutil/timestamp.h"
 #include "avfilter.h"
 #include "formats.h"
 #include "audio.h"
 #include "video.h"
 #include "internal.h"
+#include "stdbool.h"
+#include "float.h"
 
 typedef struct AudioPhaseMeterContext {
 const AVClass *class;
 AVFrame *out;
 int do_video;
+int do_phasing_detection;
 int w, h;
 AVRational frame_rate;
 int contrast[4];
 uint8_t *mpc_str;
 uint8_t mpc[4];
 int draw_median_phase;
+int is_mono;
+int is_out_phase;
+int start_mono_presence;
+int start_out_phase_presence;
+float tolerance;
+float angle;
+float phase;
+float mono_idx[2];
+float out_phase_idx[2];
+double duration;
 } AudioPhaseMeterContext;
 
 #define OFFSET(x) offsetof(AudioPhaseMeterContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+#define PI 3.14159265359
+#define get_duration(index) (index[1] - index[0])
 
 static const AVOption aphasemeter_options[] = {
 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
@@ -59,6 +75,10 @@ static const AVOption aphasemeter_options[] = {
 { "bc", "set blue contrast",  OFFSET(contrast[2]), AV_OPT_TYPE_INT, {.i64=1}, 0, 255, FLAGS },
 { "mpc", "set median phase color", OFFSET(mpc_str), AV_OPT_TYPE_STRING, {.str = "none"}, 0, 0, FLAGS },
 { "video", "set video output", OFFSET(do_video), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
+{ "phasing", "set mono and out-of-phase detection output", OFFSET(do_phasing_detection), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
+{ "tolerance", "set phase tolerance for mono detection", OFFSET(tolerance), AV_OPT_TYPE_FLOAT, {.dbl = 0.}, 0, 1, FLAGS },
+{ "angle", "set angle threshold for out-of-phase detection", OFFSET(angle), AV_OPT_TYPE_FLOAT, {.dbl = 170.}, 90, 180, FLAGS },
+{ "duration", "set minimum mono or out-of-phase duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS },
 { NULL }
 };
 
@@ -140,6 +160,22 @@ static inline int get_x(float phase, int w)
   return (phase + 1.) / 2. * (w - 1);
 }
 
+static inline float get_index(AVFilterLink *inlink, AVFrame *in)
+{
+char *index_str = av_ts2timestr(in->pts, &inlink->time_base);
+return atof(index_str);
+}
+
+static inline void add_metadata(AVFrame *insamples, const char *key, float value)
+{
+char buf[128];
+char str[128];
+
+snprintf(str, sizeof(str), "%f", value);
+snprintf(buf, sizeof(buf), "lavfi.aphasemeter.%s", key);
+av_dict_set(&insamples->metadata, buf, str, 0);
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
@@ -154,6 +190,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 AVFrame *out;
 uint8_t *dst;
 int i;
+float tolerance = 1.0 - s->tolerance;
+float angle = cos(s->angle/180.0*PI);
 
 if (s->do_video && (!s->out || s->out->width  != outlink->w ||
s->out->height != outlink->h)) {
@@ -193,7 +231,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 fphase += phase;
 }
 fphase /= in->nb_samples;
-
+s->phase = fphase;
 if (s->do_video) {
 if (s->draw_median_phase) {
 dst = out->data[0] + get_x(fphase, s->w) * 4;
@@ -206,10 +244,62 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
 metadata = &in->metadata;
 if (metadata) {
-uint8_t value[128];
+add_metadata(in, "phase", fphase);
+}
 
-snprintf(value, sizeof(value), "%f", fphase);
-av_dict_set(metadata, "lavfi.aphasemeter.phase", value, 0);
+if (s->do_phasing_detection) {
+if (!s->is_mono && ((tolerance - fphase) < FLT_EPSILON)) {
+s->is_mono = 1;
+s->start_mono_presence = 1;
+s->mono_idx[0] = get_index(inlink, in);
+}
+if (s->is_mono && ((tolerance - fphase) < FLT_EPSILON) && s->start_mono_presence) {
+float mono_duration;
+s->mono_idx[1] = get_index(inlink, in);
+ 

Re: [FFmpeg-devel] [PATCH v2] libavformat/mpegtsenc: Add minimal support for ATSC PSIP tables

2019-05-20 Thread Phil Burr
Thank you for the feedback.  I will look into adding documentation for the
atsc metadata.  ATSC requires in addition to the tables I've added, the STT
and EIT0-EIT3 tables.  I'm thinking of adding support for STT and at least
producing empty EIT tables so that the stream would be minimally compliant.

Phil

On Sun, May 19, 2019 at 11:08 AM Devin Heitmueller <
dheitmuel...@kernellabs.com> wrote:

> Hello Phillip,
>
> On Thu, May 16, 2019 at 9:32 AM Phillip Burr  wrote:
> >
> > Minimal support for ATSC PSIP tables.  Does not support STT or
> > EIT tables and so is not compliant with terrestrial ATSC.
> > ATSC tables are not created by default, and will only be transmitted
> > if either "atsc_name" or "atsc_channel" metadata is supplied.
>
> In general I am supportive of this effort (producing ATSC compliant
> streams).  Thanks for your work to improve the TS mux support in this
> area.
>
> While I haven't looked that closely at your implementation, one key
> thing missing is updated documentation that describes the new
> parameters, and in particular something that notes that streams
> generated are currently not fully compliant with the spec (as you
> noted, the lack of STT).  While it's good to have that in the patch
> description, that's something that really needs to be known to end
> users who might try to use the functionality.
>
> Regards,
>
> Devin
>
> --
> Devin J. Heitmueller - Kernel Labs
> http://www.kernellabs.com
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat/movenc: use unspecified language by default

2019-05-20 Thread Carl Eugen Hoyos
Am So., 19. Mai 2019 um 20:10 Uhr schrieb Marton Balint :

> English was used before.

A version bump is necessary.

I would also like a Changelog entry, most people prefer an entry to
apichanges though.

Carl Eugen
___
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/f_loop: do not loop if loop size is 0

2019-05-20 Thread Bodecs Bela


2019.05.20. 7:02 keltezéssel, Gyan írta:



On 20-05-2019 02:18 AM, Marton Balint wrote:



On Sun, 19 May 2019, Paul B Mahol wrote:


On 5/19/19, Marton Balint  wrote:



On Sun, 19 May 2019, Paul B Mahol wrote:


On 5/19/19, Marton Balint  wrote:

Fixes infinte loop with -vf loop=loop=1.

Possible regression since ef1aadffc785b48ed62c45d954289e754f43ef46.

Signed-off-by: Marton Balint 
---
 libavfilter/f_loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index d9d55f9837..3da753dd1e 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -343,7 +343,7 @@ static int activate(AVFilterContext *ctx)

 FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);

-    if (!s->eof && (s->nb_frames < s->size || !s->loop)) {
+    if (!s->eof && (s->nb_frames < s->size || !s->loop || 
!s->size)) {

 ret = ff_inlink_consume_frame(inlink, &frame);
 if (ret < 0)
 return ret;
--
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".


I think better fix is to change default and minimal allowed loop 
size to

1.
Does that sounds ok to you?


Well, looping the whole length of the input would be more intuitive 
to me

as the default.


That would require infinite memory.


So as the reverse filter. As long as it is properly documented that 
the looped stuff is kept in memory so the user should not use this 
for long clips, then I think it is fine.


I disagree. Yes, for loop with only loop specified, it would be 
intuitive to loop the whole stream, but relying on users to exercise 
due diligence can't be counted upon. We're talking about a scenario 
where the user hasn't bothered to specify the size variable because 
they don't know or don't care or are sloppy. They won't take heed of 
the documentation until the command fails. The defaults should be 
robust against lax use.


just an idea. What about to have no-default value for loop length/size 
at all? I mean to let the size as mandatory parameter?


bb



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 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] libavutil: add an FFT & MDCT implementation

2019-05-20 Thread Carl Eugen Hoyos
Am Di., 14. Mai 2019 um 20:41 Uhr schrieb Lynne :

> Attached a version with fft-template.c's copyright and mine

Thank you!

Carl Eugen
___
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/cpia: Check input size also against linesizes and EOL

2019-05-20 Thread Carl Eugen Hoyos
Am So., 19. Mai 2019 um 17:43 Uhr schrieb Michael Niedermayer
:
>
> Fixes: Timeout (14sec -> 29ms)
> Fixes: 
> 14733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CPIA_fuzzer-5707022445576192
>
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/cpia.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c
> index 119969389e..2e78fcff7a 100644
> --- a/libavcodec/cpia.c
> +++ b/libavcodec/cpia.c
> @@ -63,7 +63,7 @@ static int cpia_decode_frame(AVCodecContext *avctx,
>  uint8_t *y, *u, *v;
>
>  // Check header
> -if ( avpkt->size < FRAME_HEADER_SIZE
> +if ( avpkt->size < FRAME_HEADER_SIZE + avctx->height*3

lgtm except for the missing whitespace that is constantly present in the file.

Carl Eugen
___
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] ffplay: added option always on top for video window

2019-05-20 Thread Carl Eugen Hoyos
Marton,

Am Mo., 13. Mai 2019 um 13:42 Uhr schrieb Daniel Kucera
:
>
> From: Daniel Kucera 
>
> Signed-off-by: Daniel Kucera 
> ---
>  doc/ffplay.texi  | 2 ++
>  fftools/ffplay.c | 8 
>  2 files changed, 10 insertions(+)
>
> diff --git a/doc/ffplay.texi b/doc/ffplay.texi
> index c305465078..a487c0de8d 100644
> --- a/doc/ffplay.texi
> +++ b/doc/ffplay.texi
> @@ -66,6 +66,8 @@ Set custom interval, in seconds, for seeking using 
> left/right keys. Default is 1
>  Disable graphical display.
>  @item -noborder
>  Borderless window.
> +@item -alwaysontop
> +Window always on top. Available on: X11 with SDL >= 2.0.5, Windows SDL >= 
> 2.0.6.
>  @item -volume
>  Set the startup volume. 0 means silence, 100 means no volume reduction or
>  amplification. Negative values are treated as 0, values above 100 are treated
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index 8f050e16e6..8fb8faeb06 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -324,6 +324,7 @@ static int seek_by_bytes = -1;
>  static float seek_interval = 10;
>  static int display_disable;
>  static int borderless;
> +static int alwaysontop;
>  static int startup_volume = 100;
>  static int show_status = 1;
>  static int av_sync_type = AV_SYNC_AUDIO_MASTER;
> @@ -3581,6 +3582,7 @@ static const OptionDef options[] = {
>  { "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set seek 
> interval for left/right keys, in seconds", "seconds" },
>  { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" 
> },
>  { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
> +{ "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on top" },
>  { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 
> 0=min 100=max", "volume" },
>  { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" },
>  { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = 
> opt_frame_pix_fmt }, "set pixel format", "format" },
> @@ -3722,6 +3724,12 @@ int main(int argc, char **argv)
>
>  if (!display_disable) {
>  int flags = SDL_WINDOW_HIDDEN;
> +if (alwaysontop)
> +#if SDL_VERSION_ATLEAST(2,0,5)
> +flags |= SDL_WINDOW_ALWAYS_ON_TOP;
> +#else
> +av_log(NULL, AV_LOG_WARNING, "Your SDL version doesn't support 
> SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
> +#endif

Is there any reason you are against this patch?

Carl Eugen
___
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] mpeg12enc: Use all Closed Captions side data

2019-05-20 Thread Hendrik Leppkes
On Mon, May 20, 2019 at 9:44 AM Reimar Döffinger
 wrote:
>
>
>
> On 20.05.2019, at 09:23, Mathieu Duponchelle  wrote:
>
> > Thanks :)
> >
> > On 5/19/19 7:00 PM, Devin Heitmueller wrote:
> >> Hello Paul,
> >>
> >> On Fri, May 17, 2019 at 4:44 AM Paul B Mahol  wrote:
> >>> On 5/17/19, Mathieu Duponchelle  wrote:
>  There isn't one, as I said the added indentation is because of the new 
>  loop!
> >>> To get this committed to tree you need to comply to review requests.
> >> I think Mathieu's point is that the code indentation change was not
> >> cosmetic - it's because the code in question is now inside a for loop,
> >> and thus it needed to be indented another level.
> >>
> >> Are you suggesting he should make a patch which results in the
> >> indentation being wrong, and then submit a second patch which fixes
> >> the incorrect indentation introduced by the first patch?
>
> I think it should probably be up to the maintainer, but possibly yes.
> A lot of review still happens primarily by email, and if you re-indent code
> it becomes impossible to see what, if anything, you changed in that block.
> Enabling reviews of the patch via email means not re-indenting even if
> it becomes "wrong".
> Not everyone does reviews that way though, so some maintainers nowadays might 
> prefer it differently?

My main concern with such requests is that its added effort to even
make these patches, since many developers will just automatically
indent where appropriate (as it should be), or even have tooling to do
it for them.
Personally, I would have to use another editor to "un-indent" the
code, since my main editor automatically corrects this stuff for me in
newly written code. As such, I'll personally never comply with such
requests, because I think its silly, and it would be extraordinary
effort to even do it, first restoring original indent with a second
editor.

In so many cases the "cosmetic" second commit was also quite simply
forgotten, resulting in an ugly codebase. Nevermind the added noise in
the commit log.

I don't think its that much to ask for a reviewer to also use a tool
that can ignore whitespace. Maybe we can teach patchwork to offer a
button to view diffs without whitespace, if people don't want to use a
simple tool.

- 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] mpeg12enc: Use all Closed Captions side data

2019-05-20 Thread Reimar Döffinger


On 20.05.2019, at 09:23, Mathieu Duponchelle  wrote:

> Thanks :)
> 
> On 5/19/19 7:00 PM, Devin Heitmueller wrote:
>> Hello Paul,
>> 
>> On Fri, May 17, 2019 at 4:44 AM Paul B Mahol  wrote:
>>> On 5/17/19, Mathieu Duponchelle  wrote:
 There isn't one, as I said the added indentation is because of the new 
 loop!
>>> To get this committed to tree you need to comply to review requests.
>> I think Mathieu's point is that the code indentation change was not
>> cosmetic - it's because the code in question is now inside a for loop,
>> and thus it needed to be indented another level.
>> 
>> Are you suggesting he should make a patch which results in the
>> indentation being wrong, and then submit a second patch which fixes
>> the incorrect indentation introduced by the first patch?

I think it should probably be up to the maintainer, but possibly yes.
A lot of review still happens primarily by email, and if you re-indent code
it becomes impossible to see what, if anything, you changed in that block.
Enabling reviews of the patch via email means not re-indenting even if
it becomes "wrong".
Not everyone does reviews that way though, so some maintainers nowadays might 
prefer it differently?
___
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] mpeg12enc: Use all Closed Captions side data

2019-05-20 Thread Mathieu Duponchelle
Thanks :)

On 5/19/19 7:00 PM, Devin Heitmueller wrote:
> Hello Paul,
>
> On Fri, May 17, 2019 at 4:44 AM Paul B Mahol  wrote:
>> On 5/17/19, Mathieu Duponchelle  wrote:
>>> There isn't one, as I said the added indentation is because of the new loop!
>> To get this committed to tree you need to comply to review requests.
> I think Mathieu's point is that the code indentation change was not
> cosmetic - it's because the code in question is now inside a for loop,
> and thus it needed to be indented another level.
>
> Are you suggesting he should make a patch which results in the
> indentation being wrong, and then submit a second patch which fixes
> the incorrect indentation introduced by the first patch?
>
> I'm confident that Mathieu is trying to comply with review requests so
> he can get his code merged.  In this particular case, Carl raised his
> concern about the indentation, Mathieu responded by suggesting that
> given there was a functional change the re-indent was correct, and
> then there was silence (i.e. neither agreement nor disagreement).
>
> I'm also asking because I have work which I'm hoping to get upstreamed
> as well at some point, and I'm sure I've got similar things in my
> patches.  And having spent 20+ years reviewing patches on lots of
> other open source projects, I wouldn't have thought twice about
> accepting the patch as-is (given the change in indentation is a result
> of a functional change and is not cosmetic).  In my experience, this
> particular patch isn't an example of what maintainers mean when they
> say "don't mix cosmetic whitespace changes with functional changes".
>
> Regards,
>
> Devin
>
___
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] mpeg12enc: Use all Closed Captions side data

2019-05-20 Thread Mathieu Duponchelle
Hello,

Have you read the patch? The request is to split out cosmetic indentation
to a separate commit, however the added indentation is not cosmetic, but
simply due to a new inner loop ..

Best,
Mathieu

On 5/17/19 10:44 AM, Paul B Mahol wrote:
> On 5/17/19, Mathieu Duponchelle  wrote:
>> There isn't one, as I said the added indentation is because of the new loop!
> To get this committed to tree you need to comply to review requests.
>
>> On 5/13/19 3:39 PM, Carl Eugen Hoyos wrote:
>>> Am Mi., 10. Apr. 2019 um 13:26 Uhr schrieb Mathieu Duponchelle
>>> :
>>>
 No problem
>>> I don't see an updated patch.
>>>
>>> Carl Eugen
>>> ___
>>> 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".
> ___
> 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".