aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-05-23 21:41:13 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-05-23 21:48:31 +0200
commitd0ad91c258821708ce21b4ae53018922ef1f5614 (patch)
tree95332c7c22137cedd30a84bcc51cf6924ee2d631
parentd0f78e77e1cde44532d613525a4f521e8effe3ed (diff)
parent3f9d6e423978f5e905def374e9c2e9166e3ebb2c (diff)
downloadffmpeg-d0ad91c258821708ce21b4ae53018922ef1f5614.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: os_support: Define SHUT_RD, SHUT_WR and SHUT_RDWR on OS/2 http: Add support for reading http POST reply headers http: Add http_shutdown() for ending writing of posts tcp: Allow signalling end of reading/writing avio: Add a function for signalling end of reading/writing lavfi: fix comment, audio is supported now. lavfi: fix incorrect comment. lavfi: remove avfilter_null_* from public API on next bump. lavfi: remove avfilter_default_* from public API on next bump. lavfi: deprecate default config_props() callback and refactor avfilter_config_links() avfiltergraph: smarter sample format selection. avconv: rename transcode_audio/video to decode_audio/video. asyncts: reset delta to 0 when it's not used. x86: lavc: use %if HAVE_AVX guards around AVX functions in yasm code. dwt: return errors from ff_slice_buffer_init() Conflicts: ffmpeg.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/formats.c libavfilter/version.h libavfilter/vf_blackframe.c libavfilter/vf_drawtext.c libavfilter/vf_fade.c libavfilter/vf_format.c libavfilter/vf_showinfo.c libavfilter/video.c libavfilter/video.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--ffmpeg.c8
-rw-r--r--libavcodec/dwt.c7
-rw-r--r--libavcodec/dwt.h6
-rw-r--r--libavcodec/snowdec.c7
-rw-r--r--libavcodec/x86/dsputil_yasm.asm6
-rw-r--r--libavfilter/af_asyncts.c11
-rw-r--r--libavfilter/avfilter.c2
-rw-r--r--libavfilter/avfilter.h24
-rw-r--r--libavfilter/avfiltergraph.c73
-rw-r--r--libavfilter/formats.c9
-rw-r--r--libavfilter/formats.h2
-rw-r--r--libavfilter/split.c3
-rw-r--r--libavfilter/version.h6
-rw-r--r--libavfilter/vf_aspect.c9
-rw-r--r--libavfilter/vf_blackframe.c3
-rw-r--r--libavfilter/vf_copy.c7
-rw-r--r--libavfilter/vf_crop.c3
-rw-r--r--libavfilter/vf_cropdetect.c5
-rw-r--r--libavfilter/vf_delogo.c3
-rw-r--r--libavfilter/vf_drawbox.c7
-rw-r--r--libavfilter/vf_drawtext.c5
-rw-r--r--libavfilter/vf_fade.c5
-rw-r--r--libavfilter/vf_fifo.c3
-rw-r--r--libavfilter/vf_format.c17
-rw-r--r--libavfilter/vf_null.c7
-rw-r--r--libavfilter/vf_select.c3
-rw-r--r--libavfilter/vf_setpts.c3
-rw-r--r--libavfilter/vf_settb.c5
-rw-r--r--libavfilter/vf_showinfo.c3
-rw-r--r--libavfilter/vf_slicify.c5
-rw-r--r--libavfilter/vf_vflip.c3
-rw-r--r--libavfilter/vf_yadif.c3
-rw-r--r--libavfilter/video.c59
-rw-r--r--libavfilter/video.h34
-rw-r--r--libavformat/avio.c7
-rw-r--r--libavformat/http.c37
-rw-r--r--libavformat/os_support.h12
-rw-r--r--libavformat/tcp.c17
-rw-r--r--libavformat/url.h13
-rw-r--r--tools/lavfi-showfiltfmts.c3
40 files changed, 361 insertions, 84 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 8f3ffb5de6..51cd587198 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2538,7 +2538,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;
@@ -2639,7 +2639,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;
@@ -2824,10 +2824,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) {
duration = av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q);
} else if(ist->st->codec->time_base.num != 0 && ist->st->codec->time_base.den != 0) {
diff --git a/libavcodec/dwt.c b/libavcodec/dwt.c
index 748bd40f32..6c1f1310a3 100644
--- a/libavcodec/dwt.c
+++ b/libavcodec/dwt.c
@@ -24,9 +24,9 @@
#include "dwt.h"
#include "libavcodec/x86/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;
@@ -55,6 +55,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 c5a5874224..aa7d98dc28 100644
--- a/libavcodec/dwt.h
+++ b/libavcodec/dwt.h
@@ -228,9 +228,9 @@ void ff_spatial_idwt_slice2(DWTContext *d, int y);
: 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 413a4768e1..0db7ba5e92 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];
diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm
index b7af38146f..9e598b2a9c 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,
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) {
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index c6a8594514..9473c355fe 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -202,7 +202,6 @@ int avfilter_config_links(AVFilterContext *filter)
link->sample_aspect_ratio = inlink ?
inlink->sample_aspect_ratio : (AVRational){1,1};
-#if 1
if (inlink) {
if (!link->w)
link->w = inlink->w;
@@ -233,7 +232,6 @@ int avfilter_config_links(AVFilterContext *filter)
link->time_base = (AVRational) {1, link->sample_rate};
}
-#endif
if ((config_link = link->dstpad->config_props))
if ((ret = config_link(link)) < 0)
return ret;
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 758d8a8541..c9d63d65f7 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -383,7 +383,7 @@ struct AVFilterPad {
const char *name;
/**
- * AVFilterPad type. Can be AVMEDIA_TYPE_VIDEO or AVMEDIA_TYPE_AUDIO.
+ * AVFilterPad type.
*/
enum AVMediaType type;
@@ -465,7 +465,7 @@ struct AVFilterPad {
*
* Defaults to just calling the source poll_frame() method.
*
- * Output video pads only.
+ * Output pads only.
*/
int (*poll_frame)(AVFilterLink *link);
@@ -476,7 +476,7 @@ struct AVFilterPad {
* See avfilter_request_frame() for the error codes with a specific
* meaning.
*
- * Output video pads only.
+ * Output pads only.
*/
int (*request_frame)(AVFilterLink *link);
@@ -500,19 +500,28 @@ 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);
/** 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
/**
* Helpers for query_formats() which set all links to the same list of
@@ -527,21 +536,24 @@ void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *
void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats);
#endif
-/** Default handler for query_formats() */
-int avfilter_default_query_formats(AVFilterContext *ctx);
-
+#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/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 9743009eb5..8d2312e05d 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -227,7 +227,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 */
@@ -571,6 +571,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;
@@ -633,8 +701,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);
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index d0ff717d85..9e15024237 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -449,7 +449,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 :
@@ -534,6 +534,12 @@ int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx)
return 0;
}
+#if FF_API_FILTERS_PUBLIC
+int avfilter_default_query_formats(AVFilterContext *ctx)
+{
+ return ff_default_query_formats(ctx);
+}
+#endif
#ifdef TEST
#undef printf
@@ -552,4 +558,3 @@ int main(void)
}
#endif
-
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index 7b0eab5dea..c7503d649a 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -78,4 +78,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/split.c b/libavfilter/split.c
index ec34eedb91..97e5265a30 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 = (const 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/version.h b/libavfilter/version.h
index 7ae29ec36e..7d7a5873c4 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -56,5 +56,11 @@
#ifndef FF_API_PACKING
#define FF_API_PACKING (LIBAVFILTER_VERSION_MAJOR < 3)
#endif
+#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_aspect.c b/libavfilter/vf_aspect.c
index 8a56116471..685c96f2d2 100644
--- a/libavfilter/vf_aspect.c
+++ b/libavfilter/vf_aspect.c
@@ -26,6 +26,7 @@
#include "libavutil/mathematics.h"
#include "libavutil/parseutils.h"
#include "avfilter.h"
+#include "video.h"
typedef struct {
AVRational ratio;
@@ -86,9 +87,9 @@ AVFilter avfilter_vf_setdar = {
.inputs = (const 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 = (const AVFilterPad[]) {{ .name = "default",
@@ -118,9 +119,9 @@ AVFilter avfilter_vf_setsar = {
.inputs = (const 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 = (const AVFilterPad[]) {{ .name = "default",
diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c
index 7e80fd7e46..c54a8e1b45 100644
--- a/libavfilter/vf_blackframe.c
+++ b/libavfilter/vf_blackframe.c
@@ -29,6 +29,7 @@
#include "avfilter.h"
#include "internal.h"
+#include "video.h"
typedef struct {
unsigned int bamount; ///< black amount
@@ -127,7 +128,7 @@ AVFilter avfilter_vf_blackframe = {
.inputs = (const AVFilterPad[]) {{ .name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.draw_slice = draw_slice,
- .get_video_buffer = avfilter_null_get_video_buffer,
+ .get_video_buffer = ff_null_get_video_buffer,
.start_frame = ff_null_start_frame_keep_ref,
.end_frame = end_frame, },
{ .name = NULL}},
diff --git a/libavfilter/vf_copy.c b/libavfilter/vf_copy.c
index d253906786..8f128efc5b 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 = (const 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 = (const AVFilterPad[]) {{ .name = "default",
diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 5015c74dc7..b8cfd440aa 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"
@@ -352,7 +353,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 = (const AVFilterPad[]) {{ .name = "default",
diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index 36e6556888..19e6e8d375 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 = (const 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 fbc5bf6c0c..ffef1c7155 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
@@ -275,7 +276,7 @@ AVFilter avfilter_vf_delogo = {
.inputs = (const 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 4d9bae467e..c23406ad0a 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 = (const 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 59f6f00191..898bbd40c4 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
@@ -830,8 +831,8 @@ AVFilter avfilter_vf_drawtext = {
.inputs = (const 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,
.draw_slice = null_draw_slice,
.end_frame = end_frame,
.config_props = config_input,
diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index 27f5badbf0..a38387f184 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -32,6 +32,7 @@
#include "avfilter.h"
#include "drawutils.h"
#include "internal.h"
+#include "video.h"
#define R 0
#define G 1
@@ -288,8 +289,8 @@ AVFilter avfilter_vf_fade = {
.inputs = (const 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 06018116ed..91e4b9d111 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 = (const 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 cbcc24bfba..d8b3a40a7d 100644
--- a/libavfilter/vf_format.c
+++ b/libavfilter/vf_format.c
@@ -26,6 +26,7 @@
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "internal.h"
+#include "video.h"
typedef struct {
/**
@@ -102,10 +103,10 @@ AVFilter avfilter_vf_format = {
.inputs = (const 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 = (const AVFilterPad[]) {{ .name = "default",
.type = AVMEDIA_TYPE_VIDEO },
@@ -132,10 +133,10 @@ AVFilter avfilter_vf_noformat = {
.inputs = (const 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 = (const AVFilterPad[]) {{ .name = "default",
.type = AVMEDIA_TYPE_VIDEO },
diff --git a/libavfilter/vf_null.c b/libavfilter/vf_null.c
index 5718ee0c1d..b98f3efc64 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 = (const 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 = (const AVFilterPad[]) {{ .name = "default",
diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c
index 2ffa496788..d3f649cbff 100644
--- a/libavfilter/vf_select.c
+++ b/libavfilter/vf_select.c
@@ -26,6 +26,7 @@
#include "libavutil/eval.h"
#include "libavutil/fifo.h"
#include "avfilter.h"
+#include "video.h"
static const char *const var_names[] = {
"TB", ///< timebase
@@ -326,7 +327,7 @@ AVFilter avfilter_vf_select = {
.inputs = (const 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 57b97bb9bd..9a5170037f 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[] = {
"INTERLACED", ///< tell if the current frame is interlaced
@@ -139,7 +140,7 @@ AVFilter avfilter_vf_setpts = {
.inputs = (const 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 84bebd6e35..00b735cdf7 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[] = {
"AVTB", /* default timebase 1/AV_TIME_BASE */
@@ -121,9 +122,9 @@ AVFilter avfilter_vf_settb = {
.inputs = (const 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 = (const AVFilterPad[]) {{ .name = "default",
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index ece6230877..d14d99b1f1 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -28,6 +28,7 @@
#include "libavutil/timestamp.h"
#include "avfilter.h"
#include "internal.h"
+#include "video.h"
typedef struct {
unsigned int frame;
@@ -93,7 +94,7 @@ AVFilter avfilter_vf_showinfo = {
.inputs = (const 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 = ff_null_start_frame_keep_ref,
.end_frame = end_frame,
.min_perms = AV_PERM_READ, },
diff --git a/libavfilter/vf_slicify.c b/libavfilter/vf_slicify.c
index 0c2f5a66fe..f496bfd9b6 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 = (const 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 = (const AVFilterPad[]) {{ .name = "default",
.type = AVMEDIA_TYPE_VIDEO, },
diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c
index b01d9f5f10..24288e6966 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 d7fa98acc4..19b699b584 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -22,6 +22,7 @@
#include "libavutil/common.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
+#include "video.h"
#include "yadif.h"
#undef NDEBUG
@@ -179,7 +180,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 6dbc8cb4cf..5c750ff96a 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -20,6 +20,7 @@
#include "avfilter.h"
#include "internal.h"
+#include "video.h"
static char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms)
{
@@ -61,12 +62,12 @@ 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);
}
-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];
@@ -174,7 +175,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;
@@ -184,12 +185,12 @@ 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);
}
-void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
+static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
AVFilterLink *outlink = NULL;
@@ -215,7 +216,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;
@@ -246,12 +247,12 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
ff_update_link_current_pts(link, link->cur_buf->pts);
}
-void avfilter_null_end_frame(AVFilterLink *link)
+void ff_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;
@@ -275,7 +276,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);
@@ -287,12 +288,12 @@ 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);
}
-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;
@@ -340,7 +341,41 @@ 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);
+}
+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
new file mode 100644
index 0000000000..d4c31a0ba1
--- /dev/null
+++ b/libavfilter/video.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007 Bobby Bingham
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; 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);
+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 */
diff --git a/libavformat/avio.c b/libavformat/avio.c
index e732d1ad4a..c7b7bc67d5 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -376,6 +376,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/http.c b/libavformat/http.c
index 7a45fa233c..40c06d6083 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -52,6 +52,8 @@ 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. */
+ int end_header; /**< A flag which indicates we have finished to read POST reply. */
} HTTPContext;
#define OFFSET(x) offsetof(HTTPContext, x)
@@ -251,8 +253,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) {
@@ -419,6 +423,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
@@ -464,6 +469,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) {
@@ -516,16 +532,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)
@@ -585,6 +615,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,
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 159d4d7f85..bf2698405b 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -48,6 +48,18 @@ 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
+#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 fa88467164..db8dba2630 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,
};
diff --git a/libavformat/url.h b/libavformat/url.h
index dc483a3ea9..6ad754e19f 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;
@@ -201,6 +202,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.
*
* @param size the size of the URLProtocol struct referenced
diff --git a/tools/lavfi-showfiltfmts.c b/tools/lavfi-showfiltfmts.c
index 6d09cc122c..9de5a2918f 100644
--- a/tools/lavfi-showfiltfmts.c
+++ b/tools/lavfi-showfiltfmts.c
@@ -22,6 +22,7 @@
#include "libavutil/pixdesc.h"
#include "libavutil/samplefmt.h"
#include "libavfilter/avfilter.h"
+#include "libavfilter/formats.h"
static void print_formats(AVFilterContext *filter_ctx)
{
@@ -114,7 +115,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_formats(filter_ctx);