These names are mostly the same, so not using duplicates saves allocations, checks for the allocations as well as frees.
Unified · Split
| @@ -527,30 +527,22 @@ static av_cold int init(AVFilterContext *ctx) · 526 unmodified lines | ||
| 527 | 527 | /* insert output pads */ |
| 528 | 528 | if (ebur128->do_video) { |
| 529 | 529 | pad = (AVFilterPad){ |
| 530 | − .name = av_strdup("out0"), | |
| 530 | + .name = "out0", | |
| 531 | 531 | .type = AVMEDIA_TYPE_VIDEO, |
| 532 | 532 | .config_props = config_video_output, |
| 533 | 533 | }; |
| 534 | − if (!pad.name) | |
| 535 | − return AVERROR(ENOMEM); | |
| 536 | 534 | ret = ff_insert_outpad(ctx, 0, &pad); |
| 537 | − if (ret < 0) { | |
| 538 | − av_freep(&pad.name); | |
| 535 | + if (ret < 0) | |
| 539 | 536 | return ret; |
| 540 | − } | |
| 541 | 537 | } |
| 542 | 538 | pad = (AVFilterPad){ |
| 543 | − .name = av_asprintf("out%d", ebur128->do_video), | |
| 539 | + .name = ebur128->do_video ? "out1" : "out0", | |
| 544 | 540 | .type = AVMEDIA_TYPE_AUDIO, |
| 545 | 541 | .config_props = config_audio_output, |
| 546 | 542 | }; |
| 547 | − if (!pad.name) | |
| 548 | − return AVERROR(ENOMEM); | |
| 549 | 543 | ret = ff_insert_outpad(ctx, ebur128->do_video, &pad); |
| 550 | − if (ret < 0) { | |
| 551 | − av_freep(&pad.name); | |
| 544 | + if (ret < 0) | |
| 552 | 545 | return ret; |
| 553 | − } | |
| 554 | 546 | |
| 555 | 547 | /* summary */ |
| 556 | 548 | av_log(ctx, AV_LOG_VERBOSE, "EBU +%d scale\n", ebur128->meter); |
| @@ -990,8 +982,6 @@ static av_cold void uninit(AVFilterContext *ctx) · 433 unmodified lines | ||
| 990 | 982 | av_freep(&ebur128->i400.cache[i]); |
| 991 | 983 | av_freep(&ebur128->i3000.cache[i]); |
| 992 | 984 | } |
| 993 | − for (i = 0; i < ctx->nb_outputs; i++) | |
| 994 | − av_freep(&ctx->output_pads[i].name); | |
| 995 | 985 | av_frame_free(&ebur128->outpicref); |
| 996 | 986 | #if CONFIG_SWRESAMPLE |
| 997 | 987 | av_freep(&ebur128->swr_buf); |