Re: [FFmpeg-devel] [PATCH v6 1/2] avformat: refactor ff_stream_encode_params_copy() to stream_params_copy()

2022-08-06 Thread Andreas Rheinhardt
p...@sandflow.com:
> From: Pierre-Anthony Lemieux 
> 
> Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299685.html
> 
> ---
>  libavformat/avformat.c   | 68 
>  libavformat/fifo.c   |  8 ++---
>  libavformat/internal.h   | 12 +++
>  libavformat/mux.h|  9 --
>  libavformat/mux_utils.c  | 28 -
>  libavformat/segment.c|  6 ++--
>  libavformat/tee.c|  7 ++---
>  libavformat/webm_chunk.c |  6 ++--
>  8 files changed, 89 insertions(+), 55 deletions(-)
> 
> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> index 30d6ea6a49..64c9d71a24 100644
> --- a/libavformat/avformat.c
> +++ b/libavformat/avformat.c
> @@ -235,6 +235,74 @@ int ff_stream_side_data_copy(AVStream *dst, const 
> AVStream *src)
>  return 0;
>  }
>  
> +/**
> + * Copy all stream parameters from source to destination stream, with the
> + * exception of:
> + *  * the index field, which is usually set by avformat_new_stream()
> + *  * the attached_pic field, if attached_pic.size is 0 or less
> + *
> + * @param dst pointer to destination AVStream
> + * @param src pointer to source AVStream
> + * @return >=0 on success, AVERROR code on error
> + */
> +static int stream_params_copy(AVStream *dst, const AVStream *src)
> +{
> +int ret;
> +
> +dst->id  = src->id;
> +dst->time_base   = src->time_base;
> +dst->start_time  = src->start_time;
> +dst->duration= src->duration;
> +dst->nb_frames   = src->nb_frames;
> +dst->disposition = src->disposition;
> +dst->discard = src->discard;
> +dst->sample_aspect_ratio = src->sample_aspect_ratio;
> +dst->avg_frame_rate  = src->avg_frame_rate;
> +dst->event_flags = src->event_flags;
> +dst->r_frame_rate= src->r_frame_rate;
> +dst->pts_wrap_bits   = src->pts_wrap_bits;
> +
> +av_dict_free(&dst->metadata);
> +ret = av_dict_copy(&dst->metadata, src->metadata, 0);
> +if (ret < 0)
> +return ret;
> +
> +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
> +if (ret < 0)
> +return ret;
> +
> +ret = ff_stream_side_data_copy(dst, src);
> +if (ret < 0)
> +return ret;
> +
> +av_packet_unref(&dst->attached_pic);
> +if (src->attached_pic.size > 0) {

I'd rather have it that you check for attached_pic.data instead (even if
this might mean that avformat_queue_attached_pictures() might warn for
the dst stream lateron because of a packet with size zero). That way you
would be copying the packet iff the src packet is set (side-data only
attached pics don't exist).
This would also mean that the behaviour of attached pic would no longer
be exceptional, i.e. it needn't be documented.

> +ret = av_packet_ref(&dst->attached_pic, &src->attached_pic);
> +if (ret < 0)
> +return ret;
> +}
> +
> +return 0;
> +}
> +
> +AVStream *ff_stream_clone(AVFormatContext *dst_ctx, const AVStream *src)
> +{
> +AVStream *st;
> +int ret;
> +
> +st = avformat_new_stream(dst_ctx, NULL);
> +if (!st)
> +return NULL;
> +
> +ret = stream_params_copy(st, src);
> +if (ret < 0) {
> +ff_remove_stream(dst_ctx, st);
> +return NULL;
> +}
> +
> +return st;
> +}
> +
>  AVProgram *av_new_program(AVFormatContext *ac, int id)
>  {
>  AVProgram *program = NULL;
> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> index ead2bdc5cf..55d413b952 100644
> --- a/libavformat/fifo.c
> +++ b/libavformat/fifo.c
> @@ -505,13 +505,11 @@ static int fifo_mux_init(AVFormatContext *avf, const 
> AVOutputFormat *oformat,
>  avf2->flags = avf->flags;
>  
>  for (i = 0; i < avf->nb_streams; ++i) {
> -AVStream *st = avformat_new_stream(avf2, NULL);
> +AVStream *st = NULL;
> +
> +st = ff_stream_clone(avf2, avf->streams[i]);
>  if (!st)
>  return AVERROR(ENOMEM);
> -
> -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
> -if (ret < 0)
> -return ret;
>  }
>  
>  return 0;
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index b6b8fbf56f..6dd763950f 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int 
> be, int sflags);
>   */
>  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
>  
> +/**
> + * Create a new stream and copy to it all parameters from a source stream,
> + * with the exception of:
> + *  * the index field, which is set when the new stream is created
> + *  * the attached_pic field, if attached_pic.size is 0 or less> + *
> + * @param dst_ctx pointer to the context in which the new stream is created
> + * @param src pointer to source AVStream
> + * @return pointer to the new stream or NULL on error
> + */
> +AVStream *ff_stream_clone(AVFormatCont

Re: [FFmpeg-devel] [PATCH 1/9] avcodec/error_resilience: Avoid overhead of AVBuffer API

2022-08-06 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> These buffers are not shared in any way.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/error_resilience.c | 18 +-
>  libavcodec/error_resilience.h |  4 ++--
>  2 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
> index f957c68d2c..2aa6f1d864 100644
> --- a/libavcodec/error_resilience.c
> +++ b/libavcodec/error_resilience.c
> @@ -946,17 +946,17 @@ void ff_er_frame_end(ERContext *s)
>  av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
>  
>  for (i = 0; i < 2; i++) {
> -s->ref_index_buf[i]  = av_buffer_allocz(s->mb_stride * 
> s->mb_height * 4 * sizeof(uint8_t));
> -s->motion_val_buf[i] = av_buffer_allocz((size + 4) * 2 * 
> sizeof(uint16_t));
> -if (!s->ref_index_buf[i] || !s->motion_val_buf[i])
> +s->ref_index[i]   = av_calloc(s->mb_stride * s->mb_height, 4 
> * sizeof(uint8_t));
> +s->motion_val_base[i] = av_calloc(size + 4, 2 * 
> sizeof(uint16_t));
> +if (!s->ref_index[i] || !s->motion_val_base[i])
>  break;
> -s->cur_pic.ref_index[i]  = s->ref_index_buf[i]->data;
> -s->cur_pic.motion_val[i] = (int16_t 
> (*)[2])s->motion_val_buf[i]->data + 4;
> +s->cur_pic.ref_index[i]  = s->ref_index[i];
> +s->cur_pic.motion_val[i] = s->motion_val_base[i] + 4;
>  }
>  if (i < 2) {
>  for (i = 0; i < 2; i++) {
> -av_buffer_unref(&s->ref_index_buf[i]);
> -av_buffer_unref(&s->motion_val_buf[i]);
> +av_freep(&s->ref_index[i]);
> +av_freep(&s->motion_val_base[i]);
>  s->cur_pic.ref_index[i]  = NULL;
>  s->cur_pic.motion_val[i] = NULL;
>  }
> @@ -1343,8 +1343,8 @@ void ff_er_frame_end(ERContext *s)
>  }
>  
>  for (i = 0; i < 2; i++) {
> -av_buffer_unref(&s->ref_index_buf[i]);
> -av_buffer_unref(&s->motion_val_buf[i]);
> +av_freep(&s->ref_index[i]);
> +av_freep(&s->motion_val_base[i]);
>  s->cur_pic.ref_index[i]  = NULL;
>  s->cur_pic.motion_val[i] = NULL;
>  }
> diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h
> index 53e5cf2621..47cc8a4fc6 100644
> --- a/libavcodec/error_resilience.h
> +++ b/libavcodec/error_resilience.h
> @@ -75,8 +75,8 @@ typedef struct ERContext {
>  ERPicture last_pic;
>  ERPicture next_pic;
>  
> -AVBufferRef *ref_index_buf[2];
> -AVBufferRef *motion_val_buf[2];
> +int8_t *ref_index[2];
> +int16_t (*motion_val_base[2])[2];
>  
>  uint16_t pp_time;
>  uint16_t pb_time;

Will apply this patchset tomorrow unless there are objections.

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

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


[FFmpeg-devel] [PATCH] avcodec/nvdec_hevc: Fix off-by-one error

2022-08-06 Thread Andreas Rheinhardt
Fixes Coverity issues #1442912, #1442913, #1442916 and #1442917.

Signed-off-by: Andreas Rheinhardt 
---
Given that hevc_ps.c checks these values, it is actually impossible
for this error to be triggered.

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

diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index 590278ba04..cd549d2ef6 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -204,8 +204,8 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx,
 ppc->row_height_minus1[i] = pps->row_height[i] - 1;
 
 #if NVDECAPI_CHECK_VERSION(9, 0)
-if (pps->chroma_qp_offset_list_len_minus1 > 
FF_ARRAY_ELEMS(ppc->cb_qp_offset_list) ||
-pps->chroma_qp_offset_list_len_minus1 > 
FF_ARRAY_ELEMS(ppc->cr_qp_offset_list)) {
+if (pps->chroma_qp_offset_list_len_minus1 >= 
FF_ARRAY_ELEMS(ppc->cb_qp_offset_list) ||
+pps->chroma_qp_offset_list_len_minus1 >= 
FF_ARRAY_ELEMS(ppc->cr_qp_offset_list)) {
 av_log(avctx, AV_LOG_ERROR, "Too many chroma_qp_offsets\n");
 return AVERROR(ENOSYS);
 }
-- 
2.34.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] avcodec/nvdec_hevc: Fix off-by-one error

2022-08-06 Thread Timo Rothenpieler

On 06.08.2022 08:01, Andreas Rheinhardt wrote:

Fixes Coverity issues #1442912, #1442913, #1442916 and #1442917.

Signed-off-by: Andreas Rheinhardt 
---
Given that hevc_ps.c checks these values, it is actually impossible
for this error to be triggered.

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

diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index 590278ba04..cd549d2ef6 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -204,8 +204,8 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx,
  ppc->row_height_minus1[i] = pps->row_height[i] - 1;
  
  #if NVDECAPI_CHECK_VERSION(9, 0)

-if (pps->chroma_qp_offset_list_len_minus1 > 
FF_ARRAY_ELEMS(ppc->cb_qp_offset_list) ||
-pps->chroma_qp_offset_list_len_minus1 > 
FF_ARRAY_ELEMS(ppc->cr_qp_offset_list)) {
+if (pps->chroma_qp_offset_list_len_minus1 >= 
FF_ARRAY_ELEMS(ppc->cb_qp_offset_list) ||
+pps->chroma_qp_offset_list_len_minus1 >= 
FF_ARRAY_ELEMS(ppc->cr_qp_offset_list)) {
  av_log(avctx, AV_LOG_ERROR, "Too many chroma_qp_offsets\n");
  return AVERROR(ENOSYS);
  }


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] avformat/movenc: Remove experimental status of flac-in-MP4 muxing

2022-08-06 Thread Martijn van Beurden
The fLaC and dfLa box IDs have been registered with the MP4 RA
(they are now listed at https://mp4ra.org/#/codecs) and support
for muxing FLAC in MP4 has been experimental in ffmpeg for
6 years now, since Nov 21, 2016

This patch removes the experimental status and removes the MP4
object type, as none has been registered for FLAC as it was not
deemed necessary.
---
 libavformat/isom.c  | 1 -
 libavformat/isom_tags.c | 2 +-
 libavformat/movenc.c| 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index cf27f58082..6d019881e5 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -61,7 +61,6 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_DTS , 0xA9 }, /* mp4ra.org */
 { AV_CODEC_ID_OPUS, 0xAD }, /* mp4ra.org */
 { AV_CODEC_ID_VP9 , 0xB1 }, /* mp4ra.org */
-{ AV_CODEC_ID_FLAC, 0xC1 }, /* nonstandard, update when there is a 
standard value */
 { AV_CODEC_ID_TSCC2   , 0xD0 }, /* nonstandard, camtasia uses it */
 { AV_CODEC_ID_EVRC, 0xD1 }, /* nonstandard, pvAuthor uses it */
 { AV_CODEC_ID_VORBIS  , 0xDD }, /* nonstandard, gpac uses it */
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index c5fd7987f6..362cb77e8f 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -332,7 +332,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
 { AV_CODEC_ID_SPEEX,   MKTAG('S', 'P', 'X', 'N') }, /* ZygoAudio 
(quality 10 mode) */
 { AV_CODEC_ID_EVRC,MKTAG('s', 'e', 'v', 'c') }, /* 3GPP2 */
 { AV_CODEC_ID_SMV, MKTAG('s', 's', 'm', 'v') }, /* 3GPP2 */
-{ AV_CODEC_ID_FLAC,MKTAG('f', 'L', 'a', 'C') }, /* nonstandard 
*/
+{ AV_CODEC_ID_FLAC,MKTAG('f', 'L', 'a', 'C') },
 { AV_CODEC_ID_TRUEHD,  MKTAG('m', 'l', 'p', 'a') }, /* mp4ra.org */
 { AV_CODEC_ID_OPUS,MKTAG('O', 'p', 'u', 's') }, /* mp4ra.org */
 { AV_CODEC_ID_MPEGH_3D_AUDIO,  MKTAG('m', 'h', 'm', '1') }, /* MPEG-H 3D 
Audio bitstream */
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5608afde42..c8b2e141cb 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -7160,7 +7160,7 @@ static int mov_init(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "%s only supported in MP4.\n", 
avcodec_get_name(track->par->codec_id));
 return AVERROR(EINVAL);
 }
-if (track->par->codec_id != AV_CODEC_ID_OPUS &&
+if (track->par->codec_id == AV_CODEC_ID_TRUEHD &&
 s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
 av_log(s, AV_LOG_ERROR,
"%s in MP4 support is experimental, add "
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH] fftools/ffmpeg: remove OutputStream.stream_copy

2022-08-06 Thread Anton Khirnov
There are currently three possible modes for an output stream:
1) The stream is produced by encoding output from some filtergraph. This
   is true when ost->enc_ctx != NULL, or equivalently when
   ost->encoding_needed != 0.
2) The stream is produced by copying some input stream's packets. This
   is true when ost->enc_ctx == NULL && ost->source_index >= 0.
3) The stream is produced by attaching some file directly. This is true
   when ost->enc_ctx == NULL && ost->source_index < 0.

OutputStream.stream_copy is currently used to identify case 2), and
sometimes to confusingly (or even incorrectly) identify case 1). Remove
it, replacing its usage with checking enc_ctx/source_index values.
---
 fftools/ffmpeg.c | 23 +--
 fftools/ffmpeg.h |  1 -
 fftools/ffmpeg_opt.c | 33 -
 3 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 62ff1a98df..cf61706ac0 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1566,9 +1566,7 @@ static void print_final_stats(int64_t total_size)
 static void print_report(int is_last_report, int64_t timer_start, int64_t 
cur_time)
 {
 AVBPrint buf, buf_script;
-OutputStream *ost;
 int64_t total_size = of_filesize(output_files[0]);
-AVCodecContext *enc;
 int vid, i;
 double bitrate;
 double speed;
@@ -1600,11 +1598,9 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(&buf_script, 0, AV_BPRINT_SIZE_AUTOMATIC);
 for (i = 0; i < nb_output_streams; i++) {
-float q = -1;
-ost = output_streams[i];
-enc = ost->enc_ctx;
-if (!ost->stream_copy)
-q = ost->quality / (float) FF_QP2LAMBDA;
+OutputStream * const ost = output_streams[i];
+const AVCodecContext * const enc = ost->enc_ctx;
+const float q = enc ? ost->quality / (float) FF_QP2LAMBDA : -1;
 
 if (vid && ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 av_bprintf(&buf, "q=%2.1f ", q);
@@ -3258,7 +3254,7 @@ static int init_output_stream(OutputStream *ost, AVFrame 
*frame,
 // copy estimated duration as a hint to the muxer
 if (ost->st->duration <= 0 && ist && ist->st->duration > 0)
 ost->st->duration = av_rescale_q(ist->st->duration, 
ist->st->time_base, ost->st->time_base);
-} else if (ost->stream_copy) {
+} else if (ost->source_index >= 0) {
 ret = init_output_stream_streamcopy(ost);
 if (ret < 0)
 return ret;
@@ -3343,7 +3339,7 @@ static int transcode_init(void)
  *   known after the encoder is initialized.
  */
 for (i = 0; i < nb_output_streams; i++) {
-if (!output_streams[i]->stream_copy &&
+if (output_streams[i]->enc_ctx &&
 (output_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO 
||
  output_streams[i]->st->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO))
 continue;
@@ -3417,9 +3413,7 @@ static int transcode_init(void)
 av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
-if (ost->stream_copy)
-av_log(NULL, AV_LOG_INFO, " (copy)");
-else {
+if (ost->enc_ctx) {
 const AVCodec *in_codec= input_streams[ost->source_index]->dec;
 const AVCodec *out_codec   = ost->enc;
 const char *decoder_name   = "?";
@@ -3449,7 +3443,8 @@ static int transcode_init(void)
 av_log(NULL, AV_LOG_INFO, " (%s (%s) -> %s (%s))",
in_codec_name, decoder_name,
out_codec_name, encoder_name);
-}
+} else
+av_log(NULL, AV_LOG_INFO, " (copy)");
 av_log(NULL, AV_LOG_INFO, "\n");
 }
 
@@ -3959,7 +3954,7 @@ static int process_input(int file_index)
 OutputStream *ost = output_streams[j];
 
 if (ost->source_index == ifile->ist_index + i &&
-(ost->stream_copy || ost->enc->type == 
AVMEDIA_TYPE_SUBTITLE)) {
+(!ost->enc_ctx || ost->enc->type == 
AVMEDIA_TYPE_SUBTITLE)) {
 OutputFile *of = output_files[ost->file_index];
 output_packet(of, ost->pkt, ost, 1);
 }
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6417db03bd..713de42e2b 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -540,7 +540,6 @@ typedef struct OutputStream {
 char *apad;
 OSTFinished finished;/* no more packets should be written for this 
stream */
 int unavailable; /* true if the steram is unavailable 
(possibly temporarily) */
-int stream_copy;
 
 // init_output_stream() has been called for this stream
 // The encoder and the bitstream filters have been initialized and the 

Re: [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions

2022-08-06 Thread Nicolas George
Michael Niedermayer (12022-08-04):
> I suspect several filters are somewhat "wrong"
> for example hflip fliping 4:1:1
> would turn a:   *--- into ---*
> where * is teh chroma sample location, i dont think it updates the chroma
> sample location metadata nor does it apply some filter to chroma to shift by
> 3/4 samples. so it looks wrong, one of the 2 is neeed.
> 
> vf_scale contains some code to handle this but iam not seeing code considering
> the input and output frames chroma location metadata
> 
> All this leads to small errors, often probably not vissible
> when you have one one chroma sample for 4 luma samples you will always have
> some artifacts on sharp color edges, if the location of the chroma sample
> is wrong the artifact would be more to one side of a diagonal edge than the
> other. If the locations are correct it should be more symmetric in theory.

I think I understand. Would it be ok to apply this with the added
comment:

* Note: this is a quick mnemonic representation of the pixels; actual
* interaction between chroma and luma is more complex, see
* AVChromaLocation in pixfmt.h.

?

Regards,

-- 
  Nicolas George


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

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


[FFmpeg-devel] [PATCH] avfilter/avfiltergraph: remove unnecessary channel layout copy

2022-08-06 Thread James Almer
It's not modified, so we can simply use a const pointer to it.
Also check the return value of the other copy in the function while at it.

Signed-off-by: James Almer 
---
 libavfilter/avfiltergraph.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index b7dbfc063b..53f468494d 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -729,12 +729,12 @@ static int reduce_formats_on_filter(AVFilterContext 
*filter)
 /* reduce channel layouts */
 for (i = 0; i < filter->nb_inputs; i++) {
 AVFilterLink *inlink = filter->inputs[i];
-AVChannelLayout fmt = { 0 };
+const AVChannelLayout *fmt;
 
 if (!inlink->outcfg.channel_layouts ||
 inlink->outcfg.channel_layouts->nb_channel_layouts != 1)
 continue;
-av_channel_layout_copy(&fmt, 
&inlink->outcfg.channel_layouts->channel_layouts[0]);
+fmt = &inlink->outcfg.channel_layouts->channel_layouts[0];
 
 for (j = 0; j < filter->nb_outputs; j++) {
 AVFilterLink *outlink = filter->outputs[j];
@@ -745,24 +745,25 @@ static int reduce_formats_on_filter(AVFilterContext 
*filter)
 continue;
 
 if (fmts->all_layouts &&
-(KNOWN(&fmt) || fmts->all_counts)) {
+(KNOWN(fmt) || fmts->all_counts)) {
 /* Turn the infinite list into a singleton */
 fmts->all_layouts = fmts->all_counts  = 0;
-if (ff_add_channel_layout(&outlink->incfg.channel_layouts, 
&fmt) < 0)
+if (ff_add_channel_layout(&outlink->incfg.channel_layouts, 
fmt) < 0)
 ret = 1;
 break;
 }
 
 for (k = 0; k < 
outlink->incfg.channel_layouts->nb_channel_layouts; k++) {
-if (!av_channel_layout_compare(&fmts->channel_layouts[k], 
&fmt)) {
-av_channel_layout_copy(&fmts->channel_layouts[0], &fmt);
+if (!av_channel_layout_compare(&fmts->channel_layouts[k], 
fmt)) {
+ret = av_channel_layout_copy(&fmts->channel_layouts[0], 
fmt);
+if (ret < 0)
+return ret;
 fmts->nb_channel_layouts = 1;
 ret = 1;
 break;
 }
 }
 }
-av_channel_layout_uninit(&fmt);
 }
 
 return ret;
-- 
2.37.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] avfilter/avfiltergraph: remove unnecessary channel layout copy

2022-08-06 Thread Nicolas George
James Almer (12022-08-05):
> It's not modified, so we can simply use a const pointer to it.
> Also check the return value of the other copy in the function while at it.
> 
> Signed-off-by: James Almer 
> ---
>  libavfilter/avfiltergraph.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)

Ok, thanks.

Regards,

-- 
  Nicolas George


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] lswr: take const AVChannelLayout* in swr_alloc_set_opts2()

2022-08-06 Thread Andreas Rheinhardt
rcombs:
> This is fully backwards-compatible in both ABI and API,
> so it's only a minor bump.

It is not fully backwards-compatible API-wise: If you use a function
pointer for swr_alloc_set_opts2 by hardcoding its type, you will get
warnings now (or even errors depending upon your -Werror; it is an error
by default for C++). Given that I do not know about other language
bindings I have so far refrained from applying
https://patchwork.ffmpeg.org/project/ffmpeg/patch/as1pr01mb95649a21f5f9a45d40e6ac1d8f...@as1pr01mb9564.eurprd01.prod.exchangelabs.com/
This does not mean that I block your patch; to the contrary: If it
breaks nothing, I will apply the above patch after a month or so.

- Andreas

> ---
>  libswresample/swresample.c | 4 ++--
>  libswresample/swresample.h | 4 ++--
>  libswresample/version.h| 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/libswresample/swresample.c b/libswresample/swresample.c
> index 9b77ef65bf..123ac65693 100644
> --- a/libswresample/swresample.c
> +++ b/libswresample/swresample.c
> @@ -83,8 +83,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
>  
>  int swr_alloc_set_opts2(struct SwrContext **ps,
> -AVChannelLayout *out_ch_layout, enum AVSampleFormat 
> out_sample_fmt, int out_sample_rate,
> -AVChannelLayout *in_ch_layout, enum AVSampleFormat  
> in_sample_fmt, int  in_sample_rate,
> +const AVChannelLayout *out_ch_layout, enum 
> AVSampleFormat out_sample_fmt, int out_sample_rate,
> +const AVChannelLayout *in_ch_layout, enum 
> AVSampleFormat  in_sample_fmt, int  in_sample_rate,
>  int log_offset, void *log_ctx) {
>  struct SwrContext *s = *ps;
>  int ret;
> diff --git a/libswresample/swresample.h b/libswresample/swresample.h
> index 26d42fab8d..980be65783 100644
> --- a/libswresample/swresample.h
> +++ b/libswresample/swresample.h
> @@ -286,8 +286,8 @@ struct SwrContext *swr_alloc_set_opts(struct SwrContext 
> *s,
>   * On error, the Swr context is freed and *ps set to NULL.
>   */
>  int swr_alloc_set_opts2(struct SwrContext **ps,
> -AVChannelLayout *out_ch_layout, enum AVSampleFormat 
> out_sample_fmt, int out_sample_rate,
> -AVChannelLayout *in_ch_layout, enum AVSampleFormat  
> in_sample_fmt, int  in_sample_rate,
> +const AVChannelLayout *out_ch_layout, enum 
> AVSampleFormat out_sample_fmt, int out_sample_rate,
> +const AVChannelLayout *in_ch_layout, enum 
> AVSampleFormat  in_sample_fmt, int  in_sample_rate,
>  int log_offset, void *log_ctx);
>  /**
>   * @}
> diff --git a/libswresample/version.h b/libswresample/version.h
> index 66bac2fa9b..4b9952d914 100644
> --- a/libswresample/version.h
> +++ b/libswresample/version.h
> @@ -30,7 +30,7 @@
>  
>  #include "version_major.h"
>  
> -#define LIBSWRESAMPLE_VERSION_MINOR   8
> +#define LIBSWRESAMPLE_VERSION_MINOR   9
>  #define LIBSWRESAMPLE_VERSION_MICRO 100
>  
>  #define LIBSWRESAMPLE_VERSION_INT  
> AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \

___
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] lavfi/dnn: Fix OpenVINO missing model file corrupt issue.

2022-08-06 Thread Anton Khirnov
Quoting Fu, Ting (2022-08-05 05:34:30)
> Hi Anton,
> 
> Thank you for comment. 
> After double checked the OpenVINO, it is true that the code would corrupt if 
> the binary file does not exist.

Can you be more specific about what do you mean by "corrupt"?

> We would have nothing to do in this case, that's why I code to check the file 
> existence explicitly.
> Yes, you are right, it is not a proper way to do like this. But I have no 
> idea how to solve it more decently, since trying to open it as you mentioned 
> would lead to crush immediately. Maybe there is some solution I don’t know, 
> any further input would be appreciated. 😊

It should be fixed in OpenVINO, and we should disallow any older
versions from being used in lavfi. Your patch is still susceptible to
someone removing the file after the access() call.

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

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


Re: [FFmpeg-devel] [PATCH] lswr: take const AVChannelLayout* in swr_alloc_set_opts2()

2022-08-06 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2022-08-06 13:50:37)
> rcombs:
> > This is fully backwards-compatible in both ABI and API,
> > so it's only a minor bump.
> 
> It is not fully backwards-compatible API-wise: If you use a function
> pointer for swr_alloc_set_opts2 by hardcoding its type, you will get
> warnings now (or even errors depending upon your -Werror; it is an error
> by default for C++). Given that I do not know about other language
> bindings I have so far refrained from applying
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/as1pr01mb95649a21f5f9a45d40e6ac1d8f...@as1pr01mb9564.eurprd01.prod.exchangelabs.com/
> This does not mean that I block your patch; to the contrary: If it
> breaks nothing, I will apply the above patch after a month or so.

Maybe now could be a good time for a major bump, since we just had a
release. It's also been two releases since the last one.

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

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


Re: [FFmpeg-devel] [PATCH] lswr: take const AVChannelLayout* in swr_alloc_set_opts2()

2022-08-06 Thread Anton Khirnov
Quoting Anton Khirnov (2022-08-06 15:15:58)
> Quoting Andreas Rheinhardt (2022-08-06 13:50:37)
> > rcombs:
> > > This is fully backwards-compatible in both ABI and API,
> > > so it's only a minor bump.
> > 
> > It is not fully backwards-compatible API-wise: If you use a function
> > pointer for swr_alloc_set_opts2 by hardcoding its type, you will get
> > warnings now (or even errors depending upon your -Werror; it is an error
> > by default for C++). Given that I do not know about other language
> > bindings I have so far refrained from applying
> > https://patchwork.ffmpeg.org/project/ffmpeg/patch/as1pr01mb95649a21f5f9a45d40e6ac1d8f...@as1pr01mb9564.eurprd01.prod.exchangelabs.com/
> > This does not mean that I block your patch; to the contrary: If it
> > breaks nothing, I will apply the above patch after a month or so.
> 
> Maybe now could be a good time for a major bump, since we just had a
> release. It's also been two releases since the last one.

I would also love to finally get rid of FF_API_THREAD_SAFE_CALLBACKS

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

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


Re: [FFmpeg-devel] [PATCH] avformat/movenc: Remove experimental status of flac-in-MP4 muxing

2022-08-06 Thread Anton Khirnov
Quoting Martijn van Beurden (2022-08-06 10:39:42)
> The fLaC and dfLa box IDs have been registered with the MP4 RA
> (they are now listed at https://mp4ra.org/#/codecs) and support
> for muxing FLAC in MP4 has been experimental in ffmpeg for
> 6 years now, since Nov 21, 2016
> 
> This patch removes the experimental status and removes the MP4
> object type, as none has been registered for FLAC as it was not
> deemed necessary.
> ---
>  libavformat/isom.c  | 1 -
>  libavformat/isom_tags.c | 2 +-
>  libavformat/movenc.c| 2 +-
>  3 files changed, 2 insertions(+), 3 deletions(-)

Looks reasonable, will push soonish of nobody objects.

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

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


Re: [FFmpeg-devel] [PATCH] avutil/hwcontext_videotoolbox: add missing include for AVFrame

2022-08-06 Thread Anton Khirnov
Quoting Zhao Zhili (2022-08-04 12:48:48)
> From: Zhao Zhili 
> 
> Signed-off-by: Zhao Zhili 
> ---
>  libavutil/hwcontext_videotoolbox.h | 1 +
>  1 file changed, 1 insertion(+)

Looks ok.

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

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


[FFmpeg-devel] [PATCH v4 0/4] DOVI: Add NLQ pivots to AVDOVIDataMapping

2022-08-06 Thread quietvoid
The NLQ pivots are not documented but should be present
in the header for profile 7 RPU format.
It has been verified using Dolby's verification toolkit.

With the pivots parsed, the parsed values for
num_{x,y}_partitions are correct and usually equal to 1.

v3: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297730.html

Changes in v4:
  - Fixed comment from 
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298736.html 

quietvoid (4):
  libavutil/dovi_meta: Add nlq_pivots to AVDOVIDataMapping
  fftools/ffprobe: Add DOVI nlq_pivots logging
  libavfilter/vf_showinfo: Add DOVI nlq_pivots logging
  fate: Add test to parse profile 7 DOVI RPU

 fftools/ffprobe.c |   4 +
 libavcodec/dovi_rpu.c |   9 +-
 libavfilter/vf_showinfo.c |   6 +
 libavutil/dovi_meta.h |   1 +
 tests/fate/hevc.mak   |   3 +
 tests/ref/fate/hevc-dovi-profile7-rpu | 296 ++
 6 files changed, 318 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/hevc-dovi-profile7-rpu

-- 
2.37.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 v4 1/4] libavutil/dovi_meta: Add nlq_pivots to AVDOVIDataMapping

2022-08-06 Thread quietvoid
The NLQ pivots are not documented but should be present
in the header for profile 7 RPU format.
It has been verified using Dolby's verification toolkit.

Signed-off-by: quietvoid 
---
 libavcodec/dovi_rpu.c | 9 -
 libavutil/dovi_meta.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dovi_rpu.c b/libavcodec/dovi_rpu.c
index dd38936552..44fb76492d 100644
--- a/libavcodec/dovi_rpu.c
+++ b/libavcodec/dovi_rpu.c
@@ -117,7 +117,7 @@ int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
 /* Copy only the parts of these structs known to us at compiler-time. */
 #define COPY(t, a, b, last) memcpy(a, b, offsetof(t, last) + sizeof((b)->last))
 COPY(AVDOVIRpuDataHeader, av_dovi_get_header(dovi), &s->header, 
disable_residual_flag);
-COPY(AVDOVIDataMapping, av_dovi_get_mapping(dovi), s->mapping, 
nlq[2].linear_deadzone_threshold);
+COPY(AVDOVIDataMapping, av_dovi_get_mapping(dovi), s->mapping, nlq_pivots);
 COPY(AVDOVIColorMetadata, av_dovi_get_color(dovi), s->color, 
source_diagonal);
 return 0;
 }
@@ -315,7 +315,14 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, 
size_t rpu_size)
 }
 
 if (use_nlq) {
+int nlq_pivot = 0;
 vdr->mapping.nlq_method_idc = get_bits(gb, 3);
+
+for (int i = 0; i < 2; i++) {
+nlq_pivot += get_bits(gb, hdr->bl_bit_depth);
+vdr->mapping.nlq_pivots[i] = av_clip_uint16(nlq_pivot);
+}
+
 /**
  * The patent mentions another legal value, NLQ_MU_LAW, but it's
  * not documented anywhere how to parse or apply that type of NLQ.
diff --git a/libavutil/dovi_meta.h b/libavutil/dovi_meta.h
index 3d11e02bff..6afc7b055a 100644
--- a/libavutil/dovi_meta.h
+++ b/libavutil/dovi_meta.h
@@ -147,6 +147,7 @@ typedef struct AVDOVIDataMapping {
 uint32_t num_x_partitions;
 uint32_t num_y_partitions;
 AVDOVINLQParams nlq[3]; /* per component */
+uint16_t nlq_pivots[2]; /* nlq_pred_pivot_value */
 } AVDOVIDataMapping;
 
 /**
-- 
2.37.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 v4 2/4] fftools/ffprobe: Add DOVI nlq_pivots logging

2022-08-06 Thread quietvoid
Signed-off-by: quietvoid 
---
 fftools/ffprobe.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index ad633ccc44..fa53004654 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2003,6 +2003,10 @@ static void print_dovi_metadata(WriterContext *w, const 
AVDOVIMetadata *dovi)
 break;
 }
 
+if (mapping->nlq_method_idc != AV_DOVI_NLQ_NONE) {
+print_list_fmt("nlq_pivots", "%"PRIu16, 2, 
mapping->nlq_pivots[idx]);
+}
+
 print_int("num_x_partitions",  mapping->num_x_partitions);
 print_int("num_y_partitions",  mapping->num_y_partitions);
 
-- 
2.37.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 v4 3/4] libavfilter/vf_showinfo: Add DOVI nlq_pivots logging

2022-08-06 Thread quietvoid
Signed-off-by: quietvoid 
---
 libavfilter/vf_showinfo.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 2c8514fc80..bcd93de568 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -535,6 +535,12 @@ static void dump_dovi_metadata(AVFilterContext *ctx, const 
AVFrameSideData *sd)
 av_log(ctx, AV_LOG_INFO, "mapping_color_space=%"PRIu8"; ", 
mapping->mapping_color_space);
 av_log(ctx, AV_LOG_INFO, "mapping_chroma_format_idc=%"PRIu8"; ", 
mapping->mapping_chroma_format_idc);
 av_log(ctx, AV_LOG_INFO, "nlq_method_idc=%d; ", (int) 
mapping->nlq_method_idc);
+
+if (mapping->nlq_method_idc != AV_DOVI_NLQ_NONE) {
+av_log(ctx, AV_LOG_INFO, "nlq_pivots={ %"PRIu16" %"PRIu16" }; ",
+   mapping->nlq_pivots[0], mapping->nlq_pivots[1]);
+}
+
 av_log(ctx, AV_LOG_INFO, "num_x_partitions=%"PRIu32"; ", 
mapping->num_x_partitions);
 av_log(ctx, AV_LOG_INFO, "num_y_partitions=%"PRIu32"\n", 
mapping->num_y_partitions);
 
-- 
2.37.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 v4 4/4] fate: Add test to parse profile 7 DOVI RPU

2022-08-06 Thread quietvoid
Signed-off-by: quietvoid 
---
 tests/fate/hevc.mak   |   3 +
 tests/ref/fate/hevc-dovi-profile7-rpu | 296 ++
 2 files changed, 299 insertions(+)
 create mode 100644 tests/ref/fate/hevc-dovi-profile7-rpu

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 6c1e7447ad..5a5dd4abe8 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -255,6 +255,9 @@ FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += 
fate-hevc-cabac-tudepth
 fate-hevc-small422chroma: CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc/food.hevc -pix_fmt yuv422p10le -vf scale
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER SCALE_FILTER) += 
fate-hevc-small422chroma
 
+fate-hevc-dovi-profile7-rpu: CMD = probeframes -show_entries 
frame=side_data_list -select_streams 1 -read_intervals "%+\#2" 
$(TARGET_SAMPLES)/mov/dovi-p7.mp4
+FATE_HEVC_FFPROBE-$(call DEMDEC, MOV, HEVC) += fate-hevc-dovi-profile7-rpu
+
 FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes)
 FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes)
 
diff --git a/tests/ref/fate/hevc-dovi-profile7-rpu 
b/tests/ref/fate/hevc-dovi-profile7-rpu
new file mode 100644
index 00..7fa5d20f01
--- /dev/null
+++ b/tests/ref/fate/hevc-dovi-profile7-rpu
@@ -0,0 +1,296 @@
+[FRAME]
+[SIDE_DATA]
+side_data_type=Mastering display metadata
+red_x=34000/5
+red_y=16000/5
+green_x=13250/5
+green_y=34500/5
+blue_x=7500/5
+blue_y=3000/5
+white_point_x=15635/5
+white_point_y=16450/5
+min_luminance=1/1
+max_luminance=1/1
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Content light level metadata
+max_content=1000
+max_average=400
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Dolby Vision RPU Data
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Dolby Vision Metadata
+rpu_type=2
+rpu_format=18
+vdr_rpu_profile=1
+vdr_rpu_level=0
+chroma_resampling_explicit_filter_flag=0
+coef_data_type=0
+coef_log2_denom=23
+vdr_rpu_normalized_idc=1
+bl_video_full_range_flag=0
+bl_bit_depth=10
+el_bit_depth=10
+vdr_bit_depth=12
+spatial_resampling_filter_flag=0
+el_spatial_resampling_filter_flag=1
+disable_residual_flag=0
+vdr_rpu_id=0
+mapping_color_space=0
+mapping_chroma_format_idc=0
+nlq_method_idc=0
+nlq_method_idc_name=linear_dz
+nlq_pivots=0 1023
+num_x_partitions=1
+num_y_partitions=1
+[COMPONENT]
+pivots=0 128 256 384 512 640 768 896 1023
+[SECTION]
+mapping_idc=0
+mapping_idc_name=polynomial
+poly_order=1
+poly_coef=0 8388608
+[/SECTION]
+[SECTION]
+mapping_idc=0
+mapping_idc_name=polynomial
+poly_order=1
+poly_coef=0 8388608
+[/SECTION]
+[SECTION]
+mapping_idc=0
+mapping_idc_name=polynomial
+poly_order=1
+poly_coef=0 8388608
+[/SECTION]
+[SECTION]
+mapping_idc=0
+mapping_idc_name=polynomial
+poly_order=1
+poly_coef=0 8388608
+[/SECTION]
+[SECTION]
+mapping_idc=0
+mapping_idc_name=polynomial
+poly_order=1
+poly_coef=0 8388608
+[/SECTION]
+[SECTION]
+mapping_idc=0
+mapping_idc_name=polynomial
+poly_order=1
+poly_coef=0 8388608
+[/SECTION]
+[SECTION]
+mapping_idc=0
+mapping_idc_name=polynomial
+poly_order=1
+poly_coef=0 8388608
+[/SECTION]
+[SECTION]
+mapping_idc=0
+mapping_idc_name=polynomial
+poly_order=1
+poly_coef=0 8388608
+[/SECTION]
+nlq_offset=512
+vdr_in_max=1048576
+linear_deadzone_slope=2048
+linear_deadzone_threshold=0
+[/COMPONENT]
+[COMPONENT]
+pivots=0 1023
+[SECTION]
+mapping_idc=1
+mapping_idc_name=mmr
+mmr_order=3
+mmr_constant=448998
+mmr_coef=-1262056 8122466 -1703266 1622123 808554 -829469 -13459 801251 694657 
3697830 -1819391 -772917 -654425 78034 -181321 -324811 -2213356 -716030 761880 
365184 2545494
+[/SECTION]
+nlq_offset=512
+vdr_in_max=1048576
+linear_deadzone_slope=2048
+linear_deadzone_threshold=0
+[/COMPONENT]
+[COMPONENT]
+pivots=0 1023
+[SECTION]
+mapping_idc=1
+mapping_idc_name=mmr
+mmr_order=3
+mmr_constant=30364
+mmr_coef=-1369971 645159 9055254 -106426 2546351 -2246880 672220 1356576 
1789054 -3311517 -1372035 -4554569 -548063 722319 57239 -2130348 3956345 
1480062 -1696575 3919674 3414157
+[/SECTION]
+nlq_offset=512
+vdr_in_max=1048576
+linear_deadzone_slope=2048
+linear_deadzone_threshold=0
+[/COMPONENT]
+dm_metadata_id=0
+scene_refresh_flag=0
+ycc_to_rgb_matrix=9574/8192 0/8192 13802/8192 9574/8192 -1540/8192 -5348/8192 
9574/8192 17610/8192 0/8192
+ycc_to_rgb_offset=16777216/268435456 134217728/268435456 134217728/268435456
+rgb_to_lms_matrix=7222/16384 8771/16384 390/16384 2654/16384 12430/16384 
1300/16384 0/16384 422/16384 15962/16384
+signal_eotf=65535
+signal_eotf_param0=0
+signal_eotf_param1=0
+signal_eotf_param2=0
+signal_bit_depth=12
+signal_color_space=0
+signal_chroma_format=0
+signal_full_range_flag=1
+source_min_pq=7
+source_max_pq=3079
+source_diagonal=42
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Mastering display metadata
+red_x=34000/5
+red_y=16000/5
+green_x=13250/5
+green_y=34500/5
+blue_x=7500/5
+blue_y=3000/5
+white_point_x=15635/5
+white_point_y=16450/5
+min_luminance=1/1
+max_luminance=1/1
+[/SIDE_DATA]
+[SI

[FFmpeg-devel] [PATCH] MAINTAINERS: Split project server admin list

2022-08-06 Thread Michael Niedermayer
This updates the list closer to reality.
Iam not a professional server admin, iam happy to help maintain the box as i 
have
done in the past. But iam not qualified nor volunteering to fix sudden problems
nor do i do major upgrades (i lack the experience to recover the box remotely if
something goes wrong) and also iam not maintaining backups ATM (our backup 
system
had a RAID-5 failure, raz is working on setting a new one up)

Maybe this should be signaled in a different way than spliting the lines but ATM
people ping me if something is wrong and what i do is mainly mail/ping raz
and try to find another root admin so raz is not the only active & professional
admin on the team. It would be more efficient if people contact raz and others
directly instead of depending on my waking up and forwarding a "ffmpeg.org" is 
down note

Signed-off-by: Michael Niedermayer 
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 274fc89203..7ed15f96f6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -40,7 +40,8 @@ Miscellaneous Areas
 ===
 
 documentation   Stefano Sabatini, Mike Melanson, 
Timothy Gu, Gyan Doshi
-project server  Árpád Gereöffy, Michael Niedermayer, 
Reimar Doeffinger, Alexander Strasser, Nikolay Aleksandrov
+project server day to day operationsÁrpád Gereöffy, Michael Niedermayer, 
Reimar Doeffinger, Alexander Strasser, Nikolay Aleksandrov
+project server emergencies  Árpád Gereöffy, Reimar Doeffinger, 
Alexander Strasser, Nikolay Aleksandrov
 presets Robert Swain
 metadata subsystem  Aurelien Jacobs
 release management  Michael Niedermayer
-- 
2.17.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 1/3] avcodec/nvdec: Check av_buffer_ref()

2022-08-06 Thread Andreas Rheinhardt
It (unfortunately) involves an allocation and can therefore fail.

Signed-off-by: Andreas Rheinhardt 
---
I don't have any nvidia hardware, so all these patches are untested
(apart from ensuring that they compile without creating new warnings).

 libavcodec/nvdec.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index edff46d310..15665b83bb 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -532,8 +532,11 @@ static int nvdec_retrieve_data(void *logctx, AVFrame 
*frame)
 }
 
 unmap_data->idx = cf->idx;
-unmap_data->idx_ref = av_buffer_ref(cf->idx_ref);
-unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref);
+if (!(unmap_data->idx_ref = av_buffer_ref(cf->idx_ref)) ||
+!(unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref))) {
+ret = AVERROR(ENOMEM);
+goto copy_fail;
+}
 
 av_pix_fmt_get_chroma_sub_sample(hwctx->sw_format, &shift_h, &shift_v);
 for (i = 0; frame->linesize[i]; i++) {
-- 
2.34.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 2/3] avcodec/nvdec: Use av_buffer_replace() where appropriate

2022-08-06 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/nvdec.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 15665b83bb..fbaedf0b6b 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -524,12 +524,9 @@ static int nvdec_retrieve_data(void *logctx, AVFrame 
*frame)
 goto copy_fail;
 }
 
-av_buffer_unref(&frame->hw_frames_ctx);
-frame->hw_frames_ctx = av_buffer_ref(decoder->real_hw_frames_ref);
-if (!frame->hw_frames_ctx) {
-ret = AVERROR(ENOMEM);
+ret = av_buffer_replace(&frame->hw_frames_ctx, 
decoder->real_hw_frames_ref);
+if (ret < 0)
 goto copy_fail;
-}
 
 unmap_data->idx = cf->idx;
 if (!(unmap_data->idx_ref = av_buffer_ref(cf->idx_ref)) ||
-- 
2.34.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 3/3] avcodec/nvdec: Redo handling of failure in nvdec_retrieve_data()

2022-08-06 Thread Andreas Rheinhardt
Said function has a block intended for failure on the main code path
that is jumped over when no error happens:

goto finish;
copy_fail:
/* cleanup code */
finish:
/* more code */
return ret;

This commit changes this to the more common:

finish:
   /* more code */
   return ret;
copy_fail:
   /* cleanup code */
   goto finish;

Given that the cleanup code depends upon from where one jumps to it,
it is also split into two code blocks with their own labels, thereby
avoiding the check for which case one is in.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/nvdec.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index fbaedf0b6b..0a4fb30b42 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -513,26 +513,27 @@ static int nvdec_retrieve_data(void *logctx, AVFrame 
*frame)
 unmap_data = av_mallocz(sizeof(*unmap_data));
 if (!unmap_data) {
 ret = AVERROR(ENOMEM);
-goto copy_fail;
+goto early_fail;
 }
 
 frame->buf[1] = av_buffer_create((uint8_t *)unmap_data, 
sizeof(*unmap_data),
  nvdec_unmap_mapped_frame, (void*)devptr,
  AV_BUFFER_FLAG_READONLY);
 if (!frame->buf[1]) {
+av_freep(&unmap_data);
 ret = AVERROR(ENOMEM);
-goto copy_fail;
+goto early_fail;
 }
 
 ret = av_buffer_replace(&frame->hw_frames_ctx, 
decoder->real_hw_frames_ref);
 if (ret < 0)
-goto copy_fail;
+goto late_fail;
 
 unmap_data->idx = cf->idx;
 if (!(unmap_data->idx_ref = av_buffer_ref(cf->idx_ref)) ||
 !(unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref))) {
 ret = AVERROR(ENOMEM);
-goto copy_fail;
+goto late_fail;
 }
 
 av_pix_fmt_get_chroma_sub_sample(hwctx->sw_format, &shift_h, &shift_v);
@@ -542,19 +543,16 @@ static int nvdec_retrieve_data(void *logctx, AVFrame 
*frame)
 offset += pitch * (frame->height >> (i ? shift_v : 0));
 }
 
-goto finish;
-
-copy_fail:
-if (!frame->buf[1]) {
-CHECK_CU(decoder->cvdl->cuvidUnmapVideoFrame(decoder->decoder, 
devptr));
-av_freep(&unmap_data);
-} else {
-av_buffer_unref(&frame->buf[1]);
-}
-
 finish:
 CHECK_CU(decoder->cudl->cuCtxPopCurrent(&dummy));
 return ret;
+
+early_fail:
+CHECK_CU(decoder->cvdl->cuvidUnmapVideoFrame(decoder->decoder, devptr));
+goto finish;
+late_fail:
+av_buffer_unref(&frame->buf[1]);
+goto finish;
 }
 
 int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH] avcodec/libspeexdec: Fix use of uninitialized value

