[FFmpeg-cvslog] avfilter/vf_zscale: do not attempt to continue filtering if there is no graph
ffmpeg | branch: master | Paul B Mahol | Fri Mar 11 09:32:34 2022 +0100| [a0724328a82ed1ea89b86c1414ba1d4dd12c760f] | committer: Paul B Mahol avfilter/vf_zscale: do not attempt to continue filtering if there is no graph > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0724328a82ed1ea89b86c1414ba1d4dd12c760f --- libavfilter/vf_zscale.c | 27 ++- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 649ef7f6bb..bb457423b3 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -627,7 +627,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des s->alpha_graph[job_nr] = zimg_filter_graph_build(&alpha_src_format, &alpha_dst_format, &s->alpha_params); if (!s->alpha_graph[job_nr]) return print_zimg_error(ctx); - } +} return 0; } @@ -728,9 +728,11 @@ static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs dst_buf.plane[i].stride = td->out->linesize[p]; dst_buf.plane[i].mask = -1; } +if (!s->graph[job_nr]) +return AVERROR(EINVAL); ret = zimg_filter_graph_process(s->graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0); if (ret) -return print_zimg_error(ctx); +return print_zimg_error(ctx); if (td->desc->flags & AV_PIX_FMT_FLAG_ALPHA && td->odesc->flags & AV_PIX_FMT_FLAG_ALPHA) { src_buf.plane[0].data = td->in->data[3]; @@ -741,6 +743,8 @@ static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs dst_buf.plane[0].stride = td->out->linesize[3]; dst_buf.plane[0].mask = -1; +if (!s->alpha_graph[job_nr]) +return AVERROR(EINVAL); ret = zimg_filter_graph_process(s->alpha_graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0); if (ret) return print_zimg_error(ctx); @@ -854,7 +858,14 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) td.desc = desc; td.odesc = odesc; -ff_filter_execute(ctx, filter_slice, &td, NULL, s->nb_threads); +ret = ff_filter_execute(ctx, filter_slice, &td, NULL, s->nb_threads); +if (ret < 0 || !s->graph[0]) { +av_frame_free(&in); +av_frame_free(&out); +if (ret >= 0) +ret = AVERROR(EINVAL); +return ret; +} s->src_format_tmp = s->src_format; s->dst_format_tmp = s->dst_format; @@ -899,8 +910,14 @@ static av_cold void uninit(AVFilterContext *ctx) for (int i = 0; i < s->nb_threads; i++) { av_freep(&s->tmp[i]); -zimg_filter_graph_free(s->graph[i]); -zimg_filter_graph_free(s->alpha_graph[i]); +if (s->graph[i]) { +zimg_filter_graph_free(s->graph[i]); +s->graph[i] = NULL; +} +if (s->alpha_graph[i]) { +zimg_filter_graph_free(s->alpha_graph[i]); +s->alpha_graph[i] = NULL; +} } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] configure: move ranlib -D test after setting defaults
ffmpeg | branch: master | Adrian Ratiu | Mon Feb 14 15:00:07 2022 +0200| [bc5ccea3b9d2c71929af6271bd8afe9b6cfab436] | committer: Martin Storsjö configure: move ranlib -D test after setting defaults In Gentoo and ChromeOS we want to allow pure LLVM builds without using GNU tools, so we block any unwanted mixed GNU/LLVM usages (GNU tools are still kept around in our chroots for projects like glibc which cannot yet be built otherwise). The default ${cross_prefix}${ranlib_default} points to GNU and fails, so move the test a bit later - after the defaults are set and the proper values get overriden - such that ffmpeg configure calls the llvm-ranlib we desire. [1] [1] https://gitweb.gentoo.org/repo/gentoo.git/tree/media-video/ffmpeg/ffmpeg-4.4.1-r1.ebuild?id=7a34377e3277a6a0e2eedd40e90452a44c55f1e6#n477 Signed-off-by: Adrian Ratiu Signed-off-by: Martin Storsjö > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc5ccea3b9d2c71929af6271bd8afe9b6cfab436 --- configure | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 7d22c2a345..82642deabe 100755 --- a/configure +++ b/configure @@ -4403,11 +4403,7 @@ cc_default="${cross_prefix}${cc_default}" cxx_default="${cross_prefix}${cxx_default}" nm_default="${cross_prefix}${nm_default}" pkg_config_default="${cross_prefix}${pkg_config_default}" -if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then -ranlib_default="${cross_prefix}${ranlib_default} -D" -else -ranlib_default="${cross_prefix}${ranlib_default}" -fi +ranlib_default="${cross_prefix}${ranlib_default}" strip_default="${cross_prefix}${strip_default}" windres_default="${cross_prefix}${windres_default}" @@ -4440,6 +4436,10 @@ set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \ enabled cross_compile || host_cc_default=$cc set_default host_cc +if ${ranlib} 2>&1 | grep -q "\-D "; then +ranlib="${ranlib} -D" +fi + pkg_config_fail_message="" if ! $pkg_config --version >/dev/null 2>&1; then warn "$pkg_config not found, library detection may fail." ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fate/mov: Add test for muxing chapters
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 4 14:23:53 2022 +0100| [a909666d7ce110b9394a42df5ac817f322141c32] | committer: Andreas Rheinhardt fate/mov: Add test for muxing chapters Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a909666d7ce110b9394a42df5ac817f322141c32 --- tests/fate/mov.mak | 6 + tests/ref/fate/mov-mp4-chapters | 50 + 2 files changed, 56 insertions(+) diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index e956380909..b54c009f05 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -126,6 +126,12 @@ fate-mov-mp4-with-mov-in24-ver: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entr fate-mov-mp4-extended-atom: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact -select_streams v $(TARGET_SAMPLES)/mov/extended_atom_size_probe +FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL OGG_DEMUXER\ + VORBIS_DECODER MP4_MUXER MOV_DEMUXER \ + FRAMECRC_MUXER PIPE_PROTOCOL)\ + += fate-mov-mp4-chapters +fate-mov-mp4-chapters: CMD = transcode ogg $(TARGET_SAMPLES)/vorbis/vorbis_chapter_extension_demo.ogg mp4 "-c copy" "-c copy -t 0.1" "" "-show_chapters" + FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MOV_DEMUXER MJPEG_DECODER \ SCALE_FILTER PNG_ENCODER PNG_DECODER \ MP4_MUXER FRAMECRC_MUXER PIPE_PROTOCOL) \ diff --git a/tests/ref/fate/mov-mp4-chapters b/tests/ref/fate/mov-mp4-chapters new file mode 100644 index 00..d072d76a83 --- /dev/null +++ b/tests/ref/fate/mov-mp4-chapters @@ -0,0 +1,50 @@ +1fd844c2f5bf77c3344e88e30ad994e1 *tests/data/fate/mov-mp4-chapters.mp4 +111248 tests/data/fate/mov-mp4-chapters.mp4 +#extradata 0: 3469, 0xc6769ddc +#tb 0: 1/44100 +#media_type 0: audio +#codec_id 0: vorbis +#sample_rate 0: 44100 +#channel_layout 0: 4 +#channel_layout_name 0: mono +0, -256, -256, 256, 28, 0xefcf103e, F=0x5 +0, 0, 0, 1152, 198, 0xfbbe5eb5 +0, 1152, 1152, 2944, 198, 0xabd95c6c +0, 4096, 4096, 256, 41, 0x954b12a5 +0, 4352, 4352, 256, 41, 0xbccd1463 +[CHAPTER] +id=0 +time_base=1/1000 +start=0 +start_time=0.00 +end=5000 +end_time=5.00 +TAG:title=start +[/CHAPTER] +[CHAPTER] +id=1 +time_base=1/1000 +start=5000 +start_time=5.00 +end=10500 +end_time=10.50 +TAG:title=Five Seconds +[/CHAPTER] +[CHAPTER] +id=2 +time_base=1/1000 +start=10500 +start_time=10.50 +end=15000 +end_time=15.00 +TAG:title=Ten point 5 seconds +[/CHAPTER] +[CHAPTER] +id=3 +time_base=1/1000 +start=15000 +start_time=15.00 +end=19849 +end_time=19.849000 +TAG:title=15 sec - over soon +[/CHAPTER] ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/movenc: Simplify creating chapter track extradata
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 4 14:25:58 2022 +0100| [707ad03096b29de53f1a27c128891a81a7d6d7c2] | committer: Andreas Rheinhardt avformat/movenc: Simplify creating chapter track extradata Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=707ad03096b29de53f1a27c128891a81a7d6d7c2 --- libavformat/movenc.c | 79 +--- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 4c868919ae..2a6cc1bc6a 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6238,12 +6238,32 @@ fail: // as samples, and a tref pointing from the other tracks to the chapter one. static int mov_create_chapter_track(AVFormatContext *s, int tracknum) { -AVIOContext *pb; - +static const uint8_t stub_header[] = { +// TextSampleEntry +0x00, 0x00, 0x00, 0x01, // displayFlags +0x00, 0x00, // horizontal + vertical justification +0x00, 0x00, 0x00, 0x00, // bgColourRed/Green/Blue/Alpha +// BoxRecord +0x00, 0x00, 0x00, 0x00, // defTextBoxTop/Left +0x00, 0x00, 0x00, 0x00, // defTextBoxBottom/Right +// StyleRecord +0x00, 0x00, 0x00, 0x00, // startChar + endChar +0x00, 0x01, // fontID +0x00, 0x00, // fontStyleFlags + fontSize +0x00, 0x00, 0x00, 0x00, // fgColourRed/Green/Blue/Alpha +// FontTableBox +0x00, 0x00, 0x00, 0x0D, // box size +'f', 't', 'a', 'b', // box atom name +0x00, 0x01, // entry count +// FontRecord +0x00, 0x01, // font ID +0x00, // font name length +}; MOVMuxContext *mov = s->priv_data; MOVTrack *track = &mov->tracks[tracknum]; AVPacket *pkt = mov->pkt; int i, len; +int ret; track->mode = mov->mode; track->tag = MKTAG('t','e','x','t'); @@ -6252,57 +6272,10 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum) if (!track->par) return AVERROR(ENOMEM); track->par->codec_type = AVMEDIA_TYPE_SUBTITLE; -#if 0 -// These properties are required to make QT recognize the chapter track -uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, }; -if (ff_alloc_extradata(track->par, sizeof(chapter_properties))) -return AVERROR(ENOMEM); -memcpy(track->par->extradata, chapter_properties, sizeof(chapter_properties)); -#else -if (avio_open_dyn_buf(&pb) >= 0) { -int size; -uint8_t *buf; - -/* Stub header (usually for Quicktime chapter track) */ -// TextSampleEntry -avio_wb32(pb, 0x01); // displayFlags -avio_w8(pb, 0x00); // horizontal justification -avio_w8(pb, 0x00); // vertical justification -avio_w8(pb, 0x00); // bgColourRed -avio_w8(pb, 0x00); // bgColourGreen -avio_w8(pb, 0x00); // bgColourBlue -avio_w8(pb, 0x00); // bgColourAlpha -// BoxRecord -avio_wb16(pb, 0x00); // defTextBoxTop -avio_wb16(pb, 0x00); // defTextBoxLeft -avio_wb16(pb, 0x00); // defTextBoxBottom -avio_wb16(pb, 0x00); // defTextBoxRight -// StyleRecord -avio_wb16(pb, 0x00); // startChar -avio_wb16(pb, 0x00); // endChar -avio_wb16(pb, 0x01); // fontID -avio_w8(pb, 0x00); // fontStyleFlags -avio_w8(pb, 0x00); // fontSize -avio_w8(pb, 0x00); // fgColourRed -avio_w8(pb, 0x00); // fgColourGreen -avio_w8(pb, 0x00); // fgColourBlue -avio_w8(pb, 0x00); // fgColourAlpha -// FontTableBox -avio_wb32(pb, 0x0D); // box size -ffio_wfourcc(pb, "ftab"); // box atom name -avio_wb16(pb, 0x01); // entry count -// FontRecord -avio_wb16(pb, 0x01); // font ID -avio_w8(pb, 0x00); // font name length - -if ((size = avio_close_dyn_buf(pb, &buf)) > 0) { -track->par->extradata = buf; -track->par->extradata_size = size; -} else { -av_freep(&buf); -} -} -#endif +ret = ff_alloc_extradata(track->par, sizeof(stub_header)); +if (ret < 0) +return ret; +memcpy(track->par->extradata, stub_header, sizeof(stub_header)); pkt->stream_index = tracknum; pkt->flags = AV_PKT_FLAG_KEY; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/af_afftdn: remove code that have marginal impact to denoising
ffmpeg | branch: master | Paul B Mahol | Thu Mar 10 15:20:59 2022 +0100| [ea777333de770f3121680cbffd5742f51d6a756a] | committer: Paul B Mahol avfilter/af_afftdn: remove code that have marginal impact to denoising > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ea777333de770f3121680cbffd5742f51d6a756a --- libavfilter/af_afftdn.c | 68 - 1 file changed, 68 deletions(-) diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c index 2758ae8a8d..a08b2e6ce9 100644 --- a/libavfilter/af_afftdn.c +++ b/libavfilter/af_afftdn.c @@ -876,70 +876,6 @@ static int config_input(AVFilterLink *inlink) return 0; } -static void preprocess(AVComplexFloat *in, int len) -{ -double d1, d2, d3, d4, d5, d6, d7, d8, d9, d10; -int n, i, k; - -d5 = 2.0 * M_PI / len; -d8 = sin(0.5 * d5); -d8 = -2.0 * d8 * d8; -d7 = sin(d5); -d9 = 1.0 + d8; -d6 = d7; -n = len / 2; - -for (i = 1; i < len / 4; i++) { -k = n - i; -d2 = 0.5 * (in[i].re + in[k].re); -d1 = 0.5 * (in[i].im - in[k].im); -d4 = 0.5 * (in[i].im + in[k].im); -d3 = 0.5 * (in[k].re - in[i].re); -in[i].re = d2 + d9 * d4 + d6 * d3; -in[i].im = d1 + d9 * d3 - d6 * d4; -in[k].re = d2 - d9 * d4 - d6 * d3; -in[k].im = -d1 + d9 * d3 - d6 * d4; -d10 = d9; -d9 += d9 * d8 - d6 * d7; -d6 += d6 * d8 + d10 * d7; -} - -d2 = in[0].re; -in[0].re = d2 + in[0].im; -in[0].im = d2 - in[0].im; -} - -static void postprocess(AVComplexFloat *in, int len) -{ -double d1, d2, d3, d4, d5, d6, d7, d8, d9, d10; -int n, i, k; - -d5 = 2.0 * M_PI / len; -d8 = sin(0.5 * d5); -d8 = -2.0 * d8 * d8; -d7 = sin(d5); -d9 = 1.0 + d8; -d6 = d7; -n = len / 2; -for (i = 1; i < len / 4; i++) { -k = n - i; -d2 = 0.5 * (in[i].re + in[k].re); -d1 = 0.5 * (in[i].im - in[k].im); -d4 = 0.5 * (in[i].re - in[k].re); -d3 = 0.5 * (in[i].im + in[k].im); -in[i].re = d2 - d9 * d3 - d6 * d4; -in[i].im = d1 + d9 * d4 - d6 * d3; -in[k].re = d2 + d9 * d3 + d6 * d4; -in[k].im = -d1 + d9 * d4 - d6 * d3; -d10 = d9; -d9 += d9 * d8 - d6 * d7; -d6 += d6 * d8 + d10 * d7; -} -d2 = in[0].re; -in[0].re = 0.5 * (d2 + in[0].im); -in[0].im = 0.5 * (d2 - in[0].im); -} - static void init_sample_noise(DeNoiseChannel *dnch) { for (int i = 0; i < 15; i++) { @@ -970,8 +906,6 @@ static void sample_noise_block(AudioFFTDeNoiseContext *s, dnch->tx_fn(dnch->fft, dnch->fft_out, dnch->fft_in, sizeof(float)); -preprocess(dnch->fft_out, s->fft_length); - edge = s->noise_band_edge[0]; j = edge; k = 0; @@ -1132,12 +1066,10 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_job dnch->tx_fn(dnch->fft, dnch->fft_out, dnch->fft_in, sizeof(float)); -preprocess(dnch->fft_out, s->fft_length); process_frame(s, dnch, dnch->fft_out, dnch->prior, dnch->prior_band_excit, s->track_noise); -postprocess(dnch->fft_out, s->fft_length); dnch->itx_fn(dnch->ifft, dnch->fft_in, dnch->fft_out, sizeof(float)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/af_afftdn: remove special handling for first and last bin
ffmpeg | branch: master | Paul B Mahol | Thu Mar 10 15:34:45 2022 +0100| [e7caa18b4a3344b90a0574591fd86158458b7e9f] | committer: Paul B Mahol avfilter/af_afftdn: remove special handling for first and last bin > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e7caa18b4a3344b90a0574591fd86158458b7e9f --- libavfilter/af_afftdn.c | 45 ++--- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c index a08b2e6ce9..bb83e52dda 100644 --- a/libavfilter/af_afftdn.c +++ b/libavfilter/af_afftdn.c @@ -309,20 +309,9 @@ static void process_frame(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, double *prior, double *prior_band_excit, int track_noise) { double d1, d2, d3, gain; -int n, i1; - -d1 = fft_data[0].re * fft_data[0].re; -dnch->noisy_data[0] = d1; -d2 = d1 / dnch->abs_var[0]; -d3 = RATIO * prior[0] + RRATIO * fmax(d2 - 1.0, 0.0); -gain = d3 / (1.0 + d3); -gain *= (gain + M_PI_4 / fmax(d2, 1.0E-6)); -prior[0] = (d2 * gain); -dnch->clean_data[0] = (d1 * gain); -gain = sqrt(gain); -dnch->gain[0] = gain; -n = 0; -for (int i = 1; i < s->fft_length2; i++) { +int n = 0, i1; + +for (int i = 0; i < s->fft_length2; i++) { d1 = fft_data[i].re * fft_data[i].re + fft_data[i].im * fft_data[i].im; if (d1 > s->sample_floor) n = i; @@ -337,19 +326,7 @@ static void process_frame(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, gain = sqrt(gain); dnch->gain[i] = gain; } -d1 = fft_data[0].im * fft_data[0].im; -if (d1 > s->sample_floor) -n = s->fft_length2; - -dnch->noisy_data[s->fft_length2] = d1; -d2 = d1 / dnch->abs_var[s->fft_length2]; -d3 = RATIO * prior[s->fft_length2] + RRATIO * fmax(d2 - 1.0, 0.0); -gain = d3 / (1.0 + d3); -gain *= gain + M_PI_4 / fmax(d2, 1.0E-6); -prior[s->fft_length2] = d2 * gain; -dnch->clean_data[s->fft_length2] = d1 * gain; -gain = sqrt(gain); -dnch->gain[s->fft_length2] = gain; + if (n > s->fft_length2 - 2) { n = s->bin_count; i1 = s->noise_band_count; @@ -472,7 +449,7 @@ static void process_frame(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, dnch->gain[s->fft_length2] = limit_gain(dnch->gain[s->fft_length2], s->max_gain); } -for (int i = 1; i < s->fft_length2; i++) { +for (int i = 0; i < s->fft_length2; i++) { if (dnch->amt[i] > dnch->abs_var[i]) { dnch->gain[i] = 1.0; } else if (dnch->amt[i] > dnch->min_abs_var[i]) { @@ -483,13 +460,7 @@ static void process_frame(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, } } -gain = dnch->gain[0]; -dnch->clean_data[0] = (gain * gain * dnch->noisy_data[0]); -fft_data[0].re *= gain; -gain = dnch->gain[s->fft_length2]; -dnch->clean_data[s->fft_length2] = (gain * gain * dnch->noisy_data[s->fft_length2]); -fft_data[0].im *= gain; -for (int i = 1; i < s->fft_length2; i++) { +for (int i = 0; i < s->fft_length2; i++) { gain = dnch->gain[i]; dnch->clean_data[i] = (gain * gain * dnch->noisy_data[i]); fft_data[i].re *= gain; @@ -911,10 +882,6 @@ static void sample_noise_block(AudioFFTDeNoiseContext *s, k = 0; n = j; edgemax = fmin(s->fft_length2, s->noise_band_edge[15]); -dnch->fft_out[s->fft_length2].re = dnch->fft_out[0].im; -dnch->fft_out[0].im = 0.0; -dnch->fft_out[s->fft_length2].im = 0.0; - for (int i = j; i <= edgemax; i++) { if ((i == j) && (i < edgemax)) { if (j > edge) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavfi/dnn_io_proc: Return Specific Error Codes
ffmpeg | branch: master | Shubhanshu Saxena | Wed Mar 2 23:53:51 2022 +0530| [d0587daec24be3032f2111c5144aeaece973caaf] | committer: Guo Yejun lavfi/dnn_io_proc: Return Specific Error Codes This commit returns specific error codes from the functions in the dnn_io_proc instead of DNN_ERROR. Signed-off-by: Shubhanshu Saxena > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0587daec24be3032f2111c5144aeaece973caaf --- libavfilter/dnn/dnn_io_proc.c | 48 +++ libavfilter/dnn/dnn_io_proc.h | 8 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c index f55424d97c..36cc051e5e 100644 --- a/libavfilter/dnn/dnn_io_proc.c +++ b/libavfilter/dnn/dnn_io_proc.c @@ -24,16 +24,16 @@ #include "libavutil/avassert.h" #include "libavutil/detection_bbox.h" -DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx) +int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx) { struct SwsContext *sws_ctx; int bytewidth = av_image_get_linesize(frame->format, frame->width, 0); if (bytewidth < 0) { -return DNN_ERROR; +return AVERROR(EINVAL); } if (output->dt != DNN_FLOAT) { avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT"); -return DNN_ERROR; +return AVERROR(ENOSYS); } switch (frame->format) { @@ -51,7 +51,7 @@ DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *l "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32), frame->width * 3, frame->height, av_get_pix_fmt_name(AV_PIX_FMT_GRAY8), frame->width * 3, frame->height); -return DNN_ERROR; +return AVERROR(EINVAL); } sws_scale(sws_ctx, (const uint8_t *[4]){(const uint8_t *)output->data, 0, 0, 0}, (const int[4]){frame->width * 3 * sizeof(float), 0, 0, 0}, 0, frame->height, @@ -82,7 +82,7 @@ DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *l "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32), frame->width, frame->height, av_get_pix_fmt_name(AV_PIX_FMT_GRAY8), frame->width, frame->height); -return DNN_ERROR; +return AVERROR(EINVAL); } sws_scale(sws_ctx, (const uint8_t *[4]){(const uint8_t *)output->data, 0, 0, 0}, (const int[4]){frame->width * sizeof(float), 0, 0, 0}, 0, frame->height, @@ -91,22 +91,22 @@ DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *l return DNN_SUCCESS; default: avpriv_report_missing_feature(log_ctx, "%s", av_get_pix_fmt_name(frame->format)); -return DNN_ERROR; +return AVERROR(ENOSYS); } return DNN_SUCCESS; } -DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx) +int ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx) { struct SwsContext *sws_ctx; int bytewidth = av_image_get_linesize(frame->format, frame->width, 0); if (bytewidth < 0) { -return DNN_ERROR; +return AVERROR(EINVAL); } if (input->dt != DNN_FLOAT) { avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT"); -return DNN_ERROR; +return AVERROR(ENOSYS); } switch (frame->format) { @@ -124,7 +124,7 @@ DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *lo "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(AV_PIX_FMT_GRAY8), frame->width * 3, frame->height, av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32),frame->width * 3, frame->height); -return DNN_ERROR; +return AVERROR(EINVAL); } sws_scale(sws_ctx, (const uint8_t **)frame->data, frame->linesize, 0, frame->height, @@ -156,7 +156,7 @@ DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *lo "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(AV_PIX_FMT_GRAY8), frame->width, frame->height, av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32),frame->width, frame->height); -return DNN_ERROR; +return AVERROR(EINVAL); } sws_scale(sws_ctx, (const uint8_t **)frame->data, frame->linesize, 0, frame->height, @@ -166,7 +166,7 @@ DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *lo break; default: avpriv_report_missing_feature(log_ctx, "%s", av_get_pix_fmt_name(frame->format)); -return DNN_ERROR; +return AVERROR(ENOSYS); }
[FFmpeg-cvslog] libavfilter: Prepare to handle specific error codes in DNN Filters
ffmpeg | branch: master | Shubhanshu Saxena | Wed Mar 2 23:53:49 2022 +0530| [e5ce6a60708fb9cd2ec46f6302c3bc943e330f16] | committer: Guo Yejun libavfilter: Prepare to handle specific error codes in DNN Filters This commit prepares the filter side to handle specific error codes from the DNN backends instead of current DNN_ERROR. Signed-off-by: Shubhanshu Saxena > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e5ce6a60708fb9cd2ec46f6302c3bc943e330f16 --- libavfilter/dnn_filter_common.c | 10 +- libavfilter/dnn_filter_common.h | 10 +- libavfilter/vf_derain.c | 4 ++-- libavfilter/vf_dnn_processing.c | 8 libavfilter/vf_sr.c | 8 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c index 3c7a962b3a..5083e3de19 100644 --- a/libavfilter/dnn_filter_common.c +++ b/libavfilter/dnn_filter_common.c @@ -106,18 +106,18 @@ int ff_dnn_set_classify_post_proc(DnnContext *ctx, ClassifyPostProc post_proc) return 0; } -DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input) +int ff_dnn_get_input(DnnContext *ctx, DNNData *input) { return ctx->model->get_input(ctx->model->model, input, ctx->model_inputname); } -DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height) +int ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height) { return ctx->model->get_output(ctx->model->model, ctx->model_inputname, input_width, input_height, (const char *)ctx->model_outputnames[0], output_width, output_height); } -DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame) +int ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame) { DNNExecBaseParams exec_params = { .input_name = ctx->model_inputname, @@ -129,7 +129,7 @@ DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame * return (ctx->dnn_module->execute_model)(ctx->model, &exec_params); } -DNNReturnType ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target) +int ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target) { DNNExecClassificationParams class_params = { { @@ -149,7 +149,7 @@ DNNAsyncStatusType ff_dnn_get_result(DnnContext *ctx, AVFrame **in_frame, AVFram return (ctx->dnn_module->get_result)(ctx->model, in_frame, out_frame); } -DNNReturnType ff_dnn_flush(DnnContext *ctx) +int ff_dnn_flush(DnnContext *ctx) { return (ctx->dnn_module->flush)(ctx->model); } diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h index 635ae631c1..bcdf37c815 100644 --- a/libavfilter/dnn_filter_common.h +++ b/libavfilter/dnn_filter_common.h @@ -53,12 +53,12 @@ int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *fil int ff_dnn_set_frame_proc(DnnContext *ctx, FramePrePostProc pre_proc, FramePrePostProc post_proc); int ff_dnn_set_detect_post_proc(DnnContext *ctx, DetectPostProc post_proc); int ff_dnn_set_classify_post_proc(DnnContext *ctx, ClassifyPostProc post_proc); -DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input); -DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height); -DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame); -DNNReturnType ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target); +int ff_dnn_get_input(DnnContext *ctx, DNNData *input); +int ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height); +int ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame); +int ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target); DNNAsyncStatusType ff_dnn_get_result(DnnContext *ctx, AVFrame **in_frame, AVFrame **out_frame); -DNNReturnType ff_dnn_flush(DnnContext *ctx); +int ff_dnn_flush(DnnContext *ctx); void ff_dnn_uninit(DnnContext *ctx); #endif diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c index 0eb7da18da..6758cc05d2 100644 --- a/libavfilter/vf_derain.c +++ b/libavfilter/vf_derain.c @@ -62,7 +62,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; DRContext *dr_context = ctx->priv; -DNNReturnType dnn_result; +int dnn_result; AVFrame *out; out = ff_get_video_buffer(outlink, outlink->w, outlink->h); @@ -77,7 +77,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (dnn_result !=
[FFmpeg-cvslog] lavfi/dnn: Error Specificity in Native Backend Layers
ffmpeg | branch: master | Shubhanshu Saxena | Wed Mar 2 23:53:50 2022 +0530| [b602f11a0671273dcf08607c37197a41c437463e] | committer: Guo Yejun lavfi/dnn: Error Specificity in Native Backend Layers This commit returns specific error codes from the execution functions in the Native Backend layers instead of DNN_ERROR. Signed-off-by: Shubhanshu Saxena > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b602f11a0671273dcf08607c37197a41c437463e --- libavfilter/dnn/dnn_backend_native_layer_avgpool.c | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_avgpool.h | 3 ++- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 14 -- libavfilter/dnn/dnn_backend_native_layer_conv2d.h | 3 ++- libavfilter/dnn/dnn_backend_native_layer_dense.c | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_dense.h | 3 ++- libavfilter/dnn/dnn_backend_native_layer_depth2space.c | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_depth2space.h | 3 ++- libavfilter/dnn/dnn_backend_native_layer_mathbinary.c | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_mathunary.h | 3 ++- libavfilter/dnn/dnn_backend_native_layer_maximum.c | 4 ++-- libavfilter/dnn/dnn_backend_native_layer_pad.c | 4 ++-- libavfilter/dnn_interface.h| 2 ++ 14 files changed, 39 insertions(+), 30 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c index 89f1787523..510a28a8c9 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c +++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c @@ -109,12 +109,12 @@ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_ope output_operand->length = ff_calculate_operand_data_length(output_operand); if (output_operand->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); -return DNN_ERROR; +return AVERROR(EINVAL); } output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); -return DNN_ERROR; +return AVERROR(ENOMEM); } output = output_operand->data; @@ -143,5 +143,5 @@ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_ope } } -return 0; +return DNN_SUCCESS; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.h b/libavfilter/dnn/dnn_backend_native_layer_avgpool.h index d8972487de..118a160090 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.h +++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.h @@ -60,7 +60,8 @@ int ff_dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, in * @param parameters average pooling parameters * @param ctx pointer to Native model context for logging * @retval 0 if the execution succeeds - * @retval DNN_ERROR if the execution fails + * @retval AVERROR(ENOMEM) if memory allocation fails + * @retval AVERROR(EINVAL) for invalid arguments */ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters, NativeContext *ctx); diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index 7a60aa6a4b..dfa0d1ed36 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -211,12 +211,12 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera output_operand->length = ff_calculate_operand_data_length(output_operand); if (output_operand->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); -return DNN_ERROR; +return AVERROR(EINVAL); } tmp = av_realloc(output_operand->data, output_operand->length); if (!tmp) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); -return DNN_ERROR; +return AVERROR(ENOMEM); } output_operand->data = tmp; thread_common_param.output_data = output_operand->data; @@ -229,17 +229,19 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera #if HAVE_PTHREAD_CANCEL thread_param = av_malloc_array(thread_num, sizeof(*thread_param)); if (!thread_param) -return DNN_ERROR; +return AVERROR(ENOMEM); thread_stride = (height - pad_size * 2) / thread_num; //create threads for (int i = 0; i < thread_num; i++){ +int thread_ret = 0; thread_param[i].thread_common_param = &thread_common_param; thread_param[i].thread_start = thread_stride * i + pad_size; thread_param[i].thre
[FFmpeg-cvslog] lavfi/dnn_backend_common: Return specific error codes
ffmpeg | branch: master | Shubhanshu Saxena | Wed Mar 2 23:53:55 2022 +0530| [1df77bab08ac53482f94c4d4be2449cfa50b8e68] | committer: Guo Yejun lavfi/dnn_backend_common: Return specific error codes Switch to returning specific error codes or DNN_GENERIC_ERROR when an error is encountered in the common DNN backend functions. Signed-off-by: Shubhanshu Saxena > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1df77bab08ac53482f94c4d4be2449cfa50b8e68 --- libavfilter/dnn/dnn_backend_common.c | 35 ++- libavfilter/dnn/dnn_backend_common.h | 22 +- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_common.c b/libavfilter/dnn/dnn_backend_common.c index 6a9c4cc87f..64ed441415 100644 --- a/libavfilter/dnn/dnn_backend_common.c +++ b/libavfilter/dnn/dnn_backend_common.c @@ -47,19 +47,19 @@ int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func // currently, the filter does not need multiple outputs, // so we just pending the support until we really need it. avpriv_report_missing_feature(ctx, "multiple outputs"); -return AVERROR(EINVAL); +return AVERROR(ENOSYS); } return 0; } -DNNReturnType ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc) { +int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc) { if (task == NULL || exec_params == NULL || backend_model == NULL) -return DNN_ERROR; +return AVERROR(EINVAL); if (do_ioproc != 0 && do_ioproc != 1) -return DNN_ERROR; +return AVERROR(EINVAL); if (async != 0 && async != 1) -return DNN_ERROR; +return AVERROR(EINVAL); task->do_ioproc = do_ioproc; task->async = async; @@ -89,17 +89,17 @@ static void *async_thread_routine(void *args) return DNN_ASYNC_SUCCESS; } -DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module) +int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module) { void *status = 0; if (!async_module) { -return DNN_ERROR; +return AVERROR(EINVAL); } #if HAVE_PTHREAD_CANCEL pthread_join(async_module->thread_id, &status); if (status == DNN_ASYNC_FAIL) { av_log(NULL, AV_LOG_ERROR, "Last Inference Failed.\n"); -return DNN_ERROR; +return DNN_GENERIC_ERROR; } #endif async_module->start_inference = NULL; @@ -108,30 +108,31 @@ DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module) return DNN_SUCCESS; } -DNNReturnType ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module) +int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module) { int ret; void *status = 0; if (!async_module) { av_log(ctx, AV_LOG_ERROR, "async_module is null when starting async inference.\n"); -return DNN_ERROR; +return AVERROR(EINVAL); } #if HAVE_PTHREAD_CANCEL pthread_join(async_module->thread_id, &status); if (status == DNN_ASYNC_FAIL) { av_log(ctx, AV_LOG_ERROR, "Unable to start inference as previous inference failed.\n"); -return DNN_ERROR; +return DNN_GENERIC_ERROR; } ret = pthread_create(&async_module->thread_id, NULL, async_thread_routine, async_module); if (ret != 0) { av_log(ctx, AV_LOG_ERROR, "Unable to start async inference.\n"); -return DNN_ERROR; +return ret; } #else -if (async_module->start_inference(async_module->args) != DNN_SUCCESS) { -return DNN_ERROR; +ret = async_module->start_inference(async_module->args); +if (ret != DNN_SUCCESS) { +return ret; } async_module->callback(async_module->args); #endif @@ -158,7 +159,7 @@ DNNAsyncStatusType ff_dnn_get_result_common(Queue *task_queue, AVFrame **in, AVF return DAST_SUCCESS; } -DNNReturnType ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx) +int ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx) { AVFrame *in_frame = NULL; AVFrame *out_frame = NULL; @@ -166,14 +167,14 @@ DNNReturnType ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams * in_frame = av_frame_alloc(); if (!in_frame) { av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for input frame\n"); -return DNN_ERROR; +return AVERROR(ENOMEM); } out_frame = av_frame_alloc(); if (!out_frame) { av_frame_free(&in_frame); av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for output frame\n"); -return DNN_ERROR; +return AVERROR(ENOMEM);
[FFmpeg-cvslog] lavfi/dnn_backend_tf: Return Specific Error Codes
ffmpeg | branch: master | Shubhanshu Saxena | Wed Mar 2 23:53:53 2022 +0530| [3fa89bd7587f725eeebf1b42adda987eacef1962] | committer: Guo Yejun lavfi/dnn_backend_tf: Return Specific Error Codes Switch to returning specific error codes or DNN_GENERIC_ERROR when an error is encountered. For TensorFlow C API errors, currently DNN_GENERIC_ERROR is returned. Signed-off-by: Shubhanshu Saxena > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3fa89bd7587f725eeebf1b42adda987eacef1962 --- libavfilter/dnn/dnn_backend_tf.c | 148 ++- libavfilter/dnn/dnn_backend_tf.h | 4 +- 2 files changed, 85 insertions(+), 67 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 7dd48fb612..cede1286c3 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -90,7 +90,7 @@ static const AVOption dnn_tensorflow_options[] = { AVFILTER_DEFINE_CLASS(dnn_tensorflow); -static DNNReturnType execute_model_tf(TFRequestItem *request, Queue *lltask_queue); +static int execute_model_tf(TFRequestItem *request, Queue *lltask_queue); static void infer_completion_callback(void *args); static inline void destroy_request_item(TFRequestItem **arg); @@ -152,9 +152,10 @@ static TFInferRequest *tf_create_inference_request(void) * * @param request pointer to the TFRequestItem for inference * @retval DNN_SUCCESS if execution is successful - * @retval DNN_ERROR if execution fails + * @retval AVERROR(EINVAL) if request is NULL + * @retval DNN_GENERIC_ERROR if execution fails */ -static DNNReturnType tf_start_inference(void *args) +static int tf_start_inference(void *args) { TFRequestItem *request = args; TFInferRequest *infer_request = request->infer_request; @@ -164,7 +165,7 @@ static DNNReturnType tf_start_inference(void *args) if (!request) { av_log(&tf_model->ctx, AV_LOG_ERROR, "TFRequestItem is NULL\n"); -return DNN_ERROR; +return AVERROR(EINVAL); } TF_SessionRun(tf_model->session, NULL, @@ -178,7 +179,7 @@ static DNNReturnType tf_start_inference(void *args) if (ff_safe_queue_push_back(tf_model->request_queue, request) < 0) { destroy_request_item(&request); } -return DNN_ERROR; +return DNN_GENERIC_ERROR; } return DNN_SUCCESS; } @@ -202,14 +203,14 @@ static inline void destroy_request_item(TFRequestItem **arg) { av_freep(arg); } -static DNNReturnType extract_lltask_from_task(TaskItem *task, Queue *lltask_queue) +static int extract_lltask_from_task(TaskItem *task, Queue *lltask_queue) { TFModel *tf_model = task->model; TFContext *ctx = &tf_model->ctx; LastLevelTaskItem *lltask = av_malloc(sizeof(*lltask)); if (!lltask) { av_log(ctx, AV_LOG_ERROR, "Unable to allocate space for LastLevelTaskItem\n"); -return DNN_ERROR; +return AVERROR(ENOMEM); } task->inference_todo = 1; task->inference_done = 0; @@ -217,7 +218,7 @@ static DNNReturnType extract_lltask_from_task(TaskItem *task, Queue *lltask_queu if (ff_queue_push_back(lltask_queue, lltask) < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to push back lltask_queue.\n"); av_freep(&lltask); -return DNN_ERROR; +return AVERROR(ENOMEM); } return DNN_SUCCESS; } @@ -277,7 +278,7 @@ static TF_Tensor *allocate_input_tensor(const DNNData *input) input_dims[1] * input_dims[2] * input_dims[3] * size); } -static DNNReturnType get_input_tf(void *model, DNNData *input, const char *input_name) +static int get_input_tf(void *model, DNNData *input, const char *input_name) { TFModel *tf_model = model; TFContext *ctx = &tf_model->ctx; @@ -288,7 +289,7 @@ static DNNReturnType get_input_tf(void *model, DNNData *input, const char *input tf_output.oper = TF_GraphOperationByName(tf_model->graph, input_name); if (!tf_output.oper) { av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", input_name); -return DNN_ERROR; +return AVERROR(EINVAL); } tf_output.index = 0; @@ -300,7 +301,7 @@ static DNNReturnType get_input_tf(void *model, DNNData *input, const char *input if (TF_GetCode(status) != TF_OK){ TF_DeleteStatus(status); av_log(ctx, AV_LOG_ERROR, "Failed to get input tensor shape: number of dimension incorrect\n"); -return DNN_ERROR; +return DNN_GENERIC_ERROR; } TF_DeleteStatus(status); @@ -313,10 +314,10 @@ static DNNReturnType get_input_tf(void *model, DNNData *input, const char *input return DNN_SUCCESS; } -static DNNReturnType get_output_tf(void *model, const char *input_name, int input_width, int input_height, +static int get_output_tf(void *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *o
[FFmpeg-cvslog] lavfi/dnn_backend_openvino: Return Specific Error Codes
ffmpeg | branch: master | Shubhanshu Saxena | Wed Mar 2 23:53:52 2022 +0530| [91af38f2b39719ebb5682bea0fdf760bf154ec11] | committer: Guo Yejun lavfi/dnn_backend_openvino: Return Specific Error Codes Switch to returning specific error codes or DNN_GENERIC_ERROR when an error is encountered. For OpenVINO API errors, currently DNN_GENERIC_ERROR is returned. Signed-off-by: Shubhanshu Saxena > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91af38f2b39719ebb5682bea0fdf760bf154ec11 --- libavfilter/dnn/dnn_backend_openvino.c | 138 - libavfilter/dnn/dnn_backend_openvino.h | 4 +- libavfilter/dnn_interface.h| 10 +-- 3 files changed, 89 insertions(+), 63 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index f5b1454d21..2f140e996b 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -112,7 +112,7 @@ static int get_datatype_size(DNNDataType dt) } } -static DNNReturnType fill_model_input_ov(OVModel *ov_model, OVRequestItem *request) +static int fill_model_input_ov(OVModel *ov_model, OVRequestItem *request) { dimensions_t dims; precision_e precision; @@ -131,7 +131,7 @@ static DNNReturnType fill_model_input_ov(OVModel *ov_model, OVRequestItem *reque status = ie_infer_request_get_blob(request->infer_request, task->input_name, &input_blob); if (status != OK) { av_log(ctx, AV_LOG_ERROR, "Failed to get input blob with name %s\n", task->input_name); -return DNN_ERROR; +return DNN_GENERIC_ERROR; } status |= ie_blob_get_dims(input_blob, &dims); @@ -139,14 +139,14 @@ static DNNReturnType fill_model_input_ov(OVModel *ov_model, OVRequestItem *reque if (status != OK) { ie_blob_free(&input_blob); av_log(ctx, AV_LOG_ERROR, "Failed to get input blob dims/precision\n"); -return DNN_ERROR; +return DNN_GENERIC_ERROR; } status = ie_blob_get_buffer(input_blob, &blob_buffer); if (status != OK) { ie_blob_free(&input_blob); av_log(ctx, AV_LOG_ERROR, "Failed to get input blob buffer\n"); -return DNN_ERROR; +return DNN_GENERIC_ERROR; } input.height = dims.dims[2]; @@ -301,8 +301,9 @@ static void infer_completion_callback(void *args) } } -static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, const char *output_name) +static int init_model_ov(OVModel *ov_model, const char *input_name, const char *output_name) { +int ret = DNN_SUCCESS; OVContext *ctx = &ov_model->ctx; IEStatusCode status; ie_available_devices_t a_dev; @@ -317,14 +318,18 @@ static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, co if (ctx->options.batch_size > 1) { input_shapes_t input_shapes; status = ie_network_get_input_shapes(ov_model->network, &input_shapes); -if (status != OK) +if (status != OK) { +ret = DNN_GENERIC_ERROR; goto err; +} for (int i = 0; i < input_shapes.shape_num; i++) input_shapes.shapes[i].shape.dims[0] = ctx->options.batch_size; status = ie_network_reshape(ov_model->network, input_shapes); ie_network_input_shapes_free(&input_shapes); -if (status != OK) +if (status != OK) { +ret = DNN_GENERIC_ERROR; goto err; +} } // The order of dims in the openvino is fixed and it is always NCHW for 4-D data. @@ -332,11 +337,13 @@ static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, co status = ie_network_set_input_layout(ov_model->network, input_name, NHWC); if (status != OK) { av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for input %s\n", input_name); +ret = DNN_GENERIC_ERROR; goto err; } status = ie_network_set_output_layout(ov_model->network, output_name, NHWC); if (status != OK) { av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for output %s\n", output_name); +ret = DNN_GENERIC_ERROR; goto err; } @@ -350,6 +357,7 @@ static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, co status = ie_network_set_input_precision(ov_model->network, input_name, U8); if (status != OK) { av_log(ctx, AV_LOG_ERROR, "Failed to set input precision as U8 for %s\n", input_name); +ret = DNN_GENERIC_ERROR; goto err; } } @@ -360,6 +368,7 @@ static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, co status = ie_core_get_available_devices(ov_model->core, &a_dev); if (status != OK) { av_log(ctx, AV_LOG_ERROR, "Failed to get available devices\n"); +ret = DNN_GENERIC_ERROR; goto err; } for (int
[FFmpeg-cvslog] libavfilter: Remove DNNReturnType from DNN Module
ffmpeg | branch: master | Shubhanshu Saxena | Wed Mar 2 23:53:56 2022 +0530| [d0a999a0ab8313fd1b5e9cb09e35fb769fb3e51c] | committer: Guo Yejun libavfilter: Remove DNNReturnType from DNN Module This patch removes all occurences of DNNReturnType from the DNN module. This commit replaces DNN_SUCCESS by 0 (essentially the same), so the functions with DNNReturnType now return 0 in case of success, the negative values otherwise. Signed-off-by: Shubhanshu Saxena Signed-off-by: Shubhanshu Saxena > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0a999a0ab8313fd1b5e9cb09e35fb769fb3e51c --- libavfilter/dnn/dnn_backend_common.c | 10 ++-- libavfilter/dnn/dnn_backend_common.h | 8 ++-- libavfilter/dnn/dnn_backend_native.c | 16 +++ libavfilter/dnn/dnn_backend_native_layer_avgpool.c | 2 +- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 4 +- libavfilter/dnn/dnn_backend_native_layer_dense.c | 2 +- .../dnn/dnn_backend_native_layer_depth2space.c | 2 +- libavfilter/dnn/dnn_backend_openvino.c | 48 +-- libavfilter/dnn/dnn_backend_tf.c | 56 +++--- libavfilter/dnn/dnn_io_proc.c | 14 +++--- libavfilter/dnn_interface.h| 2 - libavfilter/vf_derain.c| 2 +- libavfilter/vf_dnn_classify.c | 4 +- libavfilter/vf_dnn_detect.c| 4 +- libavfilter/vf_dnn_processing.c| 8 ++-- libavfilter/vf_sr.c| 4 +- 16 files changed, 92 insertions(+), 94 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_common.c b/libavfilter/dnn/dnn_backend_common.c index 64ed441415..91a4a3c4bf 100644 --- a/libavfilter/dnn/dnn_backend_common.c +++ b/libavfilter/dnn/dnn_backend_common.c @@ -70,7 +70,7 @@ int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backe task->nb_output = exec_params->nb_output; task->output_names = exec_params->output_names; -return DNN_SUCCESS; +return 0; } /** @@ -82,7 +82,7 @@ static void *async_thread_routine(void *args) DNNAsyncExecModule *async_module = args; void *request = async_module->args; -if (async_module->start_inference(request) != DNN_SUCCESS) { +if (async_module->start_inference(request) != 0) { return DNN_ASYNC_FAIL; } async_module->callback(request); @@ -105,7 +105,7 @@ int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module) async_module->start_inference = NULL; async_module->callback = NULL; async_module->args = NULL; -return DNN_SUCCESS; +return 0; } int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module) @@ -131,12 +131,12 @@ int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module) } #else ret = async_module->start_inference(async_module->args); -if (ret != DNN_SUCCESS) { +if (ret != 0) { return ret; } async_module->callback(async_module->args); #endif -return DNN_SUCCESS; +return 0; } DNNAsyncStatusType ff_dnn_get_result_common(Queue *task_queue, AVFrame **in, AVFrame **out) diff --git a/libavfilter/dnn/dnn_backend_common.h b/libavfilter/dnn/dnn_backend_common.h index fa79caee1f..42c67c7040 100644 --- a/libavfilter/dnn/dnn_backend_common.h +++ b/libavfilter/dnn/dnn_backend_common.h @@ -92,7 +92,7 @@ int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func * @param async flag for async execution. Must be 0 or 1 * @param do_ioproc flag for IO processing. Must be 0 or 1 * - * @returns DNN_SUCCESS if successful or error code otherwise. + * @returns 0 if successful or error code otherwise. */ int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc); @@ -101,7 +101,7 @@ int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backe * * @param async_module pointer to DNNAsyncExecModule module * - * @returns DNN_SUCCESS if successful or error code otherwise. + * @returns 0 if successful or error code otherwise. */ int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module); @@ -117,7 +117,7 @@ int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module); * @param ctx pointer to the backend context * @param async_module pointer to DNNAsyncExecModule module * - * @returns DNN_SUCCESS on the start of async inference or error code otherwise. + * @returns 0 on the start of async inference or error code otherwise. */ int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module); @@ -146,7 +146,7 @@ DNNAsyncStatusType ff_dnn_get_result_common(Queue *task_queue, AVFrame **in, AVF * @param input_width width of input frame * @param ctx pointer to the backend context * - * @returns DNN_SUCCESS if successful or error code ot
[FFmpeg-cvslog] lavfi/dnn_backend_native: Return Specific Error Codes
ffmpeg | branch: master | Shubhanshu Saxena | Wed Mar 2 23:53:54 2022 +0530| [515ff6b4f83385d0557c45d6e9b71a4ef3e47374] | committer: Guo Yejun lavfi/dnn_backend_native: Return Specific Error Codes Switch to returning specific error codes or DNN_GENERIC_ERROR when an error is encountered. Signed-off-by: Shubhanshu Saxena > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=515ff6b4f83385d0557c45d6e9b71a4ef3e47374 --- libavfilter/dnn/dnn_backend_native.c | 82 +++- libavfilter/dnn/dnn_backend_native.h | 4 +- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index 13436c0484..f29e0e06bd 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -46,9 +46,9 @@ static const AVClass dnn_native_class = { .category = AV_CLASS_CATEGORY_FILTER, }; -static DNNReturnType execute_model_native(Queue *lltask_queue); +static int execute_model_native(Queue *lltask_queue); -static DNNReturnType extract_lltask_from_task(TaskItem *task, Queue *lltask_queue) +static int extract_lltask_from_task(TaskItem *task, Queue *lltask_queue) { NativeModel *native_model = task->model; NativeContext *ctx = &native_model->ctx; @@ -56,7 +56,7 @@ static DNNReturnType extract_lltask_from_task(TaskItem *task, Queue *lltask_queu if (!lltask) { av_log(ctx, AV_LOG_ERROR, "Unable to allocate space for LastLevelTaskItem\n"); -return DNN_ERROR; +return AVERROR(ENOMEM); } task->inference_todo = 1; task->inference_done = 0; @@ -65,12 +65,12 @@ static DNNReturnType extract_lltask_from_task(TaskItem *task, Queue *lltask_queu if (ff_queue_push_back(lltask_queue, lltask) < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to push back lltask_queue.\n"); av_freep(&lltask); -return DNN_ERROR; +return AVERROR(ENOMEM); } return DNN_SUCCESS; } -static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name) +static int get_input_native(void *model, DNNData *input, const char *input_name) { NativeModel *native_model = model; NativeContext *ctx = &native_model->ctx; @@ -80,7 +80,7 @@ static DNNReturnType get_input_native(void *model, DNNData *input, const char *i if (strcmp(oprd->name, input_name) == 0) { if (oprd->type != DOT_INPUT) { av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is not input node\n", input_name); -return DNN_ERROR; +return AVERROR(EINVAL); } input->dt = oprd->data_type; av_assert0(oprd->dims[0] == 1); @@ -93,13 +93,13 @@ static DNNReturnType get_input_native(void *model, DNNData *input, const char *i // do not find the input operand av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", input_name); -return DNN_ERROR; +return AVERROR(EINVAL); } -static DNNReturnType get_output_native(void *model, const char *input_name, int input_width, int input_height, +static int get_output_native(void *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height) { -DNNReturnType ret = 0; +int ret = 0; NativeModel *native_model = model; NativeContext *ctx = &native_model->ctx; TaskItem task; @@ -111,14 +111,14 @@ static DNNReturnType get_output_native(void *model, const char *input_name, int .out_frame = NULL, }; -if (ff_dnn_fill_gettingoutput_task(&task, &exec_params, native_model, input_height, input_width, ctx) != DNN_SUCCESS) { -ret = DNN_ERROR; +ret = ff_dnn_fill_gettingoutput_task(&task, &exec_params, native_model, input_height, input_width, ctx); +if (ret != DNN_SUCCESS) { goto err; } -if (extract_lltask_from_task(&task, native_model->lltask_queue) != DNN_SUCCESS) { +ret = extract_lltask_from_task(&task, native_model->lltask_queue); +if (ret != DNN_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "unable to extract last level task from task.\n"); -ret = DNN_ERROR; goto err; } @@ -297,7 +297,7 @@ fail: return NULL; } -static DNNReturnType execute_model_native(Queue *lltask_queue) +static int execute_model_native(Queue *lltask_queue) { NativeModel *native_model = NULL; NativeContext *ctx = NULL; @@ -306,12 +306,12 @@ static DNNReturnType execute_model_native(Queue *lltask_queue) DnnOperand *oprd = NULL; LastLevelTaskItem *lltask = NULL; TaskItem *task = NULL; -DNNReturnType ret = 0; +int ret = 0; lltask = ff_queue_pop_front(lltask_queue); if (!lltask) { av_log(NULL, AV_LOG_ERROR, "Failed to get LastLevelTaskItem\n"); -ret = DNN_ERROR; +ret = AVERROR(EINVAL);