Originally committed as revision 25227 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -42,10 +42,6 @@ const char *avfilter_license(void) |
| 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, |
| 116 | 116 |
|
| 117 | 117 |
link->src = src; |
| 118 | 118 |
link->dst = dst; |
| 119 |
- link->srcpad = srcpad; |
|
| 120 |
- link->dstpad = dstpad; |
|
| 119 |
+ link->srcpad = &src->output_pads[srcpad]; |
|
| 120 |
+ link->dstpad = &dst->input_pads[dstpad]; |
|
| 121 | 121 |
link->type = src->output_pads[srcpad].type; |
| 122 | 122 |
assert(PIX_FMT_NONE == -1 && SAMPLE_FMT_NONE == -1); |
| 123 | 123 |
link->format = -1; |
| ... | ... |
@@ -128,20 +124,22 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, |
| 128 | 128 |
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, |
| 129 | 129 |
unsigned in, unsigned out) |
| 130 | 130 |
{
|
| 131 |
+ unsigned dstpad_idx = link->dstpad - link->dst->input_pads; |
|
| 132 |
+ |
|
| 131 | 133 |
av_log(link->dst, AV_LOG_INFO, "auto-inserting filter '%s' " |
| 132 | 134 |
"between the filter '%s' and the filter '%s'\n", |
| 133 | 135 |
filt->name, link->src->name, link->dst->name); |
| 134 | 136 |
|
| 135 |
- link->dst->inputs[link->dstpad] = NULL; |
|
| 136 |
- if (avfilter_link(filt, out, link->dst, link->dstpad)) {
|
|
| 137 |
+ link->dst->inputs[dstpad_idx] = NULL; |
|
| 138 |
+ if (avfilter_link(filt, out, link->dst, dstpad_idx)) {
|
|
| 137 | 139 |
/* failed to link output filter to new filter */ |
| 138 |
- link->dst->inputs[link->dstpad] = link; |
|
| 140 |
+ link->dst->inputs[dstpad_idx] = link; |
|
| 139 | 141 |
return -1; |
| 140 | 142 |
} |
| 141 | 143 |
|
| 142 | 144 |
/* re-hookup the link to the new destination filter we inserted */ |
| 143 | 145 |
link->dst = filt; |
| 144 |
- link->dstpad = in; |
|
| 146 |
+ link->dstpad = &filt->input_pads[in]; |
|
| 145 | 147 |
filt->inputs[in] = link; |
| 146 | 148 |
|
| 147 | 149 |
/* if any information on supported media formats already exists on the |
| ... | ... |
@@ -175,12 +173,12 @@ int avfilter_config_links(AVFilterContext *filter) |
| 175 | 175 |
if (avfilter_config_links(link->src)) |
| 176 | 176 |
return -1; |
| 177 | 177 |
|
| 178 |
- if (!(config_link = link_spad(link).config_props)) |
|
| 178 |
+ if (!(config_link = link->srcpad->config_props)) |
|
| 179 | 179 |
config_link = avfilter_default_config_output_link; |
| 180 | 180 |
if (config_link(link)) |
| 181 | 181 |
return -1; |
| 182 | 182 |
|
| 183 |
- if ((config_link = link_dpad(link).config_props)) |
|
| 183 |
+ if ((config_link = link->dstpad->config_props)) |
|
| 184 | 184 |
if (config_link(link)) |
| 185 | 185 |
return -1; |
| 186 | 186 |
|
| ... | ... |
@@ -249,8 +247,8 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int |
| 249 | 249 |
FF_DPRINTF_START(NULL, get_video_buffer); ff_dprintf_link(NULL, link, 0); |
| 250 | 250 |
dprintf(NULL, " perms:%s w:%d h:%d\n", ff_get_ref_perms_string(buf, sizeof(buf), perms), w, h); |
| 251 | 251 |
|
| 252 |
- if (link_dpad(link).get_video_buffer) |
|
| 253 |
- ret = link_dpad(link).get_video_buffer(link, perms, w, h); |
|
| 252 |
+ if (link->dstpad->get_video_buffer) |
|
| 253 |
+ ret = link->dstpad->get_video_buffer(link, perms, w, h); |
|
| 254 | 254 |
|
| 255 | 255 |
if (!ret) |
| 256 | 256 |
ret = avfilter_default_get_video_buffer(link, perms, w, h); |
| ... | ... |
@@ -269,8 +267,8 @@ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, |
| 269 | 269 |
{
|
| 270 | 270 |
AVFilterBufferRef *ret = NULL; |
| 271 | 271 |
|
| 272 |
- if (link_dpad(link).get_audio_buffer) |
|
| 273 |
- ret = link_dpad(link).get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); |
|
| 272 |
+ if (link->dstpad->get_audio_buffer) |
|
| 273 |
+ ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); |
|
| 274 | 274 |
|
| 275 | 275 |
if (!ret) |
| 276 | 276 |
ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); |
| ... | ... |
@@ -285,8 +283,8 @@ int avfilter_request_frame(AVFilterLink *link) |
| 285 | 285 |
{
|
| 286 | 286 |
FF_DPRINTF_START(NULL, request_frame); ff_dprintf_link(NULL, link, 1); |
| 287 | 287 |
|
| 288 |
- if (link_spad(link).request_frame) |
|
| 289 |
- return link_spad(link).request_frame(link); |
|
| 288 |
+ if (link->srcpad->request_frame) |
|
| 289 |
+ return link->srcpad->request_frame(link); |
|
| 290 | 290 |
else if (link->src->inputs[0]) |
| 291 | 291 |
return avfilter_request_frame(link->src->inputs[0]); |
| 292 | 292 |
else return -1; |
| ... | ... |
@@ -296,8 +294,8 @@ int avfilter_poll_frame(AVFilterLink *link) |
| 296 | 296 |
{
|
| 297 | 297 |
int i, min = INT_MAX; |
| 298 | 298 |
|
| 299 |
- if (link_spad(link).poll_frame) |
|
| 300 |
- return link_spad(link).poll_frame(link); |
|
| 299 |
+ if (link->srcpad->poll_frame) |
|
| 300 |
+ return link->srcpad->poll_frame(link); |
|
| 301 | 301 |
|
| 302 | 302 |
for (i = 0; i < link->src->input_count; i++) {
|
| 303 | 303 |
int val; |
| ... | ... |
@@ -315,7 +313,7 @@ int avfilter_poll_frame(AVFilterLink *link) |
| 315 | 315 |
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 316 | 316 |
{
|
| 317 | 317 |
void (*start_frame)(AVFilterLink *, AVFilterBufferRef *); |
| 318 |
- AVFilterPad *dst = &link_dpad(link); |
|
| 318 |
+ AVFilterPad *dst = link->dstpad; |
|
| 319 | 319 |
|
| 320 | 320 |
FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_ref(NULL, picref, 1); |
| 321 | 321 |
|
| ... | ... |
@@ -328,7 +326,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 328 | 328 |
av_log(link->dst, AV_LOG_DEBUG, |
| 329 | 329 |
"frame copy needed (have perms %x, need %x, reject %x)\n", |
| 330 | 330 |
picref->perms, |
| 331 |
- link_dpad(link).min_perms, link_dpad(link).rej_perms); |
|
| 331 |
+ link->dstpad->min_perms, link->dstpad->rej_perms); |
|
| 332 | 332 |
|
| 333 | 333 |
link->cur_buf = avfilter_get_video_buffer(link, dst->min_perms, link->w, link->h); |
| 334 | 334 |
link->src_buf = picref; |
| ... | ... |
@@ -344,7 +342,7 @@ void avfilter_end_frame(AVFilterLink *link) |
| 344 | 344 |
{
|
| 345 | 345 |
void (*end_frame)(AVFilterLink *); |
| 346 | 346 |
|
| 347 |
- if (!(end_frame = link_dpad(link).end_frame)) |
|
| 347 |
+ if (!(end_frame = link->dstpad->end_frame)) |
|
| 348 | 348 |
end_frame = avfilter_default_end_frame; |
| 349 | 349 |
|
| 350 | 350 |
end_frame(link); |
| ... | ... |
@@ -393,7 +391,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 393 | 393 |
} |
| 394 | 394 |
} |
| 395 | 395 |
|
| 396 |
- if (!(draw_slice = link_dpad(link).draw_slice)) |
|
| 396 |
+ if (!(draw_slice = link->dstpad->draw_slice)) |
|
| 397 | 397 |
draw_slice = avfilter_default_draw_slice; |
| 398 | 398 |
draw_slice(link, y, h, slice_dir); |
| 399 | 399 |
} |
| ... | ... |
@@ -401,7 +399,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 401 | 401 |
void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) |
| 402 | 402 |
{
|
| 403 | 403 |
void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); |
| 404 |
- AVFilterPad *dst = &link_dpad(link); |
|
| 404 |
+ AVFilterPad *dst = link->dstpad; |
|
| 405 | 405 |
|
| 406 | 406 |
if (!(filter_samples = dst->filter_samples)) |
| 407 | 407 |
filter_samples = avfilter_default_filter_samples; |
| ... | ... |
@@ -412,7 +410,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) |
| 412 | 412 |
|
| 413 | 413 |
av_log(link->dst, AV_LOG_DEBUG, |
| 414 | 414 |
"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); |
|
| 415 |
+ samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms); |
|
| 416 | 416 |
|
| 417 | 417 |
link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, |
| 418 | 418 |
samplesref->format, |
| ... | ... |
@@ -534,7 +532,7 @@ void avfilter_destroy(AVFilterContext *filter) |
| 534 | 534 |
for (i = 0; i < filter->input_count; i++) {
|
| 535 | 535 |
if ((link = filter->inputs[i])) {
|
| 536 | 536 |
if (link->src) |
| 537 |
- link->src->outputs[link->srcpad] = NULL; |
|
| 537 |
+ link->src->outputs[link->srcpad - link->src->output_pads] = NULL; |
|
| 538 | 538 |
avfilter_formats_unref(&link->in_formats); |
| 539 | 539 |
avfilter_formats_unref(&link->out_formats); |
| 540 | 540 |
} |
| ... | ... |
@@ -543,7 +541,7 @@ void avfilter_destroy(AVFilterContext *filter) |
| 543 | 543 |
for (i = 0; i < filter->output_count; i++) {
|
| 544 | 544 |
if ((link = filter->outputs[i])) {
|
| 545 | 545 |
if (link->dst) |
| 546 |
- link->dst->inputs[link->dstpad] = NULL; |
|
| 546 |
+ link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL; |
|
| 547 | 547 |
avfilter_formats_unref(&link->in_formats); |
| 548 | 548 |
avfilter_formats_unref(&link->out_formats); |
| 549 | 549 |
} |
| ... | ... |
@@ -25,8 +25,8 @@ |
| 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 {
|
| 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 {
|