2022-08-06 Thread Andreas Rheinhardt
Regression since 97d9a3293854eda84f05c22e2eaefae7406ac969.
Fixes Coverity issue #1503072.

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

diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c
index daa6dec64a..af0f224b34 100644
--- a/libavcodec/libspeexdec.c
+++ b/libavcodec/libspeexdec.c
@@ -43,7 +43,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
 LibSpeexContext *s = avctx->priv_data;
 const SpeexMode *mode;
 SpeexHeader *header = NULL;
-int spx_mode, channels;
+int spx_mode, channels = avctx->ch_layout.nb_channels;
 
 if (avctx->extradata && avctx->extradata_size >= 80) {
 header = speex_packet_to_header(avctx->extradata,
-- 
2.34.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 v2] avformat/mxfdec: SMPTE RDD 48:2018 Amd 1:2022 support

2022-08-06 Thread Tomas Härdin
lör 2022-07-30 klockan 18:42 +0200 skrev Michael Niedermayer:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mxf.c    |  3 +++
>  libavformat/mxf.h    |  1 +
>  libavformat/mxfdec.c | 48
> 
>  3 files changed, 52 insertions(+)

Looks fine.

/Tomas

___
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/mxfdec: do not log warning of multiple ANC packets if count is 0

2022-08-06 Thread Tomas Härdin
fre 2022-08-05 klockan 00:03 +0100 skrev Gavin Smith:
> Some NLVEs may insert a KLV packet for EIA-608 data even though
> the number of encapsulated ANC packets is zero.
> ---
>  libavformat/mxfdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Looks OK. Also I'm looking at maybe adding S436m support to mxfenc, but
it's going to require a bit of plumbing in ffmpeg.c I think.

/Tomas

___
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 v7 1/2] avformat: refactor ff_stream_encode_params_copy() to stream_params_copy()

