[FFmpeg-cvslog] avcodec/dstdec: Check sample rate

2020-05-10 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Feb 13 20:56:56 2020 +0100| [5727b1f13f36c4db30d5d0de51640f740edf01e8] | 
committer: Michael Niedermayer

avcodec/dstdec: Check sample rate

Fixes: out of array access
Fixes: 
20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-5735812071424000

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol 
Signed-off-by: Michael Niedermayer 

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

 libavcodec/dstdec.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c
index 9feca4b085..771887faf9 100644
--- a/libavcodec/dstdec.c
+++ b/libavcodec/dstdec.c
@@ -86,6 +86,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
 return AVERROR_PATCHWELCOME;
 }
 
+if (DST_SAMPLES_PER_FRAME(avctx->sample_rate) & 7) {
+return AVERROR_PATCHWELCOME;
+}
+
 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
 
 for (i = 0; i < avctx->channels; i++)

___
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] hwcontext_vulkan: optionally enable the VK_KHR_surface extension if available

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 11:21:52 2020 
+0100| [b69f5a72cec0f604b8160c5d18a56036522635b8] | committer: Lynne

hwcontext_vulkan: optionally enable the VK_KHR_surface extension if available

This allows any phys_device derived to be used as a display rendering device.

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

 libavutil/hwcontext_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index fa53d9d121..43e7cddbc5 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -187,7 +187,7 @@ typedef struct VulkanOptExtension {
 } VulkanOptExtension;
 
 static const VulkanOptExtension optional_instance_exts[] = {
-/* For future use */
+{ VK_KHR_SURFACE_EXTENSION_NAME, EXT_OPTIONAL },
 };
 
 static const VulkanOptExtension optional_device_exts[] = {

___
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/wavenc: simplify, use av_rescale_q() instead

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Tue Apr 28 
11:49:17 2020 +0800| [026b3a901865e77b3804e6e0a82652f315d171e6] | committer: 
Limin Wang

avformat/wavenc: simplify, use av_rescale_q() instead

Signed-off-by: Limin Wang 

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

 libavformat/wavenc.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index f6f5710802..1027f107ee 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -434,10 +434,9 @@ static int wav_write_trailer(AVFormatContext *s)
"Filesize %"PRId64" invalid for wav, output file will be 
broken\n",
file_size);
 }
-
-number_of_samples = av_rescale(wav->maxpts - wav->minpts + 
wav->last_duration,
-   s->streams[0]->codecpar->sample_rate * 
(int64_t)s->streams[0]->time_base.num,
-   s->streams[0]->time_base.den);
+number_of_samples = av_rescale_q(wav->maxpts - wav->minpts + 
wav->last_duration,
+   s->streams[0]->time_base,
+   av_make_q(1, 
s->streams[0]->codecpar->sample_rate));
 
 if(s->streams[0]->codecpar->codec_tag != 0x01) {
 /* Update num_samps in fact chunk */

___
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] fate: add signalstats 8bit and 10bit test

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Mon Dec 30 
19:09:54 2019 +0800| [5752e97b4e2720805e9d40a6693b8ef833429136] | committer: 
Limin Wang

fate: add signalstats 8bit and 10bit test

Signed-off-by: Limin Wang 

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

 tests/fate/filter-video.mak  | 5 +
 tests/ref/fate/filter-metadata-signalstats-yuv420p   | 1 +
 tests/ref/fate/filter-metadata-signalstats-yuv420p10 | 1 +
 3 files changed, 7 insertions(+)

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 2da27f714a..df1675e1e7 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -754,6 +754,11 @@ FREEZEDETECT_DEPS = FFPROBE AVDEVICE LAVFI_INDEV 
MPTESTSRC_FILTER SCALE_FILTER F
 FATE_METADATA_FILTER-$(call ALLYES, $(FREEZEDETECT_DEPS)) += 
fate-filter-metadata-freezedetect
 fate-filter-metadata-freezedetect: CMD = run $(FILTER_METADATA_COMMAND) 
"sws_flags=+accurate_rnd+bitexact;mptestsrc=r=25:d=10:m=51,freezedetect"
 
+SIGNALSTATS_DEPS = FFPROBE AVDEVICE LAVFI_INDEV COLOR_FILTER SCALE_FILTER 
SIGNALSTATS_FILTER
+FATE_METADATA_FILTER-$(call ALLYES, $(SIGNALSTATS_DEPS)) += 
fate-filter-metadata-signalstats-yuv420p 
fate-filter-metadata-signalstats-yuv420p10
+fate-filter-metadata-signalstats-yuv420p: CMD = run $(FILTER_METADATA_COMMAND) 
"sws_flags=+accurate_rnd+bitexact;color=white:duration=1:r=1,signalstats"
+fate-filter-metadata-signalstats-yuv420p10: CMD = run 
$(FILTER_METADATA_COMMAND) 
"sws_flags=+accurate_rnd+bitexact;color=white:duration=1:r=1,format=yuv420p10,signalstats"
+
 SILENCEDETECT_DEPS = FFPROBE AVDEVICE LAVFI_INDEV AMOVIE_FILTER TTA_DEMUXER 
TTA_DECODER SILENCEDETECT_FILTER
 FATE_METADATA_FILTER-$(call ALLYES, $(SILENCEDETECT_DEPS)) += 
fate-filter-metadata-silencedetect
 fate-filter-metadata-silencedetect: SRC = 
