Re: [FFmpeg-devel] [PATCH 16/39] avcodec/mpeg12dec: Remove redundant writes

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:34)
> ff_mpv_decode_init() already sets MpegEncContext.avctx.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mpeg12dec.c | 3 ---
>  1 file changed, 3 deletions(-)

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

Re: [FFmpeg-devel] [PATCH 17/39] avcodec/me_cmp: Remove ff_check_alignment()

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:35)
> The usage of a static variable presents a potential for data races and
> means that this function can't be used in init functions of codecs with
> FF_CODEC_CAP_INIT_THREADSAFE (unless of course one presumes that
> everything is alright in which case the error is not triggered; but then
> the whole function is pointless...). This makes the Snow decoder
> init-threadsafe as it already claims.
> 
> Notice that this function has been removed in 2014 by Libav in commit
> 9103185bd116930f90b847090e66a64fa9971ce2, because only some codepaths
> are checked this way and because it only affects legacy compilers. The
> latter is of course even more true today.

Furthermore even if this should be checked at all, this is not the place
for it.

> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/me_cmp.c| 23 ---
>  libavcodec/me_cmp.h|  2 --
>  libavcodec/mpegvideo_enc.c |  6 --
>  3 files changed, 31 deletions(-)

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

Re: [FFmpeg-devel] [PATCH 19/39] avcodec/mpegvideo_enc: Make mpv_encode_defaults thread-safe

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:37)
> This is a prerequisite for making any encoder that uses
> ff_mpv_encode_init() init-threadsafe; it already makes the AMV,
> the MJPEG and the MPEG-1/2 encoders init-threadsafe.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mjpegenc.c  |  4 ++--
>  libavcodec/mpeg12enc.c |  4 ++--
>  libavcodec/mpegvideo_enc.c | 15 +++
>  3 files changed, 15 insertions(+), 8 deletions(-)

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

Re: [FFmpeg-devel] [PATCH 20/39] avcodec/h261dec: Don't initialize unused part of RLTable

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:38)
> The H.261 decoder only uses an RLTable's VLC table, yet it also
> initializes its index_run, max_level and max_run. This commit stops
> doing so; it will also simplify making this decoder init-threadsafe,
> as the H.261 decoder and encoder now initialize disjoint parts of their
> common RLTable.

Does it then make sense to keep this RLTable common?

-- 
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 21/39] avcodec/h261dec: Make decoder init-threadsafe

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:39)
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/h261dec.c | 15 ++-
>  1 file changed, 6 insertions(+), 9 deletions(-)

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

Re: [FFmpeg-devel] [PATCH 22/39] avcodec/h261dec: Reindentation

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:40)
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/h261dec.c | 26 +-
>  1 file changed, 13 insertions(+), 13 deletions(-)

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

Re: [FFmpeg-devel] [PATCH 23/39] avcodec/h261enc: Make encoder init-threadsafe

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:41)
> This is easy now that the H.261 encoder is the only user that
> initializes the non-VLC parts of ff_h261_rl_tcoeff.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---

Looks good modulo my previous question about shared table

-- 
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 4/4] avcodec/flashsv2enc: factorize updating block dimensions

2021-01-18 Thread Anton Khirnov
Quoting Marton Balint (2021-01-10 02:20:45)
> Signed-off-by: Marton Balint 
> ---
>  libavcodec/flashsv2enc.c | 76 +---
>  1 file changed, 32 insertions(+), 44 deletions(-)
> 
> diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c
> index 6603d0ded1..5139b17a28 100644
> --- a/libavcodec/flashsv2enc.c
> +++ b/libavcodec/flashsv2enc.c
> @@ -252,7 +259,7 @@ static av_cold int flashsv2_encode_init(AVCodecContext * 
> avctx)
>  s->use_custom_palette =  0;
>  s->palette_type   = -1;// so that the palette will be 
> generated in reconfigure_at_keyframe
>  
> -return 0;
> +return update_block_dimensions(s, 64, 64);

This looks different from the original value. Why the change?

-- 
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] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Anton Khirnov
Quoting Jean-Baptiste Kempf (2021-01-11 14:03:42)
> ---
>  doc/dev_community/resolution_process.md | 89 +
>  1 file changed, 89 insertions(+)
>  create mode 100644 doc/dev_community/resolution_process.md
> 
> diff --git a/doc/dev_community/resolution_process.md 
> b/doc/dev_community/resolution_process.md
> new file mode 100644
> index 00..91999202cb
> --- /dev/null
> +++ b/doc/dev_community/resolution_process.md
> @@ -0,0 +1,89 @@
> +# Technical Committee
> +
> +_This document only makes sense with the rules from [the community 
> document](community)_.
> +
> +The Technical Committee (**TC**) is here to arbitrate and make decisions when
> +technical conflicts occur in the project.
> +
> +The TC main role is to resolve technical conflicts.
> +It is therefore not a technical steering committee, but it is understood that
> +some decisions might impact the future of the project.
> +
> +# Process
> +
> +## Seizing
> +
> +The TC can take possession of any technical matter that it sees fit.
> +
> +To involve the TC in a matter, email tc@ or CC them on an ongoing discussion.
> +
> +As members of TC are developers, they also can email tc@ to raise an issue.
> +
> +## Announcement
> +
> +The TC, once seized, must announce itself on the main mailing list, with a 
> _[TC]_ tag.
> +
> +The TC has 2 modes of operation: a RFC one and an internal one.
> +
> +If the TC thinks it needs the input from the larger community, the TC can 
> call
> +for a RFC. Else, it can decide by itself.
> +
> +If the disagreement involves a member of the TC, that member should recuse
> +themselves from the decision.

This wasn't in the previous version IIRC, and does not seem reasonable
to me.
For one thing, it adds a possibility of a tie, which was impossible with
odd number of TC members.
For another, they are excluded from having a say precisely in those
matters where they have most expertise.

-- 
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] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Anton Khirnov
Quoting Lynne (2021-01-11 16:15:06)
> Jan 11, 2021, 14:03 by j...@videolan.org:
> 
> > ---
> >  doc/dev_community/resolution_process.md | 89 +
> >  1 file changed, 89 insertions(+)
> >  create mode 100644 doc/dev_community/resolution_process.md
> >
> > diff --git a/doc/dev_community/resolution_process.md 
> > b/doc/dev_community/resolution_process.md
> > new file mode 100644
> > index 00..91999202cb
> > --- /dev/null
> > +++ b/doc/dev_community/resolution_process.md
> > @@ -0,0 +1,89 @@
> > +# Technical Committee
> > +
> > +_This document only makes sense with the rules from [the community 
> > document](community)_.
> > +
> > +The Technical Committee (**TC**) is here to arbitrate and make decisions 
> > when
> > +technical conflicts occur in the project.
> > +
> > +The TC main role is to resolve technical conflicts.
> > +It is therefore not a technical steering committee, but it is understood 
> > that
> > +some decisions might impact the future of the project.
> > +
> > +# Process
> > +
> > +## Seizing
> > +
> > +The TC can take possession of any technical matter that it sees fit.
> > +
> > +To involve the TC in a matter, email tc@ or CC them on an ongoing 
> > discussion.
> > +
> > +As members of TC are developers, they also can email tc@ to raise an issue.
> > +
> > +## Announcement
> > +
> > +The TC, once seized, must announce itself on the main mailing list, with a 
> > _[TC]_ tag.
> > +
> > +The TC has 2 modes of operation: a RFC one and an internal one.
> > +
> > +If the TC thinks it needs the input from the larger community, the TC can 
> > call
> > +for a RFC. Else, it can decide by itself.
> > +
> > +If the disagreement involves a member of the TC, that member should recuse
> > +themselves from the decision.
> > +
> > +The decision to use a RFC process or an internal discussion is a 
> > discretionary
> > +decision of the TC.
> > +
> > +The TC can also reject a seizure for a few reasons such as:
> > +the matter was not discussed enough previously; it lacks expertise to 
> > reach a
> > +beneficial decision on the matter; or the matter is too trivial.
> > +
> > +### RFC call
> > +
> > +In the RFC mode, one person from the TC posts on the mailing list the
> > +technical question and will request input from the community.
> > +
> > +The mail will have the following specification:
> > +* a precise title
> > +* a specific tag [TC RFC]
> > +* a top-level email
> > +* contain a precise question that does not exceed 100 words and that is 
> > answerable by developers
> > +* contain a precise end date for the answers.
> >
> Add a line like "may have a description of unlimited length".
> So only the question part is limited to 100 words, while the description
> may be as long as necessary as long as its separate (e.g. in another 
> paragraph).

IIUC the idea is that the topic has already been discussed on the ML
previously and all opinions have been gathered, before it is submitted
to TC. TC is a last resort.
So the question can just link to the relevant discussion.

> 
> 
> 
> > +The answers from the community must be on the main mailing list and must 
> > have
> > +the following specification:
> > +* keep the tag and the title unchanged
> > +* limited to 400 words
> > +* a first-level, answering directly to the main email
> > +* answering to the question.
> > +
> > +Further replies to answers are permitted, as long as they conform to the
> > +community standards of politeness, they are limited to 100 words, and are 
> > not
> > +nested more than once. (max-depth=2)
> > +
> > +After the end-date, no mail on the thread is accepted.
> > +
> > +Violations of this rule will escalated through the Community Committee.
> >
> That seems a bit harsh. Posting after the end-date should be acceptable
> so long as a reasonable standard of conversation is maintained.
> Working around this by not posting on the thread would also work.
> Just remove this rule or modify it like "posts after the end-date will
> be ignored by the TC".

Doesn't mean the CC has to do anything beyond a warning.

-- 
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 24/39] avcodec/ituh263dec: Don't initialize unused parts of RLTable

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:42)
> The RLTable ff_rl_intra_aic is only used by ituh263dec and ituh263enc;
> the former only uses the RLTable's VLC, the latter only index_run,
> max_level and max_run. Yet ituh263dec also initializes the latter.
> This commit stops doing so.

Same as for h261 - should the be unshared then?

-- 
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 25/39] avcodec/ituh263enc: Remove unused function parameter

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:43)
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/ituh263enc.c | 16 ++--
>  1 file changed, 6 insertions(+), 10 deletions(-)

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

Re: [FFmpeg-devel] [PATCH 26/39] avcodec/h263data, ituh263*: Make initializing RL inter table thread-safe

2021-01-18 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-12-10 12:16:44)
> Up until now, ff_h263_rl_inter was initialized by both ituh263dec and
> ituh263enc; this is an obstacle in making the codecs that use this code
> init-threadsafe.
> 
> This obstacle is eliminated by only initializing this RLTable from
> a single place that is guarded by a dedicated AVOnce.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/h263data.c   | 16 ++--
>  libavcodec/h263data.h   |  2 +-
>  libavcodec/ituh263dec.c |  2 +-
>  libavcodec/ituh263enc.c |  5 +++--
>  4 files changed, 19 insertions(+), 6 deletions(-)

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 1/6] dnn_backend_openvino.c: add version mismatch reminder

2021-01-18 Thread Guo, Yejun
The OpenVINO model file format changes when OpenVINO goes to a new
release, it does not work if the versions between model file and
runtime are mismatched.

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_openvino.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 8a7abb33f0..bb4ef3958f 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -544,8 +544,15 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options,
 goto err;
 
 status = ie_core_read_network(ov_model->core, model_filename, NULL, 
&ov_model->network);
-if (status != OK)
+if (status != OK) {
+ie_version_t ver;
+ver = ie_c_api_version();
+av_log(ctx, AV_LOG_ERROR, "Failed to read the network from model file 
%s,\n"
+  "Please check if the model version matches 
the runtime OpenVINO %s\n",
+   model_filename, ver.api_version);
+ie_version_free(&ver);
 goto err;
+}
 
 model->get_input = &get_input_ov;
 model->get_output = &get_output_ov;
-- 
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 2/6] libavfilter/dnn: use avpriv_report_missing_feature for unsupported features

