Originally committed as revision 25227 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -42,10 +42,6 @@ const char *avfilter_license(void) · 41 unmodified lines | ||
| 42 | 42 | return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | −/** helper macros to get the in/out pad on the dst/src filter */ | |
| 46 | −#define link_dpad(link) link->dst-> input_pads[link->dstpad] | |
| 47 | −#define link_spad(link) link->src->output_pads[link->srcpad] | |
| 48 | − | |
| 49 | 45 | AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask) |
| 50 | 46 | { |
| 51 | 47 | AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef)); |
| @@ -116,8 +112,8 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, · 64 unmodified lines | ||
| 116 | 112 | |
| 117 | 113 | link->src = src; |
| 118 | 114 | link->dst = dst; |
| 119 | − link->srcpad = srcpad; | |
| 120 | − link->dstpad = dstpad; | |
| 115 | + link->srcpad = &src->output_pads[srcpad]; | |
| 116 | + link->dstpad = &dst->input_pads[dstpad]; | |
| 121 | 117 | link->type = src->output_pads[srcpad].type; |
| 122 | 118 | assert(PIX_FMT_NONE == -1 && SAMPLE_FMT_NONE == -1); |
| 123 | 119 | link->format = -1; |
| @@ -128,20 +124,22 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, · 4 unmodified lines | ||
| 128 | 124 | int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, |
| 129 | 125 | unsigned in, unsigned out) |
| 130 | 126 | { |
| 127 | + unsigned dstpad_idx = link->dstpad - link->dst->input_pads; | |
| 128 | + | |
| 131 | 129 | av_log(link->dst, AV_LOG_INFO, "auto-inserting filter '%s' " |
| 132 | 130 | "between the filter '%s' and the filter '%s'\n", |
| 133 | 131 | filt->name, link->src->name, link->dst->name); |
| 134 | 132 | |
| 135 | − link->dst->inputs[link->dstpad] = NULL; | |
| 136 | − if (avfilter_link(filt, out, link->dst, link->dstpad)) { | |
| 133 | + link->dst->inputs[dstpad_idx] = NULL; | |
| 134 | + if (avfilter_link(filt, out, link->dst, dstpad_idx)) { | |
| 137 | 135 | /* failed to link output filter to new filter */ |
| 138 | − link->dst->inputs[link->dstpad] = link; | |
| 136 | + link->dst->inputs[dstpad_idx] = link; | |
| 139 | 137 | return -1; |
| 140 | 138 | } |
| 141 | 139 | |
| 142 | 140 | /* re-hookup the link to the new destination filter we inserted */ |
| 143 | 141 | link->dst = filt; |
| 144 | − link->dstpad = in; | |
| 142 | + link->dstpad = &filt->input_pads[in]; | |
| 145 | 143 | filt->inputs[in] = link; |
| 146 | 144 | |
| 147 | 145 | /* if any information on supported media formats already exists on the |
| @@ -175,12 +173,12 @@ int avfilter_config_links(AVFilterContext *filter) · 27 unmodified lines | ||
| 175 | 173 | if (avfilter_config_links(link->src)) |
| 176 | 174 | return -1; |
| 177 | 175 | |
| 178 | − if (!(config_link = link_spad(link).config_props)) | |
| 176 | + if (!(config_link = link->srcpad->config_props)) | |
| 179 | 177 | config_link = avfilter_default_config_output_link; |
| 180 | 178 | if (config_link(link)) |
| 181 | 179 | return -1; |
| 182 | 180 | |
| 183 | − if ((config_link = link_dpad(link).config_props)) | |
| 181 | + if ((config_link = link->dstpad->config_props)) | |
| 184 | 182 | if (config_link(link)) |
| 185 | 183 | return -1; |
| 186 | 184 | |
| @@ -249,8 +247,8 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int · 62 unmodified lines | ||
| 249 | 247 | FF_DPRINTF_START(NULL, get_video_buffer); ff_dprintf_link(NULL, link, 0); |
| 250 | 248 | dprintf(NULL, " perms:%s w:%d h:%d\n", ff_get_ref_perms_string(buf, sizeof(buf), perms), w, h); |
| 251 | 249 | |
| 252 | − if (link_dpad(link).get_video_buffer) | |
| 253 | − ret = link_dpad(link).get_video_buffer(link, perms, w, h); | |
| 250 | + if (link->dstpad->get_video_buffer) | |
| 251 | + ret = link->dstpad->get_video_buffer(link, perms, w, h); | |
| 254 | 252 | |
| 255 | 253 | if (!ret) |
| 256 | 254 | ret = avfilter_default_get_video_buffer(link, perms, w, h); |
| @@ -269,8 +267,8 @@ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, · 12 unmodified lines | ||
| 269 | 267 | { |
| 270 | 268 | AVFilterBufferRef *ret = NULL; |
| 271 | 269 | |
| 272 | − if (link_dpad(link).get_audio_buffer) | |
| 273 | − ret = link_dpad(link).get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); | |
| 270 | + if (link->dstpad->get_audio_buffer) | |
| 271 | + ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); | |
| 274 | 272 | |
| 275 | 273 | if (!ret) |
| 276 | 274 | ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); |
| @@ -285,8 +283,8 @@ int avfilter_request_frame(AVFilterLink *link) · 8 unmodified lines | ||
| 285 | 283 | { |
| 286 | 284 | FF_DPRINTF_START(NULL, request_frame); ff_dprintf_link(NULL, link, 1); |
| 287 | 285 | |
| 288 | − if (link_spad(link).request_frame) | |
| 289 | − return link_spad(link).request_frame(link); | |
| 286 | + if (link->srcpad->request_frame) | |
| 287 | + return link->srcpad->request_frame(link); | |
| 290 | 288 | else if (link->src->inputs[0]) |
| 291 | 289 | return avfilter_request_frame(link->src->inputs[0]); |
| 292 | 290 | else return -1; |
| @@ -296,8 +294,8 @@ int avfilter_poll_frame(AVFilterLink *link) · 3 unmodified lines | ||
| 296 | 294 | { |
| 297 | 295 | int i, min = INT_MAX; |
| 298 | 296 | |
| 299 | − if (link_spad(link).poll_frame) | |
| 300 | − return link_spad(link).poll_frame(link); | |
| 297 | + if (link->srcpad->poll_frame) | |
| 298 | + return link->srcpad->poll_frame(link); | |
| 301 | 299 | |
| 302 | 300 | for (i = 0; i < link->src->input_count; i++) { |
| 303 | 301 | int val; |
| @@ -315,7 +313,7 @@ int avfilter_poll_frame(AVFilterLink *link) · 11 unmodified lines | ||
| 315 | 313 | void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 316 | 314 | { |
| 317 | 315 | void (*start_frame)(AVFilterLink *, AVFilterBufferRef *); |
| 318 | − AVFilterPad *dst = &link_dpad(link); | |
| 316 | + AVFilterPad *dst = link->dstpad; | |
| 319 | 317 | |
| 320 | 318 | FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_ref(NULL, picref, 1); |
| 321 | 319 | |
| @@ -328,7 +326,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 6 unmodified lines | ||
| 328 | 326 | av_log(link->dst, AV_LOG_DEBUG, |
| 329 | 327 | "frame copy needed (have perms %x, need %x, reject %x)\n", |
| 330 | 328 | picref->perms, |
| 331 | − link_dpad(link).min_perms, link_dpad(link).rej_perms); | |
| 329 | + link->dstpad->min_perms, link->dstpad->rej_perms); | |
| 332 | 330 | |
| 333 | 331 | link->cur_buf = avfilter_get_video_buffer(link, dst->min_perms, link->w, link->h); |
| 334 | 332 | link->src_buf = picref; |
| @@ -344,7 +342,7 @@ void avfilter_end_frame(AVFilterLink *link) · 9 unmodified lines | ||
| 344 | 342 | { |
| 345 | 343 | void (*end_frame)(AVFilterLink *); |
| 346 | 344 | |
| 347 | − if (!(end_frame = link_dpad(link).end_frame)) | |
| 345 | + if (!(end_frame = link->dstpad->end_frame)) | |
| 348 | 346 | end_frame = avfilter_default_end_frame; |
| 349 | 347 | |
| 350 | 348 | end_frame(link); |
| @@ -393,7 +391,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) · 42 unmodified lines | ||
| 393 | 391 | } |
| 394 | 392 | } |
| 395 | 393 | |
| 396 | − if (!(draw_slice = link_dpad(link).draw_slice)) | |
| 394 | + if (!(draw_slice = link->dstpad->draw_slice)) | |
| 397 | 395 | draw_slice = avfilter_default_draw_slice; |
| 398 | 396 | draw_slice(link, y, h, slice_dir); |
| 399 | 397 | } |
| @@ -401,7 +399,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) · 1 unmodified line | ||
| 401 | 399 | void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) |
| 402 | 400 | { |
| 403 | 401 | void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); |
| 404 | − AVFilterPad *dst = &link_dpad(link); | |
| 402 | + AVFilterPad *dst = link->dstpad; | |
| 405 | 403 | |
| 406 | 404 | if (!(filter_samples = dst->filter_samples)) |
| 407 | 405 | filter_samples = avfilter_default_filter_samples; |
| @@ -412,7 +410,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) · 4 unmodified lines | ||
| 412 | 410 | |
| 413 | 411 | av_log(link->dst, AV_LOG_DEBUG, |
| 414 | 412 | "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", |
| 415 | − samplesref->perms, link_dpad(link).min_perms, link_dpad(link).rej_perms); | |
| 413 | + samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms); | |
| 416 | 414 | |
| 417 | 415 | link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, |
| 418 | 416 | samplesref->format, |
| @@ -534,7 +532,7 @@ void avfilter_destroy(AVFilterContext *filter) · 115 unmodified lines | ||
| 534 | 532 | for (i = 0; i < filter->input_count; i++) { |
| 535 | 533 | if ((link = filter->inputs[i])) { |
| 536 | 534 | if (link->src) |
| 537 | − link->src->outputs[link->srcpad] = NULL; | |
| 535 | + link->src->outputs[link->srcpad - link->src->output_pads] = NULL; | |
| 538 | 536 | avfilter_formats_unref(&link->in_formats); |
| 539 | 537 | avfilter_formats_unref(&link->out_formats); |
| 540 | 538 | } |
| @@ -543,7 +541,7 @@ void avfilter_destroy(AVFilterContext *filter) · 2 unmodified lines | ||
| 543 | 541 | for (i = 0; i < filter->output_count; i++) { |
| 544 | 542 | if ((link = filter->outputs[i])) { |
| 545 | 543 | if (link->dst) |
| 546 | − link->dst->inputs[link->dstpad] = NULL; | |
| 544 | + link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL; | |
| 547 | 545 | avfilter_formats_unref(&link->in_formats); |
| 548 | 546 | avfilter_formats_unref(&link->out_formats); |
| 549 | 547 | } |
| @@ -25,8 +25,8 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "libavutil/avutil.h" |
| 26 | 26 | |
| 27 | 27 | #define LIBAVFILTER_VERSION_MAJOR 1 |
| 28 | −#define LIBAVFILTER_VERSION_MINOR 46 | |
| 29 | −#define LIBAVFILTER_VERSION_MICRO 1 | |
| 28 | +#define LIBAVFILTER_VERSION_MINOR 47 | |
| 29 | +#define LIBAVFILTER_VERSION_MICRO 0 | |
| 30 | 30 | |
| 31 | 31 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| 32 | 32 | LIBAVFILTER_VERSION_MINOR, \ |
| @@ -556,10 +556,10 @@ struct AVFilterContext { · 523 unmodified lines | ||
| 556 | 556 | */ |
| 557 | 557 | struct AVFilterLink { |
| 558 | 558 | AVFilterContext *src; ///< source filter |
| 559 | − unsigned int srcpad; ///< index of the output pad on the source filter | |
| 559 | + AVFilterPad *srcpad; ///< output pad on the source filter | |
| 560 | 560 | |
| 561 | 561 | AVFilterContext *dst; ///< dest filter |
| 562 | − unsigned int dstpad; ///< index of the input pad on the dest filter | |
| 562 | + AVFilterPad *dstpad; ///< input pad on the dest filter | |
| 563 | 563 | |
| 564 | 564 | /** stage of the initialization of the link properties (dimensions, etc) */ |
| 565 | 565 | enum { |