2022-08-06 Thread pal
From: Pierre-Anthony Lemieux 

Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299726.html

---
 libavformat/avformat.c   | 66 
 libavformat/fifo.c   |  8 ++---
 libavformat/internal.h   | 11 +++
 libavformat/mux.h|  9 --
 libavformat/mux_utils.c  | 28 -
 libavformat/segment.c|  6 ++--
 libavformat/tee.c|  7 ++---
 libavformat/webm_chunk.c |  6 ++--
 8 files changed, 86 insertions(+), 55 deletions(-)

diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 30d6ea6a49..19c7219471 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -235,6 +235,72 @@ int ff_stream_side_data_copy(AVStream *dst, const AVStream 
*src)
 return 0;
 }
 
+/**
+ * Copy all stream parameters from source to destination stream, with the
+ * exception of the index field, which is usually set by avformat_new_stream().
+ *
+ * @param dst pointer to destination AVStream
+ * @param src pointer to source AVStream
+ * @return >=0 on success, AVERROR code on error
+ */
+static int stream_params_copy(AVStream *dst, const AVStream *src)
+{
+int ret;
+
+dst->id  = src->id;
+dst->time_base   = src->time_base;
+dst->start_time  = src->start_time;
+dst->duration= src->duration;
+dst->nb_frames   = src->nb_frames;
+dst->disposition = src->disposition;
+dst->discard = src->discard;
+dst->sample_aspect_ratio = src->sample_aspect_ratio;
+dst->avg_frame_rate  = src->avg_frame_rate;
+dst->event_flags = src->event_flags;
+dst->r_frame_rate= src->r_frame_rate;
+dst->pts_wrap_bits   = src->pts_wrap_bits;
+
+av_dict_free(&dst->metadata);
+ret = av_dict_copy(&dst->metadata, src->metadata, 0);
+if (ret < 0)
+return ret;
+
+ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
+if (ret < 0)
+return ret;
+
+ret = ff_stream_side_data_copy(dst, src);
+if (ret < 0)
+return ret;
+
+av_packet_unref(&dst->attached_pic);
+if (src->attached_pic.data) {
+ret = av_packet_ref(&dst->attached_pic, &src->attached_pic);
+if (ret < 0)
+return ret;
+}
+
+return 0;
+}
+
+AVStream *ff_stream_clone(AVFormatContext *dst_ctx, const AVStream *src)
+{
+AVStream *st;
+int ret;
+
+st = avformat_new_stream(dst_ctx, NULL);
+if (!st)
+return NULL;
+
+ret = stream_params_copy(st, src);
+if (ret < 0) {
+ff_remove_stream(dst_ctx, st);
+return NULL;
+}
+
+return st;
+}
+
 AVProgram *av_new_program(AVFormatContext *ac, int id)
 {
 AVProgram *program = NULL;
diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index ead2bdc5cf..55d413b952 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -505,13 +505,11 @@ static int fifo_mux_init(AVFormatContext *avf, const 
AVOutputFormat *oformat,
 avf2->flags = avf->flags;
 
 for (i = 0; i < avf->nb_streams; ++i) {
-AVStream *st = avformat_new_stream(avf2, NULL);
+AVStream *st = NULL;
+
+st = ff_stream_clone(avf2, avf->streams[i]);
 if (!st)
 return AVERROR(ENOMEM);
-
-ret = ff_stream_encode_params_copy(st, avf->streams[i]);
-if (ret < 0)
-return ret;
 }
 
 return 0;
diff --git a/libavformat/internal.h b/libavformat/internal.h
index b6b8fbf56f..9b07cfb271 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -625,6 +625,17 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int 
be, int sflags);
  */
 int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
 
+/**
+ * Create a new stream and copy to it all parameters from a source stream, with
+ * the exception of the index field, which is set when the new stream is
+ * created.
+ *
+ * @param dst_ctx pointer to the context in which the new stream is created
+ * @param src pointer to source AVStream
+ * @return pointer to the new stream or NULL on error
+ */
+AVStream *ff_stream_clone(AVFormatContext *dst_ctx, const AVStream *src);
+
 /**
  * Wrap ffurl_move() and log if error happens.
  *
diff --git a/libavformat/mux.h b/libavformat/mux.h
index c01da82194..1bfcaf795f 100644
--- a/libavformat/mux.h
+++ b/libavformat/mux.h
@@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, int64_t 
read_start, int shift_size)
  */
 int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary 
**options);
 
