From: Anton Khirnov <anton@khirnov.net> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: Added siti filter Date: Mon, 31 Jan 2022 12:53:39 +0100 Message-ID: <164363001951.23111.4989616914372511566@lain.red.khirnov.net> (raw) In-Reply-To: <dba4a780-2cff-44e4-6ff3-46aa0890ef6d@mail.de> Quoting Thilo Borgmann (2022-01-18 14:58:07) > >> Violations of code style. > > Enhanced. Not enough. There are still many remaining, e.g. * opening brace of a function definition should be on its own line * the context should generally be the first argument * unsigned char* should be uint8_t* * mixed declarations and code (the compiler should warn about that) * pointless casts all over the place > +typedef struct SiTiContext { > + const AVClass *class; > + int pixel_depth; > + int width, height; > + int nb_frames; uint64_t > +static int config_input(AVFilterLink *inlink) { > + // Video input data avilable > + AVFilterContext *ctx = inlink->dst; > + SiTiContext *s = ctx->priv; > + int max_pixsteps[4]; > + > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > + av_image_fill_max_pixsteps(max_pixsteps, NULL, desc); > + > + s->pixel_depth = max_pixsteps[0]; > + s->width = inlink->w; > + s->height = inlink->h; > + size_t pixel_sz = s->pixel_depth==1 ? (size_t) sizeof(uint8_t) : (size_t) sizeof(uint16_t); > + size_t data_sz = (size_t) s->width * pixel_sz * s->height; > + s->prev_frame = av_malloc(data_sz); unchecked malloc > + > + return 0; > +} > + > +// Get frame data handling 8 and 10 bit formats > +static uint16_t get_frame_data(const unsigned char* src, int pixel_depth, int index) { > + const uint16_t *src16 = (const uint16_t *)src; > + if (pixel_depth == 2) > + return src16[index]; > + return (uint16_t) src[index]; > +} going through this branch nine times for every single pixel is just atrocious templatize convolve_sobel()/calculate_motion() for 8/16 bits > +static int filter_frame(AVFilterLink *inlink, AVFrame *frame) { > + AVFilterContext *ctx = inlink->dst; > + SiTiContext *s = ctx->priv; > + > + // Gradient matrix will not include the input frame's edges > + size_t gradient_data_sz = (size_t) (s->width - 2) * sizeof(double) * (s->height - 2); > + double *gradient_matrix = av_malloc(gradient_data_sz); > + size_t motion_data_sz = (size_t) s->width * sizeof(double) * s->height; > + double *motion_matrix = av_malloc(motion_data_sz); These have a fixed size that is known at config_input() time, no point in allocating them anew for each frame. Also, I don't see where motion_matrix is freed. -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-01-31 11:53 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20210115045832.76405-1-borbarak@fb.com> [not found] ` <MN2PR15MB2605F2669A411F794B6C2B40B5A70@MN2PR15MB2605.namprd15.prod.outlook.com> [not found] ` <MR3WgJJ--3-2@lynne.ee> [not found] ` <MN2PR15MB2605997AC36969E5639782C4B5A30@MN2PR15MB2605.namprd15.prod.outlook.com> [not found] ` <MRNyTw0--3-2@lynne.ee> 2022-01-14 16:21 ` Thilo Borgmann 2022-01-15 8:25 ` Paul B Mahol 2022-01-15 8:27 ` Paul B Mahol 2022-01-18 13:58 ` Thilo Borgmann 2022-01-24 11:10 ` Thilo Borgmann 2022-01-31 10:12 ` Thilo Borgmann 2022-01-31 11:53 ` Anton Khirnov [this message] 2022-01-31 11:55 ` James Almer 2022-02-12 10:55 ` Thilo Borgmann 2022-02-15 8:54 ` Anton Khirnov 2022-02-15 9:10 ` Paul B Mahol 2022-02-15 9:19 ` Anton Khirnov 2022-02-22 11:26 ` Thilo Borgmann 2022-02-18 16:08 ` Paul B Mahol 2022-02-22 11:30 ` Thilo Borgmann 2022-03-06 20:39 ` Thilo Borgmann 2022-03-06 21:25 ` Paul B Mahol 2022-03-07 17:09 ` Thilo Borgmann 2022-03-07 19:06 ` Paul B Mahol 2022-03-08 12:25 ` Thilo Borgmann 2022-03-09 17:31 ` Paul B Mahol 2022-03-12 9:06 ` Thilo Borgmann 2022-03-18 13:56 ` Thilo Borgmann 2022-03-18 14:04 ` Paul B Mahol 2022-03-22 8:36 ` Thilo Borgmann 2022-03-28 11:01 ` Thilo Borgmann 2022-04-01 8:58 ` Thilo Borgmann 2022-04-01 18:54 ` Thilo Borgmann
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=164363001951.23111.4989616914372511566@lain.red.khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git