[FFmpeg-devel] [PATCH] avfilter/vf_delogo: use av_log_once

2020-09-16 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/vf_delogo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 39f06512fa..023fc51ec8 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -200,6 +200,7 @@ typedef struct DelogoContext {
 char *x_expr, *y_expr, *w_expr, *h_expr;
 AVExpr *x_pexpr, *y_pexpr, *w_pexpr, *h_pexpr;
 double var_values[VAR_VARS_NB];
+int log_state[2];
 }  DelogoContext;
 
 #define OFFSET(x) offsetof(DelogoContext, x)
@@ -281,7 +282,8 @@ static int config_input(AVFilterLink *inlink)
 /* Check whether the logo area fits in the frame */
 if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w 
||
 s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > 
inlink->h) {
-av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
+av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, s->log_state,
+   "Logo area is outside of the frame,"
" logo(x:%d y:%d w:%d h:%d), frame(%dx%d),"
" auto set the area inside of the frame."
" Note: x and y must be 1 at least.\n",
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH] avfilter/vf_delogo: remove duplicated code

2020-09-15 Thread quinkblack
From: Zhao Zhili 

1. Remove the modification of x, y, w and h parameters since they
   are reset by filter_frame.
2. config_input leads to error out when logo area is outside of the
   frame, while filter_frame fix the parameters automatically. Make
   config_input don't return error to keep the logic consistent.
---
 libavfilter/vf_delogo.c | 39 +++
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 6069c30163..39f06512fa 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -271,11 +271,6 @@ static av_cold int init(AVFilterContext *ctx)
 av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
s->x, s->y, s->w, s->h, s->band, s->show);
 
-s->w += s->band*2;
-s->h += s->band*2;
-s->x -= s->band;
-s->y -= s->band;
-
 return 0;
 }
 
@@ -284,10 +279,21 @@ static int config_input(AVFilterLink *inlink)
 DelogoContext *s = inlink->dst->priv;
 
 /* Check whether the logo area fits in the frame */
-if (s->x + (s->band - 1) < 0 || s->x + s->w - (s->band*2 - 2) > inlink->w 
||
-s->y + (s->band - 1) < 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) 
{
-av_log(s, AV_LOG_ERROR, "Logo area is outside of the frame.\n");
-return AVERROR(EINVAL);
+if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w 
||
+s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > 
inlink->h) {
+av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
+   " logo(x:%d y:%d w:%d h:%d), frame(%dx%d),"
+   " auto set the area inside of the frame."
+   " Note: x and y must be 1 at least.\n",
+   s->x, s->y, s->w, s->h, inlink->w, inlink->h);
+if (s->x + (s->band - 1) <= 0)
+s->x = 1 + s->band;
+if (s->y + (s->band - 1) <= 0)
+s->y = 1 + s->band;
+if (s->x + s->w - (s->band*2 - 2) > inlink->w)
+s->w = inlink->w - s->x - (s->band*2 - 2);
+if (s->y + s->h - (s->band*2 - 2) > inlink->h)
+s->h = inlink->h - s->y - (s->band*2 - 2);
 }
 
 return 0;
@@ -313,21 +319,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 s->w = av_expr_eval(s->w_pexpr, s->var_values, s);
 s->h = av_expr_eval(s->h_pexpr, s->var_values, s);
 
