[FFmpeg-cvslog] doc: Add dev_community/community.md for general assembly and main elections process.

2020-10-19 Thread Thilo Borgmann
ffmpeg | branch: master | Thilo Borgmann  | Mon Oct 19 
14:35:14 2020 +0200| [4ccb68dc670bbc98b4dede6f21615343dd46561e] | committer: 
Thilo Borgmann

doc: Add dev_community/community.md for general assembly and main elections 
process.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ccb68dc670bbc98b4dede6f21615343dd46561e
---

 doc/dev_community/community.md | 79 ++
 1 file changed, 79 insertions(+)

diff --git a/doc/dev_community/community.md b/doc/dev_community/community.md
new file mode 100644
index 00..49d7f899aa
--- /dev/null
+++ b/doc/dev_community/community.md
@@ -0,0 +1,79 @@
+# FFmpeg project
+
+## Organisation
+
+The FFmpeg project is organized through a community working on global 
consensus.
+
+Decisions are taken by the ensemble of active members, through voting and
+are aided by two committees.
+
+## General Assembly
+
+The ensemble of active members is called the General Assembly (GA).
+
+The General Assembly is sovereign and legitimate for all its decisions
+regarding the FFmpeg project.
+
+The General Assembly is made up of active contributors.
+
+Contributors are considered "active contributors" if they have pushed more
+than 20 patches in the last 36 months in the main FFmpeg repository, or
+if they have been voted in by the GA.
+
+Additional members are added to the General Assembly through a vote after
+proposal by a member of the General Assembly.
+They are part of the GA for two years, after which they need a confirmation by
+the GA.
+
+## Voting
+
+Voting is done using a ranked voting system, currently running on 
https://vote.ffmpeg.org/ .
+
+Majority vote means more than 50% of the expressed ballots.
+
+## Technical Committee
+
+The Technical Committee (TC) is here to arbitrate and make decisions when
+technical conflicts occur in the project.
+They will consider the merits of all the positions, judge them and make a
+decision.
+
+The TC resolves technical conflicts but is not a technical steering committee.
+
+Decisions by the TC are binding for all the contributors.
+
+Decisions made by the TC can be re-opened after 1 year or by a majority vote
+of the General Assembly, requested by one of the member of the GA.
+
+The TC is elected by the General Assembly for a duration of 1 year, and
+is composed of 5 members.
+Members can be re-elected if they wish. A majority vote in the General Assembly
+can trigger a new election of the TC.
+
+The members of the TC can be elected from outside of the GA.
+Candidates for election can either be suggested or self-nominated.
+
+The conflict resolution process is detailed in the [resolution process] 
document.
+
+## Community committee
+
+The Community Committee (CC) is here to arbitrage and make decisions when
+inter-personal conflicts occur in the project. It will decide quickly and
+take actions, for the sake of the project.
+
+The CC can remove privileges of offending members, including removal of
+commit access and temporary ban from the community.
+
+Decisions made by the CC can be re-opened after 1 year or by a majority vote
+of the General Assembly. Indefinite bans from the community must be confirmed
+by the General Assembly, in a majority vote.
+
+The CC is elected by the General Assembly for a duration of 1 year, and is
+composed of 5 members.
+Members can be re-elected if they wish. A majority vote in the General Assembly
+can trigger a new election of the CC.
+
+The members of the CC can be elected from outside of the GA.
+Candidates for election can either be suggested or self-nominated.
+
+The CC is governed by and responsible for enforcing the Code of Conduct.

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

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

[FFmpeg-cvslog] dnn_backend_tf.c: add option sess_config for tf backend

2020-10-19 Thread Guo , Yejun
ffmpeg | branch: master | Guo, Yejun  | Mon Oct 12 
15:52:26 2020 +0800| [c4a3dbe726150d9217a4d3fed47b012839e33d82] | committer: 
Guo, Yejun

dnn_backend_tf.c: add option sess_config for tf backend

TensorFlow C library accepts config for session options to
set different parameters for the inference. This patch exports
this interface.

The config is a serialized tensorflow.ConfigProto proto, so we need
two steps to use it:
1. generate the serialized proto with python (see script example below)
the output looks like: 0xab...cd
where 0xcd is the least significant byte and 0xab is the most significant byte.

2. pass the python script output into ffmpeg with
dnn_processing=options=sess_config=0xab...cd

The following script is an example to specify one GPU. If the system contains
3 GPU cards, the visible_device_list could be '0', '1', '2', '0,1' etc.
'0' does not mean physical GPU card 0, we need to try and see.
And we can also add more opitions here to generate more serialized proto.

script example to generate serialized proto which specifies one GPU:
import tensorflow as tf
gpu_options = tf.GPUOptions(visible_device_list='0')
config = tf.ConfigProto(gpu_options=gpu_options)
s = config.SerializeToString()
b = ''.join("%02x" % int(ord(b)) for b in s[::-1])
print('0x%s' % b)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c4a3dbe726150d9217a4d3fed47b012839e33d82
---

 libavfilter/dnn/dnn_backend_tf.c | 94 +---
 1 file changed, 88 insertions(+), 6 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index 7923e1db69..76cc037b94 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -29,14 +29,20 @@
 #include "dnn_backend_native_layer_depth2space.h"
 #include "libavformat/avio.h"
 #include "libavutil/avassert.h"
+#include "../internal.h"
 #include "dnn_backend_native_layer_pad.h"
 #include "dnn_backend_native_layer_maximum.h"
 #include "dnn_io_proc.h"
 
 #include 
 