-/**
- * Copy encoding parameters from source to destination stream
- *
- * @param dst pointer to destination AVStream
- * @param src pointer to source AVStream
- * @return >=0 on success, AVERROR code on error
- */
-int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
-
 /**
  * Parse creation_time in AVFormatContext metadata if exists and warn if the
  * parsing fails.
diff --git a/libavformat/mux_utils.c b/libavformat/

[FFmpeg-devel] [PATCH v7 2/2] avformat/imfdec: preserve stream information

2022-08-06 Thread pal
From: Pierre-Anthony Lemieux 

---
 libavformat/imfdec.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 71dfb26958..5bbe7a53f8 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -573,18 +573,14 @@ static int 
set_context_streams_from_tracks(AVFormatContext *s)
 first_resource_stream = c->tracks[i]->resources[0].ctx->streams[0];
 av_log(s, AV_LOG_DEBUG, "Open the first resource of track %d\n", 
c->tracks[i]->index);
 
-/* Copy stream information */
-asset_stream = avformat_new_stream(s, NULL);
+asset_stream = ff_stream_clone(s, first_resource_stream);
 if (!asset_stream) {
-av_log(s, AV_LOG_ERROR, "Could not create stream\n");
+av_log(s, AV_LOG_ERROR, "Could not clone stream\n");
 return AVERROR(ENOMEM);
 }
