Any alleged performance benefits gained from the split are purely mythological and do not justify added code complexity.
Showing the changes to libavfilter/split.c (1 of 55 files). Show all
Unified · Split
| @@ -67,46 +67,23 @@ static void split_uninit(AVFilterContext *ctx) · 66 unmodified lines | ||
| 67 | 67 | av_freep(&ctx->output_pads[i].name); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | −static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | |
| 70 | +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame) | |
| 71 | 71 | { |
| 72 | 72 | AVFilterContext *ctx = inlink->dst; |
| 73 | 73 | int i, ret = 0; |
| 74 | 74 | |
| 75 | 75 | for (i = 0; i < ctx->nb_outputs; i++) { |
| 76 | − AVFilterBufferRef *buf_out = avfilter_ref_buffer(picref, ~AV_PERM_WRITE); | |
| 77 | − if (!buf_out) | |
| 78 | − return AVERROR(ENOMEM); | |
| 79 | − | |
| 80 | − ret = ff_start_frame(ctx->outputs[i], buf_out); | |
| 81 | − if (ret < 0) | |
| 82 | − break; | |
| 83 | − } | |
| 84 | − return ret; | |
| 85 | −} | |
| 86 | − | |
| 87 | −static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | |
| 88 | −{ | |
| 89 | − AVFilterContext *ctx = inlink->dst; | |
| 90 | − int i, ret = 0; | |
| 91 | − | |
| 92 | − for (i = 0; i < ctx->nb_outputs; i++) { | |
| 93 | − ret = ff_draw_slice(ctx->outputs[i], y, h, slice_dir); | |
| 94 | − if (ret < 0) | |
| 76 | + AVFilterBufferRef *buf_out = avfilter_ref_buffer(frame, ~AV_PERM_WRITE); | |
| 77 | + if (!buf_out) { | |
| 78 | + ret = AVERROR(ENOMEM); | |
| 95 | 79 | break; |
| 96 | − } | |
| 97 | − return ret; | |
| 98 | −} | |
| 99 | − | |
| 100 | −static int end_frame(AVFilterLink *inlink) | |
| 101 | −{ | |
| 102 | − AVFilterContext *ctx = inlink->dst; | |
| 103 | − int i, ret = 0; | |
| 80 | + } | |
| 104 | 81 | |
| 105 | − for (i = 0; i < ctx->nb_outputs; i++) { | |
| 106 | − ret = ff_end_frame(ctx->outputs[i]); | |
| 82 | + ret = ff_filter_frame(ctx->outputs[i], buf_out); | |
| 107 | 83 | if (ret < 0) |
| 108 | 84 | break; |
| 109 | 85 | } |
| 86 | + avfilter_unref_bufferp(&frame); | |
| 110 | 87 | return ret; |
| 111 | 88 | } |
| 112 | 89 | |
| @@ -115,9 +92,7 @@ static const AVFilterPad avfilter_vf_split_inputs[] = { · 2 unmodified lines | ||
| 115 | 92 | .name = "default", |
| 116 | 93 | .type = AVMEDIA_TYPE_VIDEO, |
| 117 | 94 | .get_video_buffer = ff_null_get_video_buffer, |
| 118 | − .start_frame = start_frame, | |
| 119 | − .draw_slice = draw_slice, | |
| 120 | − .end_frame = end_frame, | |
| 95 | + .filter_frame = filter_frame, | |
| 121 | 96 | }, |
| 122 | 97 | { NULL } |
| 123 | 98 | }; |
| @@ -133,33 +108,12 @@ AVFilter avfilter_vf_split = { · 9 unmodified lines | ||
| 133 | 108 | .outputs = NULL, |
| 134 | 109 | }; |
| 135 | 110 | |
| 136 | −static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) | |
| 137 | −{ | |
| 138 | − AVFilterContext *ctx = inlink->dst; | |
| 139 | − int i, ret = 0; | |
| 140 | − | |
| 141 | − for (i = 0; i < ctx->nb_outputs; i++) { | |
| 142 | − AVFilterBufferRef *buf_out = avfilter_ref_buffer(samplesref, | |
| 143 | − ~AV_PERM_WRITE); | |
| 144 | − if (!buf_out) { | |
| 145 | − ret = AVERROR(ENOMEM); | |
| 146 | − break; | |
| 147 | − } | |
| 148 | − | |
| 149 | − ret = ff_filter_samples(inlink->dst->outputs[i], buf_out); | |
| 150 | − if (ret < 0) | |
| 151 | − break; | |
| 152 | − } | |
| 153 | − avfilter_unref_buffer(samplesref); | |
| 154 | − return ret; | |
| 155 | −} | |
| 156 | − | |
| 157 | 111 | static const AVFilterPad avfilter_af_asplit_inputs[] = { |
| 158 | 112 | { |
| 159 | 113 | .name = "default", |
| 160 | 114 | .type = AVMEDIA_TYPE_AUDIO, |
| 161 | 115 | .get_audio_buffer = ff_null_get_audio_buffer, |
| 162 | − .filter_samples = filter_samples | |
| 116 | + .filter_frame = filter_frame, | |
| 163 | 117 | }, |
| 164 | 118 | { NULL } |
| 165 | 119 | }; |