+typedef struct TFOptions{
+char *sess_config;
+} TFOptions;
+
 typedef struct TFContext {
 const AVClass *class;
+TFOptions options;
 } TFContext;
 
 typedef struct TFModel{
@@ -47,14 +53,15 @@ typedef struct TFModel{
 TF_Status *status;
 } TFModel;
 
-static const AVClass dnn_tensorflow_class = {
-.class_name = "dnn_tensorflow",
-.item_name  = av_default_item_name,
-.option = NULL,
-.version= LIBAVUTIL_VERSION_INT,
-.category   = AV_CLASS_CATEGORY_FILTER,
+#define OFFSET(x) offsetof(TFContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
+static const AVOption dnn_tensorflow_options[] = {
+{ "sess_config", "config for SessionOptions", OFFSET(options.sess_config), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
+{ NULL }
 };
 
+AVFILTER_DEFINE_CLASS(dnn_tensorflow);
+
 static DNNReturnType execute_model_tf(const DNNModel *model, const char 
*input_name, AVFrame *in_frame,
   const char **output_names, uint32_t 
nb_output, AVFrame *out_frame,
   int do_ioproc);
@@ -194,10 +201,64 @@ static DNNReturnType load_tf_model(TFModel *tf_model, 
const char *model_filename
 TF_ImportGraphDefOptions *graph_opts;
 TF_SessionOptions *sess_opts;
 const TF_Operation *init_op;
+uint8_t *sess_config = NULL;
+int sess_config_length = 0;
+
+// prepare the sess config data
+if (tf_model->ctx.options.sess_config != NULL) {
+/*
+tf_model->ctx.options.sess_config is hex to present the serialized 
proto
+required by TF_SetConfig below, so we need to first generate the 
serialized
+proto in a python script, the following is a script example to generate
+serialized proto which specifies one GPU, we can change the script to 
add
+more options.
+
+import tensorflow as tf
+gpu_options = tf.GPUOptions(visible_device_list='0')
+config = tf.ConfigProto(gpu_options=gpu_options)
+s = config.SerializeToString()
+b = ''.join("%02x" % int(ord(b)) for b in s[::-1])
+print('0x%s' % b)
+
+the script output looks like: 0xab...cd, and then pass 0xab...cd to 
sess_config.
+*/
+char tmp[3];
+tmp[2] = '\0';
+
+if (strncmp(tf_model->ctx.options.sess_config, "0x", 2) != 0) {
+av_log(ctx, AV_LOG_ERROR, "sess_config should start with '0x'\n");
+return DNN_ERROR;
+}
+
+sess_config_length = strlen(tf_model->ctx.options.sess_config);
+if (sess_config_length % 2 != 0) {
+av_log(ctx, AV_LOG_ERROR, "the length of sess_config is not even 
(%s), "
+  "please re-generate the config.\n",
+  tf_model->ctx.options.sess_config);
+return DNN_ERROR;
+}
+
+sess_config_length -= 2; //ignore the first '0x'
+sess_config_length /= 2; //get the

[FFmpeg-cvslog] avdevice/alldevices: stop using deprecated linked list API

2020-10-19 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct  9 11:58:37 
2020 -0300| [ac36080b2d9d35a81ea2093d1dbb75717b469691] | committer: James Almer

avdevice/alldevices: stop using deprecated linked list API

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ac36080b2d9d35a81ea2093d1dbb75717b469691
---

 libavdevice/alldevices.c | 72 
 libavdevice/avdevice.c   | 46 ---
 2 files changed, 72 insertions(+), 46 deletions(-)

diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index a6f68dd3bb..92b27a1d14 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -67,3 +67,75 @@ void avdevice_register_all(void)
 {
 avpriv_register_devices(outdev_list, indev_list);
 }
+
+static void *next_input(const AVInputFormat *prev, AVClassCategory c2)
+{
+const AVClass *pc;
+const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_INPUT;
+AVClassCategory category = AV_CLASS_CATEGORY_NA;
+const AVInputFormat *fmt = NULL;
+int i = 0;
+
+while (prev && (fmt = indev_list[i])) {
+i++;
+if (prev == fmt)
+break;
+}
+
+do {
+fmt = indev_list[i++];
+if (!fmt)
+break;
+pc = fmt->priv_class;
+if (!pc)
+continue;
+category = pc->category;
+} while (category != c1 && category != c2);
+return (AVInputFormat *)fmt;
+}
+
+static void *next_output(const AVOutputFormat *prev, AVClassCategory c2)
+{
+const AVClass *pc;
+const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_OUTPUT;
+AVClassCategory category = AV_CLASS_CATEGORY_NA;
+const AVOutputFormat *fmt = NULL;
+int i = 0;
+
+while (prev && (fmt = outdev_list[i])) {
+i++;
+if (prev == fmt)
+break;
+}
+
+do {
+fmt = outdev_list[i++];
+if (!fmt)
+break;
+pc = fmt->priv_class;
+if (!pc)
+continue;
+category = pc->category;
+} while (category != c1 && category != c2);
+return (AVOutputFormat *)fmt;
+}
+
+AVInputFormat *av_input_audio_device_next(AVInputFormat  *d)
+{
+return next_input(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT);
+}
+
+AVInputFormat *av_input_video_device_next(AVInputFormat  *d)
+{
+return next_input(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT);
+}
+
+AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d)
+{
+return next_output(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT);
+}
+
+AVOutputFormat *av_output_video_device_next(AVOutputFormat *d)
+{
+return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT);
+}
diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index 3d03d89f04..ec84d3b990 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -78,52 +78,6 @@ const char * avdevice_license(void)
 return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
 }
 
-static void *device_next(void *prev, int output,
- AVClassCategory c1, AVClassCategory c2)
-{
-const AVClass *pc;
-AVClassCategory category = AV_CLASS_CATEGORY_NA;
-do {
-if (output) {
-if (!(prev = av_oformat_next(prev)))
-break;
-pc = ((AVOutputFormat *)prev)->priv_class;
-} else {
-if (!(prev = av_iformat_next(prev)))
-break;
-pc = ((AVInputFormat *)prev)->priv_class;
-}
-if (!pc)
-continue;
-category = pc->category;
-} while (category != c1 && category != c2);
-return prev;
-}
-
-AVInputFormat *av_input_audio_device_next(AVInputFormat  *d)
-{
-return device_next(d, 0, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT,
-   AV_CLASS_CATEGORY_DEVICE_INPUT);
-}
-
-AVInputFormat *av_input_video_device_next(AVInputFormat  *d)
-{
-return device_next(d, 0, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT,
-   AV_CLASS_CATEGORY_DEVICE_INPUT);
-}
-
-AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d)
-{
-return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT,
-   AV_CLASS_CATEGORY_DEVICE_OUTPUT);
-}
-
-AVOutputFormat *av_output_video_device_next(AVOutputFormat *d)
-{
-return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT,
-   AV_CLASS_CATEGORY_DEVICE_OUTPUT);
-}
-
 int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum 
