From cc7fac9970c61f764cc9ca2a263c11fb1497dd28 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 22 May 2012 13:50:23 +0200 Subject: dwt: return errors from ff_slice_buffer_init() --- libavcodec/dwt.c | 7 ++++--- libavcodec/dwt.h | 6 +++--- libavcodec/snowdec.c | 7 ++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libavcodec/dwt.c b/libavcodec/dwt.c index 675644dbe6..d3d4f3b545 100644 --- a/libavcodec/dwt.c +++ b/libavcodec/dwt.c @@ -22,9 +22,9 @@ #include "dsputil.h" #include "dwt.h" -void ff_slice_buffer_init(slice_buffer *buf, int line_count, - int max_allocated_lines, int line_width, - IDWTELEM *base_buffer) +int ff_slice_buffer_init(slice_buffer *buf, int line_count, + int max_allocated_lines, int line_width, + IDWTELEM *base_buffer) { int i; @@ -53,6 +53,7 @@ void ff_slice_buffer_init(slice_buffer *buf, int line_count, } buf->data_stack_top = max_allocated_lines - 1; + return 0; } IDWTELEM *ff_slice_buffer_load_line(slice_buffer *buf, int line) diff --git a/libavcodec/dwt.h b/libavcodec/dwt.h index 6c28447cab..9229928f33 100644 --- a/libavcodec/dwt.h +++ b/libavcodec/dwt.h @@ -137,9 +137,9 @@ typedef struct DWTContext { : ff_slice_buffer_load_line((slice_buf), \ (line_num))) -void ff_slice_buffer_init(slice_buffer *buf, int line_count, - int max_allocated_lines, int line_width, - IDWTELEM *base_buffer); +int ff_slice_buffer_init(slice_buffer *buf, int line_count, + int max_allocated_lines, int line_width, + IDWTELEM *base_buffer); void ff_slice_buffer_release(slice_buffer *buf, int line); void ff_slice_buffer_flush(slice_buffer *buf); void ff_slice_buffer_destroy(slice_buffer *buf); diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index ef5205d972..62ef5f11f4 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -396,7 +396,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac // realloc slice buffer for the case that spatial_decomposition_count changed ff_slice_buffer_destroy(&s->sb); - ff_slice_buffer_init(&s->sb, s->plane[0].height, (MB_SIZE >> s->block_max_depth) + s->spatial_decomposition_count * 8 + 1, s->plane[0].width, s->spatial_idwt_buffer); + if ((res = ff_slice_buffer_init(&s->sb, s->plane[0].height, + (MB_SIZE >> s->block_max_depth) + + s->spatial_decomposition_count * 8 + 1, + s->plane[0].width, + s->spatial_idwt_buffer)) < 0) + return res; for(plane_index=0; plane_index<3; plane_index++){ Plane *p= &s->plane[plane_index]; -- cgit v1.2.3 From 713548cbad4735d691ea286f23adfb67900e6700 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 21 May 2012 21:21:36 -0400 Subject: x86: lavc: use %if HAVE_AVX guards around AVX functions in yasm code. This is needed for older versions of yasm/nasm that do not support AVX. Signed-off-by: Diego Biurrun --- libavcodec/x86/dsputil_yasm.asm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index 708ee67678..c6ef834503 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -1156,8 +1156,10 @@ ALIGN 16 INIT_XMM sse VECTOR_FMUL +%if HAVE_AVX INIT_YMM avx VECTOR_FMUL +%endif ;----------------------------------------------------------------------------- ; void vector_fmul_reverse(float *dst, const float *src0, const float *src1, @@ -1198,8 +1200,10 @@ ALIGN 16 INIT_XMM sse VECTOR_FMUL_REVERSE +%if HAVE_AVX INIT_YMM avx VECTOR_FMUL_REVERSE +%endif ;----------------------------------------------------------------------------- ; vector_fmul_add(float *dst, const float *src0, const float *src1, @@ -1231,8 +1235,10 @@ ALIGN 16 INIT_XMM sse VECTOR_FMUL_ADD +%if HAVE_AVX INIT_YMM avx VECTOR_FMUL_ADD +%endif ;----------------------------------------------------------------------------- ; void ff_butterflies_float_interleave(float *dst, const float *src0, @@ -1279,8 +1285,10 @@ cglobal butterflies_float_interleave, 4,4,3, dst, src0, src1, len INIT_XMM sse BUTTERFLIES_FLOAT_INTERLEAVE +%if HAVE_AVX INIT_YMM avx BUTTERFLIES_FLOAT_INTERLEAVE +%endif INIT_XMM sse2 ; %1 = aligned/unaligned -- cgit v1.2.3 From f297dd3812510fc83080e265dc4534a3898005b0 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 22 May 2012 20:44:07 +0200 Subject: asyncts: reset delta to 0 when it's not used. Fixes an invalid write. --- libavfilter/af_asyncts.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_asyncts.c b/libavfilter/af_asyncts.c index 5cde0bf00a..adb5347a80 100644 --- a/libavfilter/af_asyncts.c +++ b/libavfilter/af_asyncts.c @@ -182,10 +182,13 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) if (labs(delta) > s->min_delta) { av_log(ctx, AV_LOG_VERBOSE, "Discontinuity - %"PRId64" samples.\n", delta); out_size += delta; - } else if (s->resample) { - int comp = av_clip(delta, -s->max_comp, s->max_comp); - av_log(ctx, AV_LOG_VERBOSE, "Compensating %d samples per second.\n", comp); - avresample_set_compensation(s->avr, delta, inlink->sample_rate); + } else { + if (s->resample) { + int comp = av_clip(delta, -s->max_comp, s->max_comp); + av_log(ctx, AV_LOG_VERBOSE, "Compensating %d samples per second.\n", comp); + avresample_set_compensation(s->avr, delta, inlink->sample_rate); + } + delta = 0; } if (out_size > 0) { -- cgit v1.2.3 From 0629f6128e1c7507a06377f0dff39dde4ee6c7d5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 18 May 2012 12:46:11 +0200 Subject: avconv: rename transcode_audio/video to decode_audio/video. Those functions do only decoding now, encoding is run from poll_filters(). --- avconv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/avconv.c b/avconv.c index 8a8ef808ca..5506869d3d 100644 --- a/avconv.c +++ b/avconv.c @@ -2120,7 +2120,7 @@ static int guess_input_channel_layout(InputStream *ist) return 1; } -static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output) +static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) { AVFrame *decoded_frame; AVCodecContext *avctx = ist->st->codec; @@ -2262,7 +2262,7 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output) return ret; } -static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output) +static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) { AVFrame *decoded_frame; void *buffer_to_free = NULL; @@ -2410,10 +2410,10 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) switch (ist->st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: - ret = transcode_audio (ist, &avpkt, &got_output); + ret = decode_audio (ist, &avpkt, &got_output); break; case AVMEDIA_TYPE_VIDEO: - ret = transcode_video (ist, &avpkt, &got_output); + ret = decode_video (ist, &avpkt, &got_output); if (avpkt.duration) ist->next_dts += av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q); else if (ist->st->r_frame_rate.num) -- cgit v1.2.3 From ccefa89f398a30dcd24044621ec7013387aeb455 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 19 May 2012 09:19:41 +0200 Subject: avfiltergraph: smarter sample format selection. --- libavfilter/avfiltergraph.c | 71 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index f65faae8ce..91a5f3233f 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -461,6 +461,74 @@ static void swap_channel_layouts(AVFilterGraph *graph) swap_channel_layouts_on_filter(graph->filters[i]); } +static void swap_sample_fmts_on_filter(AVFilterContext *filter) +{ + AVFilterLink *link = NULL; + int format, bps; + int i, j; + + for (i = 0; i < filter->input_count; i++) { + link = filter->inputs[i]; + + if (link->type == AVMEDIA_TYPE_AUDIO && + link->out_formats->format_count == 1) + break; + } + if (i == filter->input_count) + return; + + format = link->out_formats->formats[0]; + bps = av_get_bytes_per_sample(format); + + for (i = 0; i < filter->output_count; i++) { + AVFilterLink *outlink = filter->outputs[i]; + int best_idx, best_score = INT_MIN; + + if (outlink->type != AVMEDIA_TYPE_AUDIO || + outlink->in_formats->format_count < 2) + continue; + + for (j = 0; j < outlink->in_formats->format_count; j++) { + int out_format = outlink->in_formats->formats[j]; + int out_bps = av_get_bytes_per_sample(out_format); + int score; + + if (av_get_packed_sample_fmt(out_format) == format || + av_get_planar_sample_fmt(out_format) == format) { + best_idx = j; + break; + } + + /* for s32 and float prefer double to prevent loss of information */ + if (bps == 4 && out_bps == 8) { + best_idx = j; + break; + } + + /* prefer closest higher or equal bps */ + score = -abs(out_bps - bps); + if (out_bps >= bps) + score += INT_MAX/2; + + if (score > best_score) { + best_score = score; + best_idx = j; + } + } + FFSWAP(int, outlink->in_formats->formats[0], + outlink->in_formats->formats[best_idx]); + } +} + +static void swap_sample_fmts(AVFilterGraph *graph) +{ + int i; + + for (i = 0; i < graph->filter_count; i++) + swap_sample_fmts_on_filter(graph->filters[i]); + +} + static int pick_formats(AVFilterGraph *graph) { int i, j, ret; @@ -491,8 +559,9 @@ int ff_avfilter_graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx) * of format conversion inside filters */ reduce_formats(graph); - /* for audio filters, ensure the best sample rate and channel layout + /* for audio filters, ensure the best format, sample rate and channel layout * is selected */ + swap_sample_fmts(graph); swap_samplerates(graph); swap_channel_layouts(graph); -- cgit v1.2.3 From 88c3b87bd81829d1b7171cb26e5ef5a564dbd96a Mon Sep 17 00:00:00 2001 From: Mina Nagy Zaki Date: Thu, 4 Aug 2011 15:47:00 +0300 Subject: lavfi: deprecate default config_props() callback and refactor avfilter_config_links() Link properties have to be checked after config_props() is called to make sure everything is sane, so the default config_props() for output links was redundant. Remove now empty defaults.c Signed-off-by: Anton Khirnov --- libavfilter/Makefile | 1 - libavfilter/avfilter.c | 39 +++++++++++++++++++++++++++++++++------ libavfilter/avfilter.h | 3 +++ libavfilter/defaults.c | 48 ------------------------------------------------ libavfilter/version.h | 3 +++ 5 files changed, 39 insertions(+), 55 deletions(-) delete mode 100644 libavfilter/defaults.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 8649222ed2..212e992c3e 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -18,7 +18,6 @@ OBJS = allfilters.o \ buffer.o \ buffersink.o \ buffersrc.o \ - defaults.o \ drawutils.o \ formats.o \ graphparser.o \ diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 231c875131..2f5c37d3af 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -155,18 +155,38 @@ int avfilter_config_links(AVFilterContext *filter) if ((ret = avfilter_config_links(link->src)) < 0) return ret; - if (!(config_link = link->srcpad->config_props)) - config_link = avfilter_default_config_output_link; - if ((ret = config_link(link)) < 0) + if (!(config_link = link->srcpad->config_props)) { + if (link->src->input_count != 1) { + av_log(link->src, AV_LOG_ERROR, "Source filters and filters " + "with more than one input " + "must set config_props() " + "callbacks on all outputs\n"); + return AVERROR(EINVAL); + } + } else if ((ret = config_link(link)) < 0) return ret; if (link->time_base.num == 0 && link->time_base.den == 0) link->time_base = link->src && link->src->input_count ? link->src->inputs[0]->time_base : AV_TIME_BASE_Q; - if (link->sample_aspect_ratio.num == 0 && link->sample_aspect_ratio.den == 0) - link->sample_aspect_ratio = link->src->input_count ? - link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1}; + if (link->type == AVMEDIA_TYPE_VIDEO) { + if (!link->sample_aspect_ratio.num && !link->sample_aspect_ratio.den) + link->sample_aspect_ratio = link->src->input_count ? + link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1}; + + if (link->src->input_count) { + if (!link->w) + link->w = link->src->inputs[0]->w; + if (!link->h) + link->h = link->src->inputs[0]->h; + } else if (!link->w || !link->h) { + av_log(link->src, AV_LOG_ERROR, + "Video source filters must set their output link's " + "width and height\n"); + return AVERROR(EINVAL); + } + } if ((config_link = link->dstpad->config_props)) if ((ret = config_link(link)) < 0) @@ -400,3 +420,10 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque ret = filter->filter->init(filter, args, opaque); return ret; } + +#if FF_API_DEFAULT_CONFIG_OUTPUT_LINK +int avfilter_default_config_output_link(AVFilterLink *link) +{ + return 0; +} +#endif diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 718f77df3d..711feca9e1 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -460,8 +460,11 @@ void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir /** default handler for end_frame() for video inputs */ void avfilter_default_end_frame(AVFilterLink *link); +#if FF_API_DEFAULT_CONFIG_OUTPUT_LINK /** default handler for config_props() for audio/video outputs */ +attribute_deprecated int avfilter_default_config_output_link(AVFilterLink *link); +#endif /** default handler for get_video_buffer() for video inputs */ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c deleted file mode 100644 index ec61480c34..0000000000 --- a/libavfilter/defaults.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Filter layer - default implementations - * Copyright (c) 2007 Bobby Bingham - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavutil/audioconvert.h" -#include "libavutil/imgutils.h" -#include "libavutil/samplefmt.h" - -#include "avfilter.h" -#include "internal.h" -#include "formats.h" - -/** - * default config_link() implementation for output video links to simplify - * the implementation of one input one output video filters */ -int avfilter_default_config_output_link(AVFilterLink *link) -{ - if (link->src->input_count && link->src->inputs[0]) { - if (link->type == AVMEDIA_TYPE_VIDEO) { - link->w = link->src->inputs[0]->w; - link->h = link->src->inputs[0]->h; - link->time_base = link->src->inputs[0]->time_base; - } - } else { - /* XXX: any non-simple filter which would cause this branch to be taken - * really should implement its own config_props() for this link. */ - return -1; - } - - return 0; -} diff --git a/libavfilter/version.h b/libavfilter/version.h index f6497db364..5dd81c1dcd 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -53,5 +53,8 @@ #ifndef FF_API_VSRC_BUFFER_ADD_FRAME #define FF_API_VSRC_BUFFER_ADD_FRAME (LIBAVFILTER_VERSION_MAJOR < 3) #endif +#ifndef FF_API_DEFAULT_CONFIG_OUTPUT_LINK +#define FF_API_DEFAULT_CONFIG_OUTPUT_LINK (LIBAVFILTER_VERSION_MAJOR < 3) +#endif #endif // AVFILTER_VERSION_H -- cgit v1.2.3 From 43c7a01e9879640859d32b062ac01700e1333c7a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 19 May 2012 10:37:56 +0200 Subject: lavfi: remove avfilter_default_* from public API on next bump. Those functions are only useful inside filters. It is better to not support user filters until the API is more stable. --- libavfilter/avfilter.h | 13 ++++++++++--- libavfilter/avfiltergraph.c | 2 +- libavfilter/formats.c | 9 ++++++++- libavfilter/formats.h | 2 ++ libavfilter/version.h | 3 +++ libavfilter/vf_vflip.c | 3 ++- libavfilter/vf_yadif.c | 3 ++- libavfilter/video.c | 35 +++++++++++++++++++++++++++-------- libavfilter/video.h | 24 ++++++++++++++++++++++++ tools/lavfi-showfiltfmts.c | 3 ++- 10 files changed, 81 insertions(+), 16 deletions(-) create mode 100644 libavfilter/video.h diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 711feca9e1..0d40b7664c 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -451,13 +451,17 @@ struct AVFilterPad { int (*config_props)(AVFilterLink *link); }; +#if FF_API_FILTERS_PUBLIC /** default handler for start_frame() for video inputs */ +attribute_deprecated void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); /** default handler for draw_slice() for video inputs */ +attribute_deprecated void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); /** default handler for end_frame() for video inputs */ +attribute_deprecated void avfilter_default_end_frame(AVFilterLink *link); #if FF_API_DEFAULT_CONFIG_OUTPUT_LINK @@ -467,9 +471,15 @@ int avfilter_default_config_output_link(AVFilterLink *link); #endif /** default handler for get_video_buffer() for video inputs */ +attribute_deprecated AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h); +/** Default handler for query_formats() */ +attribute_deprecated +int avfilter_default_query_formats(AVFilterContext *ctx); +#endif + /** * A helper for query_formats() which sets all links to the same list of * formats. If there are no links hooked to this filter, the list of formats is @@ -477,9 +487,6 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, */ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); -/** Default handler for query_formats() */ -int avfilter_default_query_formats(AVFilterContext *ctx); - /** start_frame() handler for filters which simply pass video along */ void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 91a5f3233f..b2db5dcf97 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -161,7 +161,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) if (graph->filters[i]->filter->query_formats) graph->filters[i]->filter->query_formats(graph->filters[i]); else - avfilter_default_query_formats(graph->filters[i]); + ff_default_query_formats(graph->filters[i]); } /* go through and merge as many format lists as possible */ diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 36b4d6d682..63c63e32b4 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -364,7 +364,7 @@ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) avfilter_formats_ref, formats); } -int avfilter_default_query_formats(AVFilterContext *ctx) +int ff_default_query_formats(AVFilterContext *ctx) { enum AVMediaType type = ctx->inputs && ctx->inputs [0] ? ctx->inputs [0]->type : ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type : @@ -378,3 +378,10 @@ int avfilter_default_query_formats(AVFilterContext *ctx) return 0; } + +#if FF_API_FILTERS_PUBLIC +int avfilter_default_query_formats(AVFilterContext *ctx) +{ + return ff_default_query_formats(ctx); +} +#endif diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 7e0a60114c..9acd31f38a 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -75,4 +75,6 @@ void ff_channel_layouts_unref(AVFilterChannelLayouts **ref); void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, AVFilterChannelLayouts **newref); +int ff_default_query_formats(AVFilterContext *ctx); + #endif // AVFILTER_FORMATS_H diff --git a/libavfilter/version.h b/libavfilter/version.h index 5dd81c1dcd..6194876d25 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -56,5 +56,8 @@ #ifndef FF_API_DEFAULT_CONFIG_OUTPUT_LINK #define FF_API_DEFAULT_CONFIG_OUTPUT_LINK (LIBAVFILTER_VERSION_MAJOR < 3) #endif +#ifndef FF_API_FILTERS_PUBLIC +#define FF_API_FILTERS_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 3) +#endif #endif // AVFILTER_VERSION_H diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c index 09ba303bb9..a7f14c0775 100644 --- a/libavfilter/vf_vflip.c +++ b/libavfilter/vf_vflip.c @@ -25,6 +25,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" typedef struct { int vsub; ///< vertical chroma subsampling @@ -47,7 +48,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int i; if (!(perms & AV_PERM_NEG_LINESIZES)) - return avfilter_default_get_video_buffer(link, perms, w, h); + return ff_default_get_video_buffer(link, perms, w, h); picref = avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); for (i = 0; i < 4; i ++) { diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 1cecdd98cb..0c72444bee 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -23,6 +23,7 @@ #include "libavutil/common.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" #include "yadif.h" #undef NDEBUG @@ -180,7 +181,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, int height= FFALIGN(h+2, 32); int i; - picref = avfilter_default_get_video_buffer(link, perms, width, height); + picref = ff_default_get_video_buffer(link, perms, width, height); picref->video->w = w; picref->video->h = h; diff --git a/libavfilter/video.c b/libavfilter/video.c index ad033f3b8f..74b08379bf 100644 --- a/libavfilter/video.c +++ b/libavfilter/video.c @@ -20,6 +20,7 @@ #include "avfilter.h" #include "internal.h" +#include "video.h" #ifdef DEBUG static char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms) @@ -72,7 +73,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, /* TODO: set the buffer's priv member to a context structure for the whole * filter chain. This will allow for a buffer pool instead of the constant * alloc & free cycle currently implemented. */ -AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h) +AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h) { int linesize[4]; uint8_t *data[4]; @@ -149,7 +150,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int ret = link->dstpad->get_video_buffer(link, perms, w, h); if (!ret) - ret = avfilter_default_get_video_buffer(link, perms, w, h); + ret = ff_default_get_video_buffer(link, perms, w, h); if (ret) ret->type = AVMEDIA_TYPE_VIDEO; @@ -164,7 +165,7 @@ void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) avfilter_start_frame(link->dst->outputs[0], picref); } -void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) +static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) { AVFilterLink *outlink = NULL; @@ -189,7 +190,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) FF_DPRINTF_START(NULL, start_frame); ff_dlog_link(NULL, link, 0); av_dlog(NULL, " "); ff_dlog_ref(NULL, picref, 1); if (!(start_frame = dst->start_frame)) - start_frame = avfilter_default_start_frame; + start_frame = default_start_frame; if (picref->linesize[0] < 0) perms |= AV_PERM_NEG_LINESIZES; @@ -215,7 +216,7 @@ void avfilter_null_end_frame(AVFilterLink *link) avfilter_end_frame(link->dst->outputs[0]); } -void avfilter_default_end_frame(AVFilterLink *inlink) +static void default_end_frame(AVFilterLink *inlink) { AVFilterLink *outlink = NULL; @@ -239,7 +240,7 @@ void avfilter_end_frame(AVFilterLink *link) void (*end_frame)(AVFilterLink *); if (!(end_frame = link->dstpad->end_frame)) - end_frame = avfilter_default_end_frame; + end_frame = default_end_frame; end_frame(link); @@ -256,7 +257,7 @@ void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); } -void avfilter_default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) +static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { AVFilterLink *outlink = NULL; @@ -304,7 +305,25 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) } if (!(draw_slice = link->dstpad->draw_slice)) - draw_slice = avfilter_default_draw_slice; + draw_slice = default_draw_slice; draw_slice(link, y, h, slice_dir); } +#if FF_API_FILTERS_PUBLIC +AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h) +{ + return ff_default_get_video_buffer(link, perms, w, h); +} +void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) +{ + default_start_frame(inlink, picref); +} +void avfilter_default_end_frame(AVFilterLink *inlink) +{ + default_end_frame(inlink); +} +void avfilter_default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) +{ + default_draw_slice(inlink, y, h, slice_dir); +} +#endif diff --git a/libavfilter/video.h b/libavfilter/video.h new file mode 100644 index 0000000000..99f84ecde8 --- /dev/null +++ b/libavfilter/video.h @@ -0,0 +1,24 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_VIDEO_H +#define AVFILTER_VIDEO_H + +AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, + int perms, int w, int h); +#endif /* AVFILTER_VIDEO_H */ diff --git a/tools/lavfi-showfiltfmts.c b/tools/lavfi-showfiltfmts.c index d25cf3e138..146f0cd081 100644 --- a/tools/lavfi-showfiltfmts.c +++ b/tools/lavfi-showfiltfmts.c @@ -21,6 +21,7 @@ #include "libavformat/avformat.h" #include "libavutil/pixdesc.h" #include "libavfilter/avfilter.h" +#include "libavfilter/formats.h" int main(int argc, char **argv) { @@ -75,7 +76,7 @@ int main(int argc, char **argv) if (filter->query_formats) filter->query_formats(filter_ctx); else - avfilter_default_query_formats(filter_ctx); + ff_default_query_formats(filter_ctx); /* print the supported formats in input */ for (i = 0; i < filter_ctx->input_count; i++) { -- cgit v1.2.3 From c04c533f62b80e9d6bbcb89946bab6206a8873c5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 19 May 2012 10:37:56 +0200 Subject: lavfi: remove avfilter_null_* from public API on next bump. Those functions are only useful inside filters. It is better to not support user filters until the API is more stable. --- libavfilter/avfilter.h | 6 ++++++ libavfilter/split.c | 3 ++- libavfilter/vf_aspect.c | 9 +++++---- libavfilter/vf_blackframe.c | 5 +++-- libavfilter/vf_copy.c | 7 ++++--- libavfilter/vf_crop.c | 3 ++- libavfilter/vf_cropdetect.c | 5 +++-- libavfilter/vf_delogo.c | 3 ++- libavfilter/vf_drawbox.c | 7 ++++--- libavfilter/vf_drawtext.c | 3 ++- libavfilter/vf_fade.c | 5 +++-- libavfilter/vf_fifo.c | 3 ++- libavfilter/vf_format.c | 17 +++++++++-------- libavfilter/vf_null.c | 7 ++++--- libavfilter/vf_select.c | 3 ++- libavfilter/vf_setpts.c | 3 ++- libavfilter/vf_settb.c | 5 +++-- libavfilter/vf_showinfo.c | 5 +++-- libavfilter/vf_slicify.c | 5 +++-- libavfilter/video.c | 24 ++++++++++++++++++++---- libavfilter/video.h | 6 ++++++ 21 files changed, 90 insertions(+), 44 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 0d40b7664c..54adc5cf3a 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -487,18 +487,24 @@ int avfilter_default_query_formats(AVFilterContext *ctx); */ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); +#if FF_API_FILTERS_PUBLIC /** start_frame() handler for filters which simply pass video along */ +attribute_deprecated void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); /** draw_slice() handler for filters which simply pass video along */ +attribute_deprecated void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); /** end_frame() handler for filters which simply pass video along */ +attribute_deprecated void avfilter_null_end_frame(AVFilterLink *link); /** get_video_buffer() handler for filters which simply pass video along */ +attribute_deprecated AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h); +#endif /** * Filter definition. This defines the pads a filter contains, and all the diff --git a/libavfilter/split.c b/libavfilter/split.c index 83ad765081..da33b7d183 100644 --- a/libavfilter/split.c +++ b/libavfilter/split.c @@ -25,6 +25,7 @@ #include "avfilter.h" #include "audio.h" +#include "video.h" static int split_init(AVFilterContext *ctx, const char *args, void *opaque) { @@ -100,7 +101,7 @@ AVFilter avfilter_vf_split = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer= avfilter_null_get_video_buffer, + .get_video_buffer= ff_null_get_video_buffer, .start_frame = start_frame, .draw_slice = draw_slice, .end_frame = end_frame, }, diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c index 9db29c70f5..4e1fdac90e 100644 --- a/libavfilter/vf_aspect.c +++ b/libavfilter/vf_aspect.c @@ -25,6 +25,7 @@ #include "libavutil/mathematics.h" #include "avfilter.h" +#include "video.h" typedef struct { AVRational aspect; @@ -100,9 +101,9 @@ AVFilter avfilter_vf_setdar = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = setdar_config_props, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .start_frame = start_frame, - .end_frame = avfilter_null_end_frame }, + .end_frame = ff_null_end_frame }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", @@ -133,9 +134,9 @@ AVFilter avfilter_vf_setsar = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = setsar_config_props, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .start_frame = start_frame, - .end_frame = avfilter_null_end_frame }, + .end_frame = ff_null_end_frame }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c index 770eec94e0..7e69ccb1f6 100644 --- a/libavfilter/vf_blackframe.c +++ b/libavfilter/vf_blackframe.c @@ -28,6 +28,7 @@ */ #include "avfilter.h" +#include "video.h" typedef struct { unsigned int bamount; ///< black amount @@ -118,8 +119,8 @@ AVFilter avfilter_vf_blackframe = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .draw_slice = draw_slice, - .get_video_buffer = avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, + .get_video_buffer = ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, .end_frame = end_frame, }, { .name = NULL}}, diff --git a/libavfilter/vf_copy.c b/libavfilter/vf_copy.c index 705ad1e2e6..271a729211 100644 --- a/libavfilter/vf_copy.c +++ b/libavfilter/vf_copy.c @@ -22,6 +22,7 @@ */ #include "avfilter.h" +#include "video.h" AVFilter avfilter_vf_copy = { .name = "copy", @@ -29,9 +30,9 @@ AVFilter avfilter_vf_copy = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, - .end_frame = avfilter_null_end_frame, + .get_video_buffer = ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, + .end_frame = ff_null_end_frame, .rej_perms = ~0 }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index d3b5a09060..5452601068 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -26,6 +26,7 @@ /* #define DEBUG */ #include "avfilter.h" +#include "video.h" #include "libavutil/eval.h" #include "libavutil/avstring.h" #include "libavutil/libm.h" @@ -333,7 +334,7 @@ AVFilter avfilter_vf_crop = { .start_frame = start_frame, .draw_slice = draw_slice, .end_frame = end_frame, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .config_props = config_input, }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c index 34b5dc9a2a..d321afdd40 100644 --- a/libavfilter/vf_cropdetect.c +++ b/libavfilter/vf_cropdetect.c @@ -25,6 +25,7 @@ #include "libavutil/imgutils.h" #include "avfilter.h" +#include "video.h" typedef struct { int x1, y1, x2, y2; @@ -203,8 +204,8 @@ AVFilter avfilter_vf_cropdetect = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_input, - .get_video_buffer = avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, + .get_video_buffer = ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, .end_frame = end_frame, }, { .name = NULL}}, diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index ca3156814b..a54abe1a79 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -29,6 +29,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" /** * Apply a simple delogo algorithm to the image in dst and put the @@ -271,7 +272,7 @@ AVFilter avfilter_vf_delogo = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .start_frame = start_frame, .draw_slice = null_draw_slice, .end_frame = end_frame, diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c index ab5cb03415..fc80402f60 100644 --- a/libavfilter/vf_drawbox.c +++ b/libavfilter/vf_drawbox.c @@ -28,6 +28,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/parseutils.h" #include "avfilter.h" +#include "video.h" enum { Y, U, V, A }; @@ -130,10 +131,10 @@ AVFilter avfilter_vf_drawbox = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_input, - .get_video_buffer = avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, + .get_video_buffer = ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, .draw_slice = draw_slice, - .end_frame = avfilter_null_end_frame, + .end_frame = ff_null_end_frame, .min_perms = AV_PERM_WRITE | AV_PERM_READ, .rej_perms = AV_PERM_PRESERVE }, { .name = NULL}}, diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 4846716fe0..5ef0d8c1ca 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -41,6 +41,7 @@ #include "libavutil/lfg.h" #include "avfilter.h" #include "drawutils.h" +#include "video.h" #undef time @@ -875,7 +876,7 @@ AVFilter avfilter_vf_drawtext = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .start_frame = start_frame, .draw_slice = null_draw_slice, .end_frame = end_frame, diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c index 9f748b8882..a0f37d2ad5 100644 --- a/libavfilter/vf_fade.c +++ b/libavfilter/vf_fade.c @@ -27,6 +27,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" typedef struct { int factor, fade_per_frame; @@ -157,8 +158,8 @@ AVFilter avfilter_vf_fade = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_props, - .get_video_buffer = avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, + .get_video_buffer = ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, .draw_slice = draw_slice, .end_frame = end_frame, .min_perms = AV_PERM_READ | AV_PERM_WRITE, diff --git a/libavfilter/vf_fifo.c b/libavfilter/vf_fifo.c index 836cce28b5..b99cec38dc 100644 --- a/libavfilter/vf_fifo.c +++ b/libavfilter/vf_fifo.c @@ -24,6 +24,7 @@ */ #include "avfilter.h" +#include "video.h" typedef struct BufPic { AVFilterBufferRef *picref; @@ -106,7 +107,7 @@ AVFilter avfilter_vf_fifo = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer= avfilter_null_get_video_buffer, + .get_video_buffer= ff_null_get_video_buffer, .start_frame = start_frame, .draw_slice = draw_slice, .end_frame = end_frame, diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c index 9c1e0d4266..aaaca277df 100644 --- a/libavfilter/vf_format.c +++ b/libavfilter/vf_format.c @@ -25,6 +25,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" typedef struct { /** @@ -104,10 +105,10 @@ AVFilter avfilter_vf_format = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer= avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, - .draw_slice = avfilter_null_draw_slice, - .end_frame = avfilter_null_end_frame, }, + .get_video_buffer= ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, + .draw_slice = ff_null_draw_slice, + .end_frame = ff_null_end_frame, }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO }, @@ -134,10 +135,10 @@ AVFilter avfilter_vf_noformat = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer= avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, - .draw_slice = avfilter_null_draw_slice, - .end_frame = avfilter_null_end_frame, }, + .get_video_buffer= ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, + .draw_slice = ff_null_draw_slice, + .end_frame = ff_null_end_frame, }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO }, diff --git a/libavfilter/vf_null.c b/libavfilter/vf_null.c index 8414c5f4fa..470c3d28a5 100644 --- a/libavfilter/vf_null.c +++ b/libavfilter/vf_null.c @@ -22,6 +22,7 @@ */ #include "avfilter.h" +#include "video.h" AVFilter avfilter_vf_null = { .name = "null", @@ -31,9 +32,9 @@ AVFilter avfilter_vf_null = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, - .end_frame = avfilter_null_end_frame }, + .get_video_buffer = ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, + .end_frame = ff_null_end_frame }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c index 13ec0407d5..2b6b49c153 100644 --- a/libavfilter/vf_select.c +++ b/libavfilter/vf_select.c @@ -27,6 +27,7 @@ #include "libavutil/fifo.h" #include "libavutil/mathematics.h" #include "avfilter.h" +#include "video.h" static const char *const var_names[] = { "E", ///< Euler number @@ -339,7 +340,7 @@ AVFilter avfilter_vf_select = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .config_props = config_input, .start_frame = start_frame, .draw_slice = draw_slice, diff --git a/libavfilter/vf_setpts.c b/libavfilter/vf_setpts.c index b49ca5eb57..103f265782 100644 --- a/libavfilter/vf_setpts.c +++ b/libavfilter/vf_setpts.c @@ -29,6 +29,7 @@ #include "libavutil/eval.h" #include "libavutil/mathematics.h" #include "avfilter.h" +#include "video.h" static const char *const var_names[] = { "E", ///< Euler number @@ -148,7 +149,7 @@ AVFilter avfilter_vf_setpts = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .config_props = config_input, .start_frame = start_frame, }, { .name = NULL }}, diff --git a/libavfilter/vf_settb.c b/libavfilter/vf_settb.c index 49f7a57d72..b40ede87cb 100644 --- a/libavfilter/vf_settb.c +++ b/libavfilter/vf_settb.c @@ -29,6 +29,7 @@ #include "libavutil/rational.h" #include "avfilter.h" #include "internal.h" +#include "video.h" static const char *const var_names[] = { "E", @@ -130,9 +131,9 @@ AVFilter avfilter_vf_settb = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .start_frame = start_frame, - .end_frame = avfilter_null_end_frame }, + .end_frame = ff_null_end_frame }, { .name = NULL }}, .outputs = (AVFilterPad[]) {{ .name = "default", diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index aa2a7f16f9..0475f9bf90 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -26,6 +26,7 @@ #include "libavutil/imgutils.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" typedef struct { unsigned int frame; @@ -86,8 +87,8 @@ AVFilter avfilter_vf_showinfo = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, + .get_video_buffer = ff_null_get_video_buffer, + .start_frame = ff_null_start_frame, .end_frame = end_frame, .min_perms = AV_PERM_READ, }, { .name = NULL}}, diff --git a/libavfilter/vf_slicify.c b/libavfilter/vf_slicify.c index cc56fe857c..31d74979af 100644 --- a/libavfilter/vf_slicify.c +++ b/libavfilter/vf_slicify.c @@ -24,6 +24,7 @@ */ #include "avfilter.h" +#include "video.h" #include "libavutil/pixdesc.h" typedef struct { @@ -105,11 +106,11 @@ AVFilter avfilter_vf_slicify = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = avfilter_null_get_video_buffer, + .get_video_buffer = ff_null_get_video_buffer, .start_frame = start_frame, .draw_slice = draw_slice, .config_props = config_props, - .end_frame = avfilter_null_end_frame, }, + .end_frame = ff_null_end_frame, }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, }, diff --git a/libavfilter/video.c b/libavfilter/video.c index 74b08379bf..6a19388f6e 100644 --- a/libavfilter/video.c +++ b/libavfilter/video.c @@ -65,7 +65,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) av_dlog(ctx, "]%s", end ? "\n" : ""); } -AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h) +AVFilterBufferRef *ff_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h) { return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); } @@ -160,7 +160,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int return ret; } -void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) +void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) { avfilter_start_frame(link->dst->outputs[0], picref); } @@ -211,7 +211,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) start_frame(link, link->cur_buf); } -void avfilter_null_end_frame(AVFilterLink *link) +void ff_null_end_frame(AVFilterLink *link) { avfilter_end_frame(link->dst->outputs[0]); } @@ -252,7 +252,7 @@ void avfilter_end_frame(AVFilterLink *link) } } -void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) +void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); } @@ -326,4 +326,20 @@ void avfilter_default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_d { default_draw_slice(inlink, y, h, slice_dir); } +AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h) +{ + return ff_null_get_video_buffer(link, perms, w, h); +} +void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) +{ + ff_null_start_frame(link, picref); +} +void avfilter_null_end_frame(AVFilterLink *link) +{ + ff_null_end_frame(link); +} +void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) +{ + ff_null_draw_slice(link, y, h, slice_dir); +} #endif diff --git a/libavfilter/video.h b/libavfilter/video.h index 99f84ecde8..f20f30b27c 100644 --- a/libavfilter/video.h +++ b/libavfilter/video.h @@ -21,4 +21,10 @@ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h); +AVFilterBufferRef *ff_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h); + +void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); +void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); +void ff_null_end_frame(AVFilterLink *link); + #endif /* AVFILTER_VIDEO_H */ -- cgit v1.2.3 From ce353a881fe305d4e6f046d6f36f2071449ca57b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 May 2012 19:30:07 +0200 Subject: lavfi: fix incorrect comment. poll_frame()/request_frame() are used for audio too. --- libavfilter/avfilter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 54adc5cf3a..3483569bce 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -421,7 +421,7 @@ struct AVFilterPad { * * Defaults to just calling the source poll_frame() method. * - * Output video pads only. + * Output pads only. */ int (*poll_frame)(AVFilterLink *link); @@ -430,7 +430,7 @@ struct AVFilterPad { * frame being output over the given link. This should return zero on * success, and another value on error. * - * Output video pads only. + * Output pads only. */ int (*request_frame)(AVFilterLink *link); -- cgit v1.2.3 From 0ce4a627c9b8bcd2c23d05ada3e4858684cb8127 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 May 2012 19:33:35 +0200 Subject: lavfi: fix comment, audio is supported now. --- libavfilter/avfilter.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 3483569bce..289c06c331 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -338,8 +338,7 @@ struct AVFilterPad { const char *name; /** - * AVFilterPad type. Only video supported now, hopefully someone will - * add audio in the future. + * AVFilterPad type. */ enum AVMediaType type; -- cgit v1.2.3 From 32d545e0a4686e919319bf472725ea0162b72720 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 21 May 2012 11:24:54 +0200 Subject: avio: Add a function for signalling end of reading/writing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/avio.c | 7 +++++++ libavformat/url.h | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/libavformat/avio.c b/libavformat/avio.c index ba25abea38..371500e8a6 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -345,6 +345,13 @@ int ffurl_get_file_handle(URLContext *h) return h->prot->url_get_file_handle(h); } +int ffurl_shutdown(URLContext *h, int flags) +{ + if (!h->prot->url_shutdown) + return AVERROR(EINVAL); + return h->prot->url_shutdown(h, flags); +} + int ff_check_interrupt(AVIOInterruptCB *cb) { int ret; diff --git a/libavformat/url.h b/libavformat/url.h index bf8b6ed6e7..0f0de7881c 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -81,6 +81,7 @@ typedef struct URLProtocol { int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); int (*url_get_file_handle)(URLContext *h); + int (*url_shutdown)(URLContext *h, int flags); int priv_data_size; const AVClass *priv_data_class; int flags; @@ -200,6 +201,18 @@ int64_t ffurl_size(URLContext *h); */ int ffurl_get_file_handle(URLContext *h); +/** + * Signal the URLContext that we are done reading or writing the stream. + * + * @param h pointer to the resource + * @param flags flags which control how the resource indicated by url + * is to be shutdown + * + * @return a negative value if an error condition occurred, 0 + * otherwise + */ +int ffurl_shutdown(URLContext *h, int flags); + /** * Register the URLProtocol protocol. * -- cgit v1.2.3 From 4a9ca9355607053fdbcb8adcb614b08305eca88f Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 21 May 2012 11:24:55 +0200 Subject: tcp: Allow signalling end of reading/writing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tcp_shutdown() isn't needed at the moment, but is added for consistency to explain how the function is supposed to be used. Signed-off-by: Martin Storsjö --- libavformat/os_support.h | 6 ++++++ libavformat/tcp.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/libavformat/os_support.h b/libavformat/os_support.h index 20c6d73738..1088c6c31c 100644 --- a/libavformat/os_support.h +++ b/libavformat/os_support.h @@ -45,6 +45,12 @@ static inline int is_dos_path(const char *path) return 0; } +#if defined(_WIN32) +#define SHUT_RD SD_RECEIVE +#define SHUT_WR SD_SEND +#define SHUT_RDWR SD_BOTH +#endif + #if defined(_WIN32) && !defined(__MINGW32CE__) int ff_win32_open(const char *filename, int oflag, int pmode); #define open ff_win32_open diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 0ed11f321f..37f74f6e2f 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -182,6 +182,22 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size) return ret < 0 ? ff_neterrno() : ret; } +static int tcp_shutdown(URLContext *h, int flags) +{ + TCPContext *s = h->priv_data; + int how; + + if (flags & AVIO_FLAG_WRITE && flags & AVIO_FLAG_READ) { + how = SHUT_RDWR; + } else if (flags & AVIO_FLAG_WRITE) { + how = SHUT_WR; + } else { + how = SHUT_RD; + } + + return shutdown(s->fd, how); +} + static int tcp_close(URLContext *h) { TCPContext *s = h->priv_data; @@ -202,6 +218,7 @@ URLProtocol ff_tcp_protocol = { .url_write = tcp_write, .url_close = tcp_close, .url_get_file_handle = tcp_get_file_handle, + .url_shutdown = tcp_shutdown, .priv_data_size = sizeof(TCPContext), .flags = URL_PROTOCOL_FLAG_NETWORK, }; -- cgit v1.2.3 From ba354a8cc091039662e50f1a5a194f5b589056f6 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 21 May 2012 11:26:40 +0200 Subject: http: Add http_shutdown() for ending writing of posts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/http.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index ea7c693b34..124f533a1f 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -51,6 +51,7 @@ typedef struct { char *headers; int willclose; /**< Set if the server correctly handles Connection: close and will close the connection after feeding us the content. */ int chunked_post; + int end_chunked_post; /**< A flag which indicates if the end of chunked encoding has been sent. */ } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) @@ -415,6 +416,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, s->off = 0; s->filesize = -1; s->willclose = 0; + s->end_chunked_post = 0; if (post) { /* Pretend that it did work. We didn't read any header yet, since * we've still to send the POST data, but the code calling this @@ -512,16 +514,30 @@ static int http_write(URLContext *h, const uint8_t *buf, int size) return size; } -static int http_close(URLContext *h) +static int http_shutdown(URLContext *h, int flags) { int ret = 0; char footer[] = "0\r\n\r\n"; HTTPContext *s = h->priv_data; /* signal end of chunked encoding if used */ - if ((h->flags & AVIO_FLAG_WRITE) && s->chunked_post) { + if ((flags & AVIO_FLAG_WRITE) && s->chunked_post) { ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); ret = ret > 0 ? 0 : ret; + s->end_chunked_post = 1; + } + + return ret; +} + +static int http_close(URLContext *h) +{ + int ret = 0; + HTTPContext *s = h->priv_data; + + if (!s->end_chunked_post) { + /* Close the write direction by sending the end of chunked encoding. */ + ret = http_shutdown(h, h->flags); } if (s->hd) @@ -581,6 +597,7 @@ URLProtocol ff_http_protocol = { .url_seek = http_seek, .url_close = http_close, .url_get_file_handle = http_get_file_handle, + .url_shutdown = http_shutdown, .priv_data_size = sizeof(HTTPContext), .priv_data_class = &http_context_class, .flags = URL_PROTOCOL_FLAG_NETWORK, -- cgit v1.2.3 From e5773d8bc372a88b28452efa5fc87711f673bd28 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 21 May 2012 11:27:10 +0200 Subject: http: Add support for reading http POST reply headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/http.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 124f533a1f..f978dc17af 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -52,6 +52,7 @@ typedef struct { int willclose; /**< Set if the server correctly handles Connection: close and will close the connection after feeding us the content. */ int chunked_post; int end_chunked_post; /**< A flag which indicates if the end of chunked encoding has been sent. */ + int end_header; /**< A flag which indicates we have finished to read POST reply. */ } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) @@ -249,8 +250,10 @@ static int process_line(URLContext *h, char *line, int line_count, char *tag, *p, *end; /* end of header */ - if (line[0] == '\0') + if (line[0] == '\0') { + s->end_header = 1; return 0; + } p = line; if (line_count == 0) { @@ -462,6 +465,17 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int size) static int http_read(URLContext *h, uint8_t *buf, int size) { HTTPContext *s = h->priv_data; + int err, new_location; + + if (s->end_chunked_post) { + if (!s->end_header) { + err = http_read_header(h, &new_location); + if (err < 0) + return err; + } + + return http_buf_read(h, buf, size); + } if (s->chunksize >= 0) { if (!s->chunksize) { -- cgit v1.2.3 From 3f9d6e423978f5e905def374e9c2e9166e3ebb2c Mon Sep 17 00:00:00 2001 From: Dave Yeo Date: Wed, 23 May 2012 13:34:13 -0700 Subject: os_support: Define SHUT_RD, SHUT_WR and SHUT_RDWR on OS/2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/os_support.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavformat/os_support.h b/libavformat/os_support.h index 1088c6c31c..3db20a9aa8 100644 --- a/libavformat/os_support.h +++ b/libavformat/os_support.h @@ -45,6 +45,12 @@ static inline int is_dos_path(const char *path) return 0; } +#if defined(__OS2__) +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 +#endif + #if defined(_WIN32) #define SHUT_RD SD_RECEIVE #define SHUT_WR SD_SEND -- cgit v1.2.3