2021-01-18 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c   |  2 +-
 libavfilter/dnn/dnn_backend_openvino.c |  4 ++--
 libavfilter/dnn/dnn_backend_tf.c   |  4 ++--
 libavfilter/dnn/dnn_io_proc.c  | 10 --
 libavfilter/vf_dnn_processing.c|  4 ++--
 5 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 5e7fc0f10c..2700251ee6 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -327,7 +327,7 @@ static DNNReturnType execute_model_native(const DNNModel 
*model, const char *inp
 if (nb_output != 1) {
 // currently, the filter does not need multiple outputs,
 // so we just pending the support until we really need it.
-av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n");
+avpriv_report_missing_feature(ctx, "multiple outputs");
 return DNN_ERROR;
 }
 
diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index bb4ef3958f..5820afbcfd 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -588,12 +588,12 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel 
*model, const char *input_n
 if (nb_output != 1) {
 // currently, the filter does not need multiple outputs,
 // so we just pending the support until we really need it.
-av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n");
+avpriv_report_missing_feature(ctx, "multiple outputs");
 return DNN_ERROR;
 }
 
 if (ctx->options.batch_size > 1) {
-av_log(ctx, AV_LOG_ERROR, "do not support batch mode for sync 
execution.\n");
+avpriv_report_missing_feature(ctx, "batch mode for sync execution");
 return DNN_ERROR;
 }
 
diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index b9fe01693b..cbe83741f6 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -424,7 +424,7 @@ static DNNReturnType add_conv_layer(TFModel *tf_model, 
TF_Operation *transpose_o
 op_desc = TF_NewOperation(tf_model->graph, "Sigmoid", name_buffer);
 break;
 default:
-av_log(ctx, AV_LOG_ERROR, "Unsupported convolutional activation 
function\n");
+avpriv_report_missing_feature(ctx, "convolutional activation function 
%d", params->activation);
 return DNN_ERROR;
 }
 input.oper = *cur_op;
@@ -750,7 +750,7 @@ static DNNReturnType execute_model_tf(const DNNModel 
*model, const char *input_n
 if (nb_output != 1) {
 // currently, the filter does not need multiple outputs,
 // so we just pending the support until we really need it.
-av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n");
+avpriv_report_missing_feature(ctx, "multiple outputs");
 return DNN_ERROR;
 }
 
diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
index 2744cb6502..193e5bd9cc 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -27,7 +27,7 @@ DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData 
*output, void *log_
 struct SwsContext *sws_ctx;
 int bytewidth = av_image_get_linesize(frame->format, frame->width, 0);
 if (output->dt != DNN_FLOAT) {
-av_log(log_ctx, AV_LOG_ERROR, "do not support data type rather than 
DNN_FLOAT\n");
+avpriv_report_missing_feature(log_ctx, "data type rather than 
DNN_FLOAT");
 return DNN_ERROR;
 }
 
@@ -85,8 +85,7 @@ DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData 
*output, void *log_
 sws_freeContext(sws_ctx);
 return DNN_SUCCESS;
 default:
-av_log(log_ctx, AV_LOG_ERROR, "do not support frame format %s\n",
-   av_get_pix_fmt_name(frame->format));
+avpriv_report_missing_feature(log_ctx, "%s", 
av_get_pix_fmt_name(frame->format));
 return DNN_ERROR;
 }
 
@@ -98,7 +97,7 @@ DNNReturnType proc_from_frame_to_dnn(AVFrame *frame, DNNData 
*input, void *log_c
 struct SwsContext *sws_ctx;
 int bytewidth = av_image_get_linesize(frame->format, frame->width, 0);
 if (input->dt != DNN_FLOAT) {
-av_log(log_ctx, AV_LOG_ERROR, "do not support data type rather than 
DNN_FLOAT\n");
+avpriv_report_missing_feature(log_ctx, "data type rather than 
DNN_FLOAT");
 return DNN_ERROR;
 }
 
@@ -158,8 +157,7 @@ DNNReturnType proc_from_frame_to_dnn(AVFrame *frame, 
DNNData *input, void *log_c
 sws_freeContext(sws_ctx);
 break;
 default:
-av_log(log_ctx, AV_LOG_ERROR, "do not support frame format %s\n",
-   av_get_pix_fmt_name(frame->format));
+avpriv_report_missing_feature(log_ctx, "%s", 
av_get_pix_fmt_name(frame->format));
 return DNN_ERROR;
 }
 
diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter

[FFmpeg-devel] [PATCH 3/6] libavfilter/dnn: add prefix ff_ for internal functions

2021-01-18 Thread Guo, Yejun
from proc_from_frame_to_dnn to ff_proc_from_frame_to_dnn, and
from proc_from_dnn_to_frame to ff_proc_from_dnn_to_frame.

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c   | 4 ++--
 libavfilter/dnn/dnn_backend_openvino.c | 4 ++--
 libavfilter/dnn/dnn_backend_tf.c   | 4 ++--
 libavfilter/dnn/dnn_io_proc.c  | 4 ++--
 libavfilter/dnn/dnn_io_proc.h  | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 2700251ee6..2c0b938839 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -320,7 +320,7 @@ static DNNReturnType execute_model_native(const DNNModel 
*model, const char *inp
 if (native_model->model->pre_proc != NULL) {
 native_model->model->pre_proc(in_frame, &input, 
native_model->model->filter_ctx);
 } else {
-proc_from_frame_to_dnn(in_frame, &input, ctx);
+ff_proc_from_frame_to_dnn(in_frame, &input, ctx);
 }
 }
 
@@ -368,7 +368,7 @@ static DNNReturnType execute_model_native(const DNNModel 
*model, const char *inp
 if (native_model->model->post_proc != NULL) {
 native_model->model->post_proc(out_frame, &output, 
native_model->model->filter_ctx);
 } else {
-proc_from_dnn_to_frame(out_frame, &output, ctx);
+ff_proc_from_dnn_to_frame(out_frame, &output, ctx);
 }
 } else {
 out_frame->width = output.width;
diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 5820afbcfd..9c803c8188 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -160,7 +160,7 @@ static DNNReturnType fill_model_input_ov(OVModel *ov_model, 
RequestItem *request
 if (ov_model->model->pre_proc != NULL) {
 ov_model->model->pre_proc(task->in_frame, &input, 
ov_model->model->filter_ctx);
 } else {
-proc_from_frame_to_dnn(task->in_frame, &input, ctx);
+ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx);
 }
 }
 input.data = (uint8_t *)input.data
@@ -228,7 +228,7 @@ static void infer_completion_callback(void *args)
 if (task->ov_model->model->post_proc != NULL) {
 task->ov_model->model->post_proc(task->out_frame, &output, 
task->ov_model->model->filter_ctx);
 } else {
-proc_from_dnn_to_frame(task->out_frame, &output, ctx);
+ff_proc_from_dnn_to_frame(task->out_frame, &output, ctx);
 }
 } else {
 task->out_frame->width = output.width;
diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index cbe83741f6..f77f3dd817 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -743,7 +743,7 @@ static DNNReturnType execute_model_tf(const DNNModel 
*model, const char *input_n
 if (tf_model->model->pre_proc != NULL) {
 tf_model->model->pre_proc(in_frame, &input, 
tf_model->model->filter_ctx);
 } else {
-proc_from_frame_to_dnn(in_frame, &input, ctx);
+ff_proc_from_frame_to_dnn(in_frame, &input, ctx);
 }
 }
 
@@ -800,7 +800,7 @@ static DNNReturnType execute_model_tf(const DNNModel 
*model, const char *input_n
 if (tf_model->model->post_proc != NULL) {
 tf_model->model->post_proc(out_frame, &output, 
tf_model->model->filter_ctx);
 } else {
-proc_from_dnn_to_frame(out_frame, &output, ctx);
+ff_proc_from_dnn_to_frame(out_frame, &output, ctx);
 }
 } else {
 out_frame->width = output.width;
diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
index 193e5bd9cc..bee1423342 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -22,7 +22,7 @@
 #include "libavutil/imgutils.h"
 #include "libswscale/swscale.h"
 
-DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void 
*log_ctx)
+DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void 
*log_ctx)
 {
 struct SwsContext *sws_ctx;
 int bytewidth = av_image_get_linesize(frame->format, frame->width, 0);
@@ -92,7 +92,7 @@ DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData 
*output, void *log_
 return DNN_SUCCESS;
 }
 
-DNNReturnType proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void 
*log_ctx)
+DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void 
*log_ctx)
 {
 struct SwsContext *sws_ctx;
 int bytewidth = av_image_get_linesize(frame->format, frame->width, 0);
diff --git a/libavfilter/dnn/dnn_io_proc.h b/libavfilter/dnn/dnn_io_proc.h
index 4c7dc7c1a2..6a410ccc7b 100644
--- a/libavfilter/dnn/dnn_io_proc.h
+++ b/libav

[FFmpeg-devel] [PATCH 4/6] dnn/queue: remove prefix FF for Queue and SafeQueue

2021-01-18 Thread Guo, Yejun
we don't need FF prefix for internal data struct

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_openvino.c |  4 +-
 libavfilter/dnn/queue.c| 58 +-
 libavfilter/dnn/queue.h| 20 -
 libavfilter/dnn/safe_queue.c   | 18 
 libavfilter/dnn/safe_queue.h   | 14 +++
 5 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 9c803c8188..573344e628 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -55,8 +55,8 @@ typedef struct OVModel{
 ie_infer_request_t *infer_request;
 
 /* for async execution */
-FFSafeQueue *request_queue;   // holds RequestItem
-FFQueue *task_queue;  // holds TaskItem
+SafeQueue *request_queue;   // holds RequestItem
+Queue *task_queue;  // holds TaskItem
 } OVModel;
 
 typedef struct TaskItem {
diff --git a/libavfilter/dnn/queue.c b/libavfilter/dnn/queue.c
index e64f567906..954437a8b4 100644
--- a/libavfilter/dnn/queue.c
+++ b/libavfilter/dnn/queue.c
@@ -23,31 +23,31 @@
 #include "libavutil/mem.h"
 #include "libavutil/avassert.h"
 
-typedef struct FFQueueEntry FFQueueEntry;
+typedef struct QueueEntry QueueEntry;
 
-struct FFQueueEntry {
+struct QueueEntry {
 void *value;
-FFQueueEntry *prev;
-FFQueueEntry *next;
+QueueEntry *prev;
+QueueEntry *next;
 };
 
-struct FFQueue {
-FFQueueEntry *head;
-FFQueueEntry *tail;
+struct Queue {
+QueueEntry *head;
+QueueEntry *tail;
 size_t length;
 };
 
-static inline FFQueueEntry *create_entry(void *val)
+static inline QueueEntry *create_entry(void *val)
 {
-FFQueueEntry *entry = av_malloc(sizeof(*entry));
+QueueEntry *entry = av_malloc(sizeof(*entry));
 if (entry)
 entry->value = val;
 return entry;
 }
 
-FFQueue* ff_queue_create(void)
+Queue* ff_queue_create(void)
 {
-FFQueue *q = av_malloc(sizeof(*q));
+Queue *q = av_malloc(sizeof(*q));
 if (!q)
 return NULL;
 
@@ -70,15 +70,15 @@ FFQueue* ff_queue_create(void)
 return q;
 }
 
-void ff_queue_destroy(FFQueue *q)
+void ff_queue_destroy(Queue *q)
 {
-FFQueueEntry *entry;
+QueueEntry *entry;
 if (!q)
 return;
 
 entry = q->head;
 while (entry != NULL) {
-FFQueueEntry *temp = entry;
+QueueEntry *temp = entry;
 entry = entry->next;
 av_freep(&temp);
 }
@@ -86,12 +86,12 @@ void ff_queue_destroy(FFQueue *q)
 av_freep(&q);
 }
 
-size_t ff_queue_size(FFQueue *q)
+size_t ff_queue_size(Queue *q)
 {
  return q ? q->length : 0;
 }
 
-void *ff_queue_peek_front(FFQueue *q)
+void *ff_queue_peek_front(Queue *q)
 {
 if (!q || q->length == 0)
 return NULL;
@@ -99,7 +99,7 @@ void *ff_queue_peek_front(FFQueue *q)
 return q->head->next->value;
 }
 
-void *ff_queue_peek_back(FFQueue *q)
+void *ff_queue_peek_back(Queue *q)
 {
 if (!q || q->length == 0)
 return NULL;
@@ -107,10 +107,10 @@ void *ff_queue_peek_back(FFQueue *q)
 return q->tail->prev->value;
 }
 
-int ff_queue_push_front(FFQueue *q, void *v)
+int ff_queue_push_front(Queue *q, void *v)
 {
-FFQueueEntry *new_entry;
-FFQueueEntry *original_next;
+QueueEntry *new_entry;
+QueueEntry *original_next;
 if (!q)
 return 0;
 
@@ -128,10 +128,10 @@ int ff_queue_push_front(FFQueue *q, void *v)
 return q->length;
 }
 
-int ff_queue_push_back(FFQueue *q, void *v)
+int ff_queue_push_back(Queue *q, void *v)
 {
-FFQueueEntry *new_entry;
-FFQueueEntry *original_prev;
+QueueEntry *new_entry;
+QueueEntry *original_prev;
 if (!q)
 return 0;
 
@@ -149,10 +149,10 @@ int ff_queue_push_back(FFQueue *q, void *v)
 return q->length;
 }
 
-void *ff_queue_pop_front(FFQueue *q)
+void *ff_queue_pop_front(Queue *q)
 {
-FFQueueEntry *front;
-FFQueueEntry *new_head_next;
+QueueEntry *front;
+QueueEntry *new_head_next;
 void *ret;
 
 if (!q || q->length == 0)
@@ -170,10 +170,10 @@ void *ff_queue_pop_front(FFQueue *q)
 return ret;
 }
 
-void *ff_queue_pop_back(FFQueue *q)
+void *ff_queue_pop_back(Queue *q)
 {
-FFQueueEntry *back;
-FFQueueEntry *new_tail_prev;
+QueueEntry *back;
+QueueEntry *new_tail_prev;
 void *ret;
 
 if (!q || q->length == 0)
diff --git a/libavfilter/dnn/queue.h b/libavfilter/dnn/queue.h
index df913d91ac..4d7121366a 100644
--- a/libavfilter/dnn/queue.h
+++ b/libavfilter/dnn/queue.h
@@ -22,20 +22,20 @@
 #ifndef AVFILTER_DNN_QUEUE_H
 #define AVFILTER_DNN_QUEUE_H
 
-typedef struct FFQueue FFQueue;
+typedef struct Queue Queue;
 
-FFQueue *ff_queue_create(void);
-void ff_queue_destroy(FFQueue *q);
+Queue *ff_queue_create(void);
+void ff_queue_destroy(Queue *q);
 
-size_t ff_queue_size(FFQueue *q);
+size_t ff_queue_size(Queue *q);
 
-void *ff_queue_peek_front(FFQueue *q);
-void *ff_queue_peek_back(FFQueue

[FFmpeg-devel] [PATCH 5/6] dnn_backend_native_layer_conv2d.c: correct struct name with CamelCase

2021-01-18 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 .../dnn/dnn_backend_native_layer_conv2d.c  | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index 0fb968a1fc..7c6d96e916 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -26,19 +26,19 @@
 #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x)))
 
 //struct to pass parameters
-typedef struct thread_common_param{
+typedef struct ThreadCommonParam{
 DnnOperand *operands;
 const int32_t *input_operand_indexes;
 int32_t output_operand_index;
 const void *parameters;
 NativeContext *ctx;
 float *output_data;
-} thread_common_param;
+} ThreadCommonParam;
 
-typedef struct thread_param{
-thread_common_param *thread_common_param;
+typedef struct ThreadParam{
+ThreadCommonParam *thread_common_param;
 int thread_start, thread_end;
-} thread_param;
+} ThreadParam;
 
 int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
 {
@@ -108,8 +108,8 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext 
*model_file_context, int fil
 static void * dnn_execute_layer_conv2d_thread(void *threadarg)
 {
 //pass parameters
-thread_param *thread_param = (struct thread_param *)threadarg;
-thread_common_param *thread_common_param = 
thread_param->thread_common_param;
+ThreadParam *thread_param = threadarg;
+ThreadCommonParam *thread_common_param = thread_param->thread_common_param;
 DnnOperand *operands = thread_common_param->operands;
 int32_t input_operand_index = 
thread_common_param->input_operand_indexes[0];
 int height = operands[input_operand_index].dims[1];
@@ -190,8 +190,8 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t));
 int thread_stride;
 #endif
-thread_param **thread_param = av_malloc(thread_num * 
sizeof(*thread_param));
-thread_common_param thread_common_param;
+ThreadParam **thread_param = av_malloc(thread_num * sizeof(*thread_param));
+ThreadCommonParam thread_common_param;
 const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(parameters);
 int height = operands[input_operand_indexes[0]].dims[1];
 int width = operands[input_operand_indexes[0]].dims[2];
-- 
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 6/6] dnn_backend_native_layer_conv2d.c: refine code with av_malloc_array and av_freep

2021-01-18 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 .../dnn/dnn_backend_native_layer_conv2d.c | 20 +--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index 7c6d96e916..9dc50b7cbe 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -70,7 +70,7 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext 
*model_file_context, int fil
 return 0;
 }
 
-conv_params->kernel = av_malloc(kernel_size * sizeof(float));
+conv_params->kernel = av_malloc_array(kernel_size, 
sizeof(*conv_params->kernel));
 if (!conv_params->kernel) {
 av_freep(&conv_params);
 return 0;
@@ -81,7 +81,7 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext 
*model_file_context, int fil
 
 conv_params->biases = NULL;
 if (conv_params->has_bias) {
-conv_params->biases = av_malloc(conv_params->output_num * 
sizeof(float));
+conv_params->biases = av_malloc_array(conv_params->output_num, 
sizeof(*conv_params->biases));
 if (!conv_params->biases){
 av_freep(&conv_params->kernel);
 av_freep(&conv_params);
@@ -187,10 +187,10 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 int thread_num = (ctx->options.conv2d_threads <= 0 || 
ctx->options.conv2d_threads > av_cpu_count())
 ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads);
 #if HAVE_PTHREAD_CANCEL
-pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t));
+pthread_t *thread_id = av_malloc_array(thread_num, sizeof(*thread_id));
 int thread_stride;
 #endif
-ThreadParam **thread_param = av_malloc(thread_num * sizeof(*thread_param));
+ThreadParam **thread_param = av_malloc_array(thread_num, 
sizeof(*thread_param));
 ThreadCommonParam thread_common_param;
 const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(parameters);
 int height = operands[input_operand_indexes[0]].dims[1];
@@ -224,7 +224,7 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 thread_stride = (height - pad_size * 2) / thread_num;
 //create threads
 for (int i = 0; i < thread_num; i++){
-thread_param[i] = av_malloc(sizeof(**thread_param));
+thread_param[i] = av_malloc(sizeof(*thread_param[0]));
 thread_param[i]->thread_common_param = &thread_common_param;
 thread_param[i]->thread_start = thread_stride * i + pad_size;
 thread_param[i]->thread_end = (i == thread_num - 1) ? (height - 
pad_size) : (thread_param[i]->thread_start + thread_stride);
@@ -237,20 +237,20 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 }
 
 //release memory
-av_free(thread_id);
+av_freep(&thread_id);
 
 for (int i = 0; i < thread_num; i++){
-av_free(thread_param[i]);
+av_freep(&thread_param[i]);
 }
 #else
-thread_param[0] = av_malloc(sizeof(**thread_param));
+thread_param[0] = av_malloc(sizeof(*thread_param[0]));
 thread_param[0]->thread_common_param = &thread_common_param;
 thread_param[0]->thread_start = pad_size;
 thread_param[0]->thread_end = height - pad_size;
 dnn_execute_layer_conv2d_thread((void *)thread_param[0]);
-av_free(thread_param[0]);
+av_freep(&thread_param[0]);
 #endif
 
-av_free(thread_param);
+av_freep(&thread_param);
 return DNN_SUCCESS;
 }
-- 
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".

Re: [FFmpeg-devel] [PATCH] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Lynne
Jan 18, 2021, 12:59 by an...@khirnov.net:

> Quoting Lynne (2021-01-11 16:15:06)
>
>> Jan 11, 2021, 14:03 by j...@videolan.org:
>>
>> > ---
>> >  doc/dev_community/resolution_process.md | 89 +
>> >  1 file changed, 89 insertions(+)
>> >  create mode 100644 doc/dev_community/resolution_process.md
>> >
>> > diff --git a/doc/dev_community/resolution_process.md 
>> > b/doc/dev_community/resolution_process.md
>> > new file mode 100644
>> > index 00..91999202cb
>> > --- /dev/null
>> > +++ b/doc/dev_community/resolution_process.md
>> > @@ -0,0 +1,89 @@
>> > +# Technical Committee
>> > +
>> > +_This document only makes sense with the rules from [the community 
>> > document](community)_.
>> > +
>> > +The Technical Committee (**TC**) is here to arbitrate and make decisions 
>> > when
>> > +technical conflicts occur in the project.
>> > +
>> > +The TC main role is to resolve technical conflicts.
>> > +It is therefore not a technical steering committee, but it is understood 
>> > that
>> > +some decisions might impact the future of the project.
>> > +
>> > +# Process
>> > +
>> > +## Seizing
>> > +
>> > +The TC can take possession of any technical matter that it sees fit.
>> > +
>> > +To involve the TC in a matter, email tc@ or CC them on an ongoing 
>> > discussion.
>> > +
>> > +As members of TC are developers, they also can email tc@ to raise an 
>> > issue.
>> > +
>> > +## Announcement
>> > +
>> > +The TC, once seized, must announce itself on the main mailing list, with 
>> > a _[TC]_ tag.
>> > +
>> > +The TC has 2 modes of operation: a RFC one and an internal one.
>> > +
>> > +If the TC thinks it needs the input from the larger community, the TC can 
>> > call
>> > +for a RFC. Else, it can decide by itself.
>> > +
>> > +If the disagreement involves a member of the TC, that member should recuse
>> > +themselves from the decision.
>> > +
>> > +The decision to use a RFC process or an internal discussion is a 
>> > discretionary
>> > +decision of the TC.
>> > +
>> > +The TC can also reject a seizure for a few reasons such as:
>> > +the matter was not discussed enough previously; it lacks expertise to 
>> > reach a
>> > +beneficial decision on the matter; or the matter is too trivial.
>> > +
>> > +### RFC call
>> > +
>> > +In the RFC mode, one person from the TC posts on the mailing list the
>> > +technical question and will request input from the community.
>> > +
>> > +The mail will have the following specification:
>> > +* a precise title
>> > +* a specific tag [TC RFC]
>> > +* a top-level email
>> > +* contain a precise question that does not exceed 100 words and that is 
>> > answerable by developers
>> > +* contain a precise end date for the answers.
>> >
>> Add a line like "may have a description of unlimited length".
>> So only the question part is limited to 100 words, while the description
>> may be as long as necessary as long as its separate (e.g. in another 
>> paragraph).
>>
>
> IIUC the idea is that the topic has already been discussed on the ML
> previously and all opinions have been gathered, before it is submitted
> to TC. TC is a last resort.
> So the question can just link to the relevant discussion.
>

That's not the same. What you'd like is a digest of the discussion,
not links to dozens of different threads and IRC logs to sift through.
Especially for devs don't keep up to date with the ML (because it's difficult).



>> > +The answers from the community must be on the main mailing list and must 
>> > have
>> > +the following specification:
>> > +* keep the tag and the title unchanged
>> > +* limited to 400 words
>> > +* a first-level, answering directly to the main email
>> > +* answering to the question.
>> > +
>> > +Further replies to answers are permitted, as long as they conform to the
>> > +community standards of politeness, they are limited to 100 words, and are 
>> > not
>> > +nested more than once. (max-depth=2)
>> > +
>> > +After the end-date, no mail on the thread is accepted.
>> > +
>> > +Violations of this rule will escalated through the Community Committee.
>> >
>> That seems a bit harsh. Posting after the end-date should be acceptable
>> so long as a reasonable standard of conversation is maintained.
>> Working around this by not posting on the thread would also work.
>> Just remove this rule or modify it like "posts after the end-date will
>> be ignored by the TC".
>>
>
> Doesn't mean the CC has to do anything beyond a warning.
>

Or nothing at all if it's just a civilized intellectual discussion, or praise.
Hence no reason to have this rule at all.
___
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] libavformat/hls: correct indentation

2021-01-18 Thread Nachiket Tarate
Signed-off-by: Nachiket Tarate 
---
 libavformat/hls.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index bc5247b8ce..7d34f349c3 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2028,23 +2028,23 @@ static int hls_read_header(AVFormatContext *s)
 break;
 }
 } else {
-pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;
-pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? 
s->max_analyze_duration : 4 * AV_TIME_BASE;
-pls->ctx->interrupt_callback = s->interrupt_callback;
-url = av_strdup(pls->segments[0]->url);
-ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0);
-if (ret < 0) {
-/* Free the ctx - it isn't initialized properly at this point,
- * so avformat_close_input shouldn't be called. If
- * avformat_open_input fails below, it frees and zeros the
- * context, so it doesn't need any special treatment like this. */
-av_log(s, AV_LOG_ERROR, "Error when loading first segment '%s'\n", 
url);
-avformat_free_context(pls->ctx);
-pls->ctx = NULL;
+pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;
+pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? 
s->max_analyze_duration : 4 * AV_TIME_BASE;
+pls->ctx->interrupt_callback = s->interrupt_callback;
+url = av_strdup(pls->segments[0]->url);
+ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0);
+if (ret < 0) {
+/* Free the ctx - it isn't initialized properly at this point,
+* so avformat_close_input shouldn't be called. If
+* avformat_open_input fails below, it frees and zeros the
+* context, so it doesn't need any special treatment like this. 
*/
+av_log(s, AV_LOG_ERROR, "Error when loading first segment 
'%s'\n", url);
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+av_free(url);
+goto fail;
+}
 av_free(url);
-goto fail;
-}
-av_free(url);
 }
 
 pls->ctx->pb   = &pls->pb;
@@ -2079,9 +2079,9 @@ static int hls_read_header(AVFormatContext *s)
 pls->ctx->nb_streams == 1) {
 ff_hls_parse_audio_setup_info(pls->ctx->streams[0], 
&pls->audio_setup_info);
 } else {
-ret = avformat_find_stream_info(pls->ctx, NULL);
-if (ret < 0)
-goto fail;
+ret = avformat_find_stream_info(pls->ctx, NULL);
+if (ret < 0)
+goto fail;
 }
 }
 
-- 
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 2/3] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer

2021-01-18 Thread Nachiket Tarate
Apple HTTP Live Streaming Sample Encryption:

https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption

Signed-off-by: Nachiket Tarate 
---
 libavformat/Makefile |   2 +-
 libavformat/hls.c|  97 ++-
 libavformat/hls_sample_aes.c | 497 +++
 libavformat/hls_sample_aes.h |  64 +
 libavformat/mpegts.c |  12 +
 5 files changed, 658 insertions(+), 14 deletions(-)
 create mode 100644 libavformat/hls_sample_aes.c
 create mode 100644 libavformat/hls_sample_aes.h

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3a8fbcbe5f..c97930d98b 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -237,7 +237,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
-OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
+OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_aes.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
 OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 619e4800de..bc5247b8ce 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2,6 +2,7 @@
  * Apple HTTP Live Streaming demuxer
  * Copyright (c) 2010 Martin Storsjo
  * Copyright (c) 2013 Anssi Hannula
+ * Copyright (c) 2020 Nachiket Tarate
  *
  * This file is part of FFmpeg.
  *
@@ -39,6 +40,8 @@
 #include "avio_internal.h"
 #include "id3v2.h"
 
+#include "hls_sample_aes.h"
+
 #define INITIAL_BUFFER_SIZE 32768
 
 #define MAX_FIELD_LEN 64
@@ -145,6 +148,8 @@ struct playlist {
 int id3_changed; /* ID3 tag data has changed at some point */
 ID3v2ExtraMeta *id3_deferred_extra; /* stored here until subdemuxer is 
opened */
 
+HLSAudioSetupInfo audio_setup_info;
+
 int64_t seek_timestamp;
 int seek_flags;
 int seek_stream_index; /* into subdemuxer stream array */
@@ -986,7 +991,10 @@ fail:
 
 static struct segment *current_segment(struct playlist *pls)
 {
-return pls->segments[pls->cur_seq_no - pls->start_seq_no];
+int n = pls->cur_seq_no - pls->start_seq_no;
+if (n >= pls->n_segments)
+return NULL;
+return pls->segments[n];
 }
 
 static struct segment *next_segment(struct playlist *pls)
@@ -1015,10 +1023,11 @@ static int read_from_url(struct playlist *pls, struct 
segment *seg,
 
 /* Parse the raw ID3 data and pass contents to caller */
 static void parse_id3(AVFormatContext *s, AVIOContext *pb,
-  AVDictionary **metadata, int64_t *dts,
+  AVDictionary **metadata, int64_t *dts, HLSAudioSetupInfo 
*audio_setup_info,
   ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta **extra_meta)
 {
 static const char id3_priv_owner_ts[] = 
"com.apple.streaming.transportStreamTimestamp";
+static const char id3_priv_owner_audio_setup[] = 
"com.apple.streaming.audioDescription";
 ID3v2ExtraMeta *meta;
 
 ff_id3v2_read_dict(pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta);
@@ -1034,6 +1043,9 @@ static void parse_id3(AVFormatContext *s, AVIOContext *pb,
 else
 av_log(s, AV_LOG_ERROR, "Invalid HLS ID3 audio timestamp 
%"PRId64"\n", ts);
 }
+else if (priv->datasize >= 8 && !strcmp(priv->owner, 
id3_priv_owner_audio_setup)) {
+ff_hls_read_audio_setup_info(audio_setup_info, priv->data, 
priv->datasize);
+}
 } else if (!strcmp(meta->tag, "APIC") && apic)
 *apic = &meta->data.apic;
 }
@@ -1076,7 +1088,7 @@ static void handle_id3(AVIOContext *pb, struct playlist 
*pls)
 ID3v2ExtraMeta *extra_meta = NULL;
 int64_t timestamp = AV_NOPTS_VALUE;
 
-parse_id3(pls->ctx, pb, &metadata, ×tamp, &apic, &extra_meta);
+parse_id3(pls->ctx, pb, &metadata, ×tamp, &pls->audio_setup_info, 
&apic, &extra_meta);
 
 if (timestamp != AV_NOPTS_VALUE) {
 pls->id3_mpegts_timestamp = timestamp;
@@ -1230,10 +1242,7 @@ static int open_input(HLSContext *c, struct playlist 
*pls, struct segment *seg,
 av_log(pls->parent, AV_LOG_VERBOSE, "HLS request for url '%s', offset 
%"PRId64", playlist %d\n",
seg->url, seg->url_offset, pls->index);
 
-if (seg->key_type == KEY_NONE) {
-ret = open_url(pls->parent, in, seg->url, &c->avio_opts, opts, 
&is_http);
-} else if (seg->key_type == KEY_AES_128) {
-char iv[33], key[33], url[MAX_URL_SIZE];
+if (seg->key_type == KEY_AES_128 || seg->key_type == KEY_SAMPLE_AES) {
 if (strcmp(seg->key, pls->key_url)) {
 AVIOContext *pb = NULL;
 if (open_url(pls->parent, &pb, seg->key, &c->avio_opts, opts, 
NULL) == 0) {
@@ -1249,6 +1258,10 @@ static int open_input(HLSContext *c, struct playlist 
*pls, struct segment *seg,

Re: [FFmpeg-devel] [PATCH] avformat/dhav: Fix incorrect non-DHAV chunk skipping logic

2021-01-18 Thread Idan Freiberg
Can one of the maintainers review the patch please?

בתאריך יום ד׳, 13 בינו׳ 2021 ב-14:35 מאת Idan Freiberg :

> DAV files may contain a variable length padding in between chunks
> filled with 0xff bytes. The current skipping logic is incorrect as it
> may skip over DHAV chunks not appearing sequentially in the file.
>
> We now look for the 'DHAV' tag using a byte-by-byte search in order
> to handle such situations. Also the dhav->last_good_pos field will
> not be updated while skipping unrecognized data.
> ---
>  libavformat/dhav.c | 15 +++
>  1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/libavformat/dhav.c b/libavformat/dhav.c
> index 00e0d8476e..6a6c235e65 100644
> --- a/libavformat/dhav.c
> +++ b/libavformat/dhav.c
> @@ -173,18 +173,9 @@ static int read_chunk(AVFormatContext *s)
>  if (avio_feof(s->pb))
>  return AVERROR_EOF;
>
> -if (avio_rl32(s->pb) != MKTAG('D','H','A','V') && dhav->last_good_pos
> < INT64_MAX - 0x8000) {
> -dhav->last_good_pos += 0x8000;
> -avio_seek(s->pb, dhav->last_good_pos, SEEK_SET);
> -
> -while (avio_rl32(s->pb) != MKTAG('D','H','A','V')) {
> -if (avio_feof(s->pb) || dhav->last_good_pos >= INT64_MAX -
> 0x8000)
> -return AVERROR_EOF;
> -dhav->last_good_pos += 0x8000;
> -ret = avio_skip(s->pb, 0x8000 - 4);
> -if (ret < 0)
> -return ret;
> -}
> +while (avio_r8(s->pb) != 'D' || avio_r8(s->pb) != 'H' ||
> avio_r8(s->pb) != 'A' || avio_r8(s->pb) != 'V') {
> +if (avio_feof(s->pb))
> +return AVERROR_EOF;
>  }
>
>  start = avio_tell(s->pb) - 4;
> --
> 2.30.0
>
> --
Idan Freiberg Mobile: +972-52-2925213
___
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/dhav: Fix incorrect non-DHAV chunk skipping logic

2021-01-18 Thread Paul B Mahol
Isn't this applied already?

On Mon, Jan 18, 2021 at 6:46 PM Idan Freiberg  wrote:

> Can one of the maintainers review the patch please?
>
> בתאריך יום ד׳, 13 בינו׳ 2021 ב-14:35 מאת Idan Freiberg :
>
> > DAV files may contain a variable length padding in between chunks
> > filled with 0xff bytes. The current skipping logic is incorrect as it
> > may skip over DHAV chunks not appearing sequentially in the file.
> >
> > We now look for the 'DHAV' tag using a byte-by-byte search in order
> > to handle such situations. Also the dhav->last_good_pos field will
> > not be updated while skipping unrecognized data.
> > ---
> >  libavformat/dhav.c | 15 +++
> >  1 file changed, 3 insertions(+), 12 deletions(-)
> >
> > diff --git a/libavformat/dhav.c b/libavformat/dhav.c
> > index 00e0d8476e..6a6c235e65 100644
> > --- a/libavformat/dhav.c
> > +++ b/libavformat/dhav.c
> > @@ -173,18 +173,9 @@ static int read_chunk(AVFormatContext *s)
> >  if (avio_feof(s->pb))
> >  return AVERROR_EOF;
> >
> > -if (avio_rl32(s->pb) != MKTAG('D','H','A','V') &&
> dhav->last_good_pos
> > < INT64_MAX - 0x8000) {
> > -dhav->last_good_pos += 0x8000;
> > -avio_seek(s->pb, dhav->last_good_pos, SEEK_SET);
> > -
> > -while (avio_rl32(s->pb) != MKTAG('D','H','A','V')) {
> > -if (avio_feof(s->pb) || dhav->last_good_pos >= INT64_MAX -
> > 0x8000)
> > -return AVERROR_EOF;
> > -dhav->last_good_pos += 0x8000;
> > -ret = avio_skip(s->pb, 0x8000 - 4);
> > -if (ret < 0)
> > -return ret;
> > -}
> > +while (avio_r8(s->pb) != 'D' || avio_r8(s->pb) != 'H' ||
> > avio_r8(s->pb) != 'A' || avio_r8(s->pb) != 'V') {
> > +if (avio_feof(s->pb))
> > +return AVERROR_EOF;
> >  }
> >
> >  start = avio_tell(s->pb) - 4;
> > --
> > 2.30.0
> >
> > --
> Idan Freiberg Mobile: +972-52-2925213
> ___
> 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] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Nicolas George
Anton Khirnov (12021-01-18):
> This wasn't in the previous version IIRC, and does not seem reasonable
> to me.

It was added at my suggestion, AFAIK.

> For one thing, it adds a possibility of a tie, which was impossible with
> odd number of TC members.

Unless somebody abstains, which is always possible.

> For another, they are excluded from having a say precisely in those
> matters where they have most expertise.

And the matters where they are most biassed.

What we are talking about is called conflict of interest. Every
functioning institution has rules to prevent them. Let us not manage to
be a non-functioning institution from the get go.

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 1/3] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header

2021-01-18 Thread Nachiket Tarate
These will be used by HLS demuxer in case of SAMPLE-AES encryption/decryption.

Signed-off-by: Nachiket Tarate 
---
 libavcodec/adts_header.c |  1 +
 libavcodec/adts_header.h |  1 +
 libavcodec/adts_parser.c | 29 -
 libavcodec/adts_parser.h |  4 
 4 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/libavcodec/adts_header.c b/libavcodec/adts_header.c
index 0889820f8a..c6680b0fc8 100644
--- a/libavcodec/adts_header.c
+++ b/libavcodec/adts_header.c
@@ -66,6 +66,7 @@ int ff_adts_header_parse(GetBitContext *gbc, 
AACADTSHeaderInfo *hdr)
 hdr->sample_rate= avpriv_mpeg4audio_sample_rates[sr];
 hdr->samples= (rdb + 1) * 1024;
 hdr->bit_rate   = size * 8 * hdr->sample_rate / hdr->samples;
+hdr->frame_length  = size;
 
 return size;
 }
diff --git a/libavcodec/adts_header.h b/libavcodec/adts_header.h
index f615f6a9f9..c362ce46a5 100644
--- a/libavcodec/adts_header.h
+++ b/libavcodec/adts_header.h
@@ -34,6 +34,7 @@ typedef struct AACADTSHeaderInfo {
 uint8_t  sampling_index;
 uint8_t  chan_config;
 uint8_t  num_aac_frames;
+uint32_t frame_length;
 } AACADTSHeaderInfo;
 
 /**
diff --git a/libavcodec/adts_parser.c b/libavcodec/adts_parser.c
index 5c9f8ff6f2..3421d9fee8 100644
--- a/libavcodec/adts_parser.c
+++ b/libavcodec/adts_parser.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 
-#include "adts_header.h"
 #include "adts_parser.h"
 
 int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t 
*frames)
@@ -42,3 +41,31 @@ int av_adts_header_parse(const uint8_t *buf, uint32_t 
*samples, uint8_t *frames)
 return AVERROR(ENOSYS);
 #endif
 }
+
+int avpriv_adts_header_parse (AACADTSHeaderInfo **phdr, const uint8_t *buf, 
size_t size)
+{
+#if CONFIG_ADTS_HEADER
+int ret = 0;
+GetBitContext gb;
+
+if (size < AV_AAC_ADTS_HEADER_SIZE)
+return AVERROR_INVALIDDATA;
+
+if (!*phdr)
+*phdr = av_mallocz(sizeof(AACADTSHeaderInfo));
+if (!*phdr)
+return AVERROR(ENOMEM);
+
+ret = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE);
+if (ret < 0)
+return ret;
+
+ret = ff_adts_header_parse(&gb, *phdr);
+if (ret < 0)
+return ret;
+
+return 0;
+#else
+return AVERROR(ENOSYS);
+#endif
+}
diff --git a/libavcodec/adts_parser.h b/libavcodec/adts_parser.h
index f85becd131..faa6e47426 100644
--- a/libavcodec/adts_parser.h
+++ b/libavcodec/adts_parser.h
@@ -22,6 +22,8 @@
 #include 
 #include 
 
+#include "adts_header.h"
+
 #define AV_AAC_ADTS_HEADER_SIZE 7
 
 /**
@@ -34,4 +36,6 @@
 int av_adts_header_parse(const uint8_t *buf, uint32_t *samples,
  uint8_t *frames);
 
+int avpriv_adts_header_parse (AACADTSHeaderInfo **phdr, const uint8_t *buf, 
size_t size);
+
 #endif /* AVCODEC_ADTS_PARSER_H */
-- 
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".

Re: [FFmpeg-devel] [PATCH] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Ronald S. Bultje
Hi,

On Mon, Jan 18, 2021 at 1:25 PM Nicolas George  wrote:

> What we are talking about is called conflict of interest. Every
> functioning institution has rules to prevent them.


+1 on this.

Ronald
___
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] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Paul B Mahol
On Mon, Jan 18, 2021 at 7:49 PM Ronald S. Bultje  wrote:

> Hi,
>
> On Mon, Jan 18, 2021 at 1:25 PM Nicolas George  wrote:
>
> > What we are talking about is called conflict of interest. Every
> > functioning institution has rules to prevent them.
>
>
> +1 on this.
>

How do you want to prevent such conflicts of interest?


>
> Ronald
> ___
> 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 7/7] avformat/sbgdec: Reduce the amount of floating point in str_to_time()

2021-01-18 Thread Michael Niedermayer
On Sun, Jan 17, 2021 at 03:52:57PM +0100, Nicolas George wrote:
> Michael Niedermayer (12021-01-17):
> > Fixes: 1e+75 is outside the range of representable values of type 'long'
> > Fixes: 
> > 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6626834808700928
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/sbgdec.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> Should be ok.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire


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] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Anton Khirnov
Quoting Nicolas George (2021-01-18 19:25:39)
> Anton Khirnov (12021-01-18):
> > For another, they are excluded from having a say precisely in those
> > matters where they have most expertise.
> 
> And the matters where they are most biassed.
> 
> What we are talking about is called conflict of interest. Every
> functioning institution has rules to prevent them. Let us not manage to
> be a non-functioning institution from the get go.

How do you distinguish between "having a legitimate technical opinion"
from "being biased"? Seems to me it's purely in the eye of the beholder.

I don't think the notion of a conflict of interest applies here, since
TC members do not get any personal gain from it, other than being able
to steer the project direction. But since that is the entire point of
making someone a TC member, it makes no sense to take that power away
from them.

I have at some point touched most major pieces of code in the project.
I also have opinions on how many things should be done. So according to
your definition, that makes me biased and disqualified from voting on
almost anything, so there is no point in me being a TC member. Same
applies to Michael.

-- 
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 4/7] avformat/nistspheredec: Check bits_per_coded_sample and channels

2021-01-18 Thread Anton Khirnov
Quoting Michael Niedermayer (2021-01-17 00:07:26)
> Fixes: signed integer overflow: 80 * 92233009 cannot be represented in type 
> 'int'
> Fixes: 
> 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_NISTSPHERE_fuzzer-6669100654919680
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/nistspheredec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/nistspheredec.c b/libavformat/nistspheredec.c
> index 079369929f..fec5c88892 100644
> --- a/libavformat/nistspheredec.c
> +++ b/libavformat/nistspheredec.c
> @@ -80,7 +80,9 @@ static int nist_read_header(AVFormatContext *s)
>  
>  avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
>  
> -st->codecpar->block_align = st->codecpar->bits_per_coded_sample 
> * st->codecpar->channels / 8;
> +if (st->codecpar->bits_per_coded_sample * 
> (uint64_t)st->codecpar->channels / 8 > INT_MAX)
> +return AVERROR_INVALIDDATA;
> +st->codecpar->block_align = st->codecpar->bits_per_coded_sample 
> * (uint64_t)st->codecpar->channels / 8;
>  
>  if (avio_tell(s->pb) > header_size)
>  return AVERROR_INVALIDDATA;
> -- 
> 2.17.1

Both bits_per_coded_sample and channels seem to be arbitrary ints, so
you are assuming sizeof(int) < sizeof(int64)

-- 
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] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Ronald S. Bultje
Hi,

On Mon, Jan 18, 2021 at 2:55 PM Anton Khirnov  wrote:

> I have at some point touched most major pieces of code in the project.
> I also have opinions on how many things should be done. So according to
> your definition, that makes me biased and disqualified from voting on
> almost anything, so there is no point in me being a TC member. Same
> applies to Michael.


But neither disqualifies you. TC is invoked when a specific unresolvable
disagreement arises between two developers. A TC member should not vote if
he is one of these two people.

Or did you mean something else?

Ronald
___
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] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Anton Khirnov
Quoting Ronald S. Bultje (2021-01-18 21:12:50)
> Hi,
> 
> On Mon, Jan 18, 2021 at 2:55 PM Anton Khirnov  wrote:
> 
> > I have at some point touched most major pieces of code in the project.
> > I also have opinions on how many things should be done. So according to
> > your definition, that makes me biased and disqualified from voting on
> > almost anything, so there is no point in me being a TC member. Same
> > applies to Michael.
> 
> 
> But neither disqualifies you. TC is invoked when a specific unresolvable
> disagreement arises between two developers. A TC member should not vote if
> he is one of these two people.
> 
> Or did you mean something else?

Doesn't have to be two people. IIUC in the model situation there is a
disagreement on the mailing list where a consensus cannot be reached. So
potentially many people commenting. You could say that any one of them
is "involved".

-- 
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 2/3] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer

2021-01-18 Thread Anton Khirnov
Quoting Nachiket Tarate (2021-01-18 18:39:56)
> Apple HTTP Live Streaming Sample Encryption:
> 
> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
> 
> Signed-off-by: Nachiket Tarate 
> ---
>  libavformat/Makefile |   2 +-
>  libavformat/hls.c|  97 ++-
>  libavformat/hls_sample_aes.c | 497 +++
>  libavformat/hls_sample_aes.h |  64 +
>  libavformat/mpegts.c |  12 +
>  5 files changed, 658 insertions(+), 14 deletions(-)
>  create mode 100644 libavformat/hls_sample_aes.c
>  create mode 100644 libavformat/hls_sample_aes.h
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 3a8fbcbe5f..c97930d98b 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> diff --git a/libavformat/hls_sample_aes.c b/libavformat/hls_sample_aes.c
> new file mode 100644
> index 00..6094ea4ea6
> --- /dev/null
> +++ b/libavformat/hls_sample_aes.c
> @@ -0,0 +1,497 @@
> +void ff_hls_read_audio_setup_info(HLSAudioSetupInfo *info, const uint8_t 
> *buf, size_t size)
> +{
> +info->codec_tag   = AV_RL32(buf);
> +
> +if (!strncmp((const char*)&info->codec_tag, "zaac", 4))
> +info->codec_id = AV_CODEC_ID_AAC;
> +else if (!strncmp((const char*)&info->codec_tag, "zac3", 4))
> +info->codec_id = AV_CODEC_ID_AC3;
> +else if (!strncmp((const char*)&info->codec_tag, "zec3", 4))
> +info->codec_id = AV_CODEC_ID_EAC3;
> +else
> +info->codec_id = AV_CODEC_ID_NONE;
> +
> +buf += 4;
> +info->priming   = AV_RL16(buf);
> +buf += 2;
> +info->version   = *buf++;
> +info->setup_data_length = *buf++;
> +
> +memcpy(info->setup_data, buf, info->setup_data_length);

You are not checking buffer sizes, both for buf and setup_data.

> +}
> +
> +/*
> + * Parse 'dec3' EC3SpecificBox
> + */
> +static int parse_dec3(AC3HeaderInfo **phdr, const uint8_t *buf, size_t size)
> +{
> +GetBitContext gb;
> +AC3HeaderInfo *hdr;
> +int err;
> +
> +int data_rate, fscod, acmod, lfeon;
> +
> +if (!*phdr)

Will this check ever fail?


> +/*
> + * Remove start code emulation prevention 0x03 bytes
> + */
> +static void remove_scep_3_bytes (NALUnit *nalu)

Feels like we have 9001 instances of this kind of code. Can't any of
them be reused?

> +{
> +int i = 0;
> +int j = 0;
> +
> +uint8_t *data = nalu->data;
> +
> +while (i < nalu->length) {
> +if (nalu->length - i > 3 && data[i] == 0x00 && data[i+1] == 0x00 && 
> data[i+2] == 0x03 &&
> +(data[i+3] == 0x00 || data[i+3] == 0x01 || data[i+3] == 0x02 || 
> data[i+3] == 0x03)) {
> +data[j] = 0x00;
> +data[j+1] = 0x00;
> +data[j+2] = data[i+3];
> +i += 4;
> +j += 3;
> +} else {
> +data[j++] = data[i++];
> +}
> +}
> +
> +nalu->length = j;
> +}
> +
> +static int is_start_code (const uint8_t *buf, int zeros_in_start_code)
> +{
> +  int i;
> +
> +  for (i = 0; i < zeros_in_start_code; i++) {
> +if(*(buf++) != 0x00) {
> +  return 0;
> +}
> +  }
> +
> +  if(*buf != 0x01)
> +return 0;
> +
> +  return 1;
> +}
> +
> +static int get_next_nal_unit (AVParserContext *ctx, NALUnit *nalu)
> +{
> +int i;
> +  int len = 0;
> +int nalu_start_offset = 0;
> +
> +uint8_t *buf_out = ctx->buf_out;
> +
> +if (ctx->next_start_code_length != 0) {
> +for (i = 0; i < ctx->next_start_code_length - 1; i++) {
> +  *buf_out++ = 0;
> +  len++;
> +}
> +*buf_out++ = 1;
> +len++;
> +ctx->next_start_code_length = 0;
> +  } else {
> +while (ctx->buf_in < ctx->buf_end) {
> +  len++;
> +  if ((*buf_out++ = *ctx->buf_in++) != 0)
> +  break;
> +}
> +}
> +
> +if (ctx->buf_in >= ctx->buf_end) {
> +if (len == 0)
> +  return 0;
> +else
> +  return -1;
> +}
> +
> +/* No start code at the beginning of the NAL unit */
> +if(*(ctx->buf_in - 1) != 1 || len < 3) {
> +return -1;
> +}
> +
> +nalu_start_offset = len;
> +
> +while (ctx->next_start_code_length == 0) {
> +if (ctx->buf_in >= ctx->buf_end) {
> +nalu->data   = ctx->buf_out + nalu_start_offset;
> +nalu->length = len - nalu_start_offset;
> +nalu->type   = *nalu->data & 0x1F;
> +ctx->buf_out += nalu_start_offset;
> +return 0;
> +}
> +*buf_out++ = *ctx->buf_in++;
> +len++;
> +if (is_start_code(ctx->buf_in - 4, 3))
> +ctx->next_start_code_length = 4;
> +else if (is_start_code(ctx->buf_in - 3, 2))
> +ctx->next_start_code_length = 3;
> +else
> +ctx->next_start_code_length = 0;
> +}
> +
> +len -= ctx->next_start_code_length;
> +
> +nalu->data= ctx->buf_o

Re: [FFmpeg-devel] [PATCH 4/4] avcodec/flashsv2enc: factorize updating block dimensions

2021-01-18 Thread Marton Balint



On Mon, 18 Jan 2021, Anton Khirnov wrote:


Quoting Marton Balint (2021-01-10 02:20:45)

Signed-off-by: Marton Balint 
---
 libavcodec/flashsv2enc.c | 76 +---
 1 file changed, 32 insertions(+), 44 deletions(-)

diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c
index 6603d0ded1..5139b17a28 100644
--- a/libavcodec/flashsv2enc.c
+++ b/libavcodec/flashsv2enc.c
@@ -252,7 +259,7 @@ static av_cold int flashsv2_encode_init(AVCodecContext * 
avctx)
 s->use_custom_palette =  0;
 s->palette_type   = -1;// so that the palette will be 
generated in reconfigure_at_keyframe

-return 0;
+return update_block_dimensions(s, 64, 64);


This looks different from the original value. Why the change?


Block dimensions are recalculated on every keyframe, so it does not 
matter what the block width/height is after init. 64 is used 
because the current code always selects that (see the 
optimum_block_width/height functions).


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] avfilter/af_astats: fix possible crash because of undefined float to integer rounding

2021-01-18 Thread Marton Balint



On Sat, 16 Jan 2021, Marton Balint wrote:


Fixes ticket #9049.

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

diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index ebaae29f44..f50cbe199c 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -329,11 +329,11 @@ static inline void update_stat(AudioStatsContext *s, 
ChannelStats *p, double d,

drop = p->win_samples[p->win_pos];
p->win_samples[p->win_pos] = nd;
-index = av_clip(FFABS(av_clipd(nd, -1.0, 1.0)) * HISTOGRAM_MAX, 0, 
HISTOGRAM_MAX);
+index = av_clip(lrint(av_clipd(FFABS(nd), 0.0, 1.0) * HISTOGRAM_MAX), 0, 
HISTOGRAM_MAX);
p->max_index = FFMAX(p->max_index, index);
p->histogram[index]++;
if (!isnan(p->noise_floor))
-p->histogram[av_clip(FFABS(drop) * HISTOGRAM_MAX, 0, HISTOGRAM_MAX)]--;
+p->histogram[av_clip(lrint(av_clipd(FFABS(drop), 0.0, 1.0) * 
HISTOGRAM_MAX), 0, HISTOGRAM_MAX)]--;
p->win_pos++;

while (p->histogram[p->max_index] == 0)


Will apply soon.

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] [RFC][v2] Tech Resolution Process

2021-01-18 Thread Ronald S. Bultje
On Mon, Jan 18, 2021 at 3:33 PM Anton Khirnov  wrote:

> Quoting Ronald S. Bultje (2021-01-18 21:12:50)
> > Hi,
> >
> > On Mon, Jan 18, 2021 at 2:55 PM Anton Khirnov  wrote:
> >
> > > I have at some point touched most major pieces of code in the project.
> > > I also have opinions on how many things should be done. So according to
> > > your definition, that makes me biased and disqualified from voting on
> > > almost anything, so there is no point in me being a TC member. Same
> > > applies to Michael.
> >
> >
> > But neither disqualifies you. TC is invoked when a specific unresolvable
> > disagreement arises between two developers. A TC member should not vote
> if
> > he is one of these two people.
> >
> > Or did you mean something else?
>
> Doesn't have to be two people. IIUC in the model situation there is a
> disagreement on the mailing list where a consensus cannot be reached. So
> potentially many people commenting. You could say that any one of them
> is "involved".


I agree "involved" should be constrained to just be one of the two parties
bringing this up to the TC. And yes this can be gamed, everything can. It's
meant to prevent extreme cases, not make the world a perfect place. We
can't do that with rules alone.

Ronald
___
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/13] cbs_h2645: Merge SEI messages in common between codecs

2021-01-18 Thread Mark Thompson
Make a new template file for common SEI messages - this will also apply
to H.266.
---
 libavcodec/cbs_h264.h |  37 +--
 libavcodec/cbs_h2645.c|  24 +++--
 libavcodec/cbs_h264_syntax_template.c | 106 +---
 libavcodec/cbs_h265.h |  45 ++---
 libavcodec/cbs_h265_syntax_template.c | 135 --
 libavcodec/cbs_sei.h  |  60 
 libavcodec/cbs_sei_syntax_template.c  | 132 +
 libavcodec/h264_metadata_bsf.c|   2 +-
 libavcodec/vaapi_encode_h264.c|   2 +-
 libavcodec/vaapi_encode_h265.c|  11 ++-
 10 files changed, 250 insertions(+), 304 deletions(-)
 create mode 100644 libavcodec/cbs_sei.h
 create mode 100644 libavcodec/cbs_sei_syntax_template.c

diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index a6fe0a6af2..81113f1ad0 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -24,6 +24,7 @@
 
 #include "cbs.h"
 #include "cbs_h2645.h"
+#include "cbs_sei.h"
 #include "h264.h"
 
 
@@ -274,21 +275,6 @@ typedef struct H264RawSEIPanScanRect {
 uint16_t pan_scan_rect_repetition_period;
 } H264RawSEIPanScanRect;
 
-typedef struct H264RawSEIUserDataRegistered {
-uint8_t itu_t_t35_country_code;
-uint8_t itu_t_t35_country_code_extension_byte;
-uint8_t *data;
-AVBufferRef *data_ref;
-size_t   data_length;
-} H264RawSEIUserDataRegistered;
-
-typedef struct H264RawSEIUserDataUnregistered {
-uint8_t uuid_iso_iec_11578[16];
-uint8_t *data;
-AVBufferRef *data_ref;
-size_t   data_length;
-} H264RawSEIUserDataUnregistered;
-
 typedef struct H264RawSEIRecoveryPoint {
 uint16_t recovery_frame_cnt;
 uint8_t exact_match_flag;
@@ -305,19 +291,6 @@ typedef struct H264RawSEIDisplayOrientation {
 uint8_t display_orientation_extension_flag;
 } H264RawSEIDisplayOrientation;
 
-typedef struct H264RawSEIMasteringDisplayColourVolume {
-uint16_t display_primaries_x[3];
-uint16_t display_primaries_y[3];
-uint16_t white_point_x;
-uint16_t white_point_y;
-uint32_t max_display_mastering_luminance;
-uint32_t min_display_mastering_luminance;
-} H264RawSEIMasteringDisplayColourVolume;
-
-typedef struct H264RawSEIAlternativeTransferCharacteristics {
-uint8_t preferred_transfer_characteristics;
-} H264RawSEIAlternativeTransferCharacteristics;
-
 typedef struct H264RawSEIPayload {
 uint32_t payload_type;
 uint32_t payload_size;
@@ -326,12 +299,12 @@ typedef struct H264RawSEIPayload {
 H264RawSEIPicTiming pic_timing;
 H264RawSEIPanScanRect pan_scan_rect;
 // H264RawSEIFiller filler -> no fields.
-H264RawSEIUserDataRegistered user_data_registered;
-H264RawSEIUserDataUnregistered user_data_unregistered;
+SEIRawUserDataRegistered user_data_registered;
+SEIRawUserDataUnregistered user_data_unregistered;
 H264RawSEIRecoveryPoint recovery_point;
 H264RawSEIDisplayOrientation display_orientation;
-H264RawSEIMasteringDisplayColourVolume mastering_display_colour_volume;
-H264RawSEIAlternativeTransferCharacteristics
+SEIRawMasteringDisplayColourVolume mastering_display_colour_volume;
+SEIRawAlternativeTransferCharacteristics
 alternative_transfer_characteristics;
 struct {
 uint8_t *data;
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 550c059ef3..9e210abba4 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -253,9 +253,11 @@ static int 
cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t paylo
 return err; \
 } while (0)
 
-#define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
-#define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name)
-#define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name)
+#define FUNC_NAME2(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
+#define FUNC_NAME1(rw, codec, name) FUNC_NAME2(rw, codec, name)
+#define FUNC_H264(name) FUNC_NAME1(READWRITE, h264, name)
+#define FUNC_H265(name) FUNC_NAME1(READWRITE, h265, name)
+#define FUNC_SEI(name)  FUNC_NAME1(READWRITE, sei,  name)
 
 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ 
}) : NULL)
 
@@ -356,11 +358,15 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 name = name ## _ref->data; \
 } while (0)
 
-#define FUNC(name) FUNC_H264(READWRITE, name)
+#define FUNC(name) FUNC_SEI(name)
+#include "cbs_sei_syntax_template.c"
+#undef FUNC
+
+#define FUNC(name) FUNC_H264(name)
 #include "cbs_h264_syntax_template.c"
 #undef FUNC
 
-#define FUNC(name) FUNC_H265(READWRITE, name)
+#define FUNC(name) FUNC_H265(name)
 #include "cbs_h265_syntax_template.c"
 #undef FUNC
 
@@ -428,11 +434,15 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 } \
 } while (0)
 
