* qatar/master: (25 commits) rv40dsp x86: MMX/MMX2/3DNow/SSE2/SSSE3 implementations of MC ape: Use unsigned integer maths arm: dsputil: fix overreads in put/avg_pixels functions h264: K&R formatting cosmetics for header files (part II/II) h264: K&R formatting cosmetics for header files (part I/II) rtmp: Implement check bandwidth notification. rtmp: Support 'rtmp_swfurl', an option which specifies the URL of the SWF player. rtmp: Support 'rtmp_flashver', an option which overrides the version of the Flash plugin. rtmp: Support 'rtmp_tcurl', an option which overrides the URL of the target stream. cmdutils: Add fallback case to switch in check_stream_specifier(). sctp: be consistent with socket option level configure: Add _XOPEN_SOURCE=600 to Solaris preprocessor flags. vcr1enc: drop pointless empty encode_init() wrapper function vcr1: drop pointless write-only AVCodecContext member from VCR1Context vcr1: group encoder code together to save #ifdefs vcr1: cosmetics: K&R prettyprinting, typos, parentheses, dead code, comments mov: make one comment slightly more specific lavr: replace the SSE version of ff_conv_fltp_to_flt_6ch() with SSE4 and AVX lavfi: move audio-related functions to a separate file. lavfi: remove some audio-related function from public API. ... Conflicts: cmdutils.c libavcodec/h264.h libavcodec/h264_mvpred.h libavcodec/vcr1.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/defaults.c libavfilter/internal.h
Showing the changes to libavfilter/avfilter.c (1 of 44 files). Show all
Unified · Split
| @@ -27,6 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "libavutil/imgutils.h" | 27 | #include "libavutil/imgutils.h" |
| 28 | #include "libavutil/avassert.h" | 28 | #include "libavutil/avassert.h" |
| 29 | #include "libavutil/avstring.h" | 29 | #include "libavutil/avstring.h" |
| 30 | |||
| 30 | #include "avfilter.h" | 31 | #include "avfilter.h" |
| 31 | #include "internal.h" | 32 | #include "internal.h" |
| 32 | 33 | ||
| @@ -410,7 +411,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) · 377 unmodified lines | |||
| 410 | av_dlog(ctx, "]%s", end ? "\n" : ""); | 411 | av_dlog(ctx, "]%s", end ? "\n" : ""); |
| 411 | } | 412 | } |
| 412 | 413 | ||
| 413 | static void ff_dlog_link(void *ctx, AVFilterLink *link, int end) | 414 | void ff_dlog_link(void *ctx, AVFilterLink *link, int end) |
| 414 | { | 415 | { |
| 415 | if (link->type == AVMEDIA_TYPE_VIDEO) { | 416 | if (link->type == AVMEDIA_TYPE_VIDEO) { |
| 416 | av_dlog(ctx, | 417 | av_dlog(ctx, |
| @@ -434,8 +435,6 @@ static void ff_dlog_link(void *ctx, AVFilterLink *link, int end) · 17 unmodified lines | |||
| 434 | } | 435 | } |
| 435 | } | 436 | } |
| 436 | 437 | ||
| 437 | #define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func) | ||
| 438 | |||
| 439 | AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) | 438 | AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) |
| 440 | { | 439 | { |
| 441 | AVFilterBufferRef *ret = NULL; | 440 | AVFilterBufferRef *ret = NULL; |
| @@ -501,133 +500,6 @@ fail: · 59 unmodified lines | |||
| 501 | return NULL; | 500 | return NULL; |
| 502 | } | 501 | } |
| 503 | 502 | ||
| 504 | AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, | ||
| 505 | int perms, int nb_samples) | ||
| 506 | { | ||
| 507 | AVFilterBufferRef *ret = NULL; | ||
| 508 | |||
| 509 | if (link->dstpad->get_audio_buffer) | ||
| 510 | ret = link->dstpad->get_audio_buffer(link, perms, nb_samples); | ||
| 511 | |||
| 512 | if (!ret) | ||
| 513 | ret = avfilter_default_get_audio_buffer(link, perms, nb_samples); | ||
| 514 | |||
| 515 | if (ret) | ||
| 516 | ret->type = AVMEDIA_TYPE_AUDIO; | ||
| 517 | |||
| 518 | return ret; | ||
| 519 | } | ||
| 520 | |||
| 521 | AVFilterBufferRef * | ||
| 522 | avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms, | ||
| 523 | int nb_samples, enum AVSampleFormat sample_fmt, | ||
| 524 | uint64_t channel_layout, int planar) | ||
| 525 | { | ||
| 526 | AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer)); | ||
| 527 | AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef)); | ||
| 528 | |||
| 529 | if (!samples || !samplesref) | ||
| 530 | goto fail; | ||
| 531 | |||
| 532 | samplesref->buf = samples; | ||
| 533 | samplesref->buf->free = ff_avfilter_default_free_buffer; | ||
| 534 | if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps)))) | ||
| 535 | goto fail; | ||
| 536 | |||
| 537 | samplesref->audio->nb_samples = nb_samples; | ||
| 538 | samplesref->audio->channel_layout = channel_layout; | ||
| 539 | samplesref->audio->planar = planar; | ||
| 540 | |||
| 541 | /* make sure the buffer gets read permission or it's useless for output */ | ||
| 542 | samplesref->perms = perms | AV_PERM_READ; | ||
| 543 | |||
| 544 | samples->refcount = 1; | ||
| 545 | samplesref->type = AVMEDIA_TYPE_AUDIO; | ||
| 546 | samplesref->format = sample_fmt; | ||
| 547 | |||
| 548 | memcpy(samples->data, data, sizeof(samples->data)); | ||
| 549 | memcpy(samples->linesize, linesize, sizeof(samples->linesize)); | ||
| 550 | memcpy(samplesref->data, data, sizeof(samplesref->data)); | ||
| 551 | memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize)); | ||
| 552 | |||
| 553 | return samplesref; | ||
| 554 | |||
| 555 | fail: | ||
| 556 | if (samplesref && samplesref->audio) | ||
| 557 | av_freep(&samplesref->audio); | ||
| 558 | av_freep(&samplesref); | ||
| 559 | av_freep(&samples); | ||
| 560 | return NULL; | ||
| 561 | } | ||
| 562 | |||
| 563 | AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_alt(uint8_t **data, | ||
| 564 | int linesize, int perms, | ||
| 565 | int nb_samples, | ||
| 566 | enum AVSampleFormat sample_fmt, | ||
| 567 | uint64_t channel_layout) | ||
| 568 | { | ||
| 569 | int planes; | ||
| 570 | AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); | ||
| 571 | AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); | ||
| 572 | |||
| 573 | if (!samples || !samplesref) | ||
| 574 | goto fail; | ||
| 575 | |||
| 576 | samplesref->buf = samples; | ||
| 577 | samplesref->buf->free = ff_avfilter_default_free_buffer; | ||
| 578 | if (!(samplesref->audio = av_mallocz(sizeof(*samplesref->audio)))) | ||
| 579 | goto fail; | ||
| 580 | |||
| 581 | samplesref->audio->nb_samples = nb_samples; | ||
| 582 | samplesref->audio->channel_layout = channel_layout; | ||
| 583 | samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt); | ||
| 584 | |||
| 585 | planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1; | ||
| 586 | |||
| 587 | /* make sure the buffer gets read permission or it's useless for output */ | ||
| 588 | samplesref->perms = perms | AV_PERM_READ; | ||
| 589 | |||
| 590 | samples->refcount = 1; | ||
| 591 | samplesref->type = AVMEDIA_TYPE_AUDIO; | ||
| 592 | samplesref->format = sample_fmt; | ||
| 593 | |||
| 594 | memcpy(samples->data, data, | ||
| 595 | FFMIN(FF_ARRAY_ELEMS(samples->data), planes)*sizeof(samples->data[0])); | ||
| 596 | memcpy(samplesref->data, samples->data, sizeof(samples->data)); | ||
| 597 | |||
| 598 | samples->linesize[0] = samplesref->linesize[0] = linesize; | ||
| 599 | |||
| 600 | if (planes > FF_ARRAY_ELEMS(samples->data)) { | ||
| 601 | samples-> extended_data = av_mallocz(sizeof(*samples->extended_data) * | ||
| 602 | planes); | ||
| 603 | samplesref->extended_data = av_mallocz(sizeof(*samplesref->extended_data) * | ||
| 604 | planes); | ||
| 605 | |||
| 606 | if (!samples->extended_data || !samplesref->extended_data) | ||
| 607 | goto fail; | ||
| 608 | |||
| 609 | memcpy(samples-> extended_data, data, sizeof(*data)*planes); | ||
| 610 | memcpy(samplesref->extended_data, data, sizeof(*data)*planes); | ||
| 611 | } else { | ||
| 612 | samples->extended_data = samples->data; | ||
| 613 | samplesref->extended_data = samplesref->data; | ||
| 614 | } | ||
| 615 | |||
| 616 | return samplesref; | ||
| 617 | |||
| 618 | fail: | ||
| 619 | if (samples && samples->extended_data != samples->data) | ||
| 620 | av_freep(&samples->extended_data); | ||
| 621 | if (samplesref) { | ||
| 622 | av_freep(&samplesref->audio); | ||
| 623 | if (samplesref->extended_data != samplesref->data) | ||
| 624 | av_freep(&samplesref->extended_data); | ||
| 625 | } | ||
| 626 | av_freep(&samplesref); | ||
| 627 | av_freep(&samples); | ||
| 628 | return NULL; | ||
| 629 | } | ||
| 630 | |||
| 631 | int avfilter_request_frame(AVFilterLink *link) | 503 | int avfilter_request_frame(AVFilterLink *link) |
| 632 | { | 504 | { |
| 633 | FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1); | 505 | FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1); |
| @@ -657,7 +529,7 @@ int avfilter_poll_frame(AVFilterLink *link) · 23 unmodified lines | |||
| 657 | return min; | 529 | return min; |
| 658 | } | 530 | } |
| 659 | 531 | ||
| 660 | static void update_link_current_pts(AVFilterLink *link, int64_t pts) | 532 | void ff_update_link_current_pts(AVFilterLink *link, int64_t pts) |
| 661 | { | 533 | { |
| 662 | if (pts == AV_NOPTS_VALUE) | 534 | if (pts == AV_NOPTS_VALUE) |
| 663 | return; | 535 | return; |
| @@ -706,7 +578,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 42 unmodified lines | |||
| 706 | } | 578 | } |
| 707 | 579 | ||
| 708 | start_frame(link, link->cur_buf); | 580 | start_frame(link, link->cur_buf); |
| 709 | update_link_current_pts(link, link->cur_buf->pts); | 581 | ff_update_link_current_pts(link, link->cur_buf->pts); |
| 710 | } | 582 | } |
| 711 | 583 | ||
| 712 | void avfilter_end_frame(AVFilterLink *link) | 584 | void avfilter_end_frame(AVFilterLink *link) |
| @@ -778,44 +650,6 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha · 65 unmodified lines | |||
| 778 | return AVERROR(ENOSYS); | 650 | return AVERROR(ENOSYS); |
| 779 | } | 651 | } |
| 780 | 652 | ||
| 781 | void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) | ||
| 782 | { | ||
| 783 | void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); | ||
| 784 | AVFilterPad *dst = link->dstpad; | ||
| 785 | int i; | ||
| 786 | int64_t pts; | ||
| 787 | |||
| 788 | FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1); | ||
| 789 | |||
| 790 | if (!(filter_samples = dst->filter_samples)) | ||
| 791 | filter_samples = avfilter_default_filter_samples; | ||
| 792 | |||
| 793 | /* prepare to copy the samples if the buffer has insufficient permissions */ | ||
| 794 | if ((dst->min_perms & samplesref->perms) != dst->min_perms || | ||
| 795 | dst->rej_perms & samplesref->perms) { | ||
| 796 | |||
| 797 | av_log(link->dst, AV_LOG_DEBUG, | ||
| 798 | "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", | ||
| 799 | samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms); | ||
| 800 | |||
| 801 | link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, | ||
| 802 | samplesref->audio->nb_samples); | ||
| 803 | link->cur_buf->pts = samplesref->pts; | ||
| 804 | link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; | ||
| 805 | |||
| 806 | /* Copy actual data into new samples buffer */ | ||
| 807 | for (i = 0; samplesref->data[i] && i < 8; i++) | ||
| 808 | memcpy(link->cur_buf->data[i], samplesref->data[i], samplesref->linesize[0]); | ||
| 809 | |||
| 810 | avfilter_unref_buffer(samplesref); | ||
| 811 | } else | ||
| 812 | link->cur_buf = samplesref; | ||
| 813 | |||
| 814 | pts = link->cur_buf->pts; | ||
| 815 | filter_samples(link, link->cur_buf); | ||
| 816 | update_link_current_pts(link, pts); | ||
| 817 | } | ||
| 818 | |||
| 819 | #define MAX_REGISTERED_AVFILTERS_NB 128 | 653 | #define MAX_REGISTERED_AVFILTERS_NB 128 |
| 820 | 654 | ||
| 821 | static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; | 655 | static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; |