$(TARGET_SAMPLES)/lossless-audio/inside.tta
diff --git a/tests/ref/fate/filter-metadata-signalstats-yuv420p 
b/tests/ref/fate/filter-metadata-signalstats-yuv420p
new file mode 100644
index 00..2e76134b3c
--- /dev/null
+++ b/tests/ref/fate/filter-metadata-signalstats-yuv420p
@@ -0,0 +1 @@
+pkt_pts=0|tag:lavfi.signalstats.YMIN=235|tag:lavfi.signalstats.YLOW=235|tag:lavfi.signalstats.YAVG=235|tag:lavfi.signalstats.YHIGH=235|tag:lavfi.signalstats.YMAX=235|tag:lavfi.signalstats.UMIN=128|tag:lavfi.signalstats.ULOW=128|tag:lavfi.signalstats.UAVG=128|tag:lavfi.signalstats.UHIGH=128|tag:lavfi.signalstats.UMAX=128|tag:lavfi.signalstats.VMIN=128|tag:lavfi.signalstats.VLOW=128|tag:lavfi.signalstats.VAVG=128|tag:lavfi.signalstats.VHIGH=128|tag:lavfi.signalstats.VMAX=128|tag:lavfi.signalstats.SATMIN=0|tag:lavfi.signalstats.SATLOW=0|tag:lavfi.signalstats.SATAVG=0|tag:lavfi.signalstats.SATHIGH=0|tag:lavfi.signalstats.SATMAX=0|tag:lavfi.signalstats.HUEMED=180|tag:lavfi.signalstats.HUEAVG=180|tag:lavfi.signalstats.YDIF=0|tag:lavfi.signalstats.UDIF=0|tag:lavfi.signalstats.VDIF=0|tag:lavfi.signalstats.YBITDEPTH=6|tag:lavfi.signalstats.UBITDEPTH=1|tag:lavfi.signalstats.VBITDEPTH=1
diff --git a/tests/ref/fate/filter-metadata-signalstats-yuv420p10 
b/tests/ref/fate/filter-metadata-signalstats-yuv420p10
new file mode 100644
index 00..f9a794799d
--- /dev/null
+++ b/tests/ref/fate/filter-metadata-signalstats-yuv420p10
@@ -0,0 +1 @@
+pkt_pts=0|tag:lavfi.signalstats.YMIN=940|tag:lavfi.signalstats.YLOW=940|tag:lavfi.signalstats.YAVG=940|tag:lavfi.signalstats.YHIGH=940|tag:lavfi.signalstats.YMAX=940|tag:lavfi.signalstats.UMIN=512|tag:lavfi.signalstats.ULOW=512|tag:lavfi.signalstats.UAVG=512|tag:lavfi.signalstats.UHIGH=512|tag:lavfi.signalstats.UMAX=512|tag:lavfi.signalstats.VMIN=512|tag:lavfi.signalstats.VLOW=512|tag:lavfi.signalstats.VAVG=512|tag:lavfi.signalstats.VHIGH=512|tag:lavfi.signalstats.VMAX=512|tag:lavfi.signalstats.SATMIN=0|tag:lavfi.signalstats.SATLOW=0|tag:lavfi.signalstats.SATAVG=0|tag:lavfi.signalstats.SATHIGH=0|tag:lavfi.signalstats.SATMAX=0|tag:lavfi.signalstats.HUEMED=180|tag:lavfi.signalstats.HUEAVG=180|tag:lavfi.signalstats.YDIF=0|tag:lavfi.signalstats.UDIF=0|tag:lavfi.signalstats.VDIF=0|tag:lavfi.signalstats.YBITDEPTH=6|tag:lavfi.signalstats.UBITDEPTH=1|tag:lavfi.signalstats.VBITDEPTH=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/vividas: simplify, use av_rescale_q() instead

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Tue Apr 28 
11:49:16 2020 +0800| [386dbf5726368783ce4c4ae057885d873380f60c] | committer: 
Limin Wang

avformat/vividas: simplify, use av_rescale_q() instead

note it'll cause a small difference in accuracy for the pts, please see the 
testing result below:
 $ wget 
http://samples.ffmpeg.org/archive/all/unknown+unknown+unknown+unknown+5029_paramount_en_1250.viv
 $ ./ffmpeg -t 0.04 -i 
./unknown+unknown+unknown+unknown+5029_paramount_en_1250.viv -f null -
 old:
 pts: 522
 pts: 1044
 pts: 1567
 pts: 3918
 pts: 8097
 pts: 12277
 pts: 16457
 ...

 new:
 pts: 522
 pts: 1045
 pts: 1567
 pts: 3918
 pts: 8098
 pts: 12278
 pts: 16457
 ...