-if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w 
||
-s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > 
inlink->h) {
-av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
-   " auto set the area inside of the frame\n");
-}
-
-if (s->x + (s->band - 1) <= 0)
-s->x = 1 + s->band;
-if (s->y + (s->band - 1) <= 0)
-s->y = 1 + s->band;
-if (s->x + s->w - (s->band*2 - 2) > inlink->w)
-s->w = inlink->w - s->x - (s->band*2 - 2);
-if (s->y + s->h - (s->band*2 - 2) > inlink->h)
-s->h = inlink->h - s->y - (s->band*2 - 2);
-
 ret = config_input(inlink);
 if (ret < 0) {
 av_frame_free();
-- 
2.17.1


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

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

[FFmpeg-devel] [PATCH] avformat/mov: make compatible brands more readable

2020-09-09 Thread quinkblack
From: Zhao Zhili 

Use comma as separator between multiple compatible brands.
---
 libavformat/mov.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 690beb10ce..8f5341f925 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1093,7 +1093,7 @@ static int aax_filter(uint8_t *input, int size, 
MOVContext *c)
 static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 uint32_t minor_ver;
-int comp_brand_size;
+int comp_brand_count;
 char* comp_brands_str;
 uint8_t type[5] = {0};
 int ret = ffio_read_size(pb, type, 4);
@@ -1107,19 +1107,25 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 minor_ver = avio_rb32(pb); /* minor version */
 av_dict_set_int(>fc->metadata, "minor_version", minor_ver, 0);
 
-comp_brand_size = atom.size - 8;
-if (comp_brand_size < 0 || comp_brand_size == INT_MAX)
+comp_brand_count = (atom.size - 8) / 4;
+if (!comp_brand_count)
+return 0;
+else if (comp_brand_count < 0 || comp_brand_count > INT_MAX / 5)
 return AVERROR_INVALIDDATA;
-comp_brands_str = av_malloc(comp_brand_size + 1); /* Add null terminator */
+/* add separator between multiple brands, add null terminator */
+comp_brands_str = av_malloc(comp_brand_count * 5);
 if (!comp_brands_str)
 return AVERROR(ENOMEM);
 
-ret = ffio_read_size(pb, comp_brands_str, comp_brand_size);
-if (ret < 0) {
-av_freep(_brands_str);
-return ret;
+for (int i = 0; i < comp_brand_count; i++) {
+ret = ffio_read_size(pb, comp_brands_str + i * 5, 4);
+if (ret < 0) {
+av_freep(_brands_str);
+return ret;
+}
+comp_brands_str[i * 5 + 4] = ',';
 }
-comp_brands_str[comp_brand_size] = 0;
+comp_brands_str[comp_brand_count * 5 - 1] = '\0';
 av_dict_set(>fc->metadata, "compatible_brands",
 comp_brands_str, AV_DICT_DONT_STRDUP_VAL);
 
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH] avformat/http: ensure reply code in the range of 100..599

2020-08-31 Thread quinkblack
From: Zhao Zhili 

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

diff --git a/libavformat/http.c b/libavformat/http.c
index 6c39da1a8b..b77bdf1567 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -168,7 +168,7 @@ static const AVOption options[] = {
 { "reconnect_delay_max", "max reconnect delay in seconds after which to 
give up", OFFSET(reconnect_delay_max), AV_OPT_TYPE_INT, { .i64 = 120 }, 0, 
UINT_MAX/1000/1000, D },
 { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, 2, D | E },
 { "resource", "The resource requested by a client", OFFSET(resource), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
-{ "reply_code", "The http status code to return to a client", 
OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E},
+{ "reply_code", "The http status code to return to a client", 
OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, 100, 599, E},
 { NULL }
 };
 
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 2/2] avcodec/videotoolboxenc: fix use after destroy

2020-08-27 Thread quinkblack
From: Zhao Zhili 

The lock is used in clear_frame_queue().
---
 libavcodec/videotoolboxenc.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 988782f10d..758db9641f 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2496,14 +2496,17 @@ static av_cold int vtenc_close(AVCodecContext *avctx)
 {
 VTEncContext *vtctx = avctx->priv_data;
 
-pthread_cond_destroy(>cv_sample_sent);
-pthread_mutex_destroy(>lock);
-
-if(!vtctx->session) return 0;
+if(!vtctx->session) {
+pthread_cond_destroy(>cv_sample_sent);
+pthread_mutex_destroy(>lock);
+return 0;
+}
 
 VTCompressionSessionCompleteFrames(vtctx->session,
kCMTimeIndefinite);
 clear_frame_queue(vtctx);
+pthread_cond_destroy(>cv_sample_sent);
+pthread_mutex_destroy(>lock);
 CFRelease(vtctx->session);
 vtctx->session = NULL;
 
-- 
2.28.0

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

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

[FFmpeg-devel] [PATCH 1/2] avcodec/videotoolboxenc: fix align issue

2020-08-27 Thread quinkblack
From: Zhao Zhili 

bool a53_cc is accessed as int:
src/libavutil/opt.c:129:9: runtime error: store to misaligned
address 0x7fbf454121a3 for type 'int', which requires 4 byte alignment
---
 libavcodec/videotoolboxenc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index e89cfaeed8..988782f10d 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -226,7 +226,9 @@ typedef struct VTEncContext {
 bool flushing;
 bool has_b_frames;
 bool warned_color_range;
-bool a53_cc;
+
+/* can't be bool type since AVOption will access it as int */
+int a53_cc;
 } VTEncContext;
 
 static int vtenc_populate_extradata(AVCodecContext   *avctx,
-- 
2.28.0

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

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

[FFmpeg-devel] [PATCH] examples/decode_video: flush parser to fix missing frame

2020-08-18 Thread quinkblack
From: Zhao Zhili 

To reproduce, run decode_video with a single frame sample. No frame
was decoded before the patch.
---
 doc/examples/decode_video.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c
index 169188a4b9..ba753c6dc1 100644
--- a/doc/examples/decode_video.c
+++ b/doc/examples/decode_video.c
@@ -92,6 +92,7 @@ int main(int argc, char **argv)
 uint8_t *data;
 size_t   data_size;
 int ret;
+int eof;
 AVPacket *pkt;
 
 if (argc <= 2) {
@@ -150,15 +151,14 @@ int main(int argc, char **argv)
 exit(1);
 }
 
-while (!feof(f)) {
+do {
 /* read raw data from the input file */
 data_size = fread(inbuf, 1, INBUF_SIZE, f);
-if (!data_size)
-break;
+eof = !data_size;
 
 /* use the parser to split the data into frames */
 data = inbuf;
-while (data_size > 0) {
+while (data_size > 0 || eof) {
 ret = av_parser_parse2(parser, c, >data, >size,
data, data_size, AV_NOPTS_VALUE, 
AV_NOPTS_VALUE, 0);
 if (ret < 0) {
@@ -170,8 +170,10 @@ int main(int argc, char **argv)
 
 if (pkt->size)
 decode(c, frame, pkt, outfilename);
+if (eof)
+break;
 }
-}
+} while (!eof);
 
 /* flush the decoder */
 decode(c, frame, NULL, outfilename);
-- 
2.28.0

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

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

[FFmpeg-devel] [PATCH] avformat/rtsp: fix infinite loop with udp transport

2020-08-06 Thread quinkblack
From: Zhao Zhili 

User report: http://ffmpeg.org/pipermail/ffmpeg-user/2020-August/049494.html

server:
./ffmpeg -i test.mp4 -c copy -f rtsp -rtsp_transport udp  
rtsp://localhost:12345/live.sdp

client:
./ffmpeg_g -y -rtsp_flags listen -timeout 100 -i 
rtsp://localhost:12345/live.sdp -c copy test.mp4
---
 libavformat/rtsp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 5d8491b74b..0fb9fde6b4 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2051,6 +2051,11 @@ static int udp_read_packet(AVFormatContext *s, 
RTSPStream **prtsp_st,
 if ((ret = parse_rtsp_message(s)) < 0) {
 return ret;
 }
+/* Since there is no way to detect eof of udp streams, break
+ * the loop in teardown state to prevent run into infinite.
+ */
+if (rt->state == RTSP_STATE_IDLE)
+return AVERROR_EOF;
 }
 #endif
 } else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH] avformat/mov: fix memleaks

2020-06-27 Thread quinkblack
From: Zhao Zhili 

Fix two cases of memleaks:
1. The leak of dv_demux
2. The leak of dv_fctx upon dv_demux allocate failure
---
 libavformat/mov.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index adc52de947..f179b6efdd 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7357,10 +7357,9 @@ static int mov_read_close(AVFormatContext *s)
 av_freep(>coll);
 }
 
-if (mov->dv_demux) {
-avformat_free_context(mov->dv_fctx);
-mov->dv_fctx = NULL;
-}
+av_freep(>dv_demux);
+avformat_free_context(mov->dv_fctx);
+mov->dv_fctx = NULL;
 
 if (mov->meta_keys) {
 for (i = 1; i < mov->meta_keys_count; i++) {
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH] avfilter/scene_sad: add AArch64 SIMD

2020-02-01 Thread quinkblack
From: Zhao Zhili 

For 8 bit depth:
./ffmpeg -threads 1 -f lavfi -t 10 -i 
'yuvtestsrc=size=4096x2048,format=yuv444p' -vf 'freezedetect' -f null 
-benchmark -

Test results on Snapdragon 845:
Before:
frame=  250 fps= 23 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A 
speed=0.924x
bench: utime=8.360s stime=2.350s rtime=10.820s
After:
frame=  250 fps= 51 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A 
speed=2.04x
bench: utime=2.650s stime=2.210s rtime=4.909s

Test results on HiSilicon Kirin 970:
Before:
frame=  250 fps=6.0 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A 
speed=0.239x
bench: utime=35.156s stime=6.604s rtime=41.820s
After:
frame=  250 fps= 10 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A 
speed=0.403x
bench: utime=18.400s stime=6.376s rtime=24.798s

For 16 bit depth:
./ffmpeg -threads 1 -f lavfi -t 10 -i 
'yuvtestsrc=size=4096x2048,format=yuv444p16' -vf 'freezedetect' -f null 
-benchmark -

Test results on Snapdragon 845
Before:
frame=  250 fps= 19 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A 
speed=0.756x
bench: utime=8.700s stime=4.410s rtime=13.226s
After:
frame=  250 fps= 27 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A 
speed=1.07x
bench: utime=4.920s stime=4.350s rtime=9.356s

Test results on HiSilicon Kirin 970:
Before:
frame=  250 fps=4.0 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A 
speed=0.161x
bench: utime=48.868s stime=13.124s rtime=62.110s
After:
frame=  250 fps=5.1 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A 
speed=0.205x
bench: utime=35.600s stime=13.036s rtime=48.708s
---
 libavfilter/aarch64/Makefile |   2 +
 libavfilter/aarch64/scene_sad_init.c |  37 +++
 libavfilter/aarch64/scene_sad_neon.S | 149 +++
 libavfilter/scene_sad.c  |   2 +
 libavfilter/scene_sad.h  |   2 +
 5 files changed, 192 insertions(+)
 create mode 100644 libavfilter/aarch64/scene_sad_init.c
 create mode 100644 libavfilter/aarch64/scene_sad_neon.S

diff --git a/libavfilter/aarch64/Makefile b/libavfilter/aarch64/Makefile
index 6c727f9859..3a458f511f 100644
--- a/libavfilter/aarch64/Makefile
+++ b/libavfilter/aarch64/Makefile
@@ -1,7 +1,9 @@
 OBJS-$(CONFIG_NLMEANS_FILTER)+= aarch64/af_afir_init.o
 OBJS-$(CONFIG_NLMEANS_FILTER)+= aarch64/af_anlmdn_init.o
+OBJS-$(CONFIG_NLMEANS_FILTER)+= aarch64/scene_sad_init.o
 OBJS-$(CONFIG_NLMEANS_FILTER)+= aarch64/vf_nlmeans_init.o
 
 NEON-OBJS-$(CONFIG_NLMEANS_FILTER)   += aarch64/af_afir_neon.o
 NEON-OBJS-$(CONFIG_NLMEANS_FILTER)   += aarch64/af_anlmdn_neon.o
+NEON-OBJS-$(CONFIG_NLMEANS_FILTER)   += aarch64/scene_sad_neon.o
 NEON-OBJS-$(CONFIG_NLMEANS_FILTER)   += aarch64/vf_nlmeans_neon.o
diff --git a/libavfilter/aarch64/scene_sad_init.c 
b/libavfilter/aarch64/scene_sad_init.c
new file mode 100644
index 00..8de769ac10
--- /dev/null
+++ b/libavfilter/aarch64/scene_sad_init.c
@@ -0,0 +1,37 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/cpu.h"
+#include "libavfilter/scene_sad.h"
+
+void ff_scene_sad_neon(SCENE_SAD_PARAMS);
+
+void ff_scene_sad16_neon(SCENE_SAD_PARAMS);
+
+ff_scene_sad_fn ff_scene_sad_get_fn_aarch64(int depth)
+{
+int cpu_flags = av_get_cpu_flags();
+if (have_neon(cpu_flags)) {
+if (depth == 8)
+return ff_scene_sad_neon;
+if (depth == 16)
+return ff_scene_sad16_neon;
+}
+
+return NULL;
+}
diff --git a/libavfilter/aarch64/scene_sad_neon.S 
b/libavfilter/aarch64/scene_sad_neon.S
new file mode 100644
index 00..5b3b027a53
--- /dev/null
+++ b/libavfilter/aarch64/scene_sad_neon.S
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2020 Zhao Zhili
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but 

[FFmpeg-devel] [PATCH 2/2] avfilter/vf_gblur: remove unnecessary check

2020-01-04 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/vf_gblur.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index e057937fb7..0d7d5438d1 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -189,9 +189,6 @@ static void gaussianiir2d(AVFilterContext *ctx, int plane)
 const int nb_threads = ff_filter_get_nb_threads(ctx);
 ThreadData td;
 
-if (s->sigma <= 0 || s->steps < 0)
-return;
-
 td.width = width;
 td.height = height;
 ctx->internal->execute(ctx, filter_horizontally, , NULL, FFMIN(height, 
nb_threads));
@@ -301,7 +298,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 uint16_t *dst16 = (uint16_t *)out->data[plane];
 int y, x;
 
-if (!s->sigma || !(s->planes & (1 << plane))) {
+if (!(s->planes & (1 << plane))) {
 if (out != in)
 av_image_copy_plane(out->data[plane], out->linesize[plane],
 in->data[plane], in->linesize[plane],
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 1/2] avfilter/vf_gblur: fix divide by zero

2020-01-04 Thread quinkblack
From: Zhao Zhili 

./ffmpeg -i ~/Pictures/test.jpg -vf 'gblur=sigma=0' -f null -
...
src/libavfilter/vf_gblur.c:260:59: runtime error: division by zero
src/libavfilter/vf_gblur.c:261:26: runtime error: division by zero
---
 libavfilter/vf_gblur.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index 2e587f6a0a..e057937fb7 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -37,11 +37,17 @@
 #define OFFSET(x) offsetof(GBlurContext, x)
 #define FLAGS 
AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
+/* Consider the three-sigma rule, for minimum radius of 1 sigma should not
+ * be smaller than 1/3. Relax it to 0.25 if the user want to try.
+ */
+#define SIGMA_MIN   0.25
+#define SIGMA_MAX   1024.0
+
 static const AVOption gblur_options[] = {
-{ "sigma",  "set sigma",OFFSET(sigma),  AV_OPT_TYPE_FLOAT, 
{.dbl=0.5}, 0.0, 1024, FLAGS },
+{ "sigma",  "set sigma",OFFSET(sigma),  AV_OPT_TYPE_FLOAT, 
{.dbl=0.5},  SIGMA_MIN, SIGMA_MAX, FLAGS },
 { "steps",  "set number of steps",  OFFSET(steps),  AV_OPT_TYPE_INT,   
{.i64=1}, 1,6, FLAGS },
 { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT,   
{.i64=0xF},   0,  0xF, FLAGS },
-{ "sigmaV", "set vertical sigma",   OFFSET(sigmaV), AV_OPT_TYPE_FLOAT, 
{.dbl=-1},   -1, 1024, FLAGS },
+{ "sigmaV", "set vertical sigma",   OFFSET(sigmaV), AV_OPT_TYPE_FLOAT, 
{.dbl=-1},   -1, SIGMA_MAX, FLAGS },
 { NULL }
 };
 
@@ -244,7 +250,7 @@ static int config_input(AVFilterLink *inlink)
 if (!s->buffer)
 return AVERROR(ENOMEM);
 
-if (s->sigmaV < 0) {
+if (s->sigmaV < SIGMA_MIN) {
 s->sigmaV = s->sigma;
 }
 ff_gblur_init(s);
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH v3] avfilter/formats: optimize ff_all_formats

2020-01-03 Thread quinkblack
From: Zhao Zhili 

This is a micro-optimization. Saving almost 200 reallocations makes it
worth a try.
---
v3: fix an obvious infinite loop and pass fate-filter test

 libavfilter/formats.c | 41 ++---
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 33c64668a0..f29cddc250 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -348,21 +348,48 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, 
uint64_t channel_layout)
 
 AVFilterFormats *ff_all_formats(enum AVMediaType type)
 {
-AVFilterFormats *ret = NULL;
+int count, i;
+AVFilterFormats *ret = av_mallocz(sizeof(*ret));
+
+if (!ret)
+return NULL;
 
 if (type == AVMEDIA_TYPE_VIDEO) {
 const AVPixFmtDescriptor *desc = NULL;
-while ((desc = av_pix_fmt_desc_next(desc))) {
-if (ff_add_format(, av_pix_fmt_desc_get_id(desc)) < 0)
-return NULL;
+
+count = 0;
+while ((desc = av_pix_fmt_desc_next(desc)))
+count++;
+
+ret->formats = av_malloc_array(count, sizeof(*ret->formats));
+if (!ret->formats) {
+av_free(ret);
+return NULL;
+}
+ret->nb_formats = count;
+
+for (i = 0, desc = NULL; i < count; i++) {
+desc = av_pix_fmt_desc_next(desc);
+ret->formats[i] = av_pix_fmt_desc_get_id(desc);
 }
 } else if (type == AVMEDIA_TYPE_AUDIO) {
 enum AVSampleFormat fmt = 0;
-while (av_get_sample_fmt_name(fmt)) {
-if (ff_add_format(, fmt) < 0)
-return NULL;
+
+while (av_get_sample_fmt_name(fmt))
 fmt++;
+
+count = fmt;
+ret->formats = av_malloc_array(count, sizeof(*ret->formats));
+if (!ret->formats) {
+av_free(ret);
+return NULL;
 }
+ret->nb_formats = count;
+
+for (fmt = 0; fmt < count; fmt++)
+ret->formats[fmt] = fmt;
+} else {
+av_freep();
 }
 
 return ret;
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2] avfilter/formats: optimize ff_all_formats

2020-01-03 Thread quinkblack
From: Zhao Zhili 

This is a micro-optimization. Saving almost 200 reallocations makes it
worth a try.
---
 libavfilter/formats.c | 43 +++
 1 file changed, 35 insertions(+), 8 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 33c64668a0..c04253d898 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -348,21 +348,48 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, 
uint64_t channel_layout)
 
 AVFilterFormats *ff_all_formats(enum AVMediaType type)
 {
-AVFilterFormats *ret = NULL;
+int count, i;
+AVFilterFormats *ret = av_mallocz(sizeof(*ret));
+
+if (!ret)
+return NULL;
 
 if (type == AVMEDIA_TYPE_VIDEO) {
 const AVPixFmtDescriptor *desc = NULL;
-while ((desc = av_pix_fmt_desc_next(desc))) {
-if (ff_add_format(, av_pix_fmt_desc_get_id(desc)) < 0)
-return NULL;
+
+count = 0;
+while ((desc = av_pix_fmt_desc_next(desc)))
+count++;
+
+ret->formats = av_malloc_array(count, sizeof(*ret->formats));
+if (!ret->formats) {
+av_free(ret);
+return NULL;
+}
+ret->nb_formats = count;
+
+for (i = 0, desc = NULL; i < count; i++) {
+desc = av_pix_fmt_desc_next(desc);
+ret->formats[i] = av_pix_fmt_desc_get_id(desc);
 }
 } else if (type == AVMEDIA_TYPE_AUDIO) {
 enum AVSampleFormat fmt = 0;
-while (av_get_sample_fmt_name(fmt)) {
-if (ff_add_format(, fmt) < 0)
-return NULL;
-fmt++;
+
+count = 0;
+while (av_get_sample_fmt_name(fmt))
+count++;
+
+ret->formats = av_malloc_array(count, sizeof(*ret->formats));
+if (!ret->formats) {
+av_free(ret);
+return NULL;
 }
+ret->nb_formats = count;
+
+for (fmt = 0; fmt < count; fmt++)
+ret->formats[fmt] = fmt;
+} else {
+av_freep();
 }
 
 return ret;
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 7/8] avcodec/utils: remove access of AV_SAMPLE_FMT_NB

2019-12-30 Thread quinkblack
From: Zhao Zhili 

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

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 8a49234bcd..c935e07538 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1510,7 +1510,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
 
 enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
 {
-static const enum AVCodecID map[AV_SAMPLE_FMT_NB][2] = {
+static const enum AVCodecID map[][2] = {
 [AV_SAMPLE_FMT_U8  ] = { AV_CODEC_ID_PCM_U8,AV_CODEC_ID_PCM_U8
},
 [AV_SAMPLE_FMT_S16 ] = { AV_CODEC_ID_PCM_S16LE, AV_CODEC_ID_PCM_S16BE 
},
 [AV_SAMPLE_FMT_S32 ] = { AV_CODEC_ID_PCM_S32LE, AV_CODEC_ID_PCM_S32BE 
},
@@ -1523,7 +1523,7 @@ enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, 
int be)
 [AV_SAMPLE_FMT_FLTP] = { AV_CODEC_ID_PCM_F32LE, AV_CODEC_ID_PCM_F32BE 
},
 [AV_SAMPLE_FMT_DBLP] = { AV_CODEC_ID_PCM_F64LE, AV_CODEC_ID_PCM_F64BE 
},
 };
-if (fmt < 0 || fmt >= AV_SAMPLE_FMT_NB)
+if (fmt < 0 || fmt >= FF_ARRAY_ELEMS(map))
 return AV_CODEC_ID_NONE;
 if (be < 0 || be > 1)
 be = AV_NE(1, 0);
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 5/8] swscale/utils: remove access of AV_PIX_FMT_NB

2019-12-30 Thread quinkblack
From: Zhao Zhili 

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

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 57c4fd2b0f..c915cf0fca 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -95,7 +95,7 @@ typedef struct FormatEntry {
 uint8_t is_supported_endianness :1;
 } FormatEntry;
 
-static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
+static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_YUV420P] = { 1, 1 },
 [AV_PIX_FMT_YUYV422] = { 1, 1 },
 [AV_PIX_FMT_RGB24]   = { 1, 1 },
@@ -270,19 +270,19 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
 {
-return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
+return (unsigned)pix_fmt < FF_ARRAY_ELEMS(format_entries) ?
format_entries[pix_fmt].is_supported_in : 0;
 }
 
 int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)
 {
-return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
+return (unsigned)pix_fmt < FF_ARRAY_ELEMS(format_entries) ?
format_entries[pix_fmt].is_supported_out : 0;
 }
 
 int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
 {
-return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
+return (unsigned)pix_fmt < FF_ARRAY_ELEMS(format_entries) ?
format_entries[pix_fmt].is_supported_endianness : 0;
 }
 
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 3/8] avfilter/vf_dnn_processing: remove access of AV_PIX_FMT_NB

2019-12-30 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/vf_dnn_processing.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c
index ce976ec3bd..afb7275a38 100644
--- a/libavfilter/vf_dnn_processing.c
+++ b/libavfilter/vf_dnn_processing.c
@@ -60,7 +60,7 @@ static const AVOption dnn_processing_options[] = {
 { "model",   "path to model file", OFFSET(model_filename),   
AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },
 { "input",   "input name of the model",OFFSET(model_inputname),  
AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },
 { "output",  "output name of the model",   OFFSET(model_outputname), 
AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },
-{ "fmt", "AVPixelFormat of the frame", OFFSET(fmt),  
AV_OPT_TYPE_PIXEL_FMT, { .i64=AV_PIX_FMT_RGB24 }, AV_PIX_FMT_NONE, 
AV_PIX_FMT_NB - 1, FLAGS },
+{ "fmt", "AVPixelFormat of the frame", OFFSET(fmt),  
AV_OPT_TYPE_PIXEL_FMT, { .i64=AV_PIX_FMT_RGB24 }, AV_PIX_FMT_NONE, INT_MAX, 
FLAGS },
 { NULL }
 };
 
-- 
2.22.0




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

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

[FFmpeg-devel] [PATCH 8/8] avresample: remove access of AV_SAMPLE_FMT_NB

2019-12-30 Thread quinkblack
From: Zhao Zhili 

---
 libavresample/options.c |  6 +++---
 libavresample/utils.c   | 13 +
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavresample/options.c b/libavresample/options.c
index 5f08cd7e52..cdab98c357 100644
--- a/libavresample/options.c
+++ b/libavresample/options.c
@@ -37,12 +37,12 @@
 
 static const AVOption avresample_options[] = {
 { "in_channel_layout",  "Input Channel Layout", 
OFFSET(in_channel_layout),  AV_OPT_TYPE_INT64,  { .i64 = 0  }, 
INT64_MIN,INT64_MAX,  PARAM },
-{ "in_sample_fmt",  "Input Sample Format",  
OFFSET(in_sample_fmt),  AV_OPT_TYPE_INT,{ .i64 = AV_SAMPLE_FMT_S16 
}, AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_NB-1, PARAM },
+{ "in_sample_fmt",  "Input Sample Format",  
OFFSET(in_sample_fmt),  AV_OPT_TYPE_INT,{ .i64 = AV_SAMPLE_FMT_S16 
}, AV_SAMPLE_FMT_U8,  INT_MAX,PARAM },
 { "in_sample_rate", "Input Sample Rate",
OFFSET(in_sample_rate), AV_OPT_TYPE_INT,{ .i64 = 48000  }, 
1,INT_MAX,PARAM },
 { "out_channel_layout", "Output Channel Layout",
OFFSET(out_channel_layout), AV_OPT_TYPE_INT64,  { .i64 = 0  }, 
INT64_MIN,INT64_MAX,  PARAM },
-{ "out_sample_fmt", "Output Sample Format", 
OFFSET(out_sample_fmt), AV_OPT_TYPE_INT,{ .i64 = AV_SAMPLE_FMT_S16 
}, AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_NB-1, PARAM },
+{ "out_sample_fmt", "Output Sample Format", 
OFFSET(out_sample_fmt), AV_OPT_TYPE_INT,{ .i64 = AV_SAMPLE_FMT_S16 
}, AV_SAMPLE_FMT_U8,  INT_MAX,PARAM },
 { "out_sample_rate","Output Sample Rate",   
OFFSET(out_sample_rate),AV_OPT_TYPE_INT,{ .i64 = 48000  }, 
1,INT_MAX,PARAM },
-{ "internal_sample_fmt","Internal Sample Format",   
OFFSET(internal_sample_fmt),AV_OPT_TYPE_INT,{ .i64 = AV_SAMPLE_FMT_NONE 
}, AV_SAMPLE_FMT_NONE,   AV_SAMPLE_FMT_NB-1, PARAM, "internal_sample_fmt" },
+{ "internal_sample_fmt","Internal Sample Format",   
OFFSET(internal_sample_fmt),AV_OPT_TYPE_INT,{ .i64 = AV_SAMPLE_FMT_NONE 
}, AV_SAMPLE_FMT_NONE,   INT_MAX, PARAM, "internal_sample_fmt" },
 {"u8" ,  "8-bit unsigned integer",0, AV_OPT_TYPE_CONST, {.i64 
= AV_SAMPLE_FMT_U8   }, INT_MIN, INT_MAX, PARAM, "internal_sample_fmt"},
 {"s16",  "16-bit signed integer", 0, AV_OPT_TYPE_CONST, {.i64 
= AV_SAMPLE_FMT_S16  }, INT_MIN, INT_MAX, PARAM, "internal_sample_fmt"},
 {"s32",  "32-bit signed integer", 0, AV_OPT_TYPE_CONST, {.i64 
= AV_SAMPLE_FMT_S32  }, INT_MIN, INT_MAX, PARAM, "internal_sample_fmt"},
diff --git a/libavresample/utils.c b/libavresample/utils.c
index b4fb906556..0fbb28641d 100644
--- a/libavresample/utils.c
+++ b/libavresample/utils.c
@@ -42,6 +42,19 @@ int avresample_open(AVAudioResampleContext *avr)
 return AVERROR(EINVAL);
 }
 
+#define check_format(fmt, option_name)   \
+if (!av_get_sample_fmt_name(fmt)) {  \
+av_log(avr, AV_LOG_ERROR, "%s sample format %d not supported\n", \
+option_name, fmt);   \
+return AVERROR(EINVAL);  \
+}
+
+check_format(avr->in_sample_fmt, "Input")
+check_format(avr->out_sample_fmt, "Out")
+check_format(avr->internal_sample_fmt, "Internal")
+
+#undef check_format
+
 /* set channel mixing parameters */
 avr->in_channels = 
av_get_channel_layout_nb_channels(avr->in_channel_layout);
 if (avr->in_channels <= 0 || avr->in_channels > AVRESAMPLE_MAX_CHANNELS) {
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 1/8] avutil/pixdesc: add av_pix_fmt_total_count and av_sample_fmt_total_count

2019-12-30 Thread quinkblack
From: Zhao Zhili 

---
 doc/APIchanges| 3 +++
 libavutil/pixdesc.c   | 5 +
 libavutil/pixdesc.h   | 5 +
 libavutil/pixfmt.h| 2 +-
 libavutil/samplefmt.c | 5 +
 libavutil/samplefmt.h | 7 ++-
 libavutil/version.h   | 2 +-
 7 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 3c24dc6fbc..af2fc78fb9 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2019-12-28 - xx - lavu 56.39.100 - pixdesc.h
+  Add av_pix_fmt_total_count() and av_sample_fmt_total_count().
+
 2019-12-27 - xx - lavu 56.38.100 - eval.h
   Add av_expr_count_func().
 
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 05dd4a1e20..a6f145714e 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2519,6 +2519,11 @@ char *av_get_pix_fmt_string(char *buf, int buf_size,
 return buf;
 }
 
+int av_pix_fmt_total_count()
+{
+return AV_PIX_FMT_NB;
+}
+
 const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
 {
 if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index c055810ae8..8ed12a67f7 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -204,6 +204,11 @@ int av_get_bits_per_pixel(const AVPixFmtDescriptor 
*pixdesc);
  */
 int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
 
+/**
+ * @return the number of all pixel formats
+ */
+int av_pix_fmt_total_count(void);
+
 /**
  * @return a pixel format descriptor for provided pixel format or NULL if
  * this pixel format is unknown.
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 37ecebd501..aaf9602c3e 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -348,7 +348,7 @@ enum AVPixelFormat {
 AV_PIX_FMT_NV24,  ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 
plane for the UV components, which are interleaved (first byte U and the 
following byte V)
 AV_PIX_FMT_NV42,  ///< as above, but U and V bytes are swapped
 
-AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you 
want to link with shared libav* because the number of formats might differ 
between versions
+AV_PIX_FMT_NB ///< number of pixel formats, it's for libavutil 
internal use. For public access use av_pix_fmt_total_count() instead.
 };
 
 #if AV_HAVE_BIGENDIAN
diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c
index fc077f6444..6241523e5d 100644
--- a/libavutil/samplefmt.c
+++ b/libavutil/samplefmt.c
@@ -46,6 +46,11 @@ static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] 
= {
 [AV_SAMPLE_FMT_DBLP] = { .name = "dblp", .bits = 64, .planar = 1, .altform 
= AV_SAMPLE_FMT_DBL  },
 };
 
+int av_sample_fmt_total_count()
+{
+return AV_SAMPLE_FMT_NB;
+}
+
 const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
 {
 if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h
index 8cd43ae856..3173d02e5e 100644
--- a/libavutil/samplefmt.h
+++ b/libavutil/samplefmt.h
@@ -71,9 +71,14 @@ enum AVSampleFormat {
 AV_SAMPLE_FMT_S64, ///< signed 64 bits
 AV_SAMPLE_FMT_S64P,///< signed 64 bits, planar
 
-AV_SAMPLE_FMT_NB   ///< Number of sample formats. DO NOT USE if 
linking dynamically
+AV_SAMPLE_FMT_NB   ///< Number of sample formats, it's for 
libavutil internal use. For public access use av_sample_fmt_total_count() 
instead.
 };
 
+/**
+ * @return the number of all sample formats
+ */
+int av_sample_fmt_total_count(void);
+
 /**
  * Return the name of sample_fmt, or NULL if sample_fmt is not
  * recognized.
diff --git a/libavutil/version.h b/libavutil/version.h
index af8f614aff..2bc1b98615 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  38
+#define LIBAVUTIL_VERSION_MINOR  39
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 4/8] avdevice/lavfi: remove access of AV_PIX_FMT_NB

2019-12-30 Thread quinkblack
From: Zhao Zhili 

---
 libavdevice/lavfi.c | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index c949ff7e12..fc2336d8fe 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -59,24 +59,28 @@ typedef struct {
 AVPacket subcc_packet;
 } LavfiContext;
 
-static int *create_all_formats(int n)
+static int *create_all_formats()
 {
-int i, j, *fmts, count = 0;
+int i, *fmts, count = 0;
+const AVPixFmtDescriptor *desc;
 
-for (i = 0; i < n; i++) {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
+desc = NULL;
+while ((desc = av_pix_fmt_desc_next(desc))) {
 if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
 count++;
 }
 
 if (!(fmts = av_malloc((count+1) * sizeof(int
 return NULL;
-for (j = 0, i = 0; i < n; i++) {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
-if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
-fmts[j++] = i;
+
+desc = NULL;
+i = 0;
+while ((desc = av_pix_fmt_desc_next(desc))) {
+if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+fmts[i++] = av_pix_fmt_desc_get_id(desc);
+}
 }
-fmts[j] = -1;
+fmts[i] = AV_PIX_FMT_NONE;
 return fmts;
 }
 
@@ -121,7 +125,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
 LavfiContext *lavfi = avctx->priv_data;
 AVFilterInOut *input_links = NULL, *output_links = NULL, *inout;
 const AVFilter *buffersink, *abuffersink;
-int *pix_fmts = create_all_formats(AV_PIX_FMT_NB);
+int *pix_fmts = create_all_formats();
 enum AVMediaType type;
 int ret = 0, i, n;
 
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 6/8] swscale/tests/swscale: remove access of AV_PIX_FMT_NB

2019-12-30 Thread quinkblack
From: Zhao Zhili 

---
 libswscale/tests/swscale.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 19878a7877..784195f468 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -251,6 +251,18 @@ end:
 return res;
 }
 
+static int getMaxFmt()
+{
+const AVPixFmtDescriptor *desc = NULL;
+int fmt_max = AV_PIX_FMT_NONE;
+
+while ((desc = av_pix_fmt_desc_next(desc))) {
+int fmt = av_pix_fmt_desc_get_id(desc);
+fmt_max = FFMAX(fmt, fmt_max);
+}
+return fmt_max;
+}
+
 static void selfTest(const uint8_t * const ref[4], int refStride[4],
  int w, int h,
  enum AVPixelFormat srcFormat_in,
@@ -264,9 +276,10 @@ static void selfTest(const uint8_t * const ref[4], int 
refStride[4],
 const int dstH[] = { srcH - srcH / 3, srcH, srcH + srcH / 3, 0 };
 enum AVPixelFormat srcFormat, dstFormat;
 const AVPixFmtDescriptor *desc_src, *desc_dst;
+const int fmt_max = getMaxFmt();
 
 for (srcFormat = srcFormat_in != AV_PIX_FMT_NONE ? srcFormat_in : 0;
- srcFormat < AV_PIX_FMT_NB; srcFormat++) {
+ srcFormat <= fmt_max; srcFormat++) {
 if (!sws_isSupportedInput(srcFormat) ||
 !sws_isSupportedOutput(srcFormat))
 continue;
@@ -274,7 +287,7 @@ static void selfTest(const uint8_t * const ref[4], int 
refStride[4],
 desc_src = av_pix_fmt_desc_get(srcFormat);
 
 for (dstFormat = dstFormat_in != AV_PIX_FMT_NONE ? dstFormat_in : 0;
- dstFormat < AV_PIX_FMT_NB; dstFormat++) {
+ dstFormat <= fmt_max; dstFormat++) {
 int i, j, k;
 int res = 0;
 
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 2/8] avcodec/imgconvert: remove access of AV_PIX_FMT_NB

2019-12-30 Thread quinkblack
From: Zhao Zhili 

Fix av_pix_fmt_desc_get return value check.
---
 libavcodec/imgconvert.c   | 5 +++--
 libavcodec/tests/imgconvert.c | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 1fd636c83d..fb0222cdf1 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -112,7 +112,7 @@ int av_picture_crop(AVPicture *dst, const AVPicture *src,
 int x_shift;
 int max_step[4];
 
-if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
+if (!desc)
 return -1;
 
 y_shift = desc->log2_chroma_h;
@@ -147,8 +147,9 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, 
int height, int width,
 int i, y;
 int max_step[4];
 
-if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
+if (!desc) {
 return -1;
+}
 
 if (!is_yuv_planar(desc)) {
 if (src)
diff --git a/libavcodec/tests/imgconvert.c b/libavcodec/tests/imgconvert.c
index aefc324bf5..79ac654f18 100644
--- a/libavcodec/tests/imgconvert.c
+++ b/libavcodec/tests/imgconvert.c
@@ -27,8 +27,9 @@ int main(void){
 int i;
 int err=0;
 int skip = 0;
+int fmt_count = av_pix_fmt_total_count();
 
-for (i=0; iname) {
 skip ++;
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v5] avfilter/buffersrc: deprecate sws_param option

2019-12-29 Thread quinkblack
From: Zhao Zhili 

---
Rebase patch on master.

 doc/filters.texi|  8 
 libavfilter/buffersrc.c | 14 --
 libavfilter/version.h   |  5 -
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 619542e7b5..341503c7f8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21209,9 +21209,9 @@ Specify the frame rate expected for the video stream.
 The sample (pixel) aspect ratio of the input video.
 
 @item sws_param
-Specify the optional parameters to be used for the scale filter which
-is automatically inserted when an input change is detected in the
-input size or format.
+This option is deprecated and ignored. Prepend @code{sws_flags=@var{flags};}
+to the filtergraph description to specify swscale flags for automatically
+inserted scalers. See @ref{Filtergraph syntax}.
 
 @item hw_frames_ctx
 When using a hardware pixel format, this should be a reference to an
@@ -21236,7 +21236,7 @@ 
buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
 Alternatively, the options can be specified as a flat string, but this
 syntax is deprecated:
 
-@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
+@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}
 
 @section cellauto
 
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 2fa9e00daf..64940d91e2 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -51,7 +51,9 @@ typedef struct BufferSourceContext {
 int   w, h;
 enum AVPixelFormat  pix_fmt;
 AVRationalpixel_aspect;
+#if FF_API_SWS_PARAM_OPTION
 char  *sws_param;
+#endif
 
 AVBufferRef *hw_frames_ctx;
 
@@ -271,10 +273,16 @@ static av_cold int init_video(AVFilterContext *ctx)
 return AVERROR(EINVAL);
 }
 
-av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d sws_param:%s\n",
+av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d\n",
c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
c->time_base.num, c->time_base.den, c->frame_rate.num, 
c->frame_rate.den,
-   c->pixel_aspect.num, c->pixel_aspect.den, (char 
*)av_x_if_null(c->sws_param, ""));
+   c->pixel_aspect.num, c->pixel_aspect.den);
+
+#if FF_API_SWS_PARAM_OPTION
+if (c->sws_param)
+av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and 
ignored\n");
+#endif
+
 return 0;
 }
 
@@ -296,7 +304,9 @@ static const AVOption buffer_options[] = {
 { "pixel_aspect",  "sample aspect ratio",OFFSET(pixel_aspect), 
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "time_base", NULL, OFFSET(time_base),
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "frame_rate",NULL, OFFSET(frame_rate),   
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
+#if FF_API_SWS_PARAM_OPTION
 { "sws_param", NULL, OFFSET(sws_param),
AV_OPT_TYPE_STRING,.flags = V },
+#endif
 { NULL },
 };
 
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 8a9032859f..b029905ed4 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   7
 #define LIBAVFILTER_VERSION_MINOR  70
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -59,6 +59,9 @@
 #ifndef FF_API_FILTER_GET_SET
 #define FF_API_FILTER_GET_SET   (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
+#ifndef FF_API_SWS_PARAM_OPTION
+#define FF_API_SWS_PARAM_OPTION (LIBAVFILTER_VERSION_MAJOR < 8)
+#endif
 #ifndef FF_API_NEXT
 #define FF_API_NEXT (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 2/2] avfilter/vf_histogram: fix color value

2019-12-13 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/vf_histogram.c |   4 +-
 tests/ref/fate/filter-histogram-levels | 100 -
 2 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index 0d2d087beb..d6928d6b08 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -185,9 +185,9 @@ static int query_formats(AVFilterContext *ctx)
 return 0;
 }
 
-static const uint8_t black_yuva_color[4] = { 0, 127, 127, 255 };
+static const uint8_t black_yuva_color[4] = { 0, 128, 128, 255 };
 static const uint8_t black_gbrp_color[4] = { 0, 0, 0, 255 };
-static const uint8_t white_yuva_color[4] = { 255, 127, 127, 255 };
+static const uint8_t white_yuva_color[4] = { 255, 128, 128, 255 };
 static const uint8_t white_gbrp_color[4] = { 255, 255, 255, 255 };
 
 static int config_input(AVFilterLink *inlink)
diff --git a/tests/ref/fate/filter-histogram-levels 
b/tests/ref/fate/filter-histogram-levels
index 697d7d19c0..e1329593e3 100644
--- a/tests/ref/fate/filter-histogram-levels
+++ b/tests/ref/fate/filter-histogram-levels
@@ -3,53 +3,53 @@
 #codec_id 0: rawvideo
 #dimensions 0: 256x636
 #sar 0: 1/1
-0,  0,  0,1,   488448, 0xc27a6cac
-0,  1,  1,1,   488448, 0xf00a152e
-0,  2,  2,1,   488448, 0x060b8c70
-0,  3,  3,1,   488448, 0xf75d6ee2
-0,  4,  4,1,   488448, 0xd7a7f06e
-0,  5,  5,1,   488448, 0x585281a5
-0,  6,  6,1,   488448, 0xb06e3ee8
-0,  7,  7,1,   488448, 0x201d0b8c
-0,  8,  8,1,   488448, 0x4e14e319
-0,  9,  9,1,   488448, 0x5aef5cca
-0, 10, 10,1,   488448, 0x57018668
-0, 11, 11,1,   488448, 0x2ad45b3f
-0, 12, 12,1,   488448, 0x62cc36b8
-0, 13, 13,1,   488448, 0x9e84585e
-0, 14, 14,1,   488448, 0xe6552e42
-0, 15, 15,1,   488448, 0x13b90c2c
-0, 16, 16,1,   488448, 0xf9557145
-0, 17, 17,1,   488448, 0x818340bc
-0, 18, 18,1,   488448, 0x5112c6e1
-0, 19, 19,1,   488448, 0x5d5b8f43
-0, 20, 20,1,   488448, 0xf2101ea6
-0, 21, 21,1,   488448, 0x4266af4d
-0, 22, 22,1,   488448, 0xb358806e
-0, 23, 23,1,   488448, 0xe336aa60
-0, 24, 24,1,   488448, 0x64fcc339
-0, 25, 25,1,   488448, 0x86e4b729
-0, 26, 26,1,   488448, 0x48c380d0
-0, 27, 27,1,   488448, 0xaee36fd3
-0, 28, 28,1,   488448, 0x20b84429
-0, 29, 29,1,   488448, 0x84d85542
-0, 30, 30,1,   488448, 0x94aea169
-0, 31, 31,1,   488448, 0x6278fa2c
-0, 32, 32,1,   488448, 0xaadf998d
-0, 33, 33,1,   488448, 0x29bba90d
-0, 34, 34,1,   488448, 0xef1117ad
-0, 35, 35,1,   488448, 0xd961e36d
-0, 36, 36,1,   488448, 0xff53296e
-0, 37, 37,1,   488448, 0x41f381f9
-0, 38, 38,1,   488448, 0x66fcfc2a
-0, 39, 39,1,   488448, 0x758bb472
-0, 40, 40,1,   488448, 0xefc6dc9e
-0, 41, 41,1,   488448, 0x77fccb69
-0, 42, 42,1,   488448, 0x7a1d82a4
-0, 43, 43,1,   488448, 0xc9d61a1b
-0, 44, 44,1,   488448, 0x8e689deb
-0, 45, 45,1,   488448, 0x52133e75
-0, 46, 46,1,   488448, 0xcc0a098e
-0, 47, 47,1,   488448, 0x045cd17f
-0, 48, 48,1,   488448, 0x97f89963
-0, 49, 49,1,   488448, 0xa1f835ff
+0,  0,  0,1,   488448, 0x0a904cf7
+0,  1,  1,1,   488448, 0x3820f56a
+0,  2,  2,1,   488448, 0x4e126cbb
+0,  3,  3,1,   488448, 0x3f734f2d
+0,  4,  4,1,   488448, 0x1fbdd0b9
+0,  5,  5,1,   488448, 0xa05961f0
+0,  6,  6,1,   488448, 0xf8751f33
+0,  7,  7,1,   488448, 0x6824ebc8
+0,  8,  8,1,   488448, 0x961bc364
+0,  9,  9,1,   488448, 0xa2f63d15
+0, 10, 10,1,   488448, 0x9f0866b3
+0, 11, 11,1,   488448, 0x72db3b8a
+0, 12, 12,1,   488448, 0xaad31703
+0, 13, 13,1,   488448, 0xe68b38a9
+0, 14,

[FFmpeg-devel] [PATCH 1/2] avfilter/vf_histogram: clean up code

2019-12-13 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/vf_histogram.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index 5185992de6..0d2d087beb 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -266,20 +266,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 const int is_chroma = (k == 1 || k == 2);
 const int dst_h = AV_CEIL_RSHIFT(outlink->h, (is_chroma ? 
h->odesc->log2_chroma_h : 0));
 const int dst_w = AV_CEIL_RSHIFT(outlink->w, (is_chroma ? 
h->odesc->log2_chroma_w : 0));
+const int plane = h->odesc->comp[k].plane;
+uint8_t *const data = out->data[plane];
+const int linesize = out->linesize[plane];
 
 if (h->histogram_size <= 256) {
 for (i = 0; i < dst_h ; i++)
-memset(out->data[h->odesc->comp[k].plane] +
-   i * out->linesize[h->odesc->comp[k].plane],
-   h->bg_color[k], dst_w);
+memset(data + i * linesize, h->bg_color[k], dst_w);
 } else {
 const int mult = h->mult;
 
-for (i = 0; i < dst_h ; i++)
-for (j = 0; j < dst_w; j++)
-AV_WN16(out->data[h->odesc->comp[k].plane] +
-i * out->linesize[h->odesc->comp[k].plane] + j * 2,
-h->bg_color[k] * mult);
+for (j = 0; j < dst_w; j++)
+AV_WN16(data + j * 2, h->bg_color[k] * mult);
+for (i = 1; i < dst_h; i++)
+memcpy(data + i * linesize, data, dst_w * 2);
 }
 }
 
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2 4/4] avfilter/avfilter: update documentation of avfilter_graph_create_filter

2019-12-05 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/avfilter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 3eaa8a4089..197e12a625 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -947,7 +947,7 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph 
*graph, const char *nam
 /**
  * Create and add a filter instance into an existing graph.
  * The filter instance is created from the filter filt and inited
- * with the parameters args and opaque.
+ * with the parameters args. opaque is ignored currently.
  *
  * In case of success put in *filt_ctx the pointer to the created
  * filter instance, otherwise set *filt_ctx to NULL.
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2 1/4] avfilter/buffersink: remove unused macros

2019-12-05 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/buffersink.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 25b3f4ab6b..30153adbb2 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -61,8 +61,6 @@ typedef struct BufferSinkContext {
 } BufferSinkContext;
 
 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
-#define FIFO_INIT_SIZE 8
-#define FIFO_INIT_ELEMENT_SIZE sizeof(void *)
 
 int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
*frame)
 {
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2 3/4] avfilter/buffersink: deprecate AVBufferSinkParams and AVABufferSinkParams

2019-12-05 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/buffersink.c | 2 ++
 libavfilter/buffersink.h | 4 
 2 files changed, 6 insertions(+)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 5f2ed0e4b3..76a46f6678 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -125,6 +125,7 @@ int attribute_align_arg 
av_buffersink_get_samples(AVFilterContext *ctx,
 return get_frame_internal(ctx, frame, 0, nb_samples);
 }
 
+#if FF_API_NEXT
 AVBufferSinkParams *av_buffersink_params_alloc(void)
 {
 static const int pixel_fmts[] = { AV_PIX_FMT_NONE };
@@ -144,6 +145,7 @@ AVABufferSinkParams *av_abuffersink_params_alloc(void)
 return NULL;
 return params;
 }
+#endif
 
 static av_cold int common_init(AVFilterContext *ctx)
 {
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 3c846bb527..2ec821c685 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -59,6 +59,7 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, 
AVFrame *frame, int flag
  */
 #define AV_BUFFERSINK_FLAG_NO_REQUEST 2
 
+#if FF_API_NEXT
 /**
  * Struct to use for initializing a buffersink context.
  */
@@ -71,6 +72,7 @@ typedef struct AVBufferSinkParams {
  *
  * Must be freed with av_free().
  */
+attribute_deprecated
 AVBufferSinkParams *av_buffersink_params_alloc(void);
 
 /**
@@ -89,7 +91,9 @@ typedef struct AVABufferSinkParams {
  *
  * Must be freed with av_free().
  */
+attribute_deprecated
 AVABufferSinkParams *av_abuffersink_params_alloc(void);
+#endif
 
 /**
  * Set the frame size for an audio buffer sink.
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2 2/4] avfilter/buffersink: replace init_opaque by init

2019-12-05 Thread quinkblack
From: Zhao Zhili 

The argument 'opaque' is always NULL since 0acf7e2 (2013).
---
 libavfilter/buffersink.c | 35 ++-
 1 file changed, 2 insertions(+), 33 deletions(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 30153adbb2..5f2ed0e4b3 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -199,20 +199,6 @@ MAKE_AVFILTERLINK_ACCESSOR(int  , sample_rate  
  )
 
 MAKE_AVFILTERLINK_ACCESSOR(AVBufferRef *, hw_frames_ctx  )
 
-static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
-{
-BufferSinkContext *buf = ctx->priv;
-AVBufferSinkParams *params = opaque;
-int ret;
-
-if (params) {
-if ((ret = av_opt_set_int_list(buf, "pix_fmts", params->pixel_fmts, 
AV_PIX_FMT_NONE, 0)) < 0)
-return ret;
-}
-
-return common_init(ctx);
-}
-
 #define CHECK_LIST_SIZE(field) \
 if (buf->field ## _size % sizeof(*buf->field)) { \
 av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
@@ -242,23 +228,6 @@ static int vsink_query_formats(AVFilterContext *ctx)
 return 0;
 }
 
-static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
-{
-BufferSinkContext *buf = ctx->priv;
-AVABufferSinkParams *params = opaque;
-int ret;
-
-if (params) {
-if ((ret = av_opt_set_int_list(buf, "sample_fmts", 
params->sample_fmts,  AV_SAMPLE_FMT_NONE, 0)) < 0 ||
-(ret = av_opt_set_int_list(buf, "sample_rates",
params->sample_rates,-1, 0)) < 0 ||
-(ret = av_opt_set_int_list(buf, "channel_layouts", 
params->channel_layouts, -1, 0)) < 0 ||
-(ret = av_opt_set_int_list(buf, "channel_counts",  
params->channel_counts,  -1, 0)) < 0 ||
-(ret = av_opt_set_int(buf, "all_channel_counts", 
params->all_channel_counts, 0)) < 0)
-return ret;
-}
-return common_init(ctx);
-}
-
 static int asink_query_formats(AVFilterContext *ctx)
 {
 BufferSinkContext *buf = ctx->priv;
@@ -345,7 +314,7 @@ AVFilter ff_vsink_buffer = {
 .description   = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them 
available to the end of the filter graph."),
 .priv_size = sizeof(BufferSinkContext),
 .priv_class= _class,
-.init_opaque   = vsink_init,
+.init  = common_init,
 .query_formats = vsink_query_formats,
 .activate  = activate,
 .inputs= avfilter_vsink_buffer_inputs,
@@ -365,7 +334,7 @@ AVFilter ff_asink_abuffer = {
 .description   = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them 
available to the end of the filter graph."),
 .priv_class= _class,
 .priv_size = sizeof(BufferSinkContext),
-.init_opaque   = asink_init,
+.init  = common_init,
 .query_formats = asink_query_formats,
 .activate  = activate,
 .inputs= avfilter_asink_abuffer_inputs,
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 2/3] avfilter/buffersink: replace init_opaque by init

2019-12-05 Thread quinkblack
From: Zhao Zhili 

The argument 'opaque' is always NULL since 0acf7e2 (2013).
---
 libavfilter/buffersink.c | 35 ++-
 1 file changed, 2 insertions(+), 33 deletions(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 30153adbb2..5f2ed0e4b3 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -199,20 +199,6 @@ MAKE_AVFILTERLINK_ACCESSOR(int  , sample_rate  
  )
 
 MAKE_AVFILTERLINK_ACCESSOR(AVBufferRef *, hw_frames_ctx  )
 
-static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
-{
-BufferSinkContext *buf = ctx->priv;
-AVBufferSinkParams *params = opaque;
-int ret;
-
-if (params) {
-if ((ret = av_opt_set_int_list(buf, "pix_fmts", params->pixel_fmts, 
AV_PIX_FMT_NONE, 0)) < 0)
-return ret;
-}
-
-return common_init(ctx);
-}
-
 #define CHECK_LIST_SIZE(field) \
 if (buf->field ## _size % sizeof(*buf->field)) { \
 av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
@@ -242,23 +228,6 @@ static int vsink_query_formats(AVFilterContext *ctx)
 return 0;
 }
 
-static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
-{
-BufferSinkContext *buf = ctx->priv;
-AVABufferSinkParams *params = opaque;
-int ret;
-
-if (params) {
-if ((ret = av_opt_set_int_list(buf, "sample_fmts", 
params->sample_fmts,  AV_SAMPLE_FMT_NONE, 0)) < 0 ||
-(ret = av_opt_set_int_list(buf, "sample_rates",
params->sample_rates,-1, 0)) < 0 ||
-(ret = av_opt_set_int_list(buf, "channel_layouts", 
params->channel_layouts, -1, 0)) < 0 ||
-(ret = av_opt_set_int_list(buf, "channel_counts",  
params->channel_counts,  -1, 0)) < 0 ||
-(ret = av_opt_set_int(buf, "all_channel_counts", 
params->all_channel_counts, 0)) < 0)
-return ret;
-}
-return common_init(ctx);
-}
-
 static int asink_query_formats(AVFilterContext *ctx)
 {
 BufferSinkContext *buf = ctx->priv;
@@ -345,7 +314,7 @@ AVFilter ff_vsink_buffer = {
 .description   = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them 
available to the end of the filter graph."),
 .priv_size = sizeof(BufferSinkContext),
 .priv_class= _class,
-.init_opaque   = vsink_init,
+.init  = common_init,
 .query_formats = vsink_query_formats,
 .activate  = activate,
 .inputs= avfilter_vsink_buffer_inputs,
@@ -365,7 +334,7 @@ AVFilter ff_asink_abuffer = {
 .description   = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them 
available to the end of the filter graph."),
 .priv_class= _class,
 .priv_size = sizeof(BufferSinkContext),
-.init_opaque   = asink_init,
+.init  = common_init,
 .query_formats = asink_query_formats,
 .activate  = activate,
 .inputs= avfilter_asink_abuffer_inputs,
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 3/3] avfilter/buffersink: remove AVBufferSinkParams and AVABufferSinkParams

2019-12-05 Thread quinkblack
From: Zhao Zhili 

The patch breaks API in theory. Since there is no reason to allocate
an object which you can do nothing with it, the API break should have
no effect.
---
 libavfilter/buffersink.c | 20 
 libavfilter/buffersink.h | 32 
 2 files changed, 52 deletions(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 5f2ed0e4b3..5d30c55281 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -125,26 +125,6 @@ int attribute_align_arg 
av_buffersink_get_samples(AVFilterContext *ctx,
 return get_frame_internal(ctx, frame, 0, nb_samples);
 }
 
-AVBufferSinkParams *av_buffersink_params_alloc(void)
-{
-static const int pixel_fmts[] = { AV_PIX_FMT_NONE };
-AVBufferSinkParams *params = av_malloc(sizeof(AVBufferSinkParams));
-if (!params)
-return NULL;
-
-params->pixel_fmts = pixel_fmts;
-return params;
-}
-
-AVABufferSinkParams *av_abuffersink_params_alloc(void)
-{
-AVABufferSinkParams *params = av_mallocz(sizeof(AVABufferSinkParams));
-
-if (!params)
-return NULL;
-return params;
-}
-
 static av_cold int common_init(AVFilterContext *ctx)
 {
 BufferSinkContext *buf = ctx->priv;
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 3c846bb527..be63bd1af1 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -59,38 +59,6 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, 
AVFrame *frame, int flag
  */
 #define AV_BUFFERSINK_FLAG_NO_REQUEST 2
 
-/**
- * Struct to use for initializing a buffersink context.
- */
-typedef struct AVBufferSinkParams {
-const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, 
terminated by AV_PIX_FMT_NONE
-} AVBufferSinkParams;
-
-/**
- * Create an AVBufferSinkParams structure.
- *
- * Must be freed with av_free().
- */
-AVBufferSinkParams *av_buffersink_params_alloc(void);
-
-/**
- * Struct to use for initializing an abuffersink context.
- */
-typedef struct AVABufferSinkParams {
-const enum AVSampleFormat *sample_fmts; ///< list of allowed sample 
formats, terminated by AV_SAMPLE_FMT_NONE
-const int64_t *channel_layouts; ///< list of allowed channel 
layouts, terminated by -1
-const int *channel_counts;  ///< list of allowed channel 
counts, terminated by -1
-int all_channel_counts; ///< if not 0, accept any channel 
count or layout
-int *sample_rates;  ///< list of allowed sample rates, 
terminated by -1
-} AVABufferSinkParams;
-
-/**
- * Create an AVABufferSinkParams structure.
- *
- * Must be freed with av_free().
- */
-AVABufferSinkParams *av_abuffersink_params_alloc(void);
-
 /**
  * Set the frame size for an audio buffer sink.
  *
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 1/3] avfilter/buffersink: remove unused macros

2019-12-05 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/buffersink.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 25b3f4ab6b..30153adbb2 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -61,8 +61,6 @@ typedef struct BufferSinkContext {
 } BufferSinkContext;
 
 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
-#define FIFO_INIT_SIZE 8
-#define FIFO_INIT_ELEMENT_SIZE sizeof(void *)
 
 int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
*frame)
 {
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH] avutil/buffer: use appropriate atomic operations

2019-12-05 Thread quinkblack
From: Zhao Zhili 

No functional changes. ref/unref vs add/sub is symmetrical.
---
 libavutil/buffer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 8d1aa5fa84..f0034b026a 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -116,7 +116,7 @@ static void buffer_replace(AVBufferRef **dst, AVBufferRef 
**src)
 } else
 av_freep(dst);
 
-if (atomic_fetch_add_explicit(>refcount, -1, memory_order_acq_rel) == 
1) {
+if (atomic_fetch_sub_explicit(>refcount, 1, memory_order_acq_rel) == 1) 
{
 b->free(b->opaque, b->data);
 av_freep();
 }
@@ -281,7 +281,7 @@ void av_buffer_pool_uninit(AVBufferPool **ppool)
 pool   = *ppool;
 *ppool = NULL;
 
-if (atomic_fetch_add_explicit(>refcount, -1, memory_order_acq_rel) 
== 1)
+if (atomic_fetch_sub_explicit(>refcount, 1, memory_order_acq_rel) == 
1)
 buffer_pool_free(pool);
 }
 
@@ -298,7 +298,7 @@ static void pool_release_buffer(void *opaque, uint8_t *data)
 pool->pool = buf;
 ff_mutex_unlock(>mutex);
 
-if (atomic_fetch_add_explicit(>refcount, -1, memory_order_acq_rel) 
== 1)
+if (atomic_fetch_sub_explicit(>refcount, 1, memory_order_acq_rel) == 
1)
 buffer_pool_free(pool);
 }
 
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH] avfilter/buffersrc: remove redundant flag

2019-12-04 Thread quinkblack
From: Zhao Zhili 

!(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params)

equals

(c->pix_fmt == AV_PIX_FMT_NONE) && !c->got_format_from_params

1. When (c->pix_fmt == AV_PIX_FMT_NONE) is true, got_format_from_params is
always false, the flag doesn't contribute to the result.

2. When the first part is false, the second part doesn't matter, the flag
doesn't contribute to the result.

The result only depends on c->pix_fmt.
---
 libavfilter/buffersrc.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index bae7d86695..b7ff40b045 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -63,7 +63,6 @@ typedef struct BufferSourceContext {
 uint64_t channel_layout;
 char*channel_layout_str;
 
-int got_format_from_params;
 int eof;
 } BufferSourceContext;
 
@@ -105,7 +104,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, 
AVBufferSrcParameters *par
 switch (ctx->filter->outputs[0].type) {
 case AVMEDIA_TYPE_VIDEO:
 if (param->format != AV_PIX_FMT_NONE) {
-s->got_format_from_params = 1;
 s->pix_fmt = param->format;
 }
 if (param->width > 0)
@@ -125,7 +123,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, 
AVBufferSrcParameters *par
 break;
 case AVMEDIA_TYPE_AUDIO:
 if (param->format != AV_SAMPLE_FMT_NONE) {
-s->got_format_from_params = 1;
 s->sample_fmt = param->format;
 }
 if (param->sample_rate > 0)
@@ -278,7 +275,7 @@ static av_cold int init_video(AVFilterContext *ctx)
 {
 BufferSourceContext *c = ctx->priv;
 
-if (!(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params) || !c->w 
|| !c->h ||
+if (c->pix_fmt == AV_PIX_FMT_NONE || !c->w || !c->h ||
 av_q2d(c->time_base) <= 0) {
 av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n");
 return AVERROR(EINVAL);
@@ -334,7 +331,7 @@ static av_cold int init_audio(AVFilterContext *ctx)
 BufferSourceContext *s = ctx->priv;
 int ret = 0;
 
-if (!(s->sample_fmt != AV_SAMPLE_FMT_NONE || s->got_format_from_params)) {
+if (s->sample_fmt == AV_SAMPLE_FMT_NONE) {
 av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was 
invalid\n");
 return AVERROR(EINVAL);
 }
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg_filter: remove sws_param option from buffersrc

2019-12-04 Thread quinkblack
From: Zhao Zhili 

The option is deprecated and ignored by buffersrc.
---
 fftools/ffmpeg_filter.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 72838de1e2..40cc4c191c 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -786,10 +786,9 @@ static int configure_input_video_filter(FilterGraph *fg, 
InputFilter *ifilter,
 av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprintf(,
  "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
- "pixel_aspect=%d/%d:sws_param=flags=%d",
+ "pixel_aspect=%d/%d",
  ifilter->width, ifilter->height, ifilter->format,
- tb.num, tb.den, sar.num, sar.den,
- SWS_BILINEAR + ((ist->dec_ctx->flags_CODEC_FLAG_BITEXACT) ? 
SWS_BITEXACT:0));
+ tb.num, tb.den, sar.num, sar.den);
 if (fr.num && fr.den)
 av_bprintf(, ":frame_rate=%d/%d", fr.num, fr.den);
 snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v4] avfilter/buffersrc: deprecate sws_param option

2019-12-04 Thread quinkblack
From: Zhao Zhili 

---
patch v4: update doc

 doc/filters.texi|  8 
 libavfilter/buffersrc.c | 14 --
 libavfilter/version.h   |  5 -
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5fdec6f015..d15cf74c84 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21014,9 +21014,9 @@ Specify the frame rate expected for the video stream.
 The sample (pixel) aspect ratio of the input video.
 
 @item sws_param
-Specify the optional parameters to be used for the scale filter which
-is automatically inserted when an input change is detected in the
-input size or format.
+This option is deprecated and ignored. Prepend @code{sws_flags=@var{flags};}
+to the filtergraph description to specify swscale flags for automatically
+inserted scalers. See @ref{Filtergraph syntax}.
 
 @item hw_frames_ctx
 When using a hardware pixel format, this should be a reference to an
@@ -21041,7 +21041,7 @@ 
buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
 Alternatively, the options can be specified as a flat string, but this
 syntax is deprecated:
 
-@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
+@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}
 
 @section cellauto
 
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index bae7d86695..73a7eb82ca 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -52,7 +52,9 @@ typedef struct BufferSourceContext {
 int   w, h;
 enum AVPixelFormat  pix_fmt;
 AVRationalpixel_aspect;
+#if FF_API_SWS_PARAM_OPTION
 char  *sws_param;
+#endif
 
 AVBufferRef *hw_frames_ctx;
 
@@ -287,10 +289,16 @@ static av_cold int init_video(AVFilterContext *ctx)
 if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame*
 return AVERROR(ENOMEM);
 
-av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d sws_param:%s\n",
+av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d\n",
c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
c->time_base.num, c->time_base.den, c->frame_rate.num, 
c->frame_rate.den,
-   c->pixel_aspect.num, c->pixel_aspect.den, (char 
*)av_x_if_null(c->sws_param, ""));
+   c->pixel_aspect.num, c->pixel_aspect.den);
+
+#if FF_API_SWS_PARAM_OPTION
+if (c->sws_param)
+av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and 
ignored\n");
+#endif
+
 return 0;
 }
 
@@ -312,7 +320,9 @@ static const AVOption buffer_options[] = {
 { "pixel_aspect",  "sample aspect ratio",OFFSET(pixel_aspect), 
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "time_base", NULL, OFFSET(time_base),
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "frame_rate",NULL, OFFSET(frame_rate),   
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
+#if FF_API_SWS_PARAM_OPTION
 { "sws_param", NULL, OFFSET(sws_param),
AV_OPT_TYPE_STRING,.flags = V },
+#endif
 { NULL },
 };
 
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 7e8d849e0c..bf57d64d1f 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   7
 #define LIBAVFILTER_VERSION_MINOR  67
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -59,6 +59,9 @@
 #ifndef FF_API_FILTER_GET_SET
 #define FF_API_FILTER_GET_SET   (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
+#ifndef FF_API_SWS_PARAM_OPTION
+#define FF_API_SWS_PARAM_OPTION (LIBAVFILTER_VERSION_MAJOR < 8)
+#endif
 #ifndef FF_API_NEXT
 #define FF_API_NEXT (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v3] avfilter/buffersrc: deprecate sws_param option

2019-12-03 Thread quinkblack
From: Zhao Zhili 

---
patch v3: document how to set the parameters for automatically inserted filters.

 doc/filters.texi|  7 +++
 libavfilter/buffersrc.c | 14 --
 libavfilter/version.h   |  5 -
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5fdec6f015..7a700c7cc4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21014,9 +21014,8 @@ Specify the frame rate expected for the video stream.
 The sample (pixel) aspect ratio of the input video.
 
 @item sws_param
-Specify the optional parameters to be used for the scale filter which
-is automatically inserted when an input change is detected in the
-input size or format.
+This option is deprecated and ignored. Use 
@ref{sws_flags,,sws_flags,ffmpeg-scaler}
+instead to specify swscale flags for those automatically inserted scalers.
 
 @item hw_frames_ctx
 When using a hardware pixel format, this should be a reference to an
@@ -21041,7 +21040,7 @@ 
buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
 Alternatively, the options can be specified as a flat string, but this
 syntax is deprecated:
 
-@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
+@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}
 
 @section cellauto
 
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index bae7d86695..73a7eb82ca 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -52,7 +52,9 @@ typedef struct BufferSourceContext {
 int   w, h;
 enum AVPixelFormat  pix_fmt;
 AVRationalpixel_aspect;
+#if FF_API_SWS_PARAM_OPTION
 char  *sws_param;
+#endif
 
 AVBufferRef *hw_frames_ctx;
 
@@ -287,10 +289,16 @@ static av_cold int init_video(AVFilterContext *ctx)
 if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame*
 return AVERROR(ENOMEM);
 
-av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d sws_param:%s\n",
+av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d\n",
c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
c->time_base.num, c->time_base.den, c->frame_rate.num, 
c->frame_rate.den,
-   c->pixel_aspect.num, c->pixel_aspect.den, (char 
*)av_x_if_null(c->sws_param, ""));
+   c->pixel_aspect.num, c->pixel_aspect.den);
+
+#if FF_API_SWS_PARAM_OPTION
+if (c->sws_param)
+av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and 
ignored\n");
+#endif
+
 return 0;
 }
 
@@ -312,7 +320,9 @@ static const AVOption buffer_options[] = {
 { "pixel_aspect",  "sample aspect ratio",OFFSET(pixel_aspect), 
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "time_base", NULL, OFFSET(time_base),
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "frame_rate",NULL, OFFSET(frame_rate),   
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
+#if FF_API_SWS_PARAM_OPTION
 { "sws_param", NULL, OFFSET(sws_param),
AV_OPT_TYPE_STRING,.flags = V },
+#endif
 { NULL },
 };
 
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 7e8d849e0c..bf57d64d1f 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   7
 #define LIBAVFILTER_VERSION_MINOR  67
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -59,6 +59,9 @@
 #ifndef FF_API_FILTER_GET_SET
 #define FF_API_FILTER_GET_SET   (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
+#ifndef FF_API_SWS_PARAM_OPTION
+#define FF_API_SWS_PARAM_OPTION (LIBAVFILTER_VERSION_MAJOR < 8)
+#endif
 #ifndef FF_API_NEXT
 #define FF_API_NEXT (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2] avfilter/buffersrc: deprecate sws_param option

2019-12-02 Thread quinkblack
From: Zhao Zhili 

---
 doc/filters.texi|  4 +---
 libavfilter/buffersrc.c | 14 --
 libavfilter/version.h   |  5 -
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5fdec6f015..9b3c2d7c2d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21014,9 +21014,7 @@ Specify the frame rate expected for the video stream.
 The sample (pixel) aspect ratio of the input video.
 
 @item sws_param
-Specify the optional parameters to be used for the scale filter which
-is automatically inserted when an input change is detected in the
-input size or format.
+This option is deprecated and ignored.
 
 @item hw_frames_ctx
 When using a hardware pixel format, this should be a reference to an
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index bae7d86695..73a7eb82ca 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -52,7 +52,9 @@ typedef struct BufferSourceContext {
 int   w, h;
 enum AVPixelFormat  pix_fmt;
 AVRationalpixel_aspect;
+#if FF_API_SWS_PARAM_OPTION
 char  *sws_param;
+#endif
 
 AVBufferRef *hw_frames_ctx;
 
@@ -287,10 +289,16 @@ static av_cold int init_video(AVFilterContext *ctx)
 if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame*
 return AVERROR(ENOMEM);
 
-av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d sws_param:%s\n",
+av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d\n",
c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
c->time_base.num, c->time_base.den, c->frame_rate.num, 
c->frame_rate.den,
-   c->pixel_aspect.num, c->pixel_aspect.den, (char 
*)av_x_if_null(c->sws_param, ""));
+   c->pixel_aspect.num, c->pixel_aspect.den);
+
+#if FF_API_SWS_PARAM_OPTION
+if (c->sws_param)
+av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and 
ignored\n");
+#endif
+
 return 0;
 }
 
@@ -312,7 +320,9 @@ static const AVOption buffer_options[] = {
 { "pixel_aspect",  "sample aspect ratio",OFFSET(pixel_aspect), 
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "time_base", NULL, OFFSET(time_base),
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "frame_rate",NULL, OFFSET(frame_rate),   
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
+#if FF_API_SWS_PARAM_OPTION
 { "sws_param", NULL, OFFSET(sws_param),
AV_OPT_TYPE_STRING,.flags = V },
+#endif
 { NULL },
 };
 
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 7e8d849e0c..bf57d64d1f 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   7
 #define LIBAVFILTER_VERSION_MINOR  67
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -59,6 +59,9 @@
 #ifndef FF_API_FILTER_GET_SET
 #define FF_API_FILTER_GET_SET   (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
+#ifndef FF_API_SWS_PARAM_OPTION
+#define FF_API_SWS_PARAM_OPTION (LIBAVFILTER_VERSION_MAJOR < 8)
+#endif
 #ifndef FF_API_NEXT
 #define FF_API_NEXT (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: remove write-only variable

2019-12-02 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/buffersrc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index e0ff7e4dd8..bae7d86695 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -47,7 +47,6 @@ typedef struct BufferSourceContext {
 AVRationaltime_base; ///< time_base to set in the output link
 AVRationalframe_rate;///< frame_rate to set in the output link
 unsigned  nb_failed_requests;
-unsigned  warning_limit;
 
 /* video only */
 int   w, h;
@@ -292,7 +291,6 @@ static av_cold int init_video(AVFilterContext *ctx)
c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
c->time_base.num, c->time_base.den, c->frame_rate.num, 
c->frame_rate.den,
c->pixel_aspect.num, c->pixel_aspect.den, (char 
*)av_x_if_null(c->sws_param, ""));
-c->warning_limit = 100;
 return 0;
 }
 
@@ -379,7 +377,6 @@ static av_cold int init_audio(AVFilterContext *ctx)
"tb:%d/%d samplefmt:%s samplerate:%d chlayout:%s\n",
s->time_base.num, s->time_base.den, 
av_get_sample_fmt_name(s->sample_fmt),
s->sample_rate, s->channel_layout_str);
-s->warning_limit = 100;
 
 return ret;
 }
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 2/2] avfilter/buffersrc: deprecate sws_param option

2019-12-02 Thread quinkblack
From: Zhao Zhili 

---
 doc/filters.texi| 4 +---
 libavfilter/buffersrc.c | 8 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5fdec6f015..9b3c2d7c2d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21014,9 +21014,7 @@ Specify the frame rate expected for the video stream.
 The sample (pixel) aspect ratio of the input video.
 
 @item sws_param
-Specify the optional parameters to be used for the scale filter which
-is automatically inserted when an input change is detected in the
-input size or format.
+This option is deprecated and ignored.
 
 @item hw_frames_ctx
 When using a hardware pixel format, this should be a reference to an
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index bae7d86695..af6039f9b3 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -287,10 +287,14 @@ static av_cold int init_video(AVFilterContext *ctx)
 if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame*
 return AVERROR(ENOMEM);
 
-av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d sws_param:%s\n",
+av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d\n",
c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
c->time_base.num, c->time_base.den, c->frame_rate.num, 
c->frame_rate.den,
-   c->pixel_aspect.num, c->pixel_aspect.den, (char 
*)av_x_if_null(c->sws_param, ""));
+   c->pixel_aspect.num, c->pixel_aspect.den);
+
+if (c->sws_param)
+av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and 
ignored\n");
+
 return 0;
 }
 
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH] libavdevice/lavfi: check avfilter_graph_dump return value