AVAppToDevMessageType type,
 void *data, size_t data_size)
 {

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

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

[FFmpeg-cvslog] avformat/options: use the iterate API in format_child_class_next()

2020-10-19 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct  9 23:52:28 
2020 -0300| [bddf53841a3efc228b143ee51c8db0daa78643e1] | committer: James Almer

avformat/options: use the iterate API in format_child_class_next()

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bddf53841a3efc228b143ee51c8db0daa78643e1
---

 libavformat/options.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavformat/options.c b/libavformat/options.c
index 3160904fda..59e0389815 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -55,35 +55,38 @@ static void *format_child_next(void *obj, void *prev)
 }
 
 #if FF_API_CHILD_CLASS_NEXT
-FF_DISABLE_DEPRECATION_WARNINGS
 static const AVClass *format_child_class_next(const AVClass *prev)
 {
-AVInputFormat  *ifmt = NULL;
-AVOutputFormat *ofmt = NULL;
+const AVInputFormat *ifmt = NULL;
+const AVOutputFormat *ofmt = NULL;
+void *ifmt_iter = NULL, *ofmt_iter = NULL;
 
 if (!prev)
 return &ff_avio_class;
 
-while ((ifmt = av_iformat_next(ifmt)))
+while ((ifmt = av_demuxer_iterate(&ifmt_iter)))
 if (ifmt->priv_class == prev)
 break;
 
-if (!ifmt)
-while ((ofmt = av_oformat_next(ofmt)))
+if (!ifmt) {
+ifmt_iter = NULL;
+while ((ofmt = av_muxer_iterate(&ofmt_iter)))
 if (ofmt->priv_class == prev)
 break;
-if (!ofmt)
-while (ifmt = av_iformat_next(ifmt))
+}
+if (!ofmt) {
+ofmt_iter = NULL;
+while ((ifmt = av_demuxer_iterate(&ifmt_iter)))
 if (ifmt->priv_class)
 return ifmt->priv_class;
+}
 
-while (ofmt = av_oformat_next(ofmt))
+while ((ofmt = av_muxer_iterate(&ofmt_iter)))
 if (ofmt->priv_class)
 return ofmt->priv_class;
 
 return NULL;
 }
-FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 enum {

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

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

[FFmpeg-cvslog] tools/target_dem_fuzzer: switch to the iterate API

2020-10-19 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct  9 23:59:40 
2020 -0300| [a8a1a58af322b1a03f0c8d0f60ed902e0eb1663a] | committer: James Almer

tools/target_dem_fuzzer: switch to the iterate API

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a8a1a58af322b1a03f0c8d0f60ed902e0eb1663a
---

 tools/target_dem_fuzzer.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c
index a4d69bb230..8c9e373367 100644
--- a/tools/target_dem_fuzzer.c
+++ b/tools/target_dem_fuzzer.c
@@ -112,8 +112,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 #endif
 
 if (!c) {
-av_register_all();
-avcodec_register_all();
 av_log_set_level(AV_LOG_PANIC);
 c=1;
 }
@@ -139,15 +137,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 filesize   = bytestream2_get_le64(&gbc) & 0x7FFF;
 
 if ((flags & 2) && strlen(filename) < sizeof(filename) / 2) {
-AVInputFormat *avif = NULL;
+const AVInputFormat *avif = NULL;
+void *avif_iter = NULL;
 int avif_count = 0;
-while ((avif = av_iformat_next(avif))) {
+while ((avif = av_demuxer_iterate(&avif_iter))) {
 if (avif->extensions)
 avif_count ++;
 }
 avif_count =  bytestream2_get_le32(&gbc) % avif_count;
 
-while ((avif = av_iformat_next(avif))) {
+avif_iter = NULL;
+while ((avif = av_demuxer_iterate(&avif_iter))) {
 if (avif->extensions)
 if (!avif_count--)
 break;

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

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

[FFmpeg-cvslog] tools/target_dec_fuzzer: remove calls to avcodec_register*()

2020-10-19 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Oct 10 00:32:04 
2020 -0300| [3e4214109a1ef394af8cc92064deff254989bf09] | committer: James Almer

tools/target_dec_fuzzer: remove calls to avcodec_register*()

They are no longer needed.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3e4214109a1ef394af8cc92064deff254989bf09
---

 tools/target_dec_fuzzer.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 6b75e006e6..0df3e75cba 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -118,17 +118,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 #define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC)
 extern AVCodec DECODER_SYMBOL(FFMPEG_DECODER);
 codec_list[0] = &DECODER_SYMBOL(FFMPEG_DECODER);
-avcodec_register(&DECODER_SYMBOL(FFMPEG_DECODER));
 
 #if FFMPEG_DECODER == tiff || FFMPEG_DECODER == tdsc
 extern AVCodec DECODER_SYMBOL(mjpeg);
 codec_list[1] = &DECODER_SYMBOL(mjpeg);
-avcodec_register(&DECODER_SYMBOL(mjpeg));
 #endif
 
 c = &DECODER_SYMBOL(FFMPEG_DECODER);
 #else
-avcodec_register_all();
 c = AVCodecInitialize(FFMPEG_CODEC);  // Done once.
 #endif
 av_log_set_level(AV_LOG_PANIC);

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

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

[FFmpeg-cvslog] avfilter/af_aiir: fix sp2zp mapping

2020-10-19 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Oct 19 18:34:50 
2020 +0200| [f7379eafd276fd105441367759d4ca45f4c8d363] | committer: Paul B Mahol

avfilter/af_aiir: fix sp2zp mapping

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f7379eafd276fd105441367759d4ca45f4c8d363
---

 libavfilter/af_aiir.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index c5df4b1202..64bd78ad8a 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -877,23 +877,17 @@ static void convert_sp2zp(AVFilterContext *ctx, int 
channels)
 for (n = 0; n < iir->nb_ab[0]; n++) {
 double sr = iir->ab[0][2*n];
 double si = iir->ab[0][2*n+1];
-double snr = 1. + sr;
-double sdr = 1. - sr;
-double div = sdr * sdr + si * si;
 
-iir->ab[0][2*n]   = (snr * sdr - si * si) / div;
-iir->ab[0][2*n+1] = (sdr * si + snr * si) / div;
+iir->ab[0][2*n]   = exp(sr) * cos(si);
+iir->ab[0][2*n+1] = exp(sr) * sin(si);
 }
 
 for (n = 0; n < iir->nb_ab[1]; n++) {
 double sr = iir->ab[1][2*n];
 double si = iir->ab[1][2*n+1];
-double snr = 1. + sr;
-double sdr = 1. - sr;
-double div = sdr * sdr + si * si;
 
-iir->ab[1][2*n]   = (snr * sdr - si * si) / div;
-iir->ab[1][2*n+1] = (sdr * si + snr * si) / div;
+iir->ab[1][2*n]   = exp(sr) * cos(si);
+iir->ab[1][2*n+1] = exp(sr) * sin(si);
 }
 }
 }

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

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

[FFmpeg-cvslog] avfilter/af_aiir: remove unused argument

2020-10-19 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Oct 19 18:38:43 
2020 +0200| [5da94413d146fee2d3dab2339949f15952175481] | committer: Paul B Mahol

avfilter/af_aiir: remove unused argument

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5da94413d146fee2d3dab2339949f15952175481
---

 libavfilter/af_aiir.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 64bd78ad8a..2e811cff35 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -899,7 +899,7 @@ static double fact(double i)
 return i * fact(i - 1.);
 }
 
-static double coef_sf2zf(double *a, int N, int n, double fs)
+static double coef_sf2zf(double *a, int N, int n)
 {
 double z = 0.;
 
@@ -918,7 +918,7 @@ static double coef_sf2zf(double *a, int N, int n, double fs)
 return z;
 }
 
-static void convert_sf2tf(AVFilterContext *ctx, int channels, int sample_rate)
+static void convert_sf2tf(AVFilterContext *ctx, int channels)
 {
 AudioIIRContext *s = ctx->priv;
 int ch;
@@ -935,10 +935,10 @@ static void convert_sf2tf(AVFilterContext *ctx, int 
channels, int sample_rate)
 memcpy(temp1, iir->ab[1], iir->nb_ab[1] * sizeof(*temp1));
 
 for (int n = 0; n < iir->nb_ab[0]; n++)
-iir->ab[0][n] = coef_sf2zf(temp0, iir->nb_ab[0] - 1, n, 
sample_rate);
+iir->ab[0][n] = coef_sf2zf(temp0, iir->nb_ab[0] - 1, n);
 
 for (int n = 0; n < iir->nb_ab[1]; n++)
-iir->ab[1][n] = coef_sf2zf(temp1, iir->nb_ab[1] - 1, n, 
sample_rate);
+iir->ab[1][n] = coef_sf2zf(temp1, iir->nb_ab[1] - 1, n);
 
 next:
 av_free(temp0);
@@ -1235,7 +1235,7 @@ static int config_output(AVFilterLink *outlink)
 return ret;
 
 if (s->format == -1) {
-convert_sf2tf(ctx, inlink->channels, inlink->sample_rate);
+convert_sf2tf(ctx, inlink->channels);
 s->format = 0;
 } else if (s->format == 2) {
 convert_pr2zp(ctx, inlink->channels);

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

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

[FFmpeg-cvslog] avcodec/movtextenc: Simplify writing to AVBPrint

2020-10-19 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Oct 15 15:29:13 2020 +0200| [82c636313de07ecb11ed2100cc682e8503b24398] | 
committer: Andreas Rheinhardt

avcodec/movtextenc: Simplify writing to AVBPrint

The mov_text encoder uses an AVBPrint to assemble the subtitles;
yet mov_text subtitles are not pure text; they also have a binary
portion that was mostly handled as follows:

uint32_t size = /* calculation */;
size = AV_RB32(&size);
av_bprint_append_data(bprint, (const char*)&size, 4);

Here AV_RB32() is a no-op on big-endian systems and a LE-BE swap
on little-endian systems, making the output endian-independent.

Yet this is ugly and unclean: On LE systems, the variable size from
the snippet above won't contain the correct value any more. Furthermore,
using this pattern leads to lots of small writes to the AVBPrint.

This commit therefore changes this to using a temporary buffer instead:

uint8_t buf[4];
AV_WB32(buf, /* size calculation */);
av_bprint_append_data(bprint, buf, 4);

This method also allows to use bigger buffers holding more than one
element, saving calls to av_bprint_append_data() and reducing codesize.

Reviewed-by: Philip Langdale 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=82c636313de07ecb11ed2100cc682e8503b24398
---

 libavcodec/movtextenc.c | 153 +---
 1 file changed, 66 insertions(+), 87 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 42fdf98042..908b2bfde5 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -29,6 +29,7 @@
 #include "libavutil/common.h"
 #include "ass_split.h"
 #include "ass.h"
+#include "bytestream.h"
 
 #define STYLE_FLAG_BOLD (1<<0)
 #define STYLE_FLAG_ITALIC   (1<<1)
@@ -103,33 +104,27 @@ static void mov_text_cleanup(MovTextContext *s)
 
 static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
 {
-uint32_t tsmb_size;
-uint16_t style_entries;
 if ((s->box_flags & STYL_BOX) && s->count) {
-tsmb_size = s->count * STYLE_RECORD_SIZE + SIZE_ADD;
-tsmb_size = AV_RB32(&tsmb_size);
-tsmb_type = AV_RB32(&tsmb_type);
-style_entries = AV_RB16(&s->count);
+uint8_t buf[12], *p = buf;
+
+bytestream_put_be32(&p, s->count * STYLE_RECORD_SIZE + SIZE_ADD);
+bytestream_put_be32(&p, tsmb_type);
+bytestream_put_be16(&p, s->count);
 /*The above three attributes are hard coded for now
 but will come from ASS style in the future*/
-av_bprint_append_any(&s->buffer, &tsmb_size, 4);
-av_bprint_append_any(&s->buffer, &tsmb_type, 4);
-av_bprint_append_any(&s->buffer, &style_entries, 2);
+av_bprint_append_any(&s->buffer, buf, 10);
 for (unsigned j = 0; j < s->count; j++) {
-uint16_t style_start, style_end, style_fontID;
-uint32_t style_color;
-
-style_start  = AV_RB16(&s->style_attributes[j].style_start);
-style_end= AV_RB16(&s->style_attributes[j].style_end);
-style_color  = AV_RB32(&s->style_attributes[j].style_color);
-style_fontID = AV_RB16(&s->style_attributes[j].style_fontID);
-
-av_bprint_append_any(&s->buffer, &style_start, 2);
-av_bprint_append_any(&s->buffer, &style_end, 2);
-av_bprint_append_any(&s->buffer, &style_fontID, 2);
-av_bprint_append_any(&s->buffer, 
&s->style_attributes[j].style_flag, 1);
-av_bprint_append_any(&s->buffer, 
&s->style_attributes[j].style_fontsize, 1);
-av_bprint_append_any(&s->buffer, &style_color, 4);
+const StyleBox *style = &s->style_attributes[j];
+
+p = buf;
+bytestream_put_be16(&p, style->style_start);
+bytestream_put_be16(&p, style->style_end);
+bytestream_put_be16(&p, style->style_fontID);
+bytestream_put_byte(&p, style->style_flag);
+bytestream_put_byte(&p, style->style_fontsize);
+bytestream_put_be32(&p, style->style_color);
+
+av_bprint_append_any(&s->buffer, buf, 12);
 }
 }
 mov_text_cleanup(s);
@@ -137,32 +132,28 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 
 static void encode_hlit(MovTextContext *s, uint32_t tsmb_type)
 {
-uint32_t tsmb_size;
-uint16_t start, end;
 if (s->box_flags & HLIT_BOX) {
-tsmb_size = 12;
-tsmb_size = AV_RB32(&tsmb_size);
-tsmb_type = AV_RB32(&tsmb_type);
-start = AV_RB16(&s->hlit.start);
-end   = AV_RB16(&s->hlit.end);
-av_bprint_append_any(&s->buffer, &tsmb_size, 4);
-av_bprint_append_any(&s->buffer, &tsmb_type, 4);
-av_bprint_append_any(&s->buffer, &start, 2);
-av_bprint_append_any(&s->buffer, &end, 2);
+uint8_t buf[12], *p = buf;
+
+bytestream_put_be32(&p, 12);
+bytestream_put_be32(&p, tsm

[FFmpeg-cvslog] avcodec/movtextenc: Fix undefined left shifts outside the range of int

2020-10-19 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Oct 17 05:00:13 2020 +0200| [2f9fc35028364b0140fd6e0d2e4dbaffebed1acd] | 
committer: Andreas Rheinhardt

avcodec/movtextenc: Fix undefined left shifts outside the range of int

Reviewed-by: Philip Langdale 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f9fc35028364b0140fd6e0d2e4dbaffebed1acd
---

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

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 73d998d080..42fdf98042 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -45,7 +45,7 @@
 #define DEFAULT_STYLE_COLOR0x
 #define DEFAULT_STYLE_FLAG 0x00
 
-#define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 
0xff))
+#define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((uint32_t)(c) 
>> 16) & 0xff))
 #define FONTSIZE_SCALE(s,fs) ((fs) * (s)->font_scale_factor + 0.5)
 #define av_bprint_append_any(buf, data, size)   av_bprint_append_data(buf, 
((const char*)data), size)
 

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

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

[FFmpeg-cvslog] avcodec/movtextenc: Fix memleak on (re)allocation error

2020-10-19 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Oct 17 03:35:08 2020 +0200| [9a731e9fec53f121e0fd5981f22c9c5093db0793] | 
committer: Andreas Rheinhardt

avcodec/movtextenc: Fix memleak on (re)allocation error

Up until now, the mov_text encoder used the dynamic array API for its
list of style attributes; it used the (horrible) av_dynarray_add() which
works with an array of pointers; on error it frees its array but not
the buffers referenced by the pointers said array contains. It also
returns no error code, encouraging not to check for errors.

These properties imply that this function may only be used if the buffers
referenced by the list either need not be freed at all or if they are
freed by other means (i.e. if the list contains non-ownership pointers).

In this case, the style attributes are owned by the pointers of the
dynamic list. Ergo the old style attributes leak on a subsequent
reallocation failure. But given that the (re)allocation isn't checked
for success, the style attribute intended to be added to the list also
leaks because the only pointer to it gets overwritten in the belief that
it is now owned by the list.

This commit fixes this by switching to av_fast_realloc() and an array
containing the styles directly instead of pointers to individually
allocated style attributes. The current style attributes are now no longer
individually allocated, instead they are part of the context.

Furthermore, av_fast_realloc() allows to easily distinguish between
valid and allocated elements, thereby allowing to reuse the array
(which up until now has always been freed after processing an
AVSubtitleRect).

Reviewed-by: Philip Langdale 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9a731e9fec53f121e0fd5981f22c9c5093db0793
---

 libavcodec/movtextenc.c | 124 +++-
 1 file changed, 50 insertions(+), 74 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index dcdbf16e08..73d998d080 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -73,12 +73,13 @@ typedef struct {
 
 ASSSplitContext *ass_ctx;
 ASSStyle *ass_dialog_style;
+StyleBox *style_attributes;
+unsigned  count;
+unsigned  style_attributes_bytes_allocated;
+StyleBox  style_attributes_temp;
 AVBPrint buffer;
-StyleBox **style_attributes;
-StyleBox *style_attributes_temp;
 HighlightBox hlit;
 HilightcolorBox hclr;
-int count;
 uint8_t box_flags;
 StyleBox d;
 uint16_t text_pos;
@@ -96,22 +97,12 @@ typedef struct {
 
 static void mov_text_cleanup(MovTextContext *s)
 {
-int j;
-if (s->box_flags & STYL_BOX) {
-for (j = 0; j < s->count; j++) {
-av_freep(&s->style_attributes[j]);
-}
-av_freep(&s->style_attributes);
-s->count = 0;
-}
-if (s->style_attributes_temp) {
-*s->style_attributes_temp = s->d;
-}
+s->count = 0;
+s->style_attributes_temp = s->d;
 }
 
 static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
 {
-int j;
 uint32_t tsmb_size;
 uint16_t style_entries;
 if ((s->box_flags & STYL_BOX) && s->count) {
@@ -124,20 +115,20 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 av_bprint_append_any(&s->buffer, &tsmb_size, 4);
 av_bprint_append_any(&s->buffer, &tsmb_type, 4);
 av_bprint_append_any(&s->buffer, &style_entries, 2);
-for (j = 0; j < s->count; j++) {
+for (unsigned j = 0; j < s->count; j++) {
 uint16_t style_start, style_end, style_fontID;
 uint32_t style_color;
 
-style_start  = AV_RB16(&s->style_attributes[j]->style_start);
-style_end= AV_RB16(&s->style_attributes[j]->style_end);
-style_color  = AV_RB32(&s->style_attributes[j]->style_color);
-style_fontID = AV_RB16(&s->style_attributes[j]->style_fontID);
+style_start  = AV_RB16(&s->style_attributes[j].style_start);
+style_end= AV_RB16(&s->style_attributes[j].style_end);
+style_color  = AV_RB32(&s->style_attributes[j].style_color);
+style_fontID = AV_RB16(&s->style_attributes[j].style_fontID);
 
 av_bprint_append_any(&s->buffer, &style_start, 2);
 av_bprint_append_any(&s->buffer, &style_end, 2);
 av_bprint_append_any(&s->buffer, &style_fontID, 2);
-av_bprint_append_any(&s->buffer, 
&s->style_attributes[j]->style_flag, 1);
-av_bprint_append_any(&s->buffer, 
&s->style_attributes[j]->style_fontsize, 1);
+av_bprint_append_any(&s->buffer, 
&s->style_attributes[j].style_flag, 1);
+av_bprint_append_any(&s->buffer, 
&s->style_attributes[j].style_fontsize, 1);
 av_bprint_append_any(&s->buffer, &style_color, 4);
 }
 }
@@ -186,17 +177,10 @@ const static size_t box_count = FF_ARRAY_ELEMS(box_types);
 static int mov_text

[FFmpeg-cvslog] avcodec/movtextenc: Remove redundant function parameters

2020-10-19 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Oct 16 05:02:34 2020 +0200| [eab812d6d61912cddbfbe72ad4419286eb43514d] | 
committer: Andreas Rheinhardt

avcodec/movtextenc: Remove redundant function parameters

It makes no sense to call the functions to write styl, hlit or hclr boxes
with a different box name than "styl", "hlit" or "hclr". Therefore this
commit inlines these values in the functions, removes the function
parameter containing the box's name and removes the (non obsolete) box
names from the list of boxes.

Reviewed-by: Philip Langdale 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eab812d6d61912cddbfbe72ad4419286eb43514d
---

 libavcodec/movtextenc.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 908b2bfde5..2082dc9b25 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -92,8 +92,7 @@ typedef struct {
 } MovTextContext;
 
 typedef struct {
-uint32_t type;
-void (*encode)(MovTextContext *s, uint32_t tsmb_type);
+void (*encode)(MovTextContext *s);
 } Box;
 
 static void mov_text_cleanup(MovTextContext *s)
@@ -102,13 +101,13 @@ static void mov_text_cleanup(MovTextContext *s)
 s->style_attributes_temp = s->d;
 }
 
-static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
+static void encode_styl(MovTextContext *s)
 {
 if ((s->box_flags & STYL_BOX) && s->count) {
 uint8_t buf[12], *p = buf;
 
 bytestream_put_be32(&p, s->count * STYLE_RECORD_SIZE + SIZE_ADD);
-bytestream_put_be32(&p, tsmb_type);
+bytestream_put_be32(&p, MKBETAG('s','t','y','l'));
 bytestream_put_be16(&p, s->count);
 /*The above three attributes are hard coded for now
 but will come from ASS style in the future*/
@@ -130,13 +129,13 @@ static void encode_styl(MovTextContext *s, uint32_t 
tsmb_type)
 mov_text_cleanup(s);
 }
 
-static void encode_hlit(MovTextContext *s, uint32_t tsmb_type)
+static void encode_hlit(MovTextContext *s)
 {
 if (s->box_flags & HLIT_BOX) {
 uint8_t buf[12], *p = buf;
 
 bytestream_put_be32(&p, 12);
-bytestream_put_be32(&p, tsmb_type);
+bytestream_put_be32(&p, MKBETAG('h','l','i','t'));
 bytestream_put_be16(&p, s->hlit.start);
 bytestream_put_be16(&p, s->hlit.end);
 
@@ -144,13 +143,13 @@ static void encode_hlit(MovTextContext *s, uint32_t 
tsmb_type)
 }
 }
 
-static void encode_hclr(MovTextContext *s, uint32_t tsmb_type)
+static void encode_hclr(MovTextContext *s)
 {
 if (s->box_flags & HCLR_BOX) {
 uint8_t buf[12], *p = buf;
 
 bytestream_put_be32(&p, 12);
-bytestream_put_be32(&p, tsmb_type);
+bytestream_put_be32(&p, MKBETAG('h','c','l','r'));
 bytestream_put_be32(&p, s->hclr.color);
 
 av_bprint_append_any(&s->buffer, buf, 12);
@@ -158,9 +157,9 @@ static void encode_hclr(MovTextContext *s, uint32_t 
tsmb_type)
 }
 
 static const Box box_types[] = {
-{ MKBETAG('s','t','y','l'), encode_styl },
-{ MKBETAG('h','l','i','t'), encode_hlit },
-{ MKBETAG('h','c','l','r'), encode_hclr },
+{ encode_styl },
+{ encode_hlit },
+{ encode_hclr },
 };
 
 const static size_t box_count = FF_ARRAY_ELEMS(box_types);
@@ -682,7 +681,7 @@ static int mov_text_encode_frame(AVCodecContext *avctx, 
unsigned char *buf,
 #endif
 
 for (j = 0; j < box_count; j++) {
-box_types[j].encode(s, box_types[j].type);
+box_types[j].encode(s);
 }
 }
 

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

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

[FFmpeg-cvslog] avcodec/movtextenc: Cleanup generically on init failure

2020-10-19 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Oct 17 07:47:43 2020 +0200| [21346672270ae723aa774a9c8b0749954a75b3df] | 
committer: Andreas Rheinhardt

avcodec/movtextenc: Cleanup generically on init failure

Reviewed-by: Philip Langdale 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=21346672270ae723aa774a9c8b0749954a75b3df
---

 libavcodec/movtextenc.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 2082dc9b25..1bef21e0b9 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -30,6 +30,7 @@
 #include "ass_split.h"
 #include "ass.h"
 #include "bytestream.h"
+#include "internal.h"
 
 #define STYLE_FLAG_BOLD (1<<0)
 #define STYLE_FLAG_ITALIC   (1<<1)
@@ -331,19 +332,13 @@ static av_cold int mov_text_encode_init(AVCodecContext 
*avctx)
 av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
 
 s->ass_ctx = ff_ass_split(avctx->subtitle_header);
-if (!s->ass_ctx) {
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
+if (!s->ass_ctx)
+return AVERROR_INVALIDDATA;
 ret = encode_sample_description(avctx);
 if (ret < 0)
-goto fail;
+return ret;
 
 return 0;
-
-fail:
-mov_text_encode_close(avctx);
-return ret;
 }
 
 // Start a new style box if needed
@@ -736,4 +731,5 @@ AVCodec ff_movtext_encoder = {
 .init   = mov_text_encode_init,
 .encode_sub = mov_text_encode_frame,
 .close  = mov_text_encode_close,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };

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

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

[FFmpeg-cvslog] avcodec/movtextenc: Fix potential use of uninitialized value

2020-10-19 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Oct 15 14:12:21 2020 +0200| [56b3726ed2ac89df31a939a8f5f00fa66a0ad2ed] | 
committer: Andreas Rheinhardt

avcodec/movtextenc: Fix potential use of uninitialized value

Background colour was never initialized if no style was available.
Use a sane default of zero (i.e. completely transparent).

Fixes Coverity issue #1461471.

Reviewed-by: Philip Langdale 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=56b3726ed2ac89df31a939a8f5f00fa66a0ad2ed
---

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

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 5f60b8db61..11db240ab7 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -205,7 +205,7 @@ static int encode_sample_description(AVCodecContext *avctx)
 ASS *ass;
 ASSStyle *style;
 int i, j;
-uint32_t tsmb_size, tsmb_type, back_color, style_color;
+uint32_t tsmb_size, tsmb_type, back_color = 0, style_color;
 uint16_t style_start, style_end, fontID, count;
 int font_names_total_len = 0;
 MovTextContext *s = avctx->priv_data;

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

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

[FFmpeg-cvslog] avcodec/movtextenc: Reset array counter after freeing array

2020-10-19 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Oct 16 13:47:56 2020 +0200| [8d4431955ccca80933a837e1bc7f44679039335b] | 
committer: Andreas Rheinhardt

avcodec/movtextenc: Reset array counter after freeing array

Otherwise the mov_text encoder can segfault when given subtitles with more
than one AVSubtitleRect if one of the first nb_rects - 1 rects contained
a style attribute.

Reviewed-by: Philip Langdale 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d4431955ccca80933a837e1bc7f44679039335b
---

 libavcodec/movtextenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 11db240ab7..81e8c2e802 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -102,6 +102,7 @@ static void mov_text_cleanup(MovTextContext *s)
 av_freep(&s->style_attributes[j]);
 }
 av_freep(&s->style_attributes);
+s->count = 0;
 }
 if (s->style_attributes_temp) {
 *s->style_attributes_temp = s->d;

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

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

[FFmpeg-cvslog] avcodec/movtextenc: Don't presume every style to have a font

2020-10-19 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Oct 16 16:33:23 2020 +0200| [0dd7b8232d38317abc195edc48434ac1fd3e80fd] | 
committer: Andreas Rheinhardt

avcodec/movtextenc: Don't presume every style to have a font

Fixes segfaults in the absence of fonts; this can happen because the
file didn't contain any or because the allocation of the font-string
failed.

Reviewed-by: Philip Langdale 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0dd7b8232d38317abc195edc48434ac1fd3e80fd
---

 libavcodec/movtextenc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 81e8c2e802..dcdbf16e08 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -298,10 +298,14 @@ static int encode_sample_description(AVCodecContext 
*avctx)
 // is avaiable in the ASS header
 if (style && ass->styles_count) {
 // Find unique font names
-av_dynarray_add(&s->fonts, &s->font_count, style->font_name);
-font_names_total_len += strlen(style->font_name);
+if (style->font_name) {
+av_dynarray_add(&s->fonts, &s->font_count, style->font_name);
+font_names_total_len += strlen(style->font_name);
+}
 for (i = 0; i < ass->styles_count; i++) {
 int found = 0;
+if (!ass->styles[i].font_name)
+continue;
 for (j = 0; j < s->font_count; j++) {
 if (!strcmp(s->fonts[j], ass->styles[i].font_name)) {
 found = 1;

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

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

[FFmpeg-cvslog] avformat/dashdec: check the root url length

2020-10-19 Thread Steven Liu
ffmpeg | branch: master | Steven Liu  | Mon Aug 17 
20:30:18 2020 +0800| [1ee52b2b6c1f6c9618e435b5ed7608442308efe6] | committer: 
liuqi05

avformat/dashdec: check the root url length

if the length of the root url is 0, unnecessary process the root_url

Signed-off-by: Steven Liu 
Signed-off-by: liuqi05 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1ee52b2b6c1f6c9618e435b5ed7608442308efe6
---

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

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index c28bb07f44..693fc7372b 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -771,7 +771,7 @@ static int resolve_content_path(AVFormatContext *s, const 
char *url, int *max_ur
 size = strlen(root_url);
 isRootHttp = ishttp(root_url);
 
-if (root_url[size - 1] != token) {
+if (size > 0 && root_url[size - 1] != token) {
 av_strlcat(root_url, "/", size + 2);
 size += 2;
 }

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

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

[FFmpeg-cvslog] avformat/hlsenc: process hls_time value too small sence

2020-10-19 Thread Steven Liu
ffmpeg | branch: master | Steven Liu  | Tue Aug 18 
10:44:11 2020 +0800| [a424671e4f1beccca5a5958add86b69eb4fe8da7] | committer: 
liuqi05

avformat/hlsenc: process hls_time value too small sence

The target duration will be a negative value when there are
some b frames after prevous frame, the pts after current packet
is large than the pts of current packet, so the target duration
will compute as 0.04 - 0.08, then the value of the target
duration will be -0.04. so hls muxer should check the pts after
current packet minus the pts of current packet, hls muxer can split
the stream as a segment if the target duration is neither negative nor
zero, hls muxer cannot split the stream as a segment if the
target duration is either negative or zero then get the next packet
until the target duration is not negative or zero.

Signed-off-by: Steven Liu 
Suggested-by: Zhili Zhao 
Signed-off-by: liuqi05 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a424671e4f1beccca5a5958add86b69eb4fe8da7
---

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cb31d6aed7..4471858222 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2398,9 +2398,9 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 vs->duration = (double)(pkt->pts - vs->end_pts) * 
st->time_base.num / st->time_base.den;
 }
 }
-
 }
 
+can_split = can_split && (pkt->pts - vs->end_pts > 0);
 if (vs->packets_written && can_split && av_compare_ts(pkt->pts - 
vs->start_pts, st->time_base,
   end_pts, 
AV_TIME_BASE_Q) >= 0) {
 int64_t new_start_pos;

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

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

[FFmpeg-cvslog] avformat/hlsenc: support CODECS Attribute in hevc EXT-X-STREAM-INF

2020-10-19 Thread Steven Liu
ffmpeg | branch: master | Steven Liu  | Tue Oct 13 
15:05:59 2020 +0800| [a2b1dd0ce301450a47c972745a6b33c4c273aa5d] | committer: 
liuqi05

avformat/hlsenc: support CODECS Attribute in hevc EXT-X-STREAM-INF

fix ticket: 8904
parse the SPS from extradata and get profile_tier_level
write the profile_tier_level info into CODECS Attribute

HLS CODECS Attribute reference to 
:https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices/hls_authoring_specification_for_apple_devices_appendixes

Signed-off-by: Steven Liu 
Signed-off-by: liuqi05 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2b1dd0ce301450a47c972745a6b33c4c273aa5d
---

 libavformat/hlsenc.c | 48 
 1 file changed, 48 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index f7eb2411b0..8e4cc36d50 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -46,6 +46,7 @@
 
 #include "avformat.h"
 #include "avio_internal.h"
+#include "avc.h"
 #if CONFIG_HTTP_PROTOCOL
 #include "http.h"
 #endif
@@ -337,6 +338,49 @@ static void write_codec_attr(AVStream *st, VariantStream 
*vs)
 } else {
 goto fail;
 }
+} else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) {
+uint8_t *data = st->codecpar->extradata;
+int profile = FF_PROFILE_UNKNOWN;
+int level = FF_LEVEL_UNKNOWN;
+
+if (st->codecpar->profile != FF_PROFILE_UNKNOWN)
+profile = st->codecpar->profile;
+if (st->codecpar->level != FF_LEVEL_UNKNOWN)
+level = st->codecpar->level;
+
+/* check the boundary of data which from current position is small 
than extradata_size */
+while (data && (data - st->codecpar->extradata + 5) < 
st->codecpar->extradata_size) {
+/* get HEVC SPS NAL and seek to profile_tier_level */
+if (!(data[0] | data[1] | data[2]) && data[3] == 1 && ((data[4] & 
0x42) == 0x42)) {
+int remain_size = 0;
+int rbsp_size = 0;
+/* skip start code + nalu header */
+data += 6;
+/* process by reference General NAL unit syntax */
+remain_size = st->codecpar->extradata_size - (data - 
st->codecpar->extradata);
+uint8_t *rbsp_buf = ff_nal_unit_extract_rbsp(data, 
remain_size, &rbsp_size, 0);
+if (!rbsp_buf)
+return;
+if (rbsp_size < 13) {
+av_freep(&rbsp_buf);
+break;
+}
+/* skip sps_video_parameter_set_id   u(4),
+ *  sps_max_sub_layers_minus1u(3),
+ *  and sps_temporal_id_nesting_flag u(1) */
+profile = rbsp_buf[1] & 0x1f;
+/* skip 8 + 8 + 32 + 4 + 43 + 1 bit */
+level = rbsp_buf[12];
+av_freep(&rbsp_buf);
+break;
+}
+data++;
+}
+if (st->codecpar->codec_tag == MKTAG('h','v','c','1') &&
+profile != FF_PROFILE_UNKNOWN &&
+level != FF_LEVEL_UNKNOWN) {
+snprintf(attr, sizeof(attr), "%s.%d.4.L%d.B01", 
av_fourcc2str(st->codecpar->codec_tag), profile, level);
+}
 } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
 snprintf(attr, sizeof(attr), "mp4a.40.33");
 } else if (st->codecpar->codec_id == AV_CODEC_ID_MP3) {
@@ -2247,6 +2291,10 @@ static int hls_write_header(AVFormatContext *s)
 continue;
 }
 avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, 
inner_st->time_base.num, inner_st->time_base.den);
+if (outer_st->codecpar->codec_id == AV_CODEC_ID_HEVC &&
+outer_st->codecpar->codec_tag != MKTAG('h','v','c','1')) {
+av_log(s, AV_LOG_WARNING, "Stream HEVC is not hvc1, you should 
use tag:v hvc1 to set it.\n");
+}
 write_codec_attr(outer_st, vs);
 
 }

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

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

[FFmpeg-cvslog] avformat/hlsenc: compute video_keyframe_size after write keyframe

2020-10-19 Thread Steven Liu
ffmpeg | branch: master | Steven Liu  | Fri Sep 18 
09:53:27 2020 +0800| [b5ca8f2c66954614d81579082025f580efc0cffc] | committer: 
liuqi05

avformat/hlsenc: compute video_keyframe_size after write keyframe

fix ticket: 8636
When write keyframe and the keyframe is the frist packet of the segment,
then compute the size of the keyframe which have been write into segment
first packet. and set the start position of the segment, should not use
avio_tell(vs->out) to get the keyframe position, because it can be set
to 0 if close at above of the workflow, that maybe inaccurate, but the
start_pos can be used here, because start_pos is set after write
the previous packet.

Signed-off-by: Steven Liu 
Signed-off-by: liuqi05 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5ca8f2c66954614d81579082025f580efc0cffc
---

 libavformat/hlsenc.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 4471858222..f7eb2411b0 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2572,13 +2572,14 @@ static int hls_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 
 vs->packets_written++;
 if (oc->pb) {
+int64_t keyframe_pre_pos = avio_tell(oc->pb);
 ret = ff_write_chained(oc, stream_index, pkt, s, 0);
-vs->video_keyframe_size += pkt->size;
-if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && (pkt->flags & 
AV_PKT_FLAG_KEY)) {
-vs->video_keyframe_size = avio_tell(oc->pb);
-} else {
-vs->video_keyframe_pos = avio_tell(vs->out);
+if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
+(pkt->flags & AV_PKT_FLAG_KEY) && !keyframe_pre_pos) {
+av_write_frame(oc, NULL); /* Flush any buffered data */
+vs->video_keyframe_size = avio_tell(oc->pb) - keyframe_pre_pos;
 }
+vs->video_keyframe_pos = vs->start_pos;
 if (hls->ignore_io_errors)
 ret = 0;
 }

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

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