-#define FUNC(name) FUNC_H264(READWRITE, name)
+#define FUNC(name) F

[FFmpeg-devel] [PATCH v2 08/13] h264_metadata_bsf: Use common cbs bsf implementation

2021-01-18 Thread Mark Thompson
---
 libavcodec/h264_metadata_bsf.c | 232 +++--
 1 file changed, 49 insertions(+), 183 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 71b49696cd..3e99283878 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -22,20 +22,13 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
-#include "bsf_internal.h"
 #include "cbs.h"
+#include "cbs_bsf.h"
 #include "cbs_h264.h"
 #include "h264.h"
 #include "h264_levels.h"
 #include "h264_sei.h"
 
-enum {
-PASS,
-INSERT,
-REMOVE,
-EXTRACT,
-};
-
 enum {
 FLIP_HORIZONTAL = 1,
 FLIP_VERTICAL   = 2,
@@ -47,11 +40,7 @@ enum {
 };
 
 typedef struct H264MetadataContext {
-const AVClass *class;
-
-CodedBitstreamContext *input;
-CodedBitstreamContext *output;
-CodedBitstreamFragment access_unit;
+CBSBSFContext common;
 
 int done_first_au;
 
@@ -333,49 +322,6 @@ static int h264_metadata_update_sps(AVBSFContext *bsf,
 return 0;
 }
 
-static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
-{
-H264MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *au = &ctx->access_unit;
-uint8_t *side_data;
-int side_data_size;
-int err, i;
-
-side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
-&side_data_size);
-if (!side_data_size)
-return 0;
-
-err = ff_cbs_read(ctx->input, au, side_data, side_data_size);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side 
data.\n");
-return err;
-}
-
-for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == H264_NAL_SPS) {
-err = h264_metadata_update_sps(bsf, au->units[i].content);
-if (err < 0)
-return err;
-}
-}
-
-err = ff_cbs_write_fragment_data(ctx->output, au);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side 
data.\n");
-return err;
-}
-
-side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, 
au->data_size);
-if (!side_data)
-return AVERROR(ENOMEM);
-memcpy(side_data, au->data, au->data_size);
-
-ff_cbs_fragment_reset(au);
-
-return 0;
-}
-
 static int h264_metadata_handle_display_orientation(AVBSFContext *bsf,
 AVPacket *pkt,
 CodedBitstreamFragment *au,
@@ -386,7 +332,7 @@ static int 
h264_metadata_handle_display_orientation(AVBSFContext *bsf,
 int err;
 
 message = NULL;
-while (ff_cbs_sei_find_message(ctx->output, au,
+while (ff_cbs_sei_find_message(ctx->common.output, au,
H264_SEI_TYPE_DISPLAY_ORIENTATION,
&message) == 0) {
 H264RawSEIDisplayOrientation *disp = message->payload;
@@ -415,13 +361,13 @@ static int 
h264_metadata_handle_display_orientation(AVBSFContext *bsf,
 }
 }
 
-if (ctx->display_orientation == REMOVE ||
-ctx->display_orientation == INSERT) {
-ff_cbs_sei_delete_message_type(ctx->output, au,
+if (ctx->display_orientation == BSF_ELEMENT_REMOVE ||
+ctx->display_orientation == BSF_ELEMENT_INSERT) {
+ff_cbs_sei_delete_message_type(ctx->common.output, au,
H264_SEI_TYPE_DISPLAY_ORIENTATION);
 }
 
-if (ctx->display_orientation == INSERT) {
+if (ctx->display_orientation == BSF_ELEMENT_INSERT) {
 H264RawSEIDisplayOrientation *disp =
 &ctx->display_orientation_payload;
 uint8_t *data;
@@ -495,7 +441,7 @@ static int 
h264_metadata_handle_display_orientation(AVBSFContext *bsf,
 if (write) {
 disp->display_orientation_repetition_period = 1;
 
-err = ff_cbs_sei_add_message(ctx->output, au, 1,
+err = ff_cbs_sei_add_message(ctx->common.output, au, 1,
  H264_SEI_TYPE_DISPLAY_ORIENTATION,
  disp, NULL);
 if (err < 0) {
@@ -509,41 +455,21 @@ static int 
h264_metadata_handle_display_orientation(AVBSFContext *bsf,
 return 0;
 }
 
-static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
+static int h264_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+ CodedBitstreamFragment *au)
 {
 H264MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *au = &ctx->access_unit;
 int err, i, has_sps, seek_point;
 
-err = ff_bsf_get_packet_ref(bsf, pkt);
-if (err < 0)
-return err;
-
-err = h264_metadata_update_side_data(bsf, pkt);
-if (err < 0)
-goto fail;
-
-err = ff_cbs_read_packet(ctx->input, au, pkt);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to rea

[FFmpeg-devel] [PATCH v2 04/13] cbs_sei: Remove restrictions on MDCV values

2021-01-18 Thread Mark Thompson
Since this was originally written the standards have changed to allow
arbitrary values here, but leaves their meaning unspecified.
---
 libavcodec/cbs_sei_syntax_template.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavcodec/cbs_sei_syntax_template.c 
b/libavcodec/cbs_sei_syntax_template.c
index 5f84246663..9114e61ff6 100644
--- a/libavcodec/cbs_sei_syntax_template.c
+++ b/libavcodec/cbs_sei_syntax_template.c
@@ -103,17 +103,15 @@ static int FUNC(mastering_display_colour_volume)
 HEADER("Mastering Display Colour Volume");
 
 for (c = 0; c < 3; c++) {
-us(16, display_primaries_x[c], 0, 5, 1, c);
-us(16, display_primaries_y[c], 0, 5, 1, c);
+ubs(16, display_primaries_x[c], 1, c);
+ubs(16, display_primaries_y[c], 1, c);
 }
 
-u(16, white_point_x, 0, 5);
-u(16, white_point_y, 0, 5);
+ub(16, white_point_x);
+ub(16, white_point_y);
 
-u(32, max_display_mastering_luminance,
-  1, MAX_UINT_BITS(32));
-u(32, min_display_mastering_luminance,
-  0, current->max_display_mastering_luminance - 1);
+ub(32, max_display_mastering_luminance);
+ub(32, min_display_mastering_luminance);
 
 return 0;
 }
-- 
2.29.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 v2 13/13] h264_redundant_pps_bsf: Use common cbs bsf implementation

2021-01-18 Thread Mark Thompson
---
 libavcodec/h264_redundant_pps_bsf.c | 99 ++---
 1 file changed, 21 insertions(+), 78 deletions(-)

diff --git a/libavcodec/h264_redundant_pps_bsf.c 
b/libavcodec/h264_redundant_pps_bsf.c
index cf41abe96c..6ba40291d5 100644
--- a/libavcodec/h264_redundant_pps_bsf.c
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -24,15 +24,13 @@
 #include "bsf.h"
 #include "bsf_internal.h"
 #include "cbs.h"
+#include "cbs_bsf.h"
 #include "cbs_h264.h"
 #include "h264.h"
 
 
 typedef struct H264RedundantPPSContext {
-CodedBitstreamContext *input;
-CodedBitstreamContext *output;
-
-CodedBitstreamFragment access_unit;
+CBSBSFContext common;
 
 int global_pic_init_qp;
 int current_pic_init_qp;
@@ -49,7 +47,7 @@ static int 
h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx,
 // 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);
+err = ff_cbs_make_unit_writable(ctx->common.input, unit);
 if (err < 0)
 return err;
 pps = unit->content;
@@ -78,21 +76,14 @@ static int 
h264_redundant_pps_fixup_slice(H264RedundantPPSContext *ctx,
 return 0;
 }
 
-static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt)
+static int h264_redundant_pps_update_fragment(AVBSFContext *bsf,
+  AVPacket *pkt,
+  CodedBitstreamFragment *au)
 {
 H264RedundantPPSContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *au = &ctx->access_unit;
 int au_has_sps;
 int err, i;
 
-err = ff_bsf_get_packet_ref(bsf, pkt);
-if (err < 0)
-return err;
-
-err = ff_cbs_read_packet(ctx->input, au, pkt);
-if (err < 0)
-goto fail;
-
 au_has_sps = 0;
 for (i = 0; i < au->nb_units; i++) {
 CodedBitstreamUnit *nal = &au->units[i];
@@ -102,7 +93,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 if (nal->type == H264_NAL_PPS) {
 err = h264_redundant_pps_fixup_pps(ctx, nal);
 if (err < 0)
-goto fail;
+return err;
 if (!au_has_sps) {
 av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS "
"at %"PRId64".\n", pkt->pts);
@@ -118,62 +109,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 }
 }
 
-err = ff_cbs_write_packet(ctx->output, pkt, au);
-if (err < 0)
-goto fail;
-
-err = 0;
-fail:
-ff_cbs_fragment_reset(au);
-if (err < 0)
-av_packet_unref(pkt);
-
-return err;
-}
-
-static int h264_redundant_pps_init(AVBSFContext *bsf)
-{
-H264RedundantPPSContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *au = &ctx->access_unit;
-int err, i;
-
-err = ff_cbs_init(&ctx->input, AV_CODEC_ID_H264, bsf);
-if (err < 0)
-return err;
-
-err = ff_cbs_init(&ctx->output, AV_CODEC_ID_H264, bsf);
-if (err < 0)
-return err;
-
-ctx->global_pic_init_qp = 26;
-
-if (bsf->par_in->extradata) {
-err = ff_cbs_read_extradata(ctx->input, au, bsf->par_in);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
-goto fail;
-}
-
-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]);
-if (err < 0)
-goto fail;
-}
-}
-
-ctx->extradata_pic_init_qp = ctx->current_pic_init_qp;
-err = ff_cbs_write_extradata(ctx->output, bsf->par_out, au);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
-goto fail;
-}
-}
-
-err = 0;
-fail:
-ff_cbs_fragment_reset(au);
-return err;
+return 0;
 }
 
 static void h264_redundant_pps_flush(AVBSFContext *bsf)
@@ -182,13 +118,20 @@ static void h264_redundant_pps_flush(AVBSFContext *bsf)
 ctx->current_pic_init_qp = ctx->extradata_pic_init_qp;
 }
 
-static void h264_redundant_pps_close(AVBSFContext *bsf)
+static const CBSBSFType h264_redundant_pps_type = {
+.codec_id= AV_CODEC_ID_H264,
+.fragment_name   = "access unit",
+.unit_name   = "NAL unit",
+.update_fragment = &h264_redundant_pps_update_fragment,
+};
+
+static int h264_redundant_pps_init(AVBSFContext *bsf)
 {
 H264RedundantPPSContext *ctx = bsf->priv_data;
 
-ff_cbs_fragment_free(&ctx->access_unit);
-ff_cbs_close(&ctx->input);
-ff_cbs_close(&ctx->output);
+ctx->global_pic_init_qp = 26;
+
+return ff_cbs_bsf_generic_init(bsf, &h264_redundant_pps_type);
 }
 
 static const enum AVCodecID h264_redundant_pps_codec_ids[] = {
@@ -200,7 +143,

Re: [FFmpeg-devel] [PATCH v4 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-01-18 Thread Tomas Härdin
lör 2021-01-16 klockan 08:43 +0800 skrev lance.lmw...@gmail.com:
> On Fri, Jan 15, 2021 at 09:43:58PM +0100, Marton Balint wrote:
> > 
> > On Fri, 15 Jan 2021, Tomas Härdin wrote:
> > > Again, why? If you have a company that maintains a fork of FFmpeg then
> > > compile that info in here instead. Compare with FFmbc which always puts
> > > "FFmbc" as CompanyName.
> > 
> > And how can a product based on libavformat set the company name, product
> > name and product version? It seems a valid use case for me that these are
> > overridable. Also note that this product version is only the "user friendly"
> > version string, for the numeric version still LIBAVFORMAT_VERSION values are
> > used.
> 
> Yes, my use case is the product is using libavformat as library, so it's
> prefer to have way to override these information as requirements.

What I'm worried about here is that we're going to get files which
claim to have been written by something other than libavformat. I've
had situations like this before, and it is a source of headache. For 
example, if mxfenc writes some field incorrectly then this might cause
us to hack mxfdec to accept that field instead of fixing mxfenc.

/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 v2 09/13] h265_metadata_bsf: Use common cbs bsf implementation

2021-01-18 Thread Mark Thompson
---
 libavcodec/h265_metadata_bsf.c | 191 -
 1 file changed, 22 insertions(+), 169 deletions(-)

diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index 504a75dac2..4be41932bb 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -20,29 +20,19 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
-#include "bsf_internal.h"
 #include "cbs.h"
+#include "cbs_bsf.h"
 #include "cbs_h265.h"
 #include "hevc.h"
 #include "h265_profile_level.h"
 
-enum {
-PASS,
-INSERT,
-REMOVE,
-};
-
 enum {
 LEVEL_UNSET = -2,
 LEVEL_AUTO  = -1,
 };
 
 typedef struct H265MetadataContext {
-const AVClass *class;
-
-CodedBitstreamContext *input;
-CodedBitstreamContext *output;
-CodedBitstreamFragment access_unit;
+CBSBSFContext common;
 
 H265RawAUD aud_nal;
 
@@ -338,89 +328,18 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
 return 0;
 }
 
-static int h265_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
-{
-H265MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *au = &ctx->access_unit;
-uint8_t *side_data;
-int side_data_size;
-int err, i;
-
-side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
-&side_data_size);
-if (!side_data_size)
-return 0;
-
-err = ff_cbs_read(ctx->input, au, side_data, side_data_size);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side 
data.\n");
-return err;
-}
-
-if (ctx->level == LEVEL_AUTO && !ctx->level_guess)
-h265_metadata_guess_level(bsf, au);
-
-for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == HEVC_NAL_VPS) {
-err = h265_metadata_update_vps(bsf, au->units[i].content);
-if (err < 0)
-return err;
-}
-if (au->units[i].type == HEVC_NAL_SPS) {
-err = h265_metadata_update_sps(bsf, au->units[i].content);
-if (err < 0)
-return err;
-}
-}
-
-err = ff_cbs_write_fragment_data(ctx->output, au);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side 
data.\n");
-return err;
-}
-
-side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, 
au->data_size);
-if (!side_data)
-return AVERROR(ENOMEM);
-memcpy(side_data, au->data, au->data_size);
-
-ff_cbs_fragment_reset(au);
-
-return 0;
-}
-
-static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
+static int h265_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+ CodedBitstreamFragment *au)
 {
 H265MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *au = &ctx->access_unit;
 int err, i;
 
-err = ff_bsf_get_packet_ref(bsf, pkt);
-if (err < 0)
-return err;
-
-err = h265_metadata_update_side_data(bsf, pkt);
-if (err < 0)
-goto fail;
-
-err = ff_cbs_read_packet(ctx->input, au, pkt);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
-goto fail;
-}
-
-if (au->nb_units == 0) {
-av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n");
-err = AVERROR_INVALIDDATA;
-goto fail;
-}
-
 // If an AUD is present, it must be the first NAL unit.
 if (au->units[0].type == HEVC_NAL_AUD) {
-if (ctx->aud == REMOVE)
+if (ctx->aud == BSF_ELEMENT_REMOVE)
 ff_cbs_delete_unit(au, 0);
 } else {
-if (ctx->aud == INSERT) {
+if (pkt && ctx->aud == BSF_ELEMENT_INSERT) {
 H265RawAUD *aud = &ctx->aud_nal;
 int pic_type = 0, temporal_id = 8, layer_id = 0;
 
@@ -453,7 +372,7 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket 
*pkt)
 err = ff_cbs_insert_unit_content(au, 0, HEVC_NAL_AUD, aud, NULL);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
-goto fail;
+return err;
 }
 }
 }