2019-11-20 Thread quinkblack
From: Zhao Zhili 

---
 libavdevice/lavfi.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index ca8f05f3f7..c949ff7e12 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -302,9 +302,13 @@ av_cold static int lavfi_read_header(AVFormatContext 
*avctx)
 
 if (lavfi->dump_graph) {
 char *dump = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph);
-fputs(dump, stderr);
-fflush(stderr);
-av_free(dump);
+if (dump != NULL) {
+fputs(dump, stderr);
+fflush(stderr);
+av_free(dump);
+} else {
+FAIL(AVERROR(ENOMEM));
+}
 }
 
 /* fill each stream with the information in the corresponding sink */
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH] avfilter/graphdump: fix use of uninitialized variables

2019-11-20 Thread quinkblack
From: Zhao Zhili 

In case of av_bprint_finalize failed.
---
 libavfilter/graphdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
index 8bc7b162d7..79ef1a733f 100644
--- a/libavfilter/graphdump.c
+++ b/libavfilter/graphdump.c
@@ -154,7 +154,7 @@ static void avfilter_graph_dump_to_buf(AVBPrint *buf, 
AVFilterGraph *graph)
 char *avfilter_graph_dump(AVFilterGraph *graph, const char *options)
 {
 AVBPrint buf;
-char *dump;
+char *dump = NULL;
 
 av_bprint_init(, 0, AV_BPRINT_SIZE_COUNT_ONLY);
 avfilter_graph_dump_to_buf(, graph);
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2] avcodec/vp8: fix multiple ff_thread_finish_setup() calls