+
 asset_stream->id = i;
-ret = avcodec_parameters_copy(asset_stream->codecpar, 
first_resource_stream->codecpar);
-if (ret < 0) {
-av_log(s, AV_LOG_ERROR, "Could not copy stream parameters\n");
-return ret;
-}
+asset_stream->nb_frames = 0;
 avpriv_set_pts_info(asset_stream,
 first_resource_stream->pts_wrap_bits,
 first_resource_stream->time_base.num,
-- 
2.25.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 v6 1/2] avformat: refactor ff_stream_encode_params_copy() to stream_params_copy()

2022-08-06 Thread Pierre-Anthony Lemieux
On Sat, Aug 6, 2022 at 2:43 AM Andreas Rheinhardt
 wrote:
>
> p...@sandflow.com:
> > From: Pierre-Anthony Lemieux 
> >
> > Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299685.html
> >
> > ---
> >  libavformat/avformat.c   | 68 
> >  libavformat/fifo.c   |  8 ++---
> >  libavformat/internal.h   | 12 +++
> >  libavformat/mux.h|  9 --
> >  libavformat/mux_utils.c  | 28 -
> >  libavformat/segment.c|  6 ++--
> >  libavformat/tee.c|  7 ++---
> >  libavformat/webm_chunk.c |  6 ++--
> >  8 files changed, 89 insertions(+), 55 deletions(-)
> >
> > diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> > index 30d6ea6a49..64c9d71a24 100644
> > --- a/libavformat/avformat.c
> > +++ b/libavformat/avformat.c
> > @@ -235,6 +235,74 @@ int ff_stream_side_data_copy(AVStream *dst, const 
> > AVStream *src)
> >  return 0;
> >  }
> >
> > +/**
> > + * Copy all stream parameters from source to destination stream, with the
> > + * exception of:
> > + *  * the index field, which is usually set by avformat_new_stream()
> > + *  * the attached_pic field, if attached_pic.size is 0 or less
> > + *
> > + * @param dst pointer to destination AVStream
> > + * @param src pointer to source AVStream
> > + * @return >=0 on success, AVERROR code on error
> > + */
> > +static int stream_params_copy(AVStream *dst, const AVStream *src)
> > +{
> > +int ret;
> > +
> > +dst->id  = src->id;
> > +dst->time_base   = src->time_base;
> > +dst->start_time  = src->start_time;
> > +dst->duration= src->duration;
> > +dst->nb_frames   = src->nb_frames;
> > +dst->disposition = src->disposition;
> > +dst->discard = src->discard;
> > +dst->sample_aspect_ratio = src->sample_aspect_ratio;
> > +dst->avg_frame_rate  = src->avg_frame_rate;
> > +dst->event_flags = src->event_flags;
> > +dst->r_frame_rate= src->r_frame_rate;
> > +dst->pts_wrap_bits   = src->pts_wrap_bits;
> > +
> > +av_dict_free(&dst->metadata);
> > +ret = av_dict_copy(&dst->metadata, src->metadata, 0);
> > +if (ret < 0)
> > +return ret;
> > +
> > +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
> > +if (ret < 0)
> > +return ret;
> > +
> > +ret = ff_stream_side_data_copy(dst, src);
> > +if (ret < 0)
> > +return ret;
> > +
> > +av_packet_unref(&dst->attached_pic);
> > +if (src->attached_pic.size > 0) {
>
> I'd rather have it that you check for attached_pic.data instead (even if
> this might mean that avformat_queue_attached_pictures() might warn for
> the dst stream lateron because of a packet with size zero). That way you
> would be copying the packet iff the src packet is set (side-data only
> attached pics don't exist).
> This would also mean that the behaviour of attached pic would no longer
> be exceptional, i.e. it needn't be documented.

Addressed at v7

>
> > +ret = av_packet_ref(&dst->attached_pic, &src->attached_pic);
> > +if (ret < 0)
> > +return ret;
> > +}
> > +
> > +return 0;
> > +}
> > +
> > +AVStream *ff_stream_clone(AVFormatContext *dst_ctx, const AVStream *src)
> > +{
> > +AVStream *st;
> > +int ret;
> > +
> > +st = avformat_new_stream(dst_ctx, NULL);
> > +if (!st)
> > +return NULL;
> > +
> > +ret = stream_params_copy(st, src);
> > +if (ret < 0) {
> > +ff_remove_stream(dst_ctx, st);
> > +return NULL;
> > +}
> > +
> > +return st;
> > +}
> > +
> >  AVProgram *av_new_program(AVFormatContext *ac, int id)
> >  {
> >  AVProgram *program = NULL;
> > diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> > index ead2bdc5cf..55d413b952 100644
> > --- a/libavformat/fifo.c
> > +++ b/libavformat/fifo.c
> > @@ -505,13 +505,11 @@ static int fifo_mux_init(AVFormatContext *avf, const 
> > AVOutputFormat *oformat,
> >  avf2->flags = avf->flags;
> >
> >  for (i = 0; i < avf->nb_streams; ++i) {
> > -AVStream *st = avformat_new_stream(avf2, NULL);
> > +AVStream *st = NULL;
> > +
> > +st = ff_stream_clone(avf2, avf->streams[i]);
> >  if (!st)
> >  return AVERROR(ENOMEM);
> > -
> > -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
> > -if (ret < 0)
> > -return ret;
> >  }
> >
> >  return 0;
> > diff --git a/libavformat/internal.h b/libavformat/internal.h
> > index b6b8fbf56f..6dd763950f 100644
> > --- a/libavformat/internal.h
> > +++ b/libavformat/internal.h
> > @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, 
> > int be, int sflags);
> >   */
> >  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
> >
> > +/**
> > + * Create a new stream and copy to it all parameters from a source stream,
> > + * with the exception of:
> > + *  * the index field,

[FFmpeg-devel] [PATCH] swscale/output: add VUYA output support

2022-08-06 Thread James Almer
Signed-off-by: James Almer 
---
 libswscale/output.c  | 57 
 libswscale/utils.c   |  2 +-
 tests/ref/fate/filter-pixdesc-vuya   |  1 +
 tests/ref/fate/filter-pixfmts-copy   |  1 +
 tests/ref/fate/filter-pixfmts-crop   |  1 +
 tests/ref/fate/filter-pixfmts-field  |  1 +
 tests/ref/fate/filter-pixfmts-fieldorder |  1 +
 tests/ref/fate/filter-pixfmts-hflip  |  1 +
 tests/ref/fate/filter-pixfmts-il |  1 +
 tests/ref/fate/filter-pixfmts-null   |  1 +
 tests/ref/fate/filter-pixfmts-pad|  1 +
 tests/ref/fate/filter-pixfmts-scale  |  1 +
 tests/ref/fate/filter-pixfmts-transpose  |  1 +
 tests/ref/fate/filter-pixfmts-vflip  |  1 +
 14 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/filter-pixdesc-vuya

diff --git a/libswscale/output.c b/libswscale/output.c
index 773f3ce059..1b8f35bb4b 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2584,6 +2584,60 @@ yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter,
 }
 }
 
+static void
+yuv2vuya_X_c(SwsContext *c, const int16_t *lumFilter,
+ const int16_t **lumSrc, int lumFilterSize,
+ const int16_t *chrFilter, const int16_t **chrUSrc,
+ const int16_t **chrVSrc, int chrFilterSize,
+ const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
+{
+int hasAlpha = !!alpSrc;
+int i;
+
+for (i = 0; i < dstW; i++) {
+int j;
+int Y = 1 << 18, U = 1 << 18;
+int V = 1 << 18, A = 255;
+
+for (j = 0; j < lumFilterSize; j++)
+Y += lumSrc[j][i] * lumFilter[j];
+
+for (j = 0; j < lumFilterSize; j++)
+U += chrUSrc[j][i] * chrFilter[j];
+
+for (j = 0; j < lumFilterSize; j++)
+V += chrVSrc[j][i] * chrFilter[j];
+
+Y >>= 19;
+U >>= 19;
+V >>= 19;
+
+if (Y  & 0x100)
+Y = av_clip_uint8(Y);
+if (U  & 0x100)
+U = av_clip_uint8(U);
+if (V  & 0x100)
+V = av_clip_uint8(V);
+
+if (hasAlpha) {
+A = 1 << 18;
+
+for (j = 0; j < lumFilterSize; j++)
+A += alpSrc[j][i] * lumFilter[j];
+
+A >>= 19;
+
+if (A & 0x100)
+A = av_clip_uint8(A);
+}
+
+dest[4 * i] = V;
+dest[4 * i + 1] = U;
+dest[4 * i + 2] = Y;
+dest[4 * i + 3] = A;
+}
+}
+
 av_cold void ff_sws_init_output_funcs(SwsContext *c,
   yuv2planar1_fn *yuv2plane1,
   yuv2planarX_fn *yuv2planeX,
@@ -3086,5 +3140,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
 case AV_PIX_FMT_AYUV64LE:
 *yuv2packedX = yuv2ayuv64le_X_c;
 break;
+case AV_PIX_FMT_VUYA:
+*yuv2packedX = yuv2vuya_X_c;
+break;
 }
 }
diff --git a/libswscale/utils.c b/libswscale/utils.c
index bc3d1c955c..34503e57f4 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -258,7 +258,7 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_P416BE]  = { 1, 1 },
 [AV_PIX_FMT_P416LE]  = { 1, 1 },
 [AV_PIX_FMT_NV16]= { 1, 1 },
-[AV_PIX_FMT_VUYA]= { 1, 0 },
+[AV_PIX_FMT_VUYA]= { 1, 1 },
 };
 
 int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos,
diff --git a/tests/ref/fate/filter-pixdesc-vuya 
b/tests/ref/fate/filter-pixdesc-vuya
new file mode 100644
index 00..3285c08c32
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-vuya
@@ -0,0 +1 @@
+pixdesc-vuya6d7d537c388b9d53c3493cd2e0ef4e5c
diff --git a/tests/ref/fate/filter-pixfmts-copy 
b/tests/ref/fate/filter-pixfmts-copy
index 3cd0002e4e..ecdbc24f9e 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -89,6 +89,7 @@ rgbab6e1b441c365e03b5ffdf9b7b68d9a0c
 rgba64beae2ae04b5efedca3505f47c4dd6ea6ea
 rgba64leb91e1d77f799eb92241a2d2d28437b15
 uyvy422 3bcf3c80047592f2211fae3260b1b65d
+vuyab6dfd3268ed8eb82b5d534c6d0a20188
 x2bgr10le   550c0d190cf695afa4eaacb644db6b75
 x2rgb10le   c1e3ac21be04a16bb157b22784524520
 xyz12be a1ef56bf746d71f59669c28e48fc8450
diff --git a/tests/ref/fate/filter-pixfmts-crop 
b/tests/ref/fate/filter-pixfmts-crop
index 1a0f0c79ed..6f18d98a51 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -86,6 +86,7 @@ rgb89b364a8f112ad9459fec47a51cc03b30
 rgba9488ac85abceaf99a9309eac5a87697e
 rgba64be89910046972ab3c68e2a348302cc8ca9
 rgba64lefea8ebfc869b52adf353778f29eac7a7
+vuyadcc42e77d663a3a8920826f4ae1f034e
 x2bgr10le   84de725b85662c362862820dc4a309aa
 x2rgb10le   f4265aca7a67dbfa9354370098ca6f33
 xyz12be cb4571f9aaa7b59f999ef327276104b7
diff --git

Re: [FFmpeg-devel] [PATCH] avfilter/avfiltergraph: remove unnecessary channel layout copy

2022-08-06 Thread James Almer

On 8/6/2022 8:42 AM, Nicolas George wrote:

James Almer (12022-08-05):

It's not modified, so we can simply use a const pointer to it.
Also check the return value of the other copy in the function while at it.

Signed-off-by: James Almer 
---
  libavfilter/avfiltergraph.c | 15 ---
  1 file changed, 8 insertions(+), 7 deletions(-)


Ok, thanks.

Regards,


Applied.
___
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 2/3] avcodec/raw: add VUYA pixel format to raw_pix_fmt_tags

2022-08-06 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/raw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/raw.c b/libavcodec/raw.c
index a371bb36c4..1e5b48d1e0 100644
--- a/libavcodec/raw.c
+++ b/libavcodec/raw.c
@@ -72,6 +72,7 @@ static const PixelFormatTag raw_pix_fmt_tags[] = {
 { AV_PIX_FMT_GRAY8,   MKTAG('G', 'R', 'E', 'Y') },
 { AV_PIX_FMT_NV12,MKTAG('N', 'V', '1', '2') },
 { AV_PIX_FMT_NV21,MKTAG('N', 'V', '2', '1') },
+{ AV_PIX_FMT_VUYA,MKTAG('A', 'Y', 'U', 'V') }, /* MS 4:4:4:4 */
 
 /* nut */
 { AV_PIX_FMT_RGB555LE, MKTAG('R', 'G', 'B', 15) },
-- 
2.37.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 3/3] avformat/riff: map AYUV fourcc to RAWVIDEO decoder