@@ -465,101 +384,35 @@ static int h265_metadata_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 if (au->units[i].type == HEVC_NAL_VPS) {
 err = h265_metadata_update_vps(bsf, au->units[i].content);
 if (err < 0)
-goto fail;
+return err;
 }
 if (au->units[i].type == HEVC_NAL_SPS) {
 err = h265_metadata_update_sps(bsf, au->units[i].content);
 if (err < 0)
-goto fail;
+return err;
 }
 }
 
-err = ff_cbs_write_packet(ctx->output, pkt, au);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
-goto fail;
-}
-
-err = 0;
-fail:
-ff_cbs_fragment_reset(au);
-
-if (err < 0)
-av_

[FFmpeg-devel] [PATCH v2 03/13] cbs_h2645: Merge SEI message handling in common between codecs

2021-01-18 Thread Mark Thompson
---
 libavcodec/Makefile   |   4 +-
 libavcodec/cbs_h264.h |  50 +---
 libavcodec/cbs_h2645.c| 300 +++--
 libavcodec/cbs_h264_syntax_template.c | 173 +---
 libavcodec/cbs_h265.h |  33 +--
 libavcodec/cbs_h265_syntax_template.c | 271 +++
 libavcodec/cbs_sei.c  | 369 ++
 libavcodec/cbs_sei.h  | 255 ++
 libavcodec/cbs_sei_syntax_template.c  | 215 +--
 libavcodec/h264_metadata_bsf.c| 113 
 libavcodec/vaapi_encode_h264.c|  51 ++--
 libavcodec/vaapi_encode_h265.c|  38 +--
 12 files changed, 1107 insertions(+), 765 deletions(-)
 create mode 100644 libavcodec/cbs_sei.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 446e6e6b3b..1fcb94fa48 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -71,8 +71,8 @@ OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o
 OBJS-$(CONFIG_CABAC)   += cabac.o
 OBJS-$(CONFIG_CBS) += cbs.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
-OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o
-OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index 81113f1ad0..9eb97eae24 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -291,34 +291,9 @@ typedef struct H264RawSEIDisplayOrientation {
 uint8_t display_orientation_extension_flag;
 } H264RawSEIDisplayOrientation;
 
-typedef struct H264RawSEIPayload {
-uint32_t payload_type;
-uint32_t payload_size;
-union {
-H264RawSEIBufferingPeriod buffering_period;
-H264RawSEIPicTiming pic_timing;
-H264RawSEIPanScanRect pan_scan_rect;
-// H264RawSEIFiller filler -> no fields.
-SEIRawUserDataRegistered user_data_registered;
-SEIRawUserDataUnregistered user_data_unregistered;
-H264RawSEIRecoveryPoint recovery_point;
-H264RawSEIDisplayOrientation display_orientation;
-SEIRawMasteringDisplayColourVolume mastering_display_colour_volume;
-SEIRawAlternativeTransferCharacteristics
-alternative_transfer_characteristics;
-struct {
-uint8_t *data;
-AVBufferRef *data_ref;
-size_t   data_length;
-} other;
-} payload;
-} H264RawSEIPayload;
-
 typedef struct H264RawSEI {
 H264RawNALUnitHeader nal_unit_header;
-
-H264RawSEIPayload payload[H264_MAX_SEI_PAYLOADS];
-uint8_t payload_count;
+SEIRawMessageListmessage_list;
 } H264RawSEI;
 
 typedef struct H264RawSliceHeader {
@@ -438,27 +413,4 @@ typedef struct CodedBitstreamH264Context {
 uint8_t last_slice_nal_unit_type;
 } CodedBitstreamH264Context;
 
-
-/**
- * Add an SEI message to an access unit.
- *
- * On success, the payload will be owned by a unit in access_unit;
- * on failure, the content of the payload will be freed.
- */
-int ff_cbs_h264_add_sei_message(CodedBitstreamFragment *access_unit,
-H264RawSEIPayload *payload);
-
-/**
- * Delete an SEI message from an access unit.
- *
- * Deletes from nal_unit, which must be an SEI NAL unit.  If this is the
- * last message in nal_unit, also deletes it from access_unit.
- *
- * Requires nal_unit to be a unit in access_unit and position to be >= 0
- * and < the payload count of the SEI nal_unit.
- */
-void ff_cbs_h264_delete_sei_message(CodedBitstreamFragment *access_unit,
-CodedBitstreamUnit *nal_unit,
-int position);
-
 #endif /* AVCODEC_CBS_H264_H */
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 9e210abba4..6005d46e0d 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -348,6 +348,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
 
 #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw))
 
+#define bit_position(rw)   (get_bits_count(rw))
 #define byte_alignment(rw) (get_bits_count(rw) % 8)
 
 #define allocate(name, size) do { \
@@ -379,6 +380,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
 #undef xse
 #undef infer
 #undef more_rbsp_data
+#undef bit_position
 #undef byte_alignment
 #undef allocate
 
@@ -424,6 +426,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
 
 #define more_rbsp_data(var) (var)
 
+#define bit_position(rw)   (put_bits_count(rw))
 #define byte_alignment(rw) (put_bits_count(rw) % 8)
 
 #define allocate(name, size) do { \
@@ -460,6 +463,7 @@ static int cbs_h2

[FFmpeg-devel] [PATCH v2 05/13] h264_metadata_bsf: Refactor the filter function into smaller parts

2021-01-18 Thread Mark Thompson
---
 libavcodec/h264_metadata_bsf.c | 326 ++---
 1 file changed, 180 insertions(+), 146 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 4ab97aee3a..36f8aab245 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -56,6 +56,7 @@ typedef struct H264MetadataContext {
 int done_first_au;
 
 int aud;
+H264RawAUD aud_nal;
 
 AVRational sample_aspect_ratio;
 
@@ -91,6 +92,59 @@ typedef struct H264MetadataContext {
 } H264MetadataContext;
 
 
+static int h264_metadata_insert_aud(AVBSFContext *bsf,
+CodedBitstreamFragment *au)
+{
+H264MetadataContext *ctx = bsf->priv_data;
+int primary_pic_type_mask = 0xff;
+int err, i, j;
+
+static const int primary_pic_type_table[] = {
+0x084, // 2, 7
+0x0a5, // 0, 2, 5, 7
+0x0e7, // 0, 1, 2, 5, 6, 7
+0x210, // 4, 9
+0x318, // 3, 4, 8, 9
+0x294, // 2, 4, 7, 9
+0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9
+0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
+};
+
+for (i = 0; i < au->nb_units; i++) {
+if (au->units[i].type == H264_NAL_SLICE ||
+au->units[i].type == H264_NAL_IDR_SLICE) {
+H264RawSlice *slice = au->units[i].content;
+for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) {
+if (!(primary_pic_type_table[j] &
+  (1 << slice->header.slice_type)))
+primary_pic_type_mask &= ~(1 << j);
+}
+}
+}
+for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++)
+if (primary_pic_type_mask & (1 << j))
+break;
+if (j >= FF_ARRAY_ELEMS(primary_pic_type_table)) {
+av_log(bsf, AV_LOG_ERROR, "No usable primary_pic_type: "
+   "invalid slice types?\n");
+return AVERROR_INVALIDDATA;
+}
+
+ctx->aud_nal = (H264RawAUD) {
+.nal_unit_header.nal_unit_type = H264_NAL_AUD,
+.primary_pic_type = j,
+};
+
+err = ff_cbs_insert_unit_content(au, 0, H264_NAL_AUD,
+ &ctx->aud_nal, NULL);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
+return err;
+}
+
+return 0;
+}
+
 static int h264_metadata_update_sps(AVBSFContext *bsf,
 H264RawSPS *sps)
 {
@@ -322,160 +376,51 @@ static int h264_metadata_update_side_data(AVBSFContext 
*bsf, AVPacket *pkt)
 return 0;
 }
 