Signed-off-by: Limin Wang 

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

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

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index 4f54a4302e..b0f9f35ac2 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -646,7 +646,7 @@ static int viv_read_packet(AVFormatContext *s,
 pkt->stream_index = 1;
 astream = s->streams[pkt->stream_index];
 
-pkt->pts = av_rescale(viv->audio_sample, astream->time_base.den, 
astream->time_base.num) / astream->codecpar->sample_rate;
+pkt->pts = av_rescale_q(viv->audio_sample, av_make_q(1, 
astream->codecpar->sample_rate), astream->time_base);
 viv->audio_sample += 
viv->audio_subpackets[viv->current_audio_subpacket].pcm_bytes / 2 / 
astream->codecpar->channels;
 pkt->flags |= AV_PKT_FLAG_KEY;
 viv->current_audio_subpacket++;

___
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/http: Fix for invalid use of av_strtok

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Sat Apr 18 
12:19:31 2020 +0800| [3b8b6d837e49bb6a7111b866b2a9180577e67901] | committer: 
Limin Wang

avformat/http: Fix for invalid use of av_strtok

Signed-off-by: Limin Wang 

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

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

diff --git a/libavformat/http.c b/libavformat/http.c
index c9415578aa..20545ed1f8 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -786,6 +786,7 @@ static int parse_set_cookie_expiry_time(const char 
*exp_str, struct tm *buf)
 static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
 {
 char *param, *next_param, *cstr, *back;
+char *saveptr = NULL;
 
 if (!set_cookie[0])
 return 0;
@@ -803,8 +804,9 @@ static int parse_set_cookie(const char *set_cookie, 
AVDictionary **dict)
 }
 
 next_param = cstr;
-while ((param = av_strtok(next_param, ";", &next_param))) {
+while ((param = av_strtok(next_param, ";", &saveptr))) {
 char *name, *value;
+next_param = NULL;
 param += strspn(param, WHITESPACES);
 if ((name = av_strtok(param, "=", &value))) {
 if (av_dict_set(dict, name, value, 0) < 0) {
@@ -1064,6 +1066,7 @@ static int get_cookies(HTTPContext *s, char **cookies, 
const char *path,
 // Set-Cookie fields will result in multiple values delimited by a newline
 int ret = 0;
 char *cookie, *set_cookies, *next;
+char *saveptr = NULL;
 
 // destroy any cookies in the dictionary.
 av_dict_free(&s->cookie_dict);
@@ -1076,10 +1079,11 @@ static int get_cookies(HTTPContext *s, char **cookies, 
const char *path,
 return AVERROR(ENOMEM);
 
 *cookies = NULL;
-while ((cookie = av_strtok(next, "\n", &next)) && !ret) {
+while ((cookie = av_strtok(next, "\n", &saveptr)) && !ret) {
 AVDictionary *cookie_params = NULL;
 AVDictionaryEntry *cookie_entry, *e;
 
+next = NULL;
 // store the cookie in a dict in case it is updated in the response
 if (parse_cookie(s, cookie, &s->cookie_dict))
 av_log(s, AV_LOG_WARNING, "Unable to parse '%s'\n", cookie);

___
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/vf_signalstats: rename config_props -> config_output

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Mon Dec 30 
19:09:55 2019 +0800| [a8c762a17d5d12f7e6838c023e5b597737547fd4] | committer: 
Limin Wang

avfilter/vf_signalstats: rename config_props -> config_output

Signed-off-by: Limin Wang 

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

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

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index abe813d91d..cba14e4fa7 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -157,7 +157,7 @@ static AVFrame *alloc_frame(enum AVPixelFormat pixfmt, int 
w, int h)
 return frame;
 }
 
-static int config_props(AVFilterLink *outlink)
+static int config_output(AVFilterLink *outlink)
 {
 AVFilterContext *ctx = outlink->src;
 SignalstatsContext *s = ctx->priv;
@@ -1004,7 +1004,7 @@ static const AVFilterPad signalstats_inputs[] = {
 static const AVFilterPad signalstats_outputs[] = {
 {
 .name   = "default",
-.config_props   = config_props,
+.config_props   = config_output,
 .type   = AVMEDIA_TYPE_VIDEO,
 },
 { NULL }

___
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/vf_signalstats: add SignalstatsContext.maxsize variable

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Mon Dec 30 
19:09:56 2019 +0800| [764efda192df4fc79292168c2b32ca7465d94e5c] | committer: 
Limin Wang

avfilter/vf_signalstats: add SignalstatsContext.maxsize variable

Signed-off-by: Limin Wang 

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

 libavfilter/vf_signalstats.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index cba14e4fa7..7dadff45b3 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -50,6 +50,7 @@ typedef struct SignalstatsContext {
 int nb_jobs;
 int *jobs_rets;
 
+int maxsize;// history stats array size
 int *histy, *histu, *histv, *histsat;
 
 AVFrame *frame_sat;
@@ -166,11 +167,12 @@ static int config_output(AVFilterLink *outlink)
 s->hsub = desc->log2_chroma_w;
 s->vsub = desc->log2_chroma_h;
 s->depth = desc->comp[0].depth;
+s->maxsize = 1 << s->depth;
 if (s->depth > 8) {
-s->histy = av_malloc_array(1 << s->depth, sizeof(*s->histy));
-s->histu = av_malloc_array(1 << s->depth, sizeof(*s->histu));
-s->histv = av_malloc_array(1 << s->depth, sizeof(*s->histv));
-s->histsat = av_malloc_array(1 << s->depth, sizeof(*s->histsat));
+s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy));
+s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu));
+s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv));
+s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat));
 
 if (!s->histy || !s->histu || !s->histv || !s->histsat)
 return AVERROR(ENOMEM);
@@ -823,7 +825,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in)
NULL, FFMIN(s->chromah, 
ff_filter_get_nb_threads(ctx)));
 
 // Calculate luma histogram and difference with previous frame or field.
-memset(s->histy, 0, (1 << s->depth) * sizeof(*s->histy));
+memset(s->histy, 0, s->maxsize * sizeof(*s->histy));
 for (j = 0; j < link->h; j++) {
 for (i = 0; i < link->w; i++) {
 const int yuv = AV_RN16(in->data[0] + w + i * 2);
@@ -837,9 +839,9 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in)
 }
 
 // Calculate chroma histogram and difference with previous frame or field.
-memset(s->histu, 0, (1 << s->depth) * sizeof(*s->histu));
-memset(s->histv, 0, (1 << s->depth) * sizeof(*s->histv));
-memset(s->histsat, 0, (1 << s->depth) * sizeof(*s->histsat));
+memset(s->histu, 0, s->maxsize * sizeof(*s->histu));
+memset(s->histv, 0, s->maxsize * sizeof(*s->histv));
+memset(s->histsat, 0, s->maxsize * sizeof(*s->histsat));
 for (j = 0; j < s->chromah; j++) {
 for (i = 0; i < s->chromaw; i++) {
 const int yuvu = AV_RN16(in->data[1] + cw + i * 2);
@@ -884,7 +886,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in)
 chighp = lrint(s->cfs * 90 / 100.);
 
 accy = accu = accv = accsat = 0;
-for (fil = 0; fil < 1 << s->depth; fil++) {
+for (fil = 0; fil < s->maxsize; fil++) {
 if (miny   < 0 && histy[fil])   miny = fil;
 if (minu   < 0 && histu[fil])   minu = fil;
 if (minv   < 0 && histv[fil])   minv = fil;

___
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/ftp: Fix for invalid use of av_strtok

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Sat Apr 18 
12:19:30 2020 +0800| [53c88355a5ae638b3a3cf93508c4741238dc6c7f] | committer: 
Limin Wang

avformat/ftp: Fix for invalid use of av_strtok

By the av_strtok() description:
 * On the first call to av_strtok(), s should point to the string to
 * parse, and the value of saveptr is ignored. In subsequent calls, s
 * should be NULL, and saveptr should be unchanged since the previous
 * call.

Signed-off-by: Limin Wang 

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

 libavformat/ftp.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index e3d194da58..caeea42920 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -333,15 +333,15 @@ static int ftp_passive_mode(FTPContext *s)
 *end  = '\0';
 /* skip ip */
 if (!av_strtok(start, ",", &end)) goto fail;
-if (!av_strtok(end, ",", &end)) goto fail;
-if (!av_strtok(end, ",", &end)) goto fail;
-if (!av_strtok(end, ",", &end)) goto fail;
+if (!av_strtok(NULL, ",", &end)) goto fail;
+if (!av_strtok(NULL, ",", &end)) goto fail;
+if (!av_strtok(NULL, ",", &end)) goto fail;
 
 /* parse port number */
-start = av_strtok(end, ",", &end);
+start = av_strtok(NULL, ",", &end);
 if (!start) goto fail;
 s->server_data_port = atoi(start) * 256;
-start = av_strtok(end, ",", &end);
+start = av_strtok(NULL, ",", &end);
 if (!start) goto fail;
 s->server_data_port += atoi(start);
 ff_dlog(s, "Server data port: %d\n", s->server_data_port);
@@ -963,8 +963,10 @@ static int ftp_parse_entry_nlst(char *line, AVIODirEntry 
*next)
 static int ftp_parse_entry_mlsd(char *mlsd, AVIODirEntry *next)
 {
 char *fact, *value;
+char *saveptr = NULL, *p = mlsd;
 ff_dlog(NULL, "%s\n", mlsd);
-while(fact = av_strtok(mlsd, ";", &mlsd)) {
+while(fact = av_strtok(p, ";", &saveptr)) {
+p = NULL;
 if (fact[0] == ' ') {
 next->name = av_strdup(&fact[1]);
 continue;

___
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/vf_signalstats: make the alloc array used for any bit depth

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Mon Dec 30 
19:09:57 2019 +0800| [25bb72af621c4cfe90b0856e948a1301630b42b8] | committer: 
Limin Wang

avfilter/vf_signalstats: make the alloc array used for any bit depth

Signed-off-by: Limin Wang 

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

 libavfilter/vf_signalstats.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 7dadff45b3..8b2a9ca7c2 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -168,7 +168,6 @@ static int config_output(AVFilterLink *outlink)
 s->vsub = desc->log2_chroma_h;
 s->depth = desc->comp[0].depth;
 s->maxsize = 1 << s->depth;
-if (s->depth > 8) {
 s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy));
 s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu));
 s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv));
@@ -176,7 +175,6 @@ static int config_output(AVFilterLink *outlink)
 
 if (!s->histy || !s->histu || !s->histv || !s->histsat)
 return AVERROR(ENOMEM);
-}
 
 outlink->w = inlink->w;
 outlink->h = inlink->h;
@@ -464,8 +462,6 @@ static const struct {
 {NULL}
 };
 
-#define DEPTH 256
-
 static int compute_sat_hue_metrics8(AVFilterContext *ctx, void *arg, int 
jobnr, int nb_jobs)
 {
 int i, j;
@@ -559,11 +555,11 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
 pw = 0, cpw = 0; // prev
 int fil;
 char metabuf[128];
-unsigned int histy[DEPTH] = {0},
- histu[DEPTH] = {0},
- histv[DEPTH] = {0},
+unsigned int *histy = s->histy,
+ *histu = s->histu,
+ *histv = s->histv,
  histhue[360] = {0},
- histsat[DEPTH] = {0}; // limited to 8 bit data.
+ *histsat = s->histsat;
 int miny  = -1, minu  = -1, minv  = -1;
 int maxy  = -1, maxu  = -1, maxv  = -1;
 int lowy  = -1, lowu  = -1, lowv  = -1;
@@ -607,6 +603,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
NULL, FFMIN(s->chromah, 
ff_filter_get_nb_threads(ctx)));
 
 // Calculate luma histogram and difference with previous frame or field.
+memset(s->histy, 0, s->maxsize * sizeof(*s->histy));
 for (j = 0; j < link->h; j++) {
 for (i = 0; i < link->w; i++) {
 const int yuv = in->data[0][w + i];
@@ -620,6 +617,9 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
 }
 
 // Calculate chroma histogram and difference with previous frame or field.
+memset(s->histu, 0, s->maxsize * sizeof(*s->histu));
+memset(s->histv, 0, s->maxsize * sizeof(*s->histv));
+memset(s->histsat, 0, s->maxsize * sizeof(*s->histsat));
 for (j = 0; j < s->chromah; j++) {
 for (i = 0; i < s->chromaw; i++) {
 const int yuvu = in->data[1][cw+i];
@@ -664,7 +664,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
 chighp = lrint(s->cfs * 90 / 100.);
 
 accy = accu = accv = accsat = 0;
-for (fil = 0; fil < DEPTH; fil++) {
+for (fil = 0; fil < s->maxsize; fil++) {
 if (miny   < 0 && histy[fil])   miny = fil;
 if (minu   < 0 && histu[fil])   minu = fil;
 if (minv   < 0 && histv[fil])   minv = fil;

___
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/vf_signalstats: reindent after last commit

2020-05-10 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Mon Dec 30 
19:09:58 2019 +0800| [a058d81570e037fd36c427f0bf5237184361ebdc] | committer: 
Limin Wang

avfilter/vf_signalstats: reindent after last commit

Signed-off-by: Limin Wang 

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

 libavfilter/vf_signalstats.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 8b2a9ca7c2..1ccc16dd38 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -168,13 +168,13 @@ static int config_output(AVFilterLink *outlink)
 s->vsub = desc->log2_chroma_h;
 s->depth = desc->comp[0].depth;
 s->maxsize = 1 << s->depth;
-s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy));
-s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu));
-s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv));
-s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat));
+s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy));
+s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu));
+s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv));
+s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat));
 