2019-11-13 Thread quinkblack
From: Zhao Zhili 

webp decoder doesn't set update_thread_context field

$ ffmpeg -i rgb_q80.webp -f null -
[webp @ 0x7ffbd5823200] Multiple ff_thread_finish_setup() calls
---
 libavcodec/vp8.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index eb51d1f3c9..b4deb3ed67 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -2715,7 +2715,8 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 
 s->next_framep[VP56_FRAME_CURRENT] = curframe;
 
-ff_thread_finish_setup(avctx);
+if (avctx->codec->update_thread_context)
+ff_thread_finish_setup(avctx);
 
 if (avctx->hwaccel) {
 ret = avctx->hwaccel->start_frame(avctx, avpkt->data, avpkt->size);
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH] avcodec/vp8: fix multiple ff_thread_finish_setup() calls

2019-11-12 Thread quinkblack
From: Zhao Zhili 

vp7 decoder doesn't set update_thread_context field
---
 libavcodec/vp8.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index eb51d1f3c9..b4deb3ed67 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -2715,7 +2715,8 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 
 s->next_framep[VP56_FRAME_CURRENT] = curframe;
 
-ff_thread_finish_setup(avctx);
+if (avctx->codec->update_thread_context)
+ff_thread_finish_setup(avctx);
 
 if (avctx->hwaccel) {
 ret = avctx->hwaccel->start_frame(avctx, avpkt->data, avpkt->size);
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2 4/4] avcodec/avcodec.h: document add/new_side_data with the same type