-static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
+static int h264_metadata_handle_display_orientation(AVBSFContext *bsf,
+AVPacket *pkt,
+CodedBitstreamFragment *au,
+int seek_point)
 {
 H264MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *au = &ctx->access_unit;
-int err, i, j, has_sps;
-H264RawAUD aud;
-
-err = ff_bsf_get_packet_ref(bsf, pkt);
-if (err < 0)
-return err;
-
-err = h264_metadata_update_side_data(bsf, pkt);
-if (err < 0)
-goto fail;
-
-err = ff_cbs_read_packet(ctx->input, au, pkt);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
-goto fail;
-}
-
-if (au->nb_units == 0) {
-av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n");
-err = AVERROR_INVALIDDATA;
-goto fail;
-}
-
-// If an AUD is present, it must be the first NAL unit.
-if (au->units[0].type == H264_NAL_AUD) {
-if (ctx->aud == REMOVE)
-ff_cbs_delete_unit(au, 0);
-} else {
-if (ctx->aud == INSERT) {
-static const int primary_pic_type_table[] = {
-0x084, // 2, 7
-0x0a5, // 0, 2, 5, 7
-0x0e7, // 0, 1, 2, 5, 6, 7
-0x210, // 4, 9
-0x318, // 3, 4, 8, 9
-0x294, // 2, 4, 7, 9
-0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9
-0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
-};
-int primary_pic_type_mask = 0xff;
-
-for (i = 0; i < au->nb_units; i++) {
-if (au->units[i].type == H264_NAL_SLICE ||
-au->units[i].type == H264_NAL_IDR_SLICE) {
-H264RawSlice *slice = au->units[i].content;
-for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); 
j++) {
- if (!(primary_pic_type_table[j] &
-   (1 << slice->header.slice_type)))
- primary_pic_type_mask &= ~(1 << j);
-}
-}
-}
-for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++)
-if (primary_pic_type_mask & (1 << j))
-break;
-

[FFmpeg-devel] [PATCH v2 12/13] av1_metadata_bsf: Use common cbs bsf implementation

2021-01-18 Thread Mark Thompson
---
 libavcodec/av1_metadata_bsf.c | 176 --
 1 file changed, 21 insertions(+), 155 deletions(-)

diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index 3158ba995b..6114dd6b31 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -20,22 +20,12 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
-#include "bsf_internal.h"
 #include "cbs.h"
+#include "cbs_bsf.h"
 #include "cbs_av1.h"
 
-enum {
-PASS,
-INSERT,
-REMOVE,
-};
-
 typedef struct AV1MetadataContext {
-const AVClass *class;
-
-CodedBitstreamContext *input;
-CodedBitstreamContext *output;
-CodedBitstreamFragment access_unit;
+CBSBSFContext common;
 
 int td;
 
@@ -113,91 +103,27 @@ static int 
av1_metadata_update_sequence_header(AVBSFContext *bsf,
 return 0;
 }
 
-static int av1_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
+static int av1_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+CodedBitstreamFragment *frag)
 {
 AV1MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *frag = &ctx->access_unit;
-uint8_t *side_data;
-int side_data_size;
-int err, i;
-
-side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
-&side_data_size);
-if (!side_data_size)
-return 0;
-
-err = ff_cbs_read(ctx->input, frag, side_data, side_data_size);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side 
data.\n");
-return err;
-}
-
-for (i = 0; i < frag->nb_units; i++) {
-if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) {
-AV1RawOBU *obu = frag->units[i].content;
-err = av1_metadata_update_sequence_header(bsf, 
&obu->obu.sequence_header);
-if (err < 0)
-return err;
-}
-}
-
-err = ff_cbs_write_fragment_data(ctx->output, frag);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side 
data.\n");
-return err;
-}
-
-side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, 
frag->data_size);
-if (!side_data)
-return AVERROR(ENOMEM);
-memcpy(side_data, frag->data, frag->data_size);
-
-ff_cbs_fragment_reset(frag);
-
-return 0;
-}
-
-static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
-{
-AV1MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *frag = &ctx->access_unit;
 AV1RawOBU td, *obu;
 int err, i;
 
-err = ff_bsf_get_packet_ref(bsf, pkt);
-if (err < 0)
-return err;
-
-err = av1_metadata_update_side_data(bsf, pkt);
-if (err < 0)
-goto fail;
-
-err = ff_cbs_read_packet(ctx->input, frag, pkt);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
-goto fail;
-}
-
-if (frag->nb_units == 0) {
-av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n");
-err = AVERROR_INVALIDDATA;
-goto fail;
-}
-
 for (i = 0; i < frag->nb_units; i++) {
 if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) {
 obu = frag->units[i].content;
 err = av1_metadata_update_sequence_header(bsf, 
&obu->obu.sequence_header);
 if (err < 0)
-goto fail;
+return err;
 }
 }
 
 // If a Temporal Delimiter is present, it must be the first OBU.
 if (frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) {
-if (ctx->td == REMOVE)
+if (ctx->td == BSF_ELEMENT_REMOVE)
 ff_cbs_delete_unit(frag, 0);
-} else if (ctx->td == INSERT) {
+} else if (pkt && ctx->td == BSF_ELEMENT_INSERT) {
 td = (AV1RawOBU) {
 .header.obu_type = AV1_OBU_TEMPORAL_DELIMITER,
 };
@@ -206,7 +132,7 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket 
*pkt)
  &td, NULL);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "Failed to insert Temporal 
Delimiter.\n");
-goto fail;
+return err;
 }
 }
 
@@ -217,86 +143,26 @@ static int av1_metadata_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 }
 }
 
-err = ff_cbs_write_packet(ctx->output, pkt, frag);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
-goto fail;
-}
-
-err = 0;
-fail:
-ff_cbs_fragment_reset(frag);
-
-if (err < 0)
-av_packet_unref(pkt);
-
-return err;
+return 0;
 }
 
-static int av1_metadata_init(AVBSFContext *bsf)
-{
-AV1MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *frag = &ctx->access_unit;
-AV1RawOBU *obu;
-int err, i;
-
-err = ff_cbs_init(&ctx->input, AV_CODEC_ID_AV1, bsf);
-if (err < 0)
-return err;
-err = ff_cbs_init(&ctx->output, AV_CODEC_ID_A

[FFmpeg-devel] [PATCH v2 06/13] h264_metadata_bsf: Improve interpretation of input display matrices

2021-01-18 Thread Mark Thompson
The previous code here only worked in more limited cases.
---
 libavcodec/h264_metadata_bsf.c | 44 +++---
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 36f8aab245..71b49696cd 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -431,23 +431,39 @@ static int 
h264_metadata_handle_display_orientation(AVBSFContext *bsf,
 data = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size);
 if (data && size >= 9 * sizeof(int32_t)) {
 int32_t matrix[9];
-int hflip, vflip;
-double angle;
+double dmatrix[9];
+int hflip, vflip, i;
+double scale_x, scale_y, angle;
 
 memcpy(matrix, data, sizeof(matrix));
 
-hflip = vflip = 0;
-if (matrix[0] < 0 && matrix[4] > 0)
-hflip = 1;
-else if (matrix[0] > 0 && matrix[4] < 0)
-vflip = 1;
-av_display_matrix_flip(matrix, hflip, vflip);
+for (i = 0; i < 9; i++)
+dmatrix[i] = matrix[i] / 65536.0;
+
+// Extract scale factors.
+scale_x = hypot(dmatrix[0], dmatrix[3]);
+scale_y = hypot(dmatrix[1], dmatrix[4]);
+
+// Select flips to make the main diagonal positive.
+hflip = dmatrix[0] < 0.0;
+vflip = dmatrix[4] < 0.0;
+if (hflip)
+scale_x = -scale_x;
+if (vflip)
+scale_y = -scale_y;
+
+// Rescale.
+for (i = 0; i < 9; i += 3) {
+dmatrix[i] /= scale_x;
+dmatrix[i + 1] /= scale_y;
+}
 
-angle = av_display_rotation_get(matrix);
+// Extract rotation.
+angle = atan2(dmatrix[3], dmatrix[0]);
 
-if (!(angle >= -180.0 && angle <= 180.0 /* also excludes NaN */) ||
-matrix[2] != 0 || matrix[5] != 0 ||
-matrix[6] != 0 || matrix[7] != 0) {
+if (!(angle >= -M_PI && angle <= M_PI) ||
+matrix[2] != 0.0 || matrix[5] != 0.0 ||
+matrix[6] != 0.0 || matrix[7] != 0.0) {
 av_log(bsf, AV_LOG_WARNING, "Input display matrix is not "
"representable in H.264 parameters.\n");
 } else {
@@ -455,8 +471,8 @@ static int 
h264_metadata_handle_display_orientation(AVBSFContext *bsf,
 disp->ver_flip = vflip;
 disp->anticlockwise_rotation =
 (uint16_t)rint((angle >= 0.0 ? angle
- : angle + 360.0) *
-   65536.0 / 360.0);
+ : angle + 2 * M_PI) *
+   32768.0 / M_PI);
 write = 1;
 }
 }
-- 
2.29.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 v2 11/13] vp9_metadata_bsf: Use common cbs bsf implementation

2021-01-18 Thread Mark Thompson
---
 libavcodec/vp9_metadata_bsf.c | 61 +--
 1 file changed, 16 insertions(+), 45 deletions(-)

diff --git a/libavcodec/vp9_metadata_bsf.c b/libavcodec/vp9_metadata_bsf.c
index 00a5580c4d..d904a0088d 100644
--- a/libavcodec/vp9_metadata_bsf.c
+++ b/libavcodec/vp9_metadata_bsf.c
@@ -21,15 +21,12 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
-#include "bsf_internal.h"
 #include "cbs.h"
+#include "cbs_bsf.h"
 #include "cbs_vp9.h"
 
 typedef struct VP9MetadataContext {
-const AVClass *class;
-
-CodedBitstreamContext *cbc;
-CodedBitstreamFragment fragment;
+CBSBSFContext common;
 
 int color_space;
 int color_range;
@@ -38,21 +35,11 @@ typedef struct VP9MetadataContext {
 } VP9MetadataContext;
 
 
-static int vp9_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
+static int vp9_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+CodedBitstreamFragment *frag)
 {
 VP9MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *frag = &ctx->fragment;
-int err, i;
-
-err = ff_bsf_get_packet_ref(bsf, pkt);
-if (err < 0)
-return err;
-
-err = ff_cbs_read_packet(ctx->cbc, frag, pkt);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
-goto fail;
-}
+int i;
 
 for (i = 0; i < frag->nb_units; i++) {
 VP9RawFrame *frame = frag->units[i].content;
@@ -90,35 +77,19 @@ static int vp9_metadata_filter(AVBSFContext *bsf, AVPacket 
*pkt)
 }
 }
 
-err = ff_cbs_write_packet(ctx->cbc, pkt, frag);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
-goto fail;
-}
-
-err = 0;
-fail:
-ff_cbs_fragment_reset(frag);
-
-if (err < 0)
-av_packet_unref(pkt);
-
-return err;
+return 0;
 }
 
-static int vp9_metadata_init(AVBSFContext *bsf)
-{
-VP9MetadataContext *ctx = bsf->priv_data;
-
-return ff_cbs_init(&ctx->cbc, AV_CODEC_ID_VP9, bsf);
-}
+static const CBSBSFType vp9_metadata_type = {
+.codec_id= AV_CODEC_ID_VP9,
+.fragment_name   = "superframe",
+.unit_name   = "frame",
+.update_fragment = &vp9_metadata_update_fragment,
+};
 
-static void vp9_metadata_close(AVBSFContext *bsf)
+static int vp9_metadata_init(AVBSFContext *bsf)
 {
-VP9MetadataContext *ctx = bsf->priv_data;
-
-ff_cbs_fragment_free(&ctx->fragment);
-ff_cbs_close(&ctx->cbc);
+return ff_cbs_bsf_generic_init(bsf, &vp9_metadata_type);
 }
 
 #define OFFSET(x) offsetof(VP9MetadataContext, x)
@@ -169,7 +140,7 @@ const AVBitStreamFilter ff_vp9_metadata_bsf = {
 .priv_data_size = sizeof(VP9MetadataContext),
 .priv_class = &vp9_metadata_class,
 .init   = &vp9_metadata_init,
-.close  = &vp9_metadata_close,
-.filter = &vp9_metadata_filter,
+.close  = &ff_cbs_bsf_generic_close,
+.filter = &ff_cbs_bsf_generic_filter,
 .codec_ids  = vp9_metadata_codec_ids,
 };
-- 
2.29.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 v2 10/13] mpeg2_metadata_bsf: Use common cbs bsf implementation

2021-01-18 Thread Mark Thompson
This also adds support for updating new extradata.
---
 libavcodec/mpeg2_metadata_bsf.c | 94 +
 1 file changed, 12 insertions(+), 82 deletions(-)

diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c
index d0048c0e25..11b46c0ae3 100644
--- a/libavcodec/mpeg2_metadata_bsf.c
+++ b/libavcodec/mpeg2_metadata_bsf.c
@@ -21,16 +21,13 @@
 #include "libavutil/opt.h"
 
 #include "bsf.h"
-#include "bsf_internal.h"
 #include "cbs.h"