-if (!s->histy || !s->histu || !s->histv || !s->histsat)
-return AVERROR(ENOMEM);
+if (!s->histy || !s->histu || !s->histv || !s->histsat)
+return AVERROR(ENOMEM);
 
 outlink->w = inlink->w;
 outlink->h = inlink->h;

___
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: Don't reset AVIOContext pointer manually a second time

2020-05-10 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat May  9 15:34:09 2020 +0200| [a90f2265fa54ab35ee1b2058c7d6e746fd847359] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Don't reset AVIOContext pointer manually a second time

ff_format_io_close() already does it for us.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 7b289c060f..a796c124dd 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2497,7 +2497,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if ((ret = hls_window(s, 0, vs)) < 0) {
 av_log(s, AV_LOG_WARNING, "upload playlist failed, will retry 
with a new http session.\n");
 ff_format_io_close(s, &vs->out);
-vs->out = NULL;
 if ((ret = hls_window(s, 0, vs)) < 0) {
 av_freep(&old_filename);
 return ret;

___
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: Remove redundant initializations

2020-05-10 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat May  9 15:59:43 2020 +0200| [d41c93d1556e3021ebfec803e621815252afbd44] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Remove redundant initializations

For every variantstream vs, vs->packets_written is set to one, only to be
set to zero a few lines below. Given that the relevant structure has
been zeroed during the allocation, this commit removes both assignments.
A redundant initialization for vs->init_range_length has been removed as
well a few lines below. Given that the relevant structure has been
zeroed during the allocation, this commit removes both assignments. A
redundant initialization for vs->init_range_length has been removed as
well.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a796c124dd..afb4d2a0c0 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -833,7 +833,6 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 av_dict_copy(&st->metadata, vs->streams[i]->metadata, 0);
 }
 
-vs->packets_written = 1;
 vs->start_pos = 0;
 vs->new_start = 1;
 
@@ -848,9 +847,6 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 }
 }
 
-vs->packets_written = 0;
-vs->init_range_length = 0;
-
 if ((ret = avio_open_dyn_buf(&oc->pb)) < 0)
 return ret;
 

___
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: Don't cast const away

2020-05-10 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat May  9 06:54:56 2020 +0200| [940601616e4f39d7aa9da20a5e0b5e943b9ac2ca] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Don't cast const away

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index afb4d2a0c0..2a0d17baea 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -525,10 +525,10 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 int ret = 0;
 int segment_cnt = 0;
 AVBPrint path;
-char *dirname = NULL;
+const char *dirname = NULL;
 char *dirname_r = NULL;
 char *dirname_repl = NULL;
-char *vtt_dirname = NULL;
+const char *vtt_dirname = NULL;
 char *vtt_dirname_r = NULL;
 const char *proto = NULL;
 
@@ -559,7 +559,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 
 if (segment && !hls->use_localtime_mkdir) {
 dirname_r = hls->segment_filename ? av_strdup(hls->segment_filename): 
av_strdup(vs->avf->url);
-dirname = (char*)av_dirname(dirname_r);
+dirname = av_dirname(dirname_r);
 }
 
 /* if %v is present in the file's directory
@@ -598,7 +598,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 
 if ((segment->sub_filename[0] != '\0')) {
 vtt_dirname_r = av_strdup(vs->vtt_avf->url);
-vtt_dirname = (char*)av_dirname(vtt_dirname_r);
+vtt_dirname = av_dirname(vtt_dirname_r);
 
 av_bprint_clear(&path);
 av_bprintf(&path, "%s%c%s", vtt_dirname, SEPARATOR,

___
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: Simplify setting subtitle basename with av_asprintf

2020-05-10 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Apr  8 22:57:50 2020 +0200| [6b44f6839d90df344597eba385d2a589334e04a6] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Simplify setting subtitle basename with av_asprintf

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 2a0d17baea..5517cb4354 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2743,9 +2743,8 @@ static int hls_init(AVFormatContext *s)
 VariantStream *vs = NULL;
 int basename_size = 0;
 const char *pattern_localtime_fmt = get_default_pattern_localtime_fmt(s);
-const char *vtt_pattern = "%d.vtt";
+const char *vtt_pattern = hls->flags & HLS_SINGLE_FILE ? ".vtt" : "%d.vtt";
 char *p = NULL;
-int vtt_basename_size = 0;
 int http_base_proto = ff_is_http_proto(s->url);
 int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;
 
@@ -2954,28 +2953,25 @@ static int hls_init(AVFormatContext *s)
 if (!vs->vtt_oformat)
 return AVERROR_MUXER_NOT_FOUND;
 
-if (hls->flags & HLS_SINGLE_FILE)
-vtt_pattern = ".vtt";
-vtt_basename_size = strlen(vs->m3u8_name) + strlen(vtt_pattern) + 
1;
+p = strrchr(vs->m3u8_name, '.');
+if (p)
+*p = '\0';
 
-vs->vtt_basename = av_malloc(vtt_basename_size);
+vs->vtt_basename = av_asprintf("%s%s", vs->m3u8_name, vtt_pattern);
 if (!vs->vtt_basename)
 return AVERROR(ENOMEM);
-av_strlcpy(vs->vtt_basename, vs->m3u8_name, vtt_basename_size);
-p = strrchr(vs->vtt_basename, '.');
-if (p)
-*p = '\0';
 
 if (hls->subtitle_filename) {
 ret = format_name(hls->subtitle_filename, &vs->vtt_m3u8_name, 
i, vs->varname);
 if (ret < 0)
 return ret;
 } else {
-vs->vtt_m3u8_name = av_asprintf("%s_vtt.m3u8", 
vs->vtt_basename);
+vs->vtt_m3u8_name = av_asprintf("%s_vtt.m3u8", vs->m3u8_name);
 if (!vs->vtt_m3u8_name)
 return AVERROR(ENOMEM);
 }
-av_strlcat(vs->vtt_basename, vtt_pattern, vtt_basename_size);
+if (p)
+*p = '.';
 }
 
 if (hls->baseurl) {

___
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: Simplify setting basename with av_asprintf()

2020-05-10 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Apr  8 23:41:17 2020 +0200| [21553d2082a8b5997c25b7b13a9b3426ac43e116] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Simplify setting basename with av_asprintf()

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 43 ++-
 1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 5517cb4354..d80852739e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2739,15 +2739,21 @@ static int hls_init(AVFormatContext *s)
 int i = 0;
 int j = 0;
 HLSContext *hls = s->priv_data;
-const char *pattern = "%d.ts";
+const char *pattern;
 VariantStream *vs = NULL;
-int basename_size = 0;
-const char *pattern_localtime_fmt = get_default_pattern_localtime_fmt(s);
 const char *vtt_pattern = hls->flags & HLS_SINGLE_FILE ? ".vtt" : "%d.vtt";
 char *p = NULL;
 int http_base_proto = ff_is_http_proto(s->url);
 int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;
 
+if (hls->use_localtime) {
+pattern = get_default_pattern_localtime_fmt(s);
+} else {
+pattern = hls->segment_type == SEGMENT_TYPE_FMP4 ? "%d.m4s" : "%d.ts";
+if (hls->flags & HLS_SINGLE_FILE)
+pattern += 2;
+}
+
 hls->has_default_key = 0;
 hls->has_video_m3u8 = 0;
 ret = update_variant_stream_info(s);
@@ -2792,9 +2798,6 @@ static int hls_init(AVFormatContext *s)
 }
 }
 
-if (hls->segment_type == SEGMENT_TYPE_FMP4) {
-pattern = "%d.m4s";
-}
 if ((hls->start_sequence_source_type == 
HLS_START_SEQUENCE_AS_SECONDS_SINCE_EPOCH) ||
 (hls->start_sequence_source_type == 
HLS_START_SEQUENCE_AS_MICROSECONDS_SINCE_EPOCH) ||
 (hls->start_sequence_source_type == 
HLS_START_SEQUENCE_AS_FORMATTED_DATETIME)) {
@@ -2868,34 +2871,16 @@ static int hls_init(AVFormatContext *s)
 if (ret < 0)
 return ret;
 } else {
-if (hls->flags & HLS_SINGLE_FILE) {
-if (hls->segment_type == SEGMENT_TYPE_FMP4) {
-pattern = ".m4s";
-} else {
-pattern = ".ts";
-}
-}
-
-if (hls->use_localtime) {
-basename_size = strlen(vs->m3u8_name) + 
strlen(pattern_localtime_fmt) + 1;
-} else {
-basename_size = strlen(vs->m3u8_name) + strlen(pattern) + 1;
-}
+p = strrchr(vs->m3u8_name, '.');
+if (p)
+*p = '\0';
 
-vs->basename = av_malloc(basename_size);
+vs->basename = av_asprintf("%s%s", vs->m3u8_name, pattern);
 if (!vs->basename)
 return AVERROR(ENOMEM);
 
-av_strlcpy(vs->basename, vs->m3u8_name, basename_size);
-
-p = strrchr(vs->basename, '.');
 if (p)
-*p = '\0';
-if (hls->use_localtime) {
-av_strlcat(vs->basename, pattern_localtime_fmt, basename_size);
-} else {
-av_strlcat(vs->basename, pattern, basename_size);
-}
+*p = '.';
 }
 
 if (hls->segment_type == SEGMENT_TYPE_FMP4) {

___
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: Simplify setting base_output_dirname

2020-05-10 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri May  8 21:40:29 2020 +0200| [6db81e93a95d150ec828214ba7eb6183577c748c] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Simplify setting base_output_dirname

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d80852739e..be54957e9d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2908,24 +2908,18 @@ static int hls_init(AVFormatContext *s)
 return ret;
 }
 
-fmp4_init_filename_len = strlen(vs->m3u8_name) +
-strlen(vs->fmp4_init_filename) + 1;
-
-vs->base_output_dirname = av_malloc(fmp4_init_filename_len);
-if (!vs->base_output_dirname)
-return AVERROR(ENOMEM);
-
-av_strlcpy(vs->base_output_dirname, vs->m3u8_name,
-   fmp4_init_filename_len);
-p = strrchr(vs->base_output_dirname, '/');
+p = strrchr(vs->m3u8_name, '/');
 if (p) {
-*(p + 1) = '\0';
-av_strlcat(vs->base_output_dirname, vs->fmp4_init_filename,
-   fmp4_init_filename_len);
+char tmp = *(++p);
+*p = '\0';
+vs->base_output_dirname = av_asprintf("%s%s", 
vs->m3u8_name,
+  
vs->fmp4_init_filename);
+*p = tmp;
 } else {
-av_strlcpy(vs->base_output_dirname, vs->fmp4_init_filename,
-   fmp4_init_filename_len);
+vs->base_output_dirname = 
av_strdup(vs->fmp4_init_filename);
 }
+if (!vs->base_output_dirname)
+return AVERROR(ENOMEM);
 }
 }
 

___
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] hwcontext_vulkan: remove unused internal REQUIRED extension flag

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 15:17:27 2020 
+0100| [030a565baf3b565f65b93c366b789a9e72740536] | committer: Lynne

hwcontext_vulkan: remove unused internal REQUIRED extension flag

This is a leftover from an old version which used the 1.0 Vulkan API
with the maintenance extensions being required.

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

 libavutil/hwcontext_vulkan.c | 20 
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index aca34a35a8..db71e39003 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -181,8 +181,7 @@ enum VulkanExtensions {
 EXT_EXTERNAL_FD_MEMORY = 1ULL <<  2, /* VK_KHR_external_memory_fd */
 EXT_EXTERNAL_FD_SEM= 1ULL <<  3, /* VK_KHR_external_semaphore_fd */
 