2019-11-01 Thread quinkblack
From: Zhao Zhili 

---
 libavcodec/avcodec.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index bcb931f0dd..84dcf52285 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4486,6 +4486,8 @@ void av_free_packet(AVPacket *pkt);
 /**
  * Allocate new information of a packet.
  *
+ * @note replace existing side data of the same type
+ *
  * @param pkt packet
  * @param type side information type
  * @param size side information size
@@ -4497,6 +4499,8 @@ uint8_t* av_packet_new_side_data(AVPacket *pkt, enum 
AVPacketSideDataType type,
 /**
  * Wrap an existing array as a packet side data.
  *
+ * @note replace existing side data of the same type
+ *
  * @param pkt packet
  * @param type side information type
  * @param data the side data array. It must be allocated with the av_malloc()
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH v2 2/4] frame: make av_frame_remove_side_data return early

2019-11-01 Thread quinkblack
From: Zhao Zhili 

---
 libavutil/frame.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index bb20e99331..9edf971c55 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -825,6 +825,7 @@ void av_frame_remove_side_data(AVFrame *frame, enum 
AVFrameSideDataType type)
 free_side_data(>side_data[i]);
 frame->side_data[i] = frame->side_data[frame->nb_side_data - 1];
 frame->nb_side_data--;
+return;
 }
 }
 }
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2 1/4] frame: handle add side data with the same type

2019-11-01 Thread quinkblack
From: Zhao Zhili 

---
 libavutil/frame.c | 13 +
 libavutil/frame.h |  4 
 2 files changed, 17 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index dcf1fc3d17..bb20e99331 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -692,10 +692,23 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame 
*frame,
  AVBufferRef *buf)
 {
 AVFrameSideData *ret, **tmp;
+int i;
 
 if (!buf)
 return NULL;
 
+for (i = 0; i < frame->nb_side_data; i++) {
+AVFrameSideData *sd = frame->side_data[i];
+if (sd->type == type) {
+av_buffer_unref(>buf);
+av_dict_free(>metadata);
+sd->buf = buf;
+sd->data = buf->data;
+sd->size = buf->size;
+return sd;
+}
+}
+
 if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
 return NULL;
 
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 5d3231e7bb..906143f894 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -886,6 +886,8 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int 
plane);
 /**
  * Add a new side data to a frame.
  *
+ * @note replace existing side data of the same type
+ *
  * @param frame a frame to which the side data should be added
  * @param type type of the added side data
  * @param size size of the side data
@@ -899,6 +901,8 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
 /**
  * Add a new side data to a frame from an existing AVBufferRef
  *
+ * @note replace existing side data of the same type
+ *
  * @param frame a frame to which the side data should be added
  * @param type  the type of the added side data
  * @param buf   an AVBufferRef to add as side data. The ownership of
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH v2 3/4] avformat/avformat.h: document add/new_side_data with the same type

2019-11-01 Thread quinkblack
From: Zhao Zhili 

---
 libavformat/avformat.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6eb329f13f..acce242398 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2162,6 +2162,8 @@ AVStream *avformat_new_stream(AVFormatContext *s, const 
AVCodec *c);
 /**
  * Wrap an existing array as stream side data.
  *
+ * @note replace existing side data of the same type
+ *
  * @param st stream
  * @param type side information type
  * @param data the side data array. It must be allocated with the av_malloc()
@@ -2177,6 +2179,8 @@ int av_stream_add_side_data(AVStream *st, enum 
AVPacketSideDataType type,
 /**
  * Allocate new information from stream.
  *
+ * @note replace existing side data of the same type
+ *
  * @param stream stream
  * @param type desired side information type
  * @param size side information size
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 2/2] frame: make av_frame_remove_side_data return early

2019-10-24 Thread quinkblack
From: Zhao Zhili 

---
 libavutil/frame.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index bb20e99331..9edf971c55 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -825,6 +825,7 @@ void av_frame_remove_side_data(AVFrame *frame, enum 
AVFrameSideDataType type)
 free_side_data(>side_data[i]);
 frame->side_data[i] = frame->side_data[frame->nb_side_data - 1];
 frame->nb_side_data--;
+return;
 }
 }
 }
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH 1/2] frame: handle add side data with the same type

2019-10-24 Thread quinkblack
From: Zhao Zhili 

---
 libavutil/frame.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index dcf1fc3d17..bb20e99331 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -692,10 +692,23 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame 
*frame,
  AVBufferRef *buf)
 {
 AVFrameSideData *ret, **tmp;
+int i;
 
 if (!buf)
 return NULL;
 
+for (i = 0; i < frame->nb_side_data; i++) {
+AVFrameSideData *sd = frame->side_data[i];
+if (sd->type == type) {
+av_buffer_unref(>buf);
+av_dict_free(>metadata);
+sd->buf = buf;
+sd->data = buf->data;
+sd->size = buf->size;
+return sd;
+}
+}
+
 if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
 return NULL;
 
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH] avfilter: remove unused private field of AVFilterLink

2019-10-18 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/avfilter.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 3eaa8a4089..3c87f4864a 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -572,11 +572,6 @@ struct AVFilterLink {
  */
 int channels;
 