+#include "cbs_bsf.h"
 #include "cbs_mpeg2.h"
 #include "mpeg12.h"
 
 typedef struct MPEG2MetadataContext {
-const AVClass *class;
-
-CodedBitstreamContext *cbc;
-CodedBitstreamFragment fragment;
+CBSBSFContext common;
 
 MPEG2RawExtensionData sequence_display_extension;
 
@@ -48,6 +45,7 @@ typedef struct MPEG2MetadataContext {
 
 
 static int mpeg2_metadata_update_fragment(AVBSFContext *bsf,
+  AVPacket *pkt,
   CodedBitstreamFragment *frag)
 {
 MPEG2MetadataContext *ctx = bsf->priv_data;
@@ -170,49 +168,16 @@ static int mpeg2_metadata_update_fragment(AVBSFContext 
*bsf,
 return 0;
 }
 
-static int mpeg2_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
-{
-MPEG2MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *frag = &ctx->fragment;
-int err;
-
-err = ff_bsf_get_packet_ref(bsf, pkt);
-if (err < 0)
-return err;
-
-err = ff_cbs_read_packet(ctx->cbc, frag, pkt);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
-goto fail;
-}
-
-err = mpeg2_metadata_update_fragment(bsf, frag);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to update frame fragment.\n");
-goto fail;
-}
-
-err = ff_cbs_write_packet(ctx->cbc, pkt, frag);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
-goto fail;
-}
-
-err = 0;
-fail:
-ff_cbs_fragment_reset(frag);
-
-if (err < 0)
-av_packet_unref(pkt);
-
-return err;
-}
+static const CBSBSFType mpeg2_metadata_type = {
+.codec_id= AV_CODEC_ID_MPEG2VIDEO,
+.fragment_name   = "frame",
+.unit_name   = "start code",
+.update_fragment = &mpeg2_metadata_update_fragment,
+};
 
 static int mpeg2_metadata_init(AVBSFContext *bsf)
 {
 MPEG2MetadataContext *ctx = bsf->priv_data;
-CodedBitstreamFragment *frag = &ctx->fragment;
-int err;
 
 #define VALIDITY_CHECK(name) do { \
 if (!ctx->name) { \
@@ -226,42 +191,7 @@ static int mpeg2_metadata_init(AVBSFContext *bsf)
 VALIDITY_CHECK(matrix_coefficients);
 #undef VALIDITY_CHECK
 
-err = ff_cbs_init(&ctx->cbc, AV_CODEC_ID_MPEG2VIDEO, bsf);
-if (err < 0)
-return err;
-
-if (bsf->par_in->extradata) {
-err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
-goto fail;
-}
-
-err = mpeg2_metadata_update_fragment(bsf, frag);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to update metadata fragment.\n");
-goto fail;
-}
-
-err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, frag);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
-goto fail;
-}
-}
-
-err = 0;
-fail:
-ff_cbs_fragment_reset(frag);
-return err;
-}
-
-static void mpeg2_metadata_close(AVBSFContext *bsf)
-{
-MPEG2MetadataContext *ctx = bsf->priv_data;
-
-ff_cbs_fragment_free(&ctx->fragment);
-ff_cbs_close(&ctx->cbc);
+return ff_cbs_bsf_generic_init(bsf, &mpeg2_metadata_type);
 }
 
 #define OFFSET(x) offsetof(MPEG2MetadataContext, x)
@@ -307,7 +237,7 @@ const AVBitStreamFilter ff_mpeg2_metadata_bsf = {
 .priv_data_size = sizeof(MPEG2MetadataContext),
 .priv_class = &mpeg2_metadata_class,
 .init   = &mpeg2_metadata_init,
-.close  = &mpeg2_metadata_close,
-.filter = &mpeg2_metadata_filter,
+.close  = &ff_cbs_bsf_generic_close,
+.filter = &ff_cbs_bsf_generic_filter,
 .codec_ids  = mpeg2_metadata_codec_ids,
 };
-- 
2.29.2

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

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

Re: [FFmpeg-devel] [PATCH 1/5] avformat/mov: Check a.size before computing next_root_atom

2021-01-18 Thread Michael Niedermayer
On Sun, Nov 29, 2020 at 01:03:33AM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 64 + 9223372036854775799 cannot be 
> represented in type 'long'
> Fixes: 
> 27563/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6244650163372032
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mov.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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 2/5] avutil/timecode: Avoid undefined behavior with large framenum

2021-01-18 Thread Michael Niedermayer
On Sun, Nov 29, 2020 at 01:03:34AM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147462079 + 2149596 cannot be represented in 
> type 'int'
> Fixes: 
> 27565/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5091972813160448
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavutil/timecode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


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 3/5] avformat/avidec: Use av_sat_sub64() in check_stream_max_drift()

2021-01-18 Thread Michael Niedermayer
On Sun, Nov 29, 2020 at 01:03:35AM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 8833900919969684211 - -9223372036854775808 
> cannot be represented in type 'long'
> Fixes: 
> 26726/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5669377724383232
> Fixes: 
> 27587/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6294562263531520
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/avidec.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

will apply

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

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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

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

Re: [FFmpeg-devel] [PATCH 5/5] avformat/id3v2: Check against max compression ratio before allocation

2021-01-18 Thread Michael Niedermayer
On Sun, Nov 29, 2020 at 01:03:37AM +0100, Michael Niedermayer wrote:
> Fixes: Timeout (>10sec -> 12ms)
> Fixes: 
> 27612/clusterfuzz-testcase-minimized-ffmpeg_dem_PCM_S24BE_fuzzer-6605893000757248
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/id3v2.c | 2 ++
>  1 file changed, 2 insertions(+)

will apply

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


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 v2 02/13] h264_metadata_bsf: Move SEI user data parsing to init time

2021-01-18 Thread Mark Thompson
---
 libavcodec/h264_metadata_bsf.c | 91 --
 1 file changed, 43 insertions(+), 48 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index d7cf58095b..f39e649ac6 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -78,6 +78,7 @@ typedef struct H264MetadataContext {
 int crop_bottom;
 
 const char *sei_user_data;
+H264RawSEIPayload sei_user_data_payload;
 
 int delete_filler;
 
@@ -413,54 +414,10 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 // Only insert the SEI in access units containing SPSs, and also
 // unconditionally in the first access unit we ever see.
 if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) {
-H264RawSEIPayload payload = {
-.payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED,
-};
-SEIRawUserDataUnregistered *udu =
-&payload.payload.user_data_unregistered;
-
-for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) {
-int c, v;
-c = ctx->sei_user_data[i];
-if (c == '-') {
-continue;
-} else if (av_isxdigit(c)) {
-c = av_tolower(c);
-v = (c <= '9' ? c - '0' : c - 'a' + 10);
-} else {
-goto invalid_user_data;
-}
-if (j & 1)
-udu->uuid_iso_iec_11578[j / 2] |= v;
-else
-udu->uuid_iso_iec_11578[j / 2] = v << 4;
-++j;
-}
-if (j == 32 && ctx->sei_user_data[i] == '+') {
-size_t len = strlen(ctx->sei_user_data + i + 1);
-
-udu->data_ref = av_buffer_alloc(len + 1);
-if (!udu->data_ref) {
-err = AVERROR(ENOMEM);
-goto fail;
-}
-
-udu->data= udu->data_ref->data;
-udu->data_length = len + 1;
-memcpy(udu->data, ctx->sei_user_data + i + 1, len + 1);
-
-err = ff_cbs_h264_add_sei_message(au, &payload);
-if (err < 0) {
-av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI "
-   "message to access unit.\n");
-goto fail;
-}
-
-} else {
-invalid_user_data:
-av_log(bsf, AV_LOG_ERROR, "Invalid user data: "
-   "must be \"UUID+string\".\n");
-err = AVERROR(EINVAL);
+err = ff_cbs_h264_add_sei_message(au, &ctx->sei_user_data_payload);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI "
+   "message to access unit.\n");
 goto fail;
 }
 }
@@ -627,6 +584,44 @@ static int h264_metadata_init(AVBSFContext *bsf)
 CodedBitstreamFragment *au = &ctx->access_unit;
 int err, i;
 
+if (ctx->sei_user_data) {
+SEIRawUserDataUnregistered *udu =
+&ctx->sei_user_data_payload.payload.user_data_unregistered;
+int j;
+
+ctx->sei_user_data_payload.payload_type =
+H264_SEI_TYPE_USER_DATA_UNREGISTERED;
+
+// Parse UUID.  It must be a hex string of length 32, possibly
+// containing '-'s between hex digits (which we ignore).
+for (i = j = 0; j < 32 && i < 64 && ctx->sei_user_data[i]; i++) {
+int c, v;
+c = ctx->sei_user_data[i];
+if (c == '-') {
+continue;
+} else if (av_isxdigit(c)) {
+c = av_tolower(c);
+v = (c <= '9' ? c - '0' : c - 'a' + 10);
+} else {
+break;
+}
+if (j & 1)
+udu->uuid_iso_iec_11578[j / 2] |= v;
+else
+udu->uuid_iso_iec_11578[j / 2] = v << 4;
+++j;
+}
+if (j == 32 && ctx->sei_user_data[i] == '+') {
+udu->data = (uint8_t*)ctx->sei_user_data + i + 1;
+udu->data_length = strlen(udu->data) + 1;
+} else {
+av_log(bsf, AV_LOG_ERROR, "Invalid user data: "
+   "must be \"UUID+string\".\n");
+err = AVERROR(EINVAL);
+goto fail;
+}
+}
+
 err = ff_cbs_init(&ctx->input,  AV_CODEC_ID_H264, bsf);
 if (err < 0)
 return err;
-- 
2.29.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 v2 00/13] Metadata handling in CBS, first half, v2

2021-01-18 Thread Mark Thompson
This is v2 of the first half of the series, which factorises out common parts 
of the existing code and fixes some minor issues but has little external 
effect.  It is updated as noted from previous comments, but has no other 
significant changes.

I'll apply this later this week if there are no further comments.  The second 
half involves more new code and has had more changes, and so will follow after.

Thanks,

- Mark


Mark Thompson (13):
  cbs_h2645: Merge SEI messages in common between codecs
  h264_metadata_bsf: Move SEI user data parsing to init time
  cbs_h2645: Merge SEI message handling in common between codecs
  cbs_sei: Remove restrictions on MDCV values
  h264_metadata_bsf: Refactor the filter function into smaller parts
  h264_metadata_bsf: Improve interpretation of input display matrices
  cbs: Implement common parts of cbs-based bitstream filters separately
  h264_metadata_bsf: Use common cbs bsf implementation
  h265_metadata_bsf: Use common cbs bsf implementation
  mpeg2_metadata_bsf: Use common cbs bsf implementation
  vp9_metadata_bsf: Use common cbs bsf implementation
  av1_metadata_bsf: Use common cbs bsf implementation
  h264_redundant_pps_bsf: Use common cbs bsf implementation

 libavcodec/Makefile   |   6 +-
 libavcodec/av1_metadata_bsf.c | 176 +---
 libavcodec/cbs_bsf.c  | 159 +++
 libavcodec/cbs_bsf.h  | 131 ++
 libavcodec/cbs_h264.h |  79 +---
 libavcodec/cbs_h2645.c| 324 +++---
 libavcodec/cbs_h264_syntax_template.c | 271 +---
 libavcodec/cbs_h265.h |  66 +--
 libavcodec/cbs_h265_syntax_template.c | 372 ++--
 libavcodec/cbs_sei.c  | 369 
 libavcodec/cbs_sei.h  | 315 ++
 libavcodec/cbs_sei_syntax_template.c  | 307 +
 libavcodec/h264_metadata_bsf.c| 596 +++---
 libavcodec/h264_redundant_pps_bsf.c   |  99 +
 libavcodec/h265_metadata_bsf.c| 191 +
 libavcodec/mpeg2_metadata_bsf.c   |  94 +---
 libavcodec/vaapi_encode_h264.c|  53 +--
 libavcodec/vaapi_encode_h265.c|  45 +-
 libavcodec/vp9_metadata_bsf.c |  61 +--
 19 files changed, 1882 insertions(+), 1832 deletions(-)
 create mode 100644 libavcodec/cbs_bsf.c
 create mode 100644 libavcodec/cbs_bsf.h
 create mode 100644 libavcodec/cbs_sei.c
 create mode 100644 libavcodec/cbs_sei.h
 create mode 100644 libavcodec/cbs_sei_syntax_template.c

-- 
2.29.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 v2 07/13] cbs: Implement common parts of cbs-based bitstream filters separately

2021-01-18 Thread Mark Thompson
This allows removal of a lot of duplicated code between BSFs.
---
 libavcodec/Makefile  |   2 +-
 libavcodec/cbs_bsf.c | 159 +++
 libavcodec/cbs_bsf.h | 131 +++
 3 files changed, 291 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/cbs_bsf.c
 create mode 100644 libavcodec/cbs_bsf.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1fcb94fa48..6c1e7a1c7a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -69,7 +69,7 @@ OBJS-$(CONFIG_AUDIODSP)+= audiodsp.o
 OBJS-$(CONFIG_BLOCKDSP)+= blockdsp.o
 OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o
 OBJS-$(CONFIG_CABAC)   += cabac.o