2022-08-06 Thread James Almer
There's no need to keep using a custom decoder for this pixel format.

Signed-off-by: James Almer 
---
What's the process to remove a decoder? Deprecation period, or just git rm?

 libavformat/riff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/riff.c b/libavformat/riff.c
index df7e9df31b..7a97cf1ccf 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -237,6 +237,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
 { AV_CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') },
 { AV_CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') },
 { AV_CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') },
+{ AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'Y', 'U', 'V') },
 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') },
 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '8', ' ', ' ') },
 { AV_CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') },
@@ -302,7 +303,6 @@ const AVCodecTag ff_codec_bmp_tags[] = {
 { AV_CODEC_ID_V210, MKTAG('C', '2', '1', '0') },
 { AV_CODEC_ID_V308, MKTAG('v', '3', '0', '8') },
 { AV_CODEC_ID_V408, MKTAG('v', '4', '0', '8') },
-{ AV_CODEC_ID_AYUV, MKTAG('A', 'Y', 'U', 'V') },
 { AV_CODEC_ID_V410, MKTAG('v', '4', '1', '0') },
 { AV_CODEC_ID_YUV4, MKTAG('y', 'u', 'v', '4') },
 { AV_CODEC_ID_INDEO3,   MKTAG('I', 'V', '3', '1') },
-- 
2.37.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 3/3] avformat/riff: map AYUV fourcc to RAWVIDEO decoder

2022-08-06 Thread James Almer

On 8/6/2022 9:34 PM, James Almer wrote:

There's no need to keep using a custom decoder for this pixel format.

Signed-off-by: James Almer 
---
What's the process to remove a decoder? Deprecation period, or just git rm?


Actually, it's a decoder, encoder, *and* the AVCodecID, the latter which 
definitely needs a deprecation period, so might as well do it with all 
three.




  libavformat/riff.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/riff.c b/libavformat/riff.c
index df7e9df31b..7a97cf1ccf 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -237,6 +237,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
  { AV_CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') },
  { AV_CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') },
  { AV_CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') },
+{ AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'Y', 'U', 'V') },
  { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') },
  { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '8', ' ', ' ') },
  { AV_CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') },
@@ -302,7 +303,6 @@ const AVCodecTag ff_codec_bmp_tags[] = {
  { AV_CODEC_ID_V210, MKTAG('C', '2', '1', '0') },
  { AV_CODEC_ID_V308, MKTAG('v', '3', '0', '8') },
  { AV_CODEC_ID_V408, MKTAG('v', '4', '0', '8') },
-{ AV_CODEC_ID_AYUV, MKTAG('A', 'Y', 'U', 'V') },
  { AV_CODEC_ID_V410, MKTAG('v', '4', '1', '0') },
  { AV_CODEC_ID_YUV4, MKTAG('y', 'u', 'v', '4') },
  { AV_CODEC_ID_INDEO3,   MKTAG('I', 'V', '3', '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".