-/**
- * Link processing flags.
- */
-unsigned flags;
-
 /**
  * Number of past frames sent through the link.
  */
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH] avfilter: fix typo in comments

2019-10-09 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/avfilter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 9d70e7118b..3eaa8a4089 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -79,7 +79,7 @@ int avfilter_pad_count(const AVFilterPad *pads);
  * Get the name of an AVFilterPad.
  *
  * @param pads an array of AVFilterPads
- * @param pad_idx index of the pad in the array it; is the caller's
+ * @param pad_idx index of the pad in the array; it is the caller's
  *responsibility to ensure the index is valid
  *
  * @return name of the pad_idx'th pad in pads
-- 
2.22.0



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

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

[FFmpeg-devel] [PATCH] FATE/dnn: fix stack buffer overflow

2019-10-01 Thread quinkblack
From: Zhao Zhili 

---
 tests/dnn/dnn-layer-pad-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/dnn/dnn-layer-pad-test.c b/tests/dnn/dnn-layer-pad-test.c
index 1fb2be1590..ea8c824d1e 100644
--- a/tests/dnn/dnn-layer-pad-test.c
+++ b/tests/dnn/dnn-layer-pad-test.c
@@ -203,7 +203,7 @@ static int test_with_mode_constant(void)
 params.paddings[3][1] = 2;
 
 operands[0].data = input;
-operands[0].dims[0] = 3;
+operands[0].dims[0] = 1;
 operands[0].dims[1] = 2;
 operands[0].dims[2] = 2;
 operands[0].dims[3] = 3;
-- 
2.17.1



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

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

[FFmpeg-devel] [PATCH] avfilter/formats: remove unnecessary unreference

2019-09-30 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/formats.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 31ee445c49..15c3adf80b 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -317,7 +317,6 @@ do {
\
 void *oldf = *f;\
 \
 if (!(*f) && !(*f = av_mallocz(sizeof(**f { \
-unref_fn(f);\
 return AVERROR(ENOMEM); \
 }   \
 \
-- 
2.22.0



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

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