-OBJS-$(CONFIG_CBS) += cbs.o
+OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o
diff --git a/libavcodec/cbs_bsf.c b/libavcodec/cbs_bsf.c
new file mode 100644
index 00..9b521cf111
--- /dev/null
+++ b/libavcodec/cbs_bsf.c
@@ -0,0 +1,159 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "bsf_internal.h"
+#include "cbs_bsf.h"
+
+static int cbs_bsf_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
+{
+CBSBSFContext   *ctx = bsf->priv_data;
+CodedBitstreamFragment *frag = &ctx->fragment;
+uint8_t *side_data;
+int side_data_size;
+int err;
+
+side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+&side_data_size);
+if (!side_data_size)
+return 0;
+
+err = ff_cbs_read(ctx->input, frag, side_data, side_data_size);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR,
+   "Failed to read extradata from packet side data.\n");
+return err;
+}
+
+err = ctx->type->update_fragment(bsf, NULL, frag);
+if (err < 0)
+return err;
+
+err = ff_cbs_write_fragment_data(ctx->output, frag);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR,
+   "Failed to write extradata into packet side data.\n");
+return err;
+}
+
+side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+frag->data_size);
+if (!side_data)
+return AVERROR(ENOMEM);
+memcpy(side_data, frag->data, frag->data_size);
+
+ff_cbs_fragment_reset(frag);
+return 0;
+}
+
+int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt)
+{
+CBSBSFContext   *ctx = bsf->priv_data;
+CodedBitstreamFragment *frag = &ctx->fragment;
+int err;
+
+err = ff_bsf_get_packet_ref(bsf, pkt);
+if (err < 0)
+return err;
+
+err = cbs_bsf_update_side_data(bsf, pkt);
+if (err < 0)
+goto fail;
+
+err = ff_cbs_read_packet(ctx->input, frag, pkt);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to read %s from packet.\n",
+   ctx->type->fragment_name);
+goto fail;
+}
+
+if (frag->nb_units == 0) {
+av_log(bsf, AV_LOG_ERROR, "No %s found in packet.\n",
+   ctx->type->unit_name);
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+err = ctx->type->update_fragment(bsf, pkt, frag);
+if (err < 0)
+goto fail;
+
+err = ff_cbs_write_packet(ctx->output, pkt, frag);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to write %s into packet.\n",
+   ctx->type->fragment_name);
+goto fail;
+}
+
+err = 0;
+fail:
+ff_cbs_fragment_reset(frag);
+
+if (err < 0)
+av_packet_unref(pkt);
+
+return err;
+}
+
+int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type)
+{
+CBSBSFContext   *ctx = bsf->priv_data;
+CodedBitstreamFragment *frag = &ctx->fragment;
+int err;
+
+ctx->type = type;
+
+err = ff_cbs_init(&ctx->input, type->codec_id, bsf);
+if (err < 0)
+return err;
+
+err = ff_cbs_init(&ctx->output, type->codec_id, bsf);
+if (err < 0)
+return err;
+
+if (bsf->par_in->extradata) {
+err 

Re: [FFmpeg-devel] [PATCH] libavdevice: Add KMS/DRM output device

2021-01-18 Thread Mark Thompson

On 16/01/2021 22:12, Nicolas Caramelli wrote:

This patch adds KMS/DRM output device for rendering a video stream
using KMS/DRM dumb buffer.
The proposed implementation is very basic, only bgr0 pixel format is
currently supported (the most common format with KMS/DRM).
To enable this output device you need to configure FFmpeg with --enable-libdrm.
Example: ffmpeg -re -i INPUT -pix_fmt bgr0 -f kmsdumb /dev/dri/card0


If you want to render things to a normal display device why not use a normal 
video player?  Or even ffplay?

IMO something like this would be of more value as a simple video player example 
with the documentation rather than including it as weirdly constrained library 
code which will see very little use.

(Note that I would argue against adding more general display output devices 
which are already present, like fb and xv, because they are of essentially no 
value to libavdevice users.  Removing legacy code is harder, though.)

- 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 v2 07/13] cbs: Implement common parts of cbs-based bitstream filters separately

2021-01-18 Thread James Almer

On 1/18/2021 7:44 PM, Mark Thompson wrote:

+#define BSF_ELEMENT_OPTIONS_PIR(name, help, field, unit_name) \


You could reuse name instead of also passing unit_name. The only bsf 
where it differs is h264_metadata with display_orientation vs disp_or, 
and changing the latter into the former should be fine (Is it even user 
facing?).



+{ name, help, OFFSET(field), AV_OPT_TYPE_INT, \
+{ .i64 = BSF_ELEMENT_PASS }, \
+BSF_ELEMENT_PASS, BSF_ELEMENT_REMOVE, FLAGS, unit_name }, \


This depends on FLAGS being defined before this macro is invoked. It's 
probably safer and/or more robust to pass the flags as an argument.



+{ "pass",   NULL, 0, AV_OPT_TYPE_CONST, \
+{ .i64 = BSF_ELEMENT_PASS   }, .flags = FLAGS, .unit = unit_name }, \
+{ "insert", NULL, 0, AV_OPT_TYPE_CONST, \
+{ .i64 = BSF_ELEMENT_INSERT }, .flags = FLAGS, .unit = unit_name }, \
+{ "remove", NULL, 0, AV_OPT_TYPE_CONST, \
+{ .i64 = BSF_ELEMENT_REMOVE }, .flags = FLAGS, .unit = unit_name }
+
+#define BSF_ELEMENT_OPTIONS_PIRE(name, help, field, unit_name) \
+{ name, help, OFFSET(field), AV_OPT_TYPE_INT, \
+{ .i64 = BSF_ELEMENT_PASS }, \
+BSF_ELEMENT_PASS, BSF_ELEMENT_EXTRACT, FLAGS, unit_name }, \
+{ "pass",   NULL, 0, AV_OPT_TYPE_CONST, \
+{ .i64 = BSF_ELEMENT_PASS   }, .flags = FLAGS, .unit = unit_name }, \
+{ "insert", NULL, 0, AV_OPT_TYPE_CONST, \
+{ .i64 = BSF_ELEMENT_INSERT }, .flags = FLAGS, .unit = unit_name }, \
+{ "remove", NULL, 0, AV_OPT_TYPE_CONST, \
+{ .i64 = BSF_ELEMENT_REMOVE }, .flags = FLAGS, .unit = unit_name }, \
+{ "extract", NULL, 0, AV_OPT_TYPE_CONST, \
+{ .i64 = BSF_ELEMENT_EXTRACT }, .flags = FLAGS, .unit = unit_name } \


___
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: Added siti filter

2021-01-18 Thread Boris Baracaldo
Calculate Spatial Info (SI) and Temporal Info (TI) scores for a video, as 
defined
in ITU-T P.910: Subjective video quality assessment methods for multimedia
applications.

Update: Fixed bracket style. I'm already adding the data to the frame's 
metadata, is the suggestion to remove the file option altogether?

---
 Changelog|   1 +
 doc/filters.texi |  25 
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_siti.c| 321 +++
 6 files changed, 350 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/vf_siti.c

diff --git a/Changelog b/Changelog
index 0b27c15122..5e1f107204 100644
--- a/Changelog
+++ b/Changelog
@@ -56,6 +56,7 @@ version :
 - shufflepixels filter
 - tmidequalizer filter
 - estdif filter
+- siti filter


 version 4.3:
diff --git a/doc/filters.texi b/doc/filters.texi
index 3ce6699d7c..910558e162 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -18239,6 +18239,31 @@ ffmpeg -i input1.mkv -i input2.mkv -filter_complex 
"[0:v][1:v] signature=nb_inpu

 @end itemize

+@anchor{siti}
+@section siti
+
+Calculate Spatial Info (SI) and Temporal Info (TI) scores for a video, as 
defined
+in ITU-T P.910: Subjective video quality assessment methods for multimedia
+applications. Available PDF at 
@url{https://www.itu.int/rec/T-REC-P.910-199909-S/en }.
+Per frame metrics can be written into a file in csv format.
+
+It accepts the following option:
+
+@table @option
+@item stats_file
+Set the path to the file where per frame SI and TI metrics will be written. If 
no file
+is specified, only summary statistics will be printed to the console.
+@end table
+
+@subsection Examples
+@itemize
+@item
+To calculate SI/TI metrics and store per frame data to stats.csv:
+@example
+ffmpeg -i input.mp4 -vf siti=stats_file='siti.csv' -f null -
+@end example
+@end itemize
+
 @anchor{smartblur}
 @section smartblur

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 44afa79963..7f96c22b12 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -414,6 +414,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER)  += 
vf_smartblur.o
 OBJS-$(CONFIG_SOBEL_FILTER)  += vf_convolution.o
 OBJS-$(CONFIG_SOBEL_OPENCL_FILTER)   += vf_convolution_opencl.o 
opencl.o \
 opencl/convolution.o
+OBJS-$(CONFIG_SITI_FILTER)   += vf_siti.o
 OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
 OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o qp_table.o
 OBJS-$(CONFIG_SR_FILTER) += vf_sr.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 471844a603..0138c22cac 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -394,6 +394,7 @@ extern AVFilter ff_vf_signature;
 extern AVFilter ff_vf_smartblur;
 extern AVFilter ff_vf_sobel;
 extern AVFilter ff_vf_sobel_opencl;
+extern AVFilter ff_vf_siti;
 extern AVFilter ff_vf_split;
 extern AVFilter ff_vf_spp;
 extern AVFilter ff_vf_sr;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 2136235e54..e949e9bfb8 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"

 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  96
+#define LIBAVFILTER_VERSION_MINOR  97
 #define LIBAVFILTER_VERSION_MICRO 100


diff --git a/libavfilter/vf_siti.c b/libavfilter/vf_siti.c
new file mode 100644
index 00..de2868fd93
--- /dev/null
+++ b/libavfilter/vf_siti.c
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2002 A'rpi
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/**
+ * @file
+ * Calculate Spatial Info (SI) and Temporal Info (TI) scores
+ */
+
+#include 
+
+#include "libavutil/imgutils.h"
+#include "libavutil/internal.h"
+#include "libavutil/opt.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+static const int X_FILTER[9] = {
+1, 0, -1,
+2, 0, -2,
+1, 0, -1
+};
+
+static const int Y_FILTER[9] = {
+1, 2, 1,
+0, 0, 0,
+-1, -2, -1
+};
+
+typedef struct SiTiContext {
+const AVClass *class;
+int pixel_depth;
+int width, height;
+int nb_frames;

Re: [FFmpeg-devel] [PATCH] avfilter: Added siti filter

2021-01-18 Thread Lynne
Jan 19, 2021, 01:07 by borba...@fb.com:

> Calculate Spatial Info (SI) and Temporal Info (TI) scores for a video, as 
> defined
> in ITU-T P.910: Subjective video quality assessment methods for multimedia
> applications.
>
> Update: Fixed bracket style.
>

Thanks, looks much neater now.



> I'm already adding the data to the frame's metadata, is the suggestion to 
> remove the file option altogether?
>

Yes. We want to avoid filters having their own file in/out options rather
than using generic ones.

 

> +
> +#include "libavutil/imgutils.h"
> +#include "libavutil/internal.h"
> +#include "libavutil/opt.h"
> +
> +#include "avfilter.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "video.h"
> +
> +static const int X_FILTER[9] = {
> +1, 0, -1,
> +2, 0, -2,
> +1, 0, -1
> +};
> +
> +static const int Y_FILTER[9] = {
> +1, 2, 1,
> +0, 0, 0,
> +-1, -2, -1
> +};
>

We have optimized assembly to apply 3x3 matrices. Check out
libavfilter/x86/vf_convolution.asm:ff_filter_3x3_sse4
 vf_convolution already applies a sobel filter that way. Maybe
look into sharing some DSP code with it?

___
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/xbmenc: Do not add last comma into output

2021-01-18 Thread Jose Da Silva
There is a minor bug in xbm encode which adds a trailing comma at the end 
of data. This isn't a big problem, but it would be nicer to be more 
technically true to an array of data (by not including the last comma).

This bug fixes the output from something like this (having 4 values):
static unsigned char image_bits[] = { 0x00, 0x11, 0x22, }
to C code that looks like this instead (having 3 values):
static unsigned char image_bits[] = { 0x00, 0x11, 0x22 }
which is the intended results.
From 2d8cf781bd855dd0dc832e622e25a53daba2ce5b Mon Sep 17 00:00:00 2001
From: Joe Da Silva 
Date: Sat, 16 Jan 2021 22:43:57 -0800
Subject: [PATCH 1/3] avcodec/xbmenc: Do not add last comma into output array

xbm outputs c arrays of data.
Including a comma at the end means there is another value to be added.
This bug fix changes something like this:
static unsigned char image_bits[] = { 0x00, 0x11, 0x22, }
to C code like this:
static unsigned char image_bits[] = { 0x00, 0x11, 0x22 }

Signed-off-by: Joe Da Silva 
---
 libavcodec/xbmenc.c | 12 
 tests/ref/lavf/xbm  |  4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index b25615f2a4..3fc0e3185a 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -27,11 +27,12 @@
 static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 const AVFrame *p, int *got_packet)
 {
-int i, j, ret, size, linesize;
+int i, j, commas, ret, size, linesize;
 uint8_t *ptr, *buf;
 
 linesize = (avctx->width + 7) / 8;
-size = avctx->height * (linesize * 7 + 2) + 110;
+commas   = avctx->height * linesize;
+size = avctx->height * (linesize * 7 + 2) + 109;
 if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0)
 return ret;
 
@@ -42,8 +43,11 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 buf += snprintf(buf, 33, "#define image_height %u\n", avctx->height);
 buf += snprintf(buf, 40, "static unsigned char image_bits[] = {\n");
 for (i = 0; i < avctx->height; i++) {
-for (j = 0; j < linesize; j++)
-buf += snprintf(buf, 7, " 0x%02X,", ff_reverse[*ptr++]);
+for (j = 0; j < linesize; j++) {
+buf += snprintf(buf, 6, " 0x%02X", ff_reverse[*ptr++]);
+if (--commas > 0)
+buf += snprintf(buf, 2, ",");
+}
 ptr += p->linesize[0] - linesize;
 buf += snprintf(buf, 2, "\n");
 }
diff --git a/tests/ref/lavf/xbm b/tests/ref/lavf/xbm
index bc157834ff..e54d6bc226 100644
--- a/tests/ref/lavf/xbm
+++ b/tests/ref/lavf/xbm
@@ -1,3 +1,3 @@
-0629055fd82366317c651a0af4bb82d7 *tests/data/images/xbm/02.xbm
+83ed197cc88f382d9253365ffef70ec5 *tests/data/images/xbm/02.xbm
 tests/data/images/xbm/%02d.xbm CRC=0xc9a20204
-76411 tests/data/images/xbm/02.xbm
+76410 tests/data/images/xbm/02.xbm
-- 
2.30.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".

[FFmpeg-devel] [PATCH 2/3] avcodec/xbmenc: xbm Lower memory use

2021-01-18 Thread Jose Da Silva
Two minor memory improvements.

First bug reduces memory needed to about 6/7 the needed amount, which 
allows you to host almost 7 pictures in the same memory needed for 6
Second is a recalculation of the total additional memory for headers etc.

size = avctx->height x (linesize * 6 + 1) + (31+32+38+4+1)
From 5a64812cfd99bb2fbeb8dda64d37a510104dc0fd Mon Sep 17 00:00:00 2001
From: Joe Da Silva 
Date: Sun, 17 Jan 2021 00:16:16 -0800
Subject: [PATCH 2/3] avcodec/xbmenc: xbm Lower memory use

Small 6/7th size memory reduction.
size = avctx->height x (linesize * 6 + 1) + (31+32+38+4+1)

Signed-off-by: Joe Da Silva 
---
 libavcodec/xbmenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index 3fc0e3185a..193ced652a 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -32,7 +32,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
 linesize = (avctx->width + 7) / 8;
 commas   = avctx->height * linesize;
-size = avctx->height * (linesize * 7 + 2) + 109;
+size = avctx->height * (linesize * 6 + 1) + 106;
 if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0)
 return ret;
 
@@ -41,7 +41,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
 buf += snprintf(buf, 32, "#define image_width %u\n", avctx->width);
 buf += snprintf(buf, 33, "#define image_height %u\n", avctx->height);
-buf += snprintf(buf, 40, "static unsigned char image_bits[] = {\n");
+buf += snprintf(buf, 39, "static unsigned char image_bits[] = {\n");
 for (i = 0; i < avctx->height; i++) {
 for (j = 0; j < linesize; j++) {
 buf += snprintf(buf, 6, " 0x%02X", ff_reverse[*ptr++]);
-- 
2.30.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".

[FFmpeg-devel] [PATCH 3/3] avcodec/xbmenc: Allow for making UW images

2021-01-18 Thread Jose Da Silva
I've run into some bugs where I was downloading a bunch of data and began 
seeing weird hiccups. For example, javascript promises to allow you to push 
some very long lines of data, but the hiccups I saw was with data larger 
than 2k in length (windows) pushed out of a child process stdout piped into 
the stdin of the calling parent program.
Soo much for smooth promises, this was broken and would run into similar 
problems on a linux PC with 32k line limits.
The solution was to break the data into smaller chunks than 2k - and then 
these data hiccups disappeared (windows PC).

It would be expected to be similar for linux PCs (32k I think) and other 
OSes with different sizes.

If the ANSI required minimum needs to be 509 chars or larger (assuming 
509+++<0>=512), then 509 was chosen as the shortest worst-case 
scenario) in this patch.
Most small pictures will go output looking pretty much the same data out 
until you get to about 84bytes (672 pixels wide), where lines out begin to 
be split. For example a UW 4K will exceed a 2k readln and a UW 10K picture 
approaches an 8k readln

The purpose for this patch is to ensure that data remains below the 
readline limits (of 509 chars), so that programs (like javascript) can push 
data in large chunks without breaking into hiccups because the data length 
is too long to be pushed cleanly in one go.
From 3b1927820b3681c79962cce7955f6a3e470d1501 Mon Sep 17 00:00:00 2001
From: Joe Da Silva 
Date: Sun, 17 Jan 2021 20:26:14 -0800
Subject: [PATCH 3/3] avcodec/xbmenc: Allow for making UW images

Worst-case ANSI must allow for 509 chars, while Windows allows for 2048
and Linux for 32K line length. This allows an OS with a small readline
access limitation to fetch very wide images (created from ffmpeg).
---
 libavcodec/xbmenc.c | 30 +++---
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index 193ced652a..1cf13f6f0b 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -24,15 +24,25 @@
 #include "internal.h"
 #include "mathops.h"
 
+#define ANSI_MIN_READLINE 509
+
 static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 const AVFrame *p, int *got_packet)
 {
-int i, j, commas, ret, size, linesize;
+int i, j, l, commas, ret, size, linesize, lineout, rowsout;
 uint8_t *ptr, *buf;
 
-linesize = (avctx->width + 7) / 8;
+linesize = lineout = (avctx->width + 7) / 8;
 commas   = avctx->height * linesize;
-size = avctx->height * (linesize * 6 + 1) + 106;
+
+/* ANSI worst case minimum readline is 509 chars. */
+rowsout  = avctx->height;
+if (lineout > (ANSI_MIN_READLINE / 6)) {
+lineout = ANSI_MIN_READLINE / 6;
+rowsout = (commas + lineout - 1) / lineout;
+}
+
+size = rowsout * (lineout * 6 + 1) + 106;
 if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0)
 return ret;
 
@@ -42,14 +52,20 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 buf += snprintf(buf, 32, "#define image_width %u\n", avctx->width);
 buf += snprintf(buf, 33, "#define image_height %u\n", avctx->height);
 buf += snprintf(buf, 39, "static unsigned char image_bits[] = {\n");
-for (i = 0; i < avctx->height; i++) {
+for (i = 0, l = lineout; i < avctx->height; i++) {
 for (j = 0; j < linesize; j++) {
 buf += snprintf(buf, 6, " 0x%02X", ff_reverse[*ptr++]);
-if (--commas > 0)
-buf += snprintf(buf, 2, ",");
+if (--commas <= 0) {
+buf += snprintf(buf, 2, "\n");
+break;
+}
+buf += snprintf(buf, 2, ",");
+if (--l <= 0) {
+buf += snprintf(buf, 2, "\n");
+l = lineout;
+}
 }
 ptr += p->linesize[0] - linesize;
-buf += snprintf(buf, 2, "\n");
 }
 buf += snprintf(buf, 5, " };\n");
 
-- 
2.30.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] avformat/movenc: Remove dts delay from duration.

2021-01-18 Thread Josh Allmann
Hi Martin,

On Fri, 15 Jan 2021 at 04:59, Martin Storsjö  wrote:
>
> Hi Josh,
>
> On Tue, 22 Dec 2020, Josh Allmann wrote:
>
> > Thank you for taking the time to look into this! Tested with your
> > alternative patch and it does seem to be an improvement. I was able to
> > find a case where it didn't seem to do the correct thing (described
> > below), but this is not a regression; master doesn't do the correct
> > thing, and neither does my patch. I haven't looked much at what the
> > code is doing beyond running these tests, but could find some time to
> > dig in early 2021 if it's not fixed by then.
> >
>
> I think this issue isn't related to the mov muxer at least, but is more
> related to how stream copy works at the ffmpeg.c level, and/or how the
> seeking is done.
>

Thanks for the tip - still haven't had a chance to investigate the behavior.

> As that's unrelated, and I haven't heard any objections to my version of
> the patch, I think I'll go ahead and land it soon then.
>

The patch is certainly an improvement over the current behavior, no
objections from me.

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

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

Re: [FFmpeg-devel] [PATCH v4 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-01-18 Thread Tobias Rapp

On 18.01.2021 23:53, Tomas Härdin wrote:

lör 2021-01-16 klockan 08:43 +0800 skrev lance.lmw...@gmail.com:

On Fri, Jan 15, 2021 at 09:43:58PM +0100, Marton Balint wrote:


On Fri, 15 Jan 2021, Tomas Härdin wrote:

Again, why? If you have a company that maintains a fork of FFmpeg then
compile that info in here instead. Compare with FFmbc which always puts
"FFmbc" as CompanyName.


And how can a product based on libavformat set the company name, product
name and product version? It seems a valid use case for me that these are
overridable. Also note that this product version is only the "user friendly"
version string, for the numeric version still LIBAVFORMAT_VERSION values are
used.


Yes, my use case is the product is using libavformat as library, so it's
prefer to have way to override these information as requirements.


What I'm worried about here is that we're going to get files which
claim to have been written by something other than libavformat. I've
had situations like this before, and it is a source of headache. For
example, if mxfenc writes some field incorrectly then this might cause
us to hack mxfdec to accept that field instead of fixing mxfenc.


I agree that especially for the MXF format with its flexible structure 
it is more relevant to know the muxing library rather than the hosting 
application. Have seen MXF output files of other commercial products 
that also contain library identifiers like "libMXF" or "MXFtk" here.


Other formats in FFmpeg use the "encoder" metadata key for embedding 
library information in the output file. A quick test with AVI output 
shows that this metadata is generated internally and cannot be 
overridden on the command-line.


Regards,
Tobias

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