-EXT_OPTIONAL   = 1ULL << 62,
-EXT_REQUIRED   = 1ULL << 63,
+EXT_NO_FLAG= 1ULL << 63,
 };
 
 typedef struct VulkanOptExtension {
@@ -191,7 +190,7 @@ typedef struct VulkanOptExtension {
 } VulkanOptExtension;
 
 static const VulkanOptExtension optional_instance_exts[] = {
-{ VK_KHR_SURFACE_EXTENSION_NAME, EXT_OPTIONAL },
+{ VK_KHR_SURFACE_EXTENSION_NAME, EXT_NO_FLAG },
 };
 
 static const VulkanOptExtension optional_device_exts[] = {
@@ -321,9 +320,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int 
dev, AVDictionary *opts,
 }
 
 for (int i = 0; i < optional_exts_num; i++) {
-int req = optional_exts[i].flag & EXT_REQUIRED;
 tstr = optional_exts[i].name;
-
 found = 0;
 for (int j = 0; j < sup_ext_count; j++) {
 if (!strcmp(tstr, sup_ext[j].extensionName)) {
@@ -331,20 +328,11 @@ static int check_extensions(AVHWDeviceContext *ctx, int 
dev, AVDictionary *opts,
 break;
 }
 }
-if (!found) {
-int lvl = req ? AV_LOG_ERROR : AV_LOG_VERBOSE;
-av_log(ctx, lvl, "Extension \"%s\" not found!\n", tstr);
-if (req) {
-err = AVERROR(EINVAL);
-goto end;
-}
+if (!found)
 continue;
-}
-if (!req)
-p->extensions |= optional_exts[i].flag;
 
 av_log(ctx, AV_LOG_VERBOSE, "Using %s extension \"%s\"\n", mod, tstr);
-
+p->extensions |= optional_exts[i].flag;
 ADD_VAL_TO_LIST(extension_names, extensions_found, tstr);
 }
 

___
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] hwcontext_vulkan: expose enabled device and instance extensions

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 11:47:50 2020 
+0100| [dccd07f66dfc236206bd37633a4666dbe666c0d5] | committer: Lynne

hwcontext_vulkan: expose enabled device and instance extensions

This solves a huge oversight - it lets users reliably use their own
AVVulkanDeviceContext. Otherwise, the extensions supplied and enabled
are not discoverable by anything outside of hwcontext_vulkan.
Also clarifies that any user-supplied VkInstance must be at least 1.1.

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

 doc/APIchanges   |  4 
 libavutil/hwcontext_vulkan.c | 40 +++-
 libavutil/hwcontext_vulkan.h | 21 -
 libavutil/version.h  |  2 +-
 4 files changed, 56 insertions(+), 11 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index b3e7e89412..75cfdb08b0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-05-10 - xx - lavu 56.44.100 - hwcontext_vulkan.h
+  Add enabled_inst_extensions, num_enabled_inst_extensions, 
enabled_dev_extensions
+  and num_enabled_dev_extensions fields to AVVulkanDeviceContext
+
 2020-04-22 - 0e1db79e37 - lavc 58.81.100 - packet.h
 - lavu 56.43.100 - dovi_meta.h
   Add AV_PKT_DATA_DOVI_CONF and AVDOVIDecoderConfigurationRecord.
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index cb805b0d1b..aca34a35a8 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -445,15 +445,13 @@ static int create_instance(AVHWDeviceContext *ctx, 
AVDictionary *opts)
 /* Try to create the instance */
 ret = vkCreateInstance(&inst_props, hwctx->alloc, &hwctx->inst);
 
-/* Free used memory */
-for (int i = 0; i < inst_props.enabledExtensionCount; i++)
-av_free((void *)inst_props.ppEnabledExtensionNames[i]);
-av_free((void *)inst_props.ppEnabledExtensionNames);
-
 /* Check for errors */
 if (ret != VK_SUCCESS) {
 av_log(ctx, AV_LOG_ERROR, "Instance creation failure: %s\n",
vk_ret2str(ret));
+for (int i = 0; i < inst_props.enabledExtensionCount; i++)
+av_free((void *)inst_props.ppEnabledExtensionNames[i]);
+av_free((void *)inst_props.ppEnabledExtensionNames);
 return AVERROR_EXTERNAL;
 }
 
@@ -476,6 +474,9 @@ static int create_instance(AVHWDeviceContext *ctx, 
AVDictionary *opts)
hwctx->alloc, &p->debug_ctx);
 }
 
+hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames;
+hwctx->nb_enabled_inst_extensions = inst_props.enabledExtensionCount;
+
 return 0;
 }
 
@@ -781,6 +782,14 @@ static void vulkan_device_free(AVHWDeviceContext *ctx)
 }
 
 vkDestroyInstance(hwctx->inst, hwctx->alloc);
+
+for (int i = 0; i < hwctx->nb_enabled_inst_extensions; i++)
+av_free((void *)hwctx->enabled_inst_extensions[i]);
+av_free((void *)hwctx->enabled_inst_extensions);
+
+for (int i = 0; i < hwctx->nb_enabled_dev_extensions; i++)
+av_free((void *)hwctx->enabled_dev_extensions[i]);
+av_free((void *)hwctx->enabled_dev_extensions);
 }
 
 static int vulkan_device_create_internal(AVHWDeviceContext *ctx,
@@ -841,13 +850,12 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 ret = vkCreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc,
  &hwctx->act_dev);
 
-for (int i = 0; i < dev_info.enabledExtensionCount; i++)
-av_free((void *)dev_info.ppEnabledExtensionNames[i]);
-av_free((void *)dev_info.ppEnabledExtensionNames);
-
 if (ret != VK_SUCCESS) {
 av_log(ctx, AV_LOG_ERROR, "Device creation failure: %s\n",
vk_ret2str(ret));
+for (int i = 0; i < dev_info.enabledExtensionCount; i++)
+av_free((void *)dev_info.ppEnabledExtensionNames[i]);
+av_free((void *)dev_info.ppEnabledExtensionNames);
 err = AVERROR_EXTERNAL;
 goto end;
 }
@@ -857,6 +865,9 @@ static int vulkan_device_create_internal(AVHWDeviceContext 
*ctx,
 if (opt_d)
 p->use_linear_images = strtol(opt_d->value, NULL, 10);
 
+hwctx->enabled_dev_extensions = dev_info.ppEnabledExtensionNames;
+hwctx->nb_enabled_dev_extensions = dev_info.enabledExtensionCount;
+
 end:
 return err;
 }
@@ -868,6 +879,17 @@ static int vulkan_device_init(AVHWDeviceContext *ctx)
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
 VulkanDevicePriv *p = ctx->internal->priv;
 
+/* Set device extension flags */
+for (int i = 0; i < hwctx->nb_enabled_dev_extensions; i++) {
+for (int j = 0; j < FF_ARRAY_ELEMS(optional_device_exts); j++) {
+if (!strcmp(hwctx->enabled_dev_extensions[i],
+optional_device_exts[j].name)) {
+p->extensions |= optional_device_exts[j].flag;
+ 

[FFmpeg-cvslog] hwcontext_vulkan: create all images with concurrent sharing mode

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 21:53:39 2020 
+0100| [875c1707e5f6287a6dabc7bc2dc5e1a9f3dc811b] | committer: Lynne

hwcontext_vulkan: create all images with concurrent sharing mode

As it turns out, we were already assuming and treating all images as if they had
concurrent access mode. This just changes the flag to CONCURRENT, which has less
restrictions than EXCLUSIVE, and fixed validation messages on machines with
multiple queues.
The validation layer didn't pick this up because the machine I was testing on
had only a single queue.

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

 libavutil/hwcontext_vulkan.c | 79 +++-
 libavutil/hwcontext_vulkan.h |  4 +++
 2 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 085187c175..df738457c1 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -53,6 +53,10 @@ typedef struct VulkanDevicePriv {
 VkPhysicalDeviceProperties props;
 VkPhysicalDeviceMemoryProperties mprops;
 
+/* Queues */
+uint32_t qfs[3];
+int num_qfs;
+
 /* Debug callback */
 VkDebugUtilsMessengerEXT debug_ctx;
 
@@ -897,6 +901,14 @@ if (n >= queue_num) {
 
 #undef CHECK_QUEUE
 
+p->qfs[p->num_qfs++] = hwctx->queue_family_index;
+if ((hwctx->queue_family_tx_index != hwctx->queue_family_index) &&
+(hwctx->queue_family_tx_index != hwctx->queue_family_comp_index))
+p->qfs[p->num_qfs++] = hwctx->queue_family_tx_index;
+if ((hwctx->queue_family_comp_index != hwctx->queue_family_index) &&
+(hwctx->queue_family_comp_index != hwctx->queue_family_tx_index))
+p->qfs[p->num_qfs++] = hwctx->queue_family_comp_index;
+
 /* Create exec context - if there's something invalid this will error out 
*/
 err = create_exec_ctx(ctx, &p->cmd, hwctx->queue_family_tx_index);
 if (err)
@@ -1333,21 +1345,24 @@ static int create_frame(AVHWFramesContext *hwfc, 
AVVkFrame **frame,
 const int p_h = i > 0 ? AV_CEIL_RSHIFT(h, desc->log2_chroma_h) : h;
 
 VkImageCreateInfo image_create_info = {
-.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
-.pNext = create_pnext,
-.imageType = VK_IMAGE_TYPE_2D,
-.format= img_fmts[i],
-.extent.width  = p_w,
-.extent.height = p_h,
-.extent.depth  = 1,
-.mipLevels = 1,
-.arrayLayers   = 1,
-.flags = VK_IMAGE_CREATE_ALIAS_BIT,
-.tiling= tiling,
-.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
-.usage = usage,
-.sharingMode   = VK_SHARING_MODE_EXCLUSIVE,
-.samples   = VK_SAMPLE_COUNT_1_BIT,
+.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
+.pNext = create_pnext,
+.imageType = VK_IMAGE_TYPE_2D,
+.format= img_fmts[i],
+.extent.width  = p_w,
+.extent.height = p_h,
+.extent.depth  = 1,
+.mipLevels = 1,
+.arrayLayers   = 1,
+.flags = VK_IMAGE_CREATE_ALIAS_BIT,
+.tiling= tiling,
+.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
+.usage = usage,
+.samples   = VK_SAMPLE_COUNT_1_BIT,
+.pQueueFamilyIndices   = p->qfs,
+.queueFamilyIndexCount = p->num_qfs,
+.sharingMode   = p->num_qfs > 1 ? 
VK_SHARING_MODE_CONCURRENT :
+  
VK_SHARING_MODE_EXCLUSIVE,
 };
 
 ret = vkCreateImage(hwctx->act_dev, &image_create_info,
@@ -1820,22 +1835,24 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 const int p_h = i > 0 ? AV_CEIL_RSHIFT(hwfc->height, 
fmt_desc->log2_chroma_h) : hwfc->height;
 
 VkImageCreateInfo image_create_info = {
-.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
-.pNext = &einfo,
-.imageType = VK_IMAGE_TYPE_2D,
-.format= drm_to_vulkan_fmt(desc->layers[i].format),
-.extent.width  = p_w,
-.extent.height = p_h,
-.extent.depth  = 1,
-.mipLevels = 1,
-.arrayLayers   = 1,
-.flags = VK_IMAGE_CREATE_ALIAS_BIT |
- (signal_p ? VK_IMAGE_CREATE_DISJOINT_BIT : 0x0),
-.tiling= f->tiling,
-.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, /* specs say so */
-.usage = DEFAULT_USAGE_FLAGS,
-.sharingMode   = VK_SHARING_MODE_EXCLUSIVE,
-.samples

[FFmpeg-cvslog] hwcontext_vulkan: let users enable device and instance extensions using options

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 11:26:40 2020 
+0100| [3c5e5a5095144d72f0ce6387e4ce840f46f454ea] | committer: Lynne

hwcontext_vulkan: let users enable device and instance extensions using options

Also documents all options supported by the hwdevice.
This lets users enable all extensions they need without writing their own
instance initialization code.

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

 doc/ffmpeg.texi  | 15 +
 libavutil/hwcontext_vulkan.c | 73 +++-
 2 files changed, 81 insertions(+), 7 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 29753f06ca..ed437bb16f 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1034,6 +1034,18 @@ If @var{device} is an integer, it selects the device by 
its index in a
 system-dependent list of devices.  If @var{device} is any other string, it
 selects the first device with a name containing that string as a substring.
 
+The following options are recognized:
+@table @option
+@item debug
+If set to 1, enables the validation layer, if installed.
+@item linear_images
+If set to 1, images allocated by the hwcontext will be linear and locally 
mappable.
+@item instance_extensions
+A plus separated list of additional instance extensions to enable.
+@item device_extensions
+A plus separated list of additional device extensions to enable.
+@end table
+
 Examples:
 @table @emph
 @item -init_hw_device vulkan:1
@@ -1041,6 +1053,9 @@ Choose the second device on the system.
 
 @item -init_hw_device vulkan:RADV
 Choose the first device with a name containing the string @emph{RADV}.
+
+@item -init_hw_device 
vulkan:0,instance_extensions=VK_KHR_wayland_surface+VK_KHR_xcb_surface
+Choose the first device and enable the Wayland and XCB instance extensions.
 @end table
 
 @end table
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 43e7cddbc5..cb805b0d1b 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -98,9 +98,13 @@ typedef struct AVVkFrameInternal {
 list = av_realloc_array(list, sizeof(*list), ++count); 
\
 if (!list) {   
\
 err = AVERROR(ENOMEM); 
\
-goto end;  
\
+goto fail; 
\
+}  
\
+list[count - 1] = av_strdup(val);  
\
+if (!list[count - 1]) {
\
+err = AVERROR(ENOMEM); 
\
+goto fail; 
\
 }  
\
-list[count - 1] = val; 
\
 } while(0)
 
 static const struct {
@@ -261,7 +265,7 @@ static VkBool32 
vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity,
 return 0;
 }
 
-static int check_extensions(AVHWDeviceContext *ctx, int dev,
+static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary 
*opts,
 const char * const **dst, uint32_t *num, int debug)
 {
 const char *tstr;
@@ -273,6 +277,8 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev,
 const char *mod;
 int optional_exts_num;
 uint32_t sup_ext_count;
+char *user_exts_str = NULL;
+AVDictionaryEntry *user_exts;
 VkExtensionProperties *sup_ext;
 const VulkanOptExtension *optional_exts;
 
@@ -280,6 +286,14 @@ static int check_extensions(AVHWDeviceContext *ctx, int 
dev,
 mod = "instance";
 optional_exts = optional_instance_exts;
 optional_exts_num = FF_ARRAY_ELEMS(optional_instance_exts);
+user_exts = av_dict_get(opts, "instance_extensions", NULL, 0);
+if (user_exts) {
+user_exts_str = av_strdup(user_exts->value);
+if (!user_exts_str) {
+err = AVERROR(ENOMEM);
+goto fail;
+}
+}
 vkEnumerateInstanceExtensionProperties(NULL, &sup_ext_count, NULL);
 sup_ext = av_malloc_array(sup_ext_count, 
sizeof(VkExtensionProperties));
 if (!sup_ext)
@@ -289,6 +303,14 @@ static int check_extensions(AVHWDeviceContext *ctx, int 
dev,
 mod = "device";
 optional_exts = optional_device_exts;
 optional_exts_num = FF_ARRAY_ELEMS(optional_device_exts);
+user_exts = av_dict_get(opts, "device_extensions", NULL, 0);
+if (user_exts) {
+user_exts_str = av_strdup(user_exts->value);
+if (!user_exts_str) {
+err = AVERROR(ENOMEM);
+  

[FFmpeg-cvslog] hwcontext_vulkan: update debugging layer name

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 21:13:55 2020 
+0100| [acfef378b7f68ce26c0c8fe9cd8da64613a19d7f] | committer: Lynne

hwcontext_vulkan: update debugging layer name

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

 libavutil/hwcontext_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index db71e39003..b62d0a6c6c 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -425,7 +425,7 @@ static int create_instance(AVHWDeviceContext *ctx, 
AVDictionary *opts)
 return err;
 
 if (debug_mode) {
-static const char *layers[] = { "VK_LAYER_LUNARG_standard_validation" 
};
+static const char *layers[] = { "VK_LAYER_KHRONOS_validation" };
 inst_props.ppEnabledLayerNames = layers;
 inst_props.enabledLayerCount = FF_ARRAY_ELEMS(layers);
 }

___
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] hwcontext_vulkan: fix inverted condition when exporting images to drm_prime

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 21:30:15 2020 
+0100| [7c080dc190ac1d85de1ca873347d0ac8855985e0] | committer: Lynne

hwcontext_vulkan: fix inverted condition when exporting images to drm_prime

Calling vkGetImageSubresourceLayout is only legal for linear and drm images.

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

 libavutil/hwcontext_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index b62d0a6c6c..085187c175 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2327,7 +2327,7 @@ static int vulkan_map_to_drm(AVHWFramesContext *hwfc, 
AVFrame *dst,
 
 drm_desc->layers[i].planes[0].object_index = FFMIN(i, 
drm_desc->nb_objects - 1);
 
-if (f->tiling != VK_IMAGE_TILING_OPTIMAL)
+if (f->tiling == VK_IMAGE_TILING_OPTIMAL)
 continue;
 
 vkGetImageSubresourceLayout(hwctx->act_dev, f->img[i], &sub, &layout);

___
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] hwcontext_vulkan: convert to general layout and transfer queue when exporting

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 22:00:38 2020 
+0100| [fc99a24782fb2b763b0ea37757561d531272195e] | committer: Lynne

hwcontext_vulkan: convert to general layout and transfer queue when exporting

The specs note that images should be in the GENERAL layout when exporting
for maximum compatibility.
CUDA exported images are handled differently, and the queue is the same,
so we don't need to do that there.

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

 libavutil/hwcontext_vulkan.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index df738457c1..a5983f2735 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1225,12 +1225,14 @@ static int alloc_bind_mem(AVHWFramesContext *hwfc, 
AVVkFrame *f,
 enum PrepMode {
 PREP_MODE_WRITE,
 PREP_MODE_RO_SHADER,
+PREP_MODE_EXTERNAL_EXPORT,
 };
 
 static int prepare_frame(AVHWFramesContext *hwfc, VulkanExecCtx *ectx,
  AVVkFrame *frame, enum PrepMode pmode)
 {
 VkResult ret;
+uint32_t dst_qf;
 VkImageLayout new_layout;
 VkAccessFlags new_access;
 AVHWDeviceContext *ctx = hwfc->device_ctx;
@@ -1244,6 +1246,8 @@ static int prepare_frame(AVHWFramesContext *hwfc, 
VulkanExecCtx *ectx,
 .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
 };
 
+VkPipelineStageFlagBits wait_st = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
+
 VkSubmitInfo s_info = {
 .sType= VK_STRUCTURE_TYPE_SUBMIT_INFO,
 .commandBufferCount   = 1,
@@ -1257,10 +1261,20 @@ static int prepare_frame(AVHWFramesContext *hwfc, 
VulkanExecCtx *ectx,
 case PREP_MODE_WRITE:
 new_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
 new_access = VK_ACCESS_TRANSFER_WRITE_BIT;
+dst_qf = VK_QUEUE_FAMILY_IGNORED;
 break;
 case PREP_MODE_RO_SHADER:
 new_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
 new_access = VK_ACCESS_TRANSFER_READ_BIT;
+dst_qf = VK_QUEUE_FAMILY_IGNORED;
+break;
+case PREP_MODE_EXTERNAL_EXPORT:
+new_layout = VK_IMAGE_LAYOUT_GENERAL;
+new_access = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
+dst_qf = VK_QUEUE_FAMILY_EXTERNAL_KHR;
+s_info.pWaitSemaphores = &frame->sem;
+s_info.pWaitDstStageMask = &wait_st;
+s_info.waitSemaphoreCount = 1;
 break;
 }
 
@@ -1278,7 +1292,7 @@ static int prepare_frame(AVHWFramesContext *hwfc, 
VulkanExecCtx *ectx,
 img_bar[i].oldLayout = frame->layout[i];
 img_bar[i].newLayout = new_layout;
 img_bar[i].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
-img_bar[i].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+img_bar[i].dstQueueFamilyIndex = dst_qf;
 img_bar[i].image = frame->img[i];
 img_bar[i].subresourceRange.levelCount = 1;
 img_bar[i].subresourceRange.layerCount = 1;
@@ -2288,6 +2302,10 @@ static int vulkan_map_to_drm(AVHWFramesContext *hwfc, 
AVFrame *dst,
 if (!drm_desc)
 return AVERROR(ENOMEM);
 
+err = prepare_frame(hwfc, &p->cmd, f, PREP_MODE_EXTERNAL_EXPORT);
+if (err < 0)
+goto end;
+
 err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src, 
&vulkan_unmap_to_drm, drm_desc);
 if (err < 0)
 goto end;

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