From 4a49d2d59cce5d10b8ac40ca0185ccf1f8deb99c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 2 Apr 2011 13:18:00 +0200 Subject: lavc: mark mb_qmin/mb_qmax for removal on next major bump. They've been unused and deprecated for about five years. --- libavcodec/avcodec.h | 6 ++++-- libavcodec/options.c | 2 ++ libavcodec/version.h | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 83e0e56555..eb355b0b33 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1818,19 +1818,21 @@ typedef struct AVCodecContext { */ uint64_t error[4]; +#if FF_API_MB_Q /** * minimum MB quantizer * - encoding: unused * - decoding: unused */ - int mb_qmin; + attribute_deprecated int mb_qmin; /** * maximum MB quantizer * - encoding: unused * - decoding: unused */ - int mb_qmax; + attribute_deprecated int mb_qmax; +#endif /** * motion estimation comparison function diff --git a/libavcodec/options.c b/libavcodec/options.c index fb7d371607..e1188cdeb5 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -259,8 +259,10 @@ static const AVOption options[]={ {"pf", "forward predicted MVs of P-frames", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_P_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"}, {"bf", "forward predicted MVs of B-frames", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"}, {"bb", "backward predicted MVs of B-frames", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_BACK, INT_MIN, INT_MAX, V|D, "debug_mv"}, +#if FF_API_MB_Q {"mb_qmin", "obsolete, use qmin", OFFSET(mb_qmin), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, {"mb_qmax", "obsolete, use qmax", OFFSET(mb_qmax), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, +#endif {"cmp", "full pel me compare function", OFFSET(me_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"}, {"subcmp", "sub pel me compare function", OFFSET(me_sub_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"}, {"mbcmp", "macroblock compare function", OFFSET(mb_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 9d211b90fe..a0e19754a7 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -77,5 +77,8 @@ #ifndef FF_API_RATE_EMU #define FF_API_RATE_EMU (LIBAVCODEC_VERSION_MAJOR < 53) #endif +#ifndef FF_API_MB_Q +#define FF_API_MB_Q (LIBAVCODEC_VERSION_MAJOR < 53) +#endif #endif /* AVCODEC_VERSION_H */ -- cgit v1.2.3 From 4e3945fd2875c497d25f49a3c35cd6cf6577259e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 2 Apr 2011 13:34:12 +0200 Subject: lavc: deprecate AVCodecContext.antialias_algo It's been unused since mp3float decoder was added. --- libavcodec/avcodec.h | 5 ++++- libavcodec/options.c | 2 ++ libavcodec/version.h | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index eb355b0b33..95a933dcfc 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2153,16 +2153,19 @@ typedef struct AVCodecContext { */ int error_rate; +#if FF_API_ANTIALIAS_ALGO /** * MP3 antialias algorithm, see FF_AA_* below. * - encoding: unused * - decoding: Set by user. */ - int antialias_algo; + attribute_deprecated int antialias_algo; #define FF_AA_AUTO 0 #define FF_AA_FASTINT 1 //not implemented yet #define FF_AA_INT 2 #define FF_AA_FLOAT 3 +#endif + /** * quantizer noise shaping * - encoding: Set by user. diff --git a/libavcodec/options.c b/libavcodec/options.c index e1188cdeb5..ae8abb2674 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -319,7 +319,9 @@ static const AVOption options[]={ {"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, {"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP|CODEC_FLAG2_BIT_RESERVOIR|CODEC_FLAG2_PSY|CODEC_FLAG2_MBTREE, 0, UINT_MAX, V|A|E|D, "flags2"}, {"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, +#if FF_API_ANTIALIAS_ALGO {"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"}, +#endif {"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_AUTO, INT_MIN, INT_MAX, V|D, "aa"}, {"fastint", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_FASTINT, INT_MIN, INT_MAX, V|D, "aa"}, {"int", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_INT, INT_MIN, INT_MAX, V|D, "aa"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index a0e19754a7..b93e7534bb 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -80,5 +80,8 @@ #ifndef FF_API_MB_Q #define FF_API_MB_Q (LIBAVCODEC_VERSION_MAJOR < 53) #endif +#ifndef FF_API_ANTIALIAS_ALGO +#define FF_API_ANTIALIAS_ALGO (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ -- cgit v1.2.3 From 233ed6b314ee6b8d37d16a958f1bc309ae667393 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 18 Feb 2011 19:10:33 +0100 Subject: Change yadif to not use out of picture lines. Fixes issue2272. Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- libavfilter/vf_yadif.c | 31 ++++++++++++++++--------------- libavfilter/x86/yadif_template.c | 6 +++--- libavfilter/yadif.h | 6 +++--- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index e12a3c31b7..176349a5c4 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -50,42 +50,42 @@ typedef struct { AVFilterBufferRef *out; void (*filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, - int w, int refs, int parity, int mode); + int w, int prefs, int mrefs, int parity, int mode); } YADIFContext; static void filter_line_c(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, - int w, int refs, int parity, int mode) + int w, int prefs, int mrefs, int parity, int mode) { int x; uint8_t *prev2 = parity ? prev : cur ; uint8_t *next2 = parity ? cur : next; for (x = 0; x < w; x++) { - int c = cur[-refs]; + int c = cur[mrefs]; int d = (prev2[0] + next2[0])>>1; - int e = cur[+refs]; + int e = cur[prefs]; int temporal_diff0 = FFABS(prev2[0] - next2[0]); - int temporal_diff1 =(FFABS(prev[-refs] - c) + FFABS(prev[+refs] - e) )>>1; - int temporal_diff2 =(FFABS(next[-refs] - c) + FFABS(next[+refs] - e) )>>1; + int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; + int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; int diff = FFMAX3(temporal_diff0>>1, temporal_diff1, temporal_diff2); int spatial_pred = (c+e)>>1; - int spatial_score = FFABS(cur[-refs-1] - cur[+refs-1]) + FFABS(c-e) - + FFABS(cur[-refs+1] - cur[+refs+1]) - 1; + int spatial_score = FFABS(cur[mrefs-1] - cur[prefs-1]) + FFABS(c-e) + + FFABS(cur[mrefs+1] - cur[prefs+1]) - 1; #define CHECK(j)\ - { int score = FFABS(cur[-refs-1+(j)] - cur[+refs-1-(j)])\ - + FFABS(cur[-refs +(j)] - cur[+refs -(j)])\ - + FFABS(cur[-refs+1+(j)] - cur[+refs+1-(j)]);\ + { int score = FFABS(cur[mrefs-1+(j)] - cur[prefs-1-(j)])\ + + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\ + + FFABS(cur[mrefs+1+(j)] - cur[prefs+1-(j)]);\ if (score < spatial_score) {\ spatial_score= score;\ - spatial_pred= (cur[-refs +(j)] + cur[+refs -(j)])>>1;\ + spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\ CHECK(-1) CHECK(-2) }} }} CHECK( 1) CHECK( 2) }} }} if (mode < 2) { - int b = (prev2[-2*refs] + next2[-2*refs])>>1; - int f = (prev2[+2*refs] + next2[+2*refs])>>1; + int b = (prev2[2*mrefs] + next2[2*mrefs])>>1; + int f = (prev2[2*prefs] + next2[2*prefs])>>1; #if 0 int a = cur[-3*refs]; int g = cur[+3*refs]; @@ -133,7 +133,8 @@ static void filter(AVFilterContext *ctx, AVFilterBufferRef *dstpic, uint8_t *cur = &yadif->cur ->data[i][y*refs]; uint8_t *next = &yadif->next->data[i][y*refs]; uint8_t *dst = &dstpic->data[i][y*dstpic->linesize[i]]; - yadif->filter_line(dst, prev, cur, next, w, refs, parity ^ tff, yadif->mode); + int mode = y==1 || y+2==h ? 2 : yadif->mode; + yadif->filter_line(dst, prev, cur, next, w, y+1data[i][y*dstpic->linesize[i]], &yadif->cur->data[i][y*refs], w); diff --git a/libavfilter/x86/yadif_template.c b/libavfilter/x86/yadif_template.c index 524048e77d..962a7c777d 100644 --- a/libavfilter/x86/yadif_template.c +++ b/libavfilter/x86/yadif_template.c @@ -105,7 +105,7 @@ void RENAME(ff_yadif_filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, - int w, int refs, int parity, int mode) + int w, int prefs, int mrefs, int parity, int mode) { DECLARE_ALIGNED(16, uint8_t, tmp0[16]); DECLARE_ALIGNED(16, uint8_t, tmp1[16]); @@ -226,8 +226,8 @@ void RENAME(ff_yadif_filter_line)(uint8_t *dst, :[prev] "r"(prev),\ [cur] "r"(cur),\ [next] "r"(next),\ - [prefs]"r"((x86_reg)refs),\ - [mrefs]"r"((x86_reg)-refs),\ + [prefs]"r"((x86_reg)prefs),\ + [mrefs]"r"((x86_reg)mrefs),\ [mode] "g"(mode)\ );\ __asm__ volatile(MOV" "MM"1, %0" :"=m"(*dst));\ diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h index 2212a0793c..d658b683d7 100644 --- a/libavfilter/yadif.h +++ b/libavfilter/yadif.h @@ -23,14 +23,14 @@ void ff_yadif_filter_line_mmx(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, - int w, int refs, int parity, int mode); + int w, int prefs, int mrefs, int parity, int mode); void ff_yadif_filter_line_sse2(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, - int w, int refs, int parity, int mode); + int w, int prefs, int mrefs, int parity, int mode); void ff_yadif_filter_line_ssse3(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, - int w, int refs, int parity, int mode); + int w, int prefs, int mrefs, int parity, int mode); #endif /* AVFILTER_YADIF_H */ -- cgit v1.2.3 From aadfc9ee747eeb37f9ea77c0cc56a88226b9d21b Mon Sep 17 00:00:00 2001 From: Brandon Mintern Date: Mon, 21 Feb 2011 12:02:57 +0100 Subject: lavfi: add fade filter Port fade filter from libavfilter soc repo, with minor fixes by Stefano. Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- doc/filters.texi | 33 +++++++++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/avfilter.h | 2 +- libavfilter/vf_fade.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 libavfilter/vf_fade.c diff --git a/doc/filters.texi b/doc/filters.texi index 2bd7bf56ff..872afc6ca1 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -353,6 +353,39 @@ drawbox drawbox=10:20:200:60:red@@0.5" @end example +@section fade + +Apply fade-in/out effect to input video. + +It accepts the parameters: +@var{type}:@var{start_frame}:@var{nb_frames} + +@var{type} specifies if the effect type, can be either "in" for +fade-in, or "out" for a fade-out effect. + +@var{start_frame} specifies the number of the start frame for starting +to apply the fade effect. + +@var{nb_frames} specifies the number of frames for which the fade +effect has to last. At the end of the fade-in effect the output video +will have the same intensity as the input video, at the end of the +fade-out transition the output video will be completely black. + +A few usage examples follow, usable too as test scenarios. +@example +# fade in first 30 frames of video +fade=in:0:30 + +# fade out last 45 frames of a 200-frame video +fade=out:155:45 + +# fade in first 25 frames and fade out last 25 frames of a 1000-frame video +fade=in:0:25, fade=out:975:25 + +# make first 5 frames black, then fade in from frame 5-24 +fade=in:5:20 +@end example + @section fifo Buffer input images and send them when they are requested. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index bbd820238a..f7bc98df98 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -26,6 +26,7 @@ OBJS-$(CONFIG_COPY_FILTER) += vf_copy.o OBJS-$(CONFIG_CROP_FILTER) += vf_crop.o OBJS-$(CONFIG_CROPDETECT_FILTER) += vf_cropdetect.o OBJS-$(CONFIG_DRAWBOX_FILTER) += vf_drawbox.o +OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o OBJS-$(CONFIG_FIFO_FILTER) += vf_fifo.o OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 6afd1d7ec3..34e87f5fd9 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -45,6 +45,7 @@ void avfilter_register_all(void) REGISTER_FILTER (CROP, crop, vf); REGISTER_FILTER (CROPDETECT, cropdetect, vf); REGISTER_FILTER (DRAWBOX, drawbox, vf); + REGISTER_FILTER (FADE, fade, vf); REGISTER_FILTER (FIFO, fifo, vf); REGISTER_FILTER (FORMAT, format, vf); REGISTER_FILTER (FREI0R, frei0r, vf); diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index b4af4859d3..74435813fa 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -26,7 +26,7 @@ #include "libavutil/samplefmt.h" #define LIBAVFILTER_VERSION_MAJOR 1 -#define LIBAVFILTER_VERSION_MINOR 76 +#define LIBAVFILTER_VERSION_MINOR 77 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c new file mode 100644 index 0000000000..203a18656e --- /dev/null +++ b/libavfilter/vf_fade.c @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2010 Brandon Mintern + * 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 + */ + +/** + * @file + * video fade filter + * based heavily on vf_negate.c by Bobby Bingham + */ + +#include "libavutil/pixdesc.h" +#include "avfilter.h" + +typedef struct { + int factor, fade_per_frame; + unsigned int frame_index, start_frame, stop_frame; + int hsub, vsub, bpp; +} FadeContext; + +static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) +{ + FadeContext *fade = ctx->priv; + unsigned int nb_frames; + char in_out[4]; + + if (!args || + sscanf(args, " %3[^:]:%u:%u", in_out, &fade->start_frame, &nb_frames) != 3) { + av_log(ctx, AV_LOG_ERROR, + "Expected 3 arguments '(in|out):#:#':'%s'\n", args); + return AVERROR(EINVAL); + } + + nb_frames = nb_frames ? nb_frames : 1; + fade->fade_per_frame = (1 << 16) / nb_frames; + if (!strcmp(in_out, "in")) + fade->factor = 0; + else if (!strcmp(in_out, "out")) { + fade->fade_per_frame = -fade->fade_per_frame; + fade->factor = (1 << 16); + } else { + av_log(ctx, AV_LOG_ERROR, + "first argument must be 'in' or 'out':'%s'\n", in_out); + return AVERROR(EINVAL); + } + fade->stop_frame = fade->start_frame + nb_frames; + + av_log(ctx, AV_LOG_INFO, + "type:%s start_frame:%d nb_frames:%d\n", + in_out, fade->start_frame, nb_frames); + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + const static enum PixelFormat pix_fmts[] = { + PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, + PIX_FMT_YUV411P, PIX_FMT_YUV410P, + PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P, + PIX_FMT_YUV440P, PIX_FMT_YUVJ440P, + PIX_FMT_RGB24, PIX_FMT_BGR24, + PIX_FMT_NONE + }; + + avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + return 0; +} + +static int config_props(AVFilterLink *inlink) +{ + FadeContext *fade = inlink->dst->priv; + const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[inlink->format]; + + fade->hsub = pixdesc->log2_chroma_w; + fade->vsub = pixdesc->log2_chroma_h; + + fade->bpp = av_get_bits_per_pixel(pixdesc) >> 3; + return 0; +} + +static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) +{ + FadeContext *fade = inlink->dst->priv; + AVFilterBufferRef *outpic = inlink->cur_buf; + uint8_t *p; + int i, j, plane; + + if (fade->factor < 65536) { + /* luma or rgb plane */ + for (i = 0; i < h; i++) { + p = outpic->data[0] + (y+i) * outpic->linesize[0]; + for (j = 0; j < inlink->w * fade->bpp; j++) { + /* fade->factor is using 16 lower-order bits for decimal + * places. 32768 = 1 << 15, it is an integer representation + * of 0.5 and is for rounding. */ + *p = (*p * fade->factor + 32768) >> 16; + p++; + } + } + + if (outpic->data[0] && outpic->data[1]) { + /* chroma planes */ + for (plane = 1; plane < 3; plane++) { + for (i = 0; i < h; i++) { + p = outpic->data[plane] + ((y+i) >> fade->vsub) * outpic->linesize[plane]; + for (j = 0; j < inlink->w >> fade->hsub; j++) { + /* 8421367 = ((128 << 1) + 1) << 15. It is an integer + * representation of 128.5. The .5 is for rounding + * purposes. */ + *p = ((*p - 128) * fade->factor + 8421367) >> 16; + p++; + } + } + } + } + } + + avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); +} + +static void end_frame(AVFilterLink *inlink) +{ + FadeContext *fade = inlink->dst->priv; + + avfilter_end_frame(inlink->dst->outputs[0]); + + if (fade->frame_index >= fade->start_frame && + fade->frame_index <= fade->stop_frame) + fade->factor += fade->fade_per_frame; + fade->factor = av_clip_uint16(fade->factor); + fade->frame_index++; +} + +AVFilter avfilter_vf_fade = { + .name = "fade", + .description = NULL_IF_CONFIG_SMALL("Fade in/out input video"), + .init = init, + .priv_size = sizeof(FadeContext), + .query_formats = query_formats, + + .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, + .draw_slice = draw_slice, + .end_frame = end_frame, + .min_perms = AV_PERM_READ | AV_PERM_WRITE, + .rej_perms = AV_PERM_PRESERVE, }, + { .name = NULL}}, + .outputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, }, + { .name = NULL}}, +}; -- cgit v1.2.3 From 79997def65fd2313b48a5f3c3a884c6149ae9b5d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 21 Mar 2011 18:07:59 +0000 Subject: ac3enc: use generic fixed-point mdct This makes the AC3 encoder use the shared fixed-point MDCT rather than its own implementation. The checksum changes are due to different rounding in the MDCT. Signed-off-by: Mans Rullgard --- libavcodec/ac3enc.c | 26 ++-- libavcodec/ac3enc_fixed.c | 298 +-------------------------------------------- libavcodec/ac3enc_fixed.h | 61 ---------- libavcodec/ac3enc_float.c | 11 -- libavcodec/ac3enc_float.h | 47 ------- tests/ref/acodec/ac3_fixed | 2 +- tests/ref/lavf/rm | 2 +- 7 files changed, 23 insertions(+), 424 deletions(-) delete mode 100644 libavcodec/ac3enc_fixed.h delete mode 100644 libavcodec/ac3enc_float.h diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index a869d7de9d..372f019f64 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -29,6 +29,8 @@ //#define DEBUG //#define ASSERT_LEVEL 2 +#include + #include "libavutil/audioconvert.h" #include "libavutil/avassert.h" #include "libavutil/crc.h" @@ -39,6 +41,7 @@ #include "ac3dsp.h" #include "ac3.h" #include "audioconvert.h" +#include "fft.h" #ifndef CONFIG_AC3ENC_FLOAT @@ -55,16 +58,22 @@ #define AC3_REMATRIXING_NONE 1 #define AC3_REMATRIXING_ALWAYS 3 -/** Scale a float value by 2^bits and convert to an integer. */ -#define SCALE_FLOAT(a, bits) lrintf((a) * (float)(1 << (bits))) - - #if CONFIG_AC3ENC_FLOAT -#include "ac3enc_float.h" +#define MAC_COEF(d,a,b) ((d)+=(a)*(b)) +typedef float SampleType; +typedef float CoefType; +typedef float CoefSumType; #else -#include "ac3enc_fixed.h" +#define MAC_COEF(d,a,b) MAC64(d,a,b) +typedef int16_t SampleType; +typedef int32_t CoefType; +typedef int64_t CoefSumType; #endif +typedef struct AC3MDCTContext { + const SampleType *window; ///< MDCT window function + FFTContext fft; ///< FFT context for MDCT calculation +} AC3MDCTContext; /** * Encoding Options used by AVOption. @@ -279,8 +288,6 @@ static av_cold void mdct_end(AC3MDCTContext *mdct); static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits); -static void mdct512(AC3MDCTContext *mdct, CoefType *out, SampleType *in); - static void apply_window(DSPContext *dsp, SampleType *output, const SampleType *input, const SampleType *window, unsigned int len); @@ -386,7 +393,8 @@ static void apply_mdct(AC3EncodeContext *s) block->coeff_shift[ch] = normalize_samples(s); - mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples); + s->mdct.fft.mdct_calcw(&s->mdct.fft, block->mdct_coef[ch], + s->windowed_samples); } } } diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index 967c7f0805..720d87d5d7 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -26,54 +26,17 @@ * fixed-point AC-3 encoder. */ +#define CONFIG_FFT_FLOAT 0 #undef CONFIG_AC3ENC_FLOAT #include "ac3enc.c" -/** Scale a float value by 2^15, convert to an integer, and clip to range -32767..32767. */ -#define FIX15(a) av_clip(SCALE_FLOAT(a, 15), -32767, 32767) - - /** * Finalize MDCT and free allocated memory. */ static av_cold void mdct_end(AC3MDCTContext *mdct) { - mdct->nbits = 0; - av_freep(&mdct->costab); - av_freep(&mdct->sintab); - av_freep(&mdct->xcos1); - av_freep(&mdct->xsin1); - av_freep(&mdct->rot_tmp); - av_freep(&mdct->cplx_tmp); -} - - -/** - * Initialize FFT tables. - * @param ln log2(FFT size) - */ -static av_cold int fft_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int ln) -{ - int i, n, n2; - float alpha; - - n = 1 << ln; - n2 = n >> 1; - - FF_ALLOC_OR_GOTO(avctx, mdct->costab, n2 * sizeof(*mdct->costab), fft_alloc_fail); - FF_ALLOC_OR_GOTO(avctx, mdct->sintab, n2 * sizeof(*mdct->sintab), fft_alloc_fail); - - for (i = 0; i < n2; i++) { - alpha = 2.0 * M_PI * i / n; - mdct->costab[i] = FIX15(cos(alpha)); - mdct->sintab[i] = FIX15(sin(alpha)); - } - - return 0; -fft_alloc_fail: - mdct_end(mdct); - return AVERROR(ENOMEM); + ff_fft_end(&mdct->fft); } @@ -84,167 +47,9 @@ fft_alloc_fail: static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits) { - int i, n, n4, ret; - - n = 1 << nbits; - n4 = n >> 2; - - mdct->nbits = nbits; - - ret = fft_init(avctx, mdct, nbits - 2); - if (ret) - return ret; - + int ret = ff_mdct_init(&mdct->fft, nbits, 0, 1.0); mdct->window = ff_ac3_window; - - FF_ALLOC_OR_GOTO(avctx, mdct->xcos1, n4 * sizeof(*mdct->xcos1), mdct_alloc_fail); - FF_ALLOC_OR_GOTO(avctx, mdct->xsin1, n4 * sizeof(*mdct->xsin1), mdct_alloc_fail); - FF_ALLOC_OR_GOTO(avctx, mdct->rot_tmp, n * sizeof(*mdct->rot_tmp), mdct_alloc_fail); - FF_ALLOC_OR_GOTO(avctx, mdct->cplx_tmp, n4 * sizeof(*mdct->cplx_tmp), mdct_alloc_fail); - - for (i = 0; i < n4; i++) { - float alpha = 2.0 * M_PI * (i + 1.0 / 8.0) / n; - mdct->xcos1[i] = FIX15(-cos(alpha)); - mdct->xsin1[i] = FIX15(-sin(alpha)); - } - - return 0; -mdct_alloc_fail: - mdct_end(mdct); - return AVERROR(ENOMEM); -} - - -/** Butterfly op */ -#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \ -{ \ - int ax, ay, bx, by; \ - bx = pre1; \ - by = pim1; \ - ax = qre1; \ - ay = qim1; \ - pre = (bx + ax) >> 1; \ - pim = (by + ay) >> 1; \ - qre = (bx - ax) >> 1; \ - qim = (by - ay) >> 1; \ -} - - -/** Complex multiply */ -#define CMUL(pre, pim, are, aim, bre, bim, rshift) \ -{ \ - pre = (MUL16(are, bre) - MUL16(aim, bim)) >> rshift; \ - pim = (MUL16(are, bim) + MUL16(bre, aim)) >> rshift; \ -} - - -/** - * Calculate a 2^n point complex FFT on 2^ln points. - * @param z complex input/output samples - * @param ln log2(FFT size) - */ -static void fft(AC3MDCTContext *mdct, IComplex *z, int ln) -{ - int j, l, np, np2; - int nblocks, nloops; - register IComplex *p,*q; - int tmp_re, tmp_im; - - np = 1 << ln; - - /* reverse */ - for (j = 0; j < np; j++) { - int k = av_reverse[j] >> (8 - ln); - if (k < j) - FFSWAP(IComplex, z[k], z[j]); - } - - /* pass 0 */ - - p = &z[0]; - j = np >> 1; - do { - BF(p[0].re, p[0].im, p[1].re, p[1].im, - p[0].re, p[0].im, p[1].re, p[1].im); - p += 2; - } while (--j); - - /* pass 1 */ - - p = &z[0]; - j = np >> 2; - do { - BF(p[0].re, p[0].im, p[2].re, p[2].im, - p[0].re, p[0].im, p[2].re, p[2].im); - BF(p[1].re, p[1].im, p[3].re, p[3].im, - p[1].re, p[1].im, p[3].im, -p[3].re); - p+=4; - } while (--j); - - /* pass 2 .. ln-1 */ - - nblocks = np >> 3; - nloops = 1 << 2; - np2 = np >> 1; - do { - p = z; - q = z + nloops; - for (j = 0; j < nblocks; j++) { - BF(p->re, p->im, q->re, q->im, - p->re, p->im, q->re, q->im); - p++; - q++; - for(l = nblocks; l < np2; l += nblocks) { - CMUL(tmp_re, tmp_im, mdct->costab[l], -mdct->sintab[l], q->re, q->im, 15); - BF(p->re, p->im, q->re, q->im, - p->re, p->im, tmp_re, tmp_im); - p++; - q++; - } - p += nloops; - q += nloops; - } - nblocks = nblocks >> 1; - nloops = nloops << 1; - } while (nblocks); -} - - -/** - * Calculate a 512-point MDCT - * @param out 256 output frequency coefficients - * @param in 512 windowed input audio samples - */ -static void mdct512(AC3MDCTContext *mdct, int32_t *out, int16_t *in) -{ - int i, re, im, n, n2, n4; - int16_t *rot = mdct->rot_tmp; - IComplex *x = mdct->cplx_tmp; - - n = 1 << mdct->nbits; - n2 = n >> 1; - n4 = n >> 2; - - /* shift to simplify computations */ - for (i = 0; i > 1; - im = -((int)rot[n2+2*i] - (int)rot[n2-1-2*i]) >> 1; - CMUL(x[i].re, x[i].im, re, im, -mdct->xcos1[i], mdct->xsin1[i], 15); - } - - fft(mdct, x, mdct->nbits - 2); - - /* post rotation */ - for (i = 0; i < n4; i++) { - re = x[i].re; - im = x[i].im; - CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i], 0); - } + return ret; } @@ -304,101 +109,6 @@ static void scale_coefficients(AC3EncodeContext *s) } -#ifdef TEST -/*************************************************************************/ -/* TEST */ - -#include "libavutil/lfg.h" - -#define MDCT_NBITS 9 -#define MDCT_SAMPLES (1 << MDCT_NBITS) -#define FN (MDCT_SAMPLES/4) - - -static void fft_test(AC3MDCTContext *mdct, AVLFG *lfg) -{ - IComplex in[FN], in1[FN]; - int k, n, i; - float sum_re, sum_im, a; - - for (i = 0; i < FN; i++) { - in[i].re = av_lfg_get(lfg) % 65535 - 32767; - in[i].im = av_lfg_get(lfg) % 65535 - 32767; - in1[i] = in[i]; - } - fft(mdct, in, 7); - - /* do it by hand */ - for (k = 0; k < FN; k++) { - sum_re = 0; - sum_im = 0; - for (n = 0; n < FN; n++) { - a = -2 * M_PI * (n * k) / FN; - sum_re += in1[n].re * cos(a) - in1[n].im * sin(a); - sum_im += in1[n].re * sin(a) + in1[n].im * cos(a); - } - av_log(NULL, AV_LOG_DEBUG, "%3d: %6d,%6d %6.0f,%6.0f\n", - k, in[k].re, in[k].im, sum_re / FN, sum_im / FN); - } -} - - -static void mdct_test(AC3MDCTContext *mdct, AVLFG *lfg) -{ - int16_t input[MDCT_SAMPLES]; - int32_t output[AC3_MAX_COEFS]; - float input1[MDCT_SAMPLES]; - float output1[AC3_MAX_COEFS]; - float s, a, err, e, emax; - int i, k, n; - - for (i = 0; i < MDCT_SAMPLES; i++) { - input[i] = (av_lfg_get(lfg) % 65535 - 32767) * 9 / 10; - input1[i] = input[i]; - } - - mdct512(mdct, output, input); - - /* do it by hand */ - for (k = 0; k < AC3_MAX_COEFS; k++) { - s = 0; - for (n = 0; n < MDCT_SAMPLES; n++) { - a = (2*M_PI*(2*n+1+MDCT_SAMPLES/2)*(2*k+1) / (4 * MDCT_SAMPLES)); - s += input1[n] * cos(a); - } - output1[k] = -2 * s / MDCT_SAMPLES; - } - - err = 0; - emax = 0; - for (i = 0; i < AC3_MAX_COEFS; i++) { - av_log(NULL, AV_LOG_DEBUG, "%3d: %7d %7.0f\n", i, output[i], output1[i]); - e = output[i] - output1[i]; - if (e > emax) - emax = e; - err += e * e; - } - av_log(NULL, AV_LOG_DEBUG, "err2=%f emax=%f\n", err / AC3_MAX_COEFS, emax); -} - - -int main(void) -{ - AVLFG lfg; - AC3MDCTContext mdct; - - mdct.avctx = NULL; - av_log_set_level(AV_LOG_DEBUG); - mdct_init(&mdct, 9); - - fft_test(&mdct, &lfg); - mdct_test(&mdct, &lfg); - - return 0; -} -#endif /* TEST */ - - AVCodec ff_ac3_fixed_encoder = { "ac3_fixed", AVMEDIA_TYPE_AUDIO, diff --git a/libavcodec/ac3enc_fixed.h b/libavcodec/ac3enc_fixed.h deleted file mode 100644 index 0c9e6a16c6..0000000000 --- a/libavcodec/ac3enc_fixed.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The simplest AC-3 encoder - * Copyright (c) 2000 Fabrice Bellard - * Copyright (c) 2006-2010 Justin Ruggles - * Copyright (c) 2006-2010 Prakash Punnoor - * - * 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 - */ - -/** - * @file - * fixed-point AC-3 encoder header. - */ - -#ifndef AVCODEC_AC3ENC_FIXED_H -#define AVCODEC_AC3ENC_FIXED_H - -#include - - -typedef int16_t SampleType; -typedef int32_t CoefType; -typedef int64_t CoefSumType; - -#define MAC_COEF(d,a,b) MAC64(d,a,b) - - -/** - * Compex number. - * Used in fixed-point MDCT calculation. - */ -typedef struct IComplex { - int16_t re,im; -} IComplex; - -typedef struct AC3MDCTContext { - const int16_t *window; ///< MDCT window function - int nbits; ///< log2(transform size) - int16_t *costab; ///< FFT cos table - int16_t *sintab; ///< FFT sin table - int16_t *xcos1; ///< MDCT cos table - int16_t *xsin1; ///< MDCT sin table - int16_t *rot_tmp; ///< temp buffer for pre-rotated samples - IComplex *cplx_tmp; ///< temp buffer for complex pre-rotated samples -} AC3MDCTContext; - -#endif /* AVCODEC_AC3ENC_FIXED_H */ diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 19afd27bb1..d2435dee15 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -68,17 +68,6 @@ static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, } -/** - * Calculate a 512-point MDCT - * @param out 256 output frequency coefficients - * @param in 512 windowed input audio samples - */ -static void mdct512(AC3MDCTContext *mdct, float *out, float *in) -{ - mdct->fft.mdct_calc(&mdct->fft, out, in); -} - - /** * Apply KBD window to input samples prior to MDCT. */ diff --git a/libavcodec/ac3enc_float.h b/libavcodec/ac3enc_float.h deleted file mode 100644 index ecdc421e92..0000000000 --- a/libavcodec/ac3enc_float.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The simplest AC-3 encoder - * Copyright (c) 2000 Fabrice Bellard - * Copyright (c) 2006-2010 Justin Ruggles - * Copyright (c) 2006-2010 Prakash Punnoor - * - * 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 - */ - -/** - * @file - * floating-point AC-3 encoder header. - */ - -#ifndef AVCODEC_AC3ENC_FLOAT_H -#define AVCODEC_AC3ENC_FLOAT_H - -#include "fft.h" - - -typedef float SampleType; -typedef float CoefType; -typedef float CoefSumType; - -#define MAC_COEF(d,a,b) ((d)+=(a)*(b)) - - -typedef struct AC3MDCTContext { - const float *window; ///< MDCT window function - FFTContext fft; ///< FFT context for MDCT calculation -} AC3MDCTContext; - -#endif /* AVCODEC_AC3ENC_FLOAT_H */ diff --git a/tests/ref/acodec/ac3_fixed b/tests/ref/acodec/ac3_fixed index d4ade32ddd..ce1a8ec29e 100644 --- a/tests/ref/acodec/ac3_fixed +++ b/tests/ref/acodec/ac3_fixed @@ -1,2 +1,2 @@ -346073c97eada69330f61e103a170ca1 *./tests/data/acodec/ac3.rm +408f47ee5a60866fc751f7bc2314cbd6 *./tests/data/acodec/ac3.rm 98751 ./tests/data/acodec/ac3.rm diff --git a/tests/ref/lavf/rm b/tests/ref/lavf/rm index bb0b1db6ed..fbf3e0fbde 100644 --- a/tests/ref/lavf/rm +++ b/tests/ref/lavf/rm @@ -1,2 +1,2 @@ -7b7ede9548a09346675edad36acfbf19 *./tests/data/lavf/lavf.rm +da74fe749c2eb21bbead7de81d2f3078 *./tests/data/lavf/lavf.rm 346706 ./tests/data/lavf/lavf.rm -- cgit v1.2.3 From 8978fedaeefdff50ed4deefbfe822ad07f19f616 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 5 Mar 2011 21:06:46 +0100 Subject: avio: introduce an AVIOContext.seekable field Use it instead of url_is_streamed and AVIOContext.is_streamed. --- ffserver.c | 8 ++++---- libavformat/aiffdec.c | 2 +- libavformat/aiffenc.c | 2 +- libavformat/ape.c | 2 +- libavformat/asfenc.c | 4 ++-- libavformat/au.c | 2 +- libavformat/avidec.c | 4 ++-- libavformat/avienc.c | 18 +++++++++--------- libavformat/avio.h | 19 ++++++++++++++++--- libavformat/aviobuf.c | 8 +++++++- libavformat/bink.c | 2 +- libavformat/cafdec.c | 4 ++-- libavformat/ffmdec.c | 2 +- libavformat/filmstripdec.c | 2 +- libavformat/flacenc.c | 2 +- libavformat/flvdec.c | 4 ++-- libavformat/gxfenc.c | 2 +- libavformat/id3v1.c | 2 +- libavformat/matroskadec.c | 2 +- libavformat/matroskaenc.c | 12 ++++++------ libavformat/mmf.c | 2 +- libavformat/mov.c | 12 ++++++------ libavformat/movenc.c | 4 ++-- libavformat/mpc.c | 2 +- libavformat/mpeg.c | 2 +- libavformat/mxfenc.c | 2 +- libavformat/nutdec.c | 2 +- libavformat/oggdec.c | 2 +- libavformat/r3d.c | 2 +- libavformat/rmdec.c | 2 +- libavformat/rmenc.c | 6 +++--- libavformat/rsoenc.c | 2 +- libavformat/soxenc.c | 2 +- libavformat/swfenc.c | 2 +- libavformat/tty.c | 2 +- libavformat/utils.c | 2 +- libavformat/vc1testenc.c | 2 +- libavformat/vocdec.c | 2 +- libavformat/wav.c | 4 ++-- libavformat/wv.c | 4 ++-- 40 files changed, 91 insertions(+), 72 deletions(-) diff --git a/ffserver.c b/ffserver.c index 078ee116e1..bc056dd9f0 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2260,7 +2260,7 @@ static int http_prepare_data(HTTPContext *c) /* XXX: potential leak */ return -1; } - c->fmt_ctx.pb->is_streamed = 1; + c->fmt_ctx.pb->seekable = 0; /* * HACK to avoid mpeg ps muxer to spit many underflow errors @@ -2399,7 +2399,7 @@ static int http_prepare_data(HTTPContext *c) } ost = ctx->streams[pkt.stream_index]; - ctx->pb->is_streamed = 1; + ctx->pb->seekable = 0; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts = av_rescale_q(pkt.dts, ist->time_base, ost->time_base); if (pkt.pts != AV_NOPTS_VALUE) @@ -2436,7 +2436,7 @@ static int http_prepare_data(HTTPContext *c) /* XXX: potential leak */ return -1; } - c->fmt_ctx.pb->is_streamed = 1; + c->fmt_ctx.pb->seekable = 0; av_write_trailer(ctx); len = url_close_dyn_buf(ctx->pb, &c->pb_buffer); c->buffer_ptr = c->pb_buffer; @@ -2723,7 +2723,7 @@ static int http_receive_data(HTTPContext *c) pb = avio_alloc_context(c->buffer, c->buffer_end - c->buffer, 0, NULL, NULL, NULL, NULL); - pb->is_streamed = 1; + pb->seekable = 0; if (av_open_input_stream(&s, pb, c->stream->feed_filename, fmt_in, NULL) < 0) { av_free(pb); diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index c3ad44e6df..8678f9bb9b 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -238,7 +238,7 @@ static int aiff_read_header(AVFormatContext *s, offset += avio_tell(pb); /* Compute absolute data offset */ if (st->codec->block_align) /* Assume COMM already parsed */ goto got_sound; - if (url_is_streamed(pb)) { + if (!pb->seekable) { av_log(s, AV_LOG_ERROR, "file is not seekable\n"); return -1; } diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index c61150987f..3bdb4f4f8c 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -124,7 +124,7 @@ static int aiff_write_trailer(AVFormatContext *s) end_size++; } - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* File length */ avio_seek(pb, aiff->form, SEEK_SET); avio_wb32(pb, file_size - aiff->form - 4); diff --git a/libavformat/ape.c b/libavformat/ape.c index 5aac00c56a..956036d5a8 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -296,7 +296,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) ape_dumpinfo(s, ape); /* try to read APE tags */ - if (!url_is_streamed(pb)) { + if (pb->seekable) { ff_ape_parse_tag(s); avio_seek(pb, 0, SEEK_SET); } diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 677c6882bf..c029c0e163 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -347,7 +347,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data avio_wl64(pb, duration); /* end time stamp (in 100ns units) */ avio_wl64(pb, asf->duration); /* duration (in 100ns units) */ avio_wl64(pb, PREROLL_TIME); /* start time stamp */ - avio_wl32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */ + avio_wl32(pb, (asf->is_streamed || !pb->seekable ) ? 3 : 2); /* ??? */ avio_wl32(pb, s->packet_size); /* packet size */ avio_wl32(pb, s->packet_size); /* packet size */ avio_wl32(pb, bit_rate); /* Nominal data rate in bps */ @@ -866,7 +866,7 @@ static int asf_write_trailer(AVFormatContext *s) } avio_flush(s->pb); - if (asf->is_streamed || url_is_streamed(s->pb)) { + if (asf->is_streamed || !s->pb->seekable) { put_chunk(s, 0x4524, 0, 0); /* end of stream */ } else { /* rewrite an updated header */ diff --git a/libavformat/au.c b/libavformat/au.c index f70f47ab39..6cffe1c1ce 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -91,7 +91,7 @@ static int au_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; int64_t file_size; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* update file size */ file_size = avio_tell(pb); diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 43ced28001..ae8d32045f 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -665,7 +665,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) break; case MKTAG('i', 'n', 'd', 'x'): i= avio_tell(pb); - if(!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX)){ + if(pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX)){ read_braindead_odml_indx(s, 0); } avio_seek(pb, i+size, SEEK_SET); @@ -721,7 +721,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) return -1; } - if(!avi->index_loaded && !url_is_streamed(pb)) + if(!avi->index_loaded && pb->seekable) avi_load_index(s); avi->index_loaded = 1; avi->non_interleaved |= guess_ni_flag(s); diff --git a/libavformat/avienc.c b/libavformat/avienc.c index 6b528c8f25..1b6f64527e 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -197,7 +197,7 @@ static int avi_write_header(AVFormatContext *s) } avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */ avio_wl32(pb, 0); /* padding */ - if (url_is_streamed(pb)) + if (!pb->seekable) avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */ else avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */ @@ -259,7 +259,7 @@ static int avi_write_header(AVFormatContext *s) avio_wl32(pb, 0); /* start */ avist->frames_hdr_strm = avio_tell(pb); /* remember this offset to fill later */ - if (url_is_streamed(pb)) + if (!pb->seekable) avio_wl32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */ else avio_wl32(pb, 0); /* length, XXX: filled later */ @@ -303,7 +303,7 @@ static int avi_write_header(AVFormatContext *s) } } - if (!url_is_streamed(pb)) { + if (pb->seekable) { unsigned char tag[5]; int j; @@ -362,7 +362,7 @@ static int avi_write_header(AVFormatContext *s) ff_end_tag(pb, list2); } - if (!url_is_streamed(pb)) { + if (pb->seekable) { /* AVI could become an OpenDML one, if it grows beyond 2Gb range */ avi->odml_list = ff_start_tag(pb, "JUNK"); ffio_wfourcc(pb, "odml"); @@ -406,7 +406,7 @@ static int avi_write_ix(AVFormatContext *s) char ix_tag[] = "ix00"; int i, j; - assert(!url_is_streamed(pb)); + assert(pb->seekable); if (avi->riff_id > AVI_MASTER_INDEX_SIZE) return -1; @@ -464,7 +464,7 @@ static int avi_write_idx1(AVFormatContext *s) int i; char tag[5]; - if (!url_is_streamed(pb)) { + if (pb->seekable) { AVIStream *avist; AVIIentry* ie = 0, *tie; int empty, stream_id = -1; @@ -532,7 +532,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) avist->packet_count++; // Make sure to put an OpenDML chunk when the file size exceeds the limits - if (!url_is_streamed(pb) && + if (pb->seekable && (avio_tell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) { avi_write_ix(s); @@ -552,7 +552,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) avist->audio_strm_length += size; } - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { AVIIndex* idx = &avist->indexes; int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE; int id = idx->entry % AVI_INDEX_CLUSTER_SIZE; @@ -590,7 +590,7 @@ static int avi_write_trailer(AVFormatContext *s) int i, j, n, nb_frames; int64_t file_size; - if (!url_is_streamed(pb)){ + if (pb->seekable){ if (avi->riff_id == 1) { ff_end_tag(pb, avi->movi_list); res = avi_write_idx1(s); diff --git a/libavformat/avio.h b/libavformat/avio.h index 7c2726f656..80446b4808 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -332,6 +332,8 @@ attribute_deprecated int av_register_protocol(URLProtocol *protocol); */ int av_register_protocol2(URLProtocol *protocol, int size); +#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */ + /** * Bytestream IO Context. * New fields can be added to the end with minor version bumps. @@ -351,7 +353,9 @@ typedef struct { int must_flush; /**< true if the next seek should flush */ int eof_reached; /**< true if eof reached */ int write_flag; /**< true if open for writing */ - int is_streamed; +#if FF_API_OLD_AVIO + attribute_deprecated int is_streamed; +#endif int max_packet_size; unsigned long checksum; unsigned char *checksum_ptr; @@ -360,6 +364,10 @@ typedef struct { int (*read_pause)(void *opaque, int pause); int64_t (*read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags); + /** + * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable. + */ + int seekable; } AVIOContext; #if FF_API_OLD_AVIO @@ -604,10 +612,15 @@ unsigned int avio_rb24(AVIOContext *s); unsigned int avio_rb32(AVIOContext *s); uint64_t avio_rb64(AVIOContext *s); -static inline int url_is_streamed(AVIOContext *s) +#if FF_API_OLD_AVIO +/** + * @deprecated Use AVIOContext.seekable field directly. + */ +attribute_deprecated static inline int url_is_streamed(AVIOContext *s) { - return s->is_streamed; + return !s->seekable; } +#endif /** * Create and initialize a AVIOContext for accessing the diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 2e7ee15b2a..dd997d73e2 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -62,7 +62,10 @@ int ffio_init_context(AVIOContext *s, s->must_flush = 0; s->eof_reached = 0; s->error = 0; +#if FF_API_OLD_AVIO s->is_streamed = 0; +#endif + s->seekable = AVIO_SEEKABLE_NORMAL; s->max_packet_size = 0; s->update_checksum= NULL; if(!read_packet && !write_flag){ @@ -202,7 +205,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) { /* can do the seek inside the buffer */ s->buf_ptr = s->buffer + offset1; - } else if ((s->is_streamed || + } else if ((!s->seekable || offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) && !s->write_flag && offset1 >= 0 && (whence != SEEK_END || force)) { @@ -831,7 +834,10 @@ int url_fdopen(AVIOContext **s, URLContext *h) av_freep(s); return AVERROR(EIO); } +#if FF_API_OLD_AVIO (*s)->is_streamed = h->is_streamed; +#endif + (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL; (*s)->max_packet_size = max_packet_size; if(h->prot) { (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause; diff --git a/libavformat/bink.c b/libavformat/bink.c index 1103aca873..76b457c21b 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -247,7 +247,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in BinkDemuxContext *bink = s->priv_data; AVStream *vst = s->streams[0]; - if (url_is_streamed(s->pb)) + if (!s->pb->seekable) return -1; /* seek to the first frame */ diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 45a6629fc1..c720c34375 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -223,7 +223,7 @@ static int read_header(AVFormatContext *s, /* stop at data chunk if seeking is not supported or data chunk size is unknown */ - if (found_data && (caf->data_size < 0 || url_is_streamed(pb))) + if (found_data && (caf->data_size < 0 || !pb->seekable)) break; tag = avio_rb32(pb); @@ -236,7 +236,7 @@ static int read_header(AVFormatContext *s, avio_skip(pb, 4); /* edit count */ caf->data_start = avio_tell(pb); caf->data_size = size < 0 ? -1 : size - 4; - if (caf->data_size > 0 && !url_is_streamed(pb)) + if (caf->data_size > 0 && pb->seekable) avio_skip(pb, caf->data_size); found_data = 1; break; diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index edea965034..6cd2b51392 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -281,7 +281,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; ffm->write_index = avio_rb64(pb); /* get also filesize */ - if (!url_is_streamed(pb)) { + if (pb->seekable) { ffm->file_size = avio_size(pb); if (ffm->write_index) adjust_write_index(s); diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c index 9af8e745d6..095bf9e809 100644 --- a/libavformat/filmstripdec.c +++ b/libavformat/filmstripdec.c @@ -40,7 +40,7 @@ static int read_header(AVFormatContext *s, AVIOContext *pb = s->pb; AVStream *st; - if (url_is_streamed(s->pb)) + if (!s->pb->seekable) return AVERROR(EIO); avio_seek(pb, avio_size(pb) - 36, SEEK_SET); diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index 35c796bdca..38c3265d0c 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -98,7 +98,7 @@ static int flac_write_trailer(struct AVFormatContext *s) if (!ff_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo)) return -1; - if (!url_is_streamed(pb)) { + if (pb->seekable) { /* rewrite the STREAMINFO header block data */ file_size = avio_tell(pb); avio_seek(pb, 8, SEEK_SET); diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 972b4d95dd..ef26b05b3b 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -437,7 +437,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) } // if not streamed and no duration from metadata then seek to end to find the duration from the timestamps - if(!url_is_streamed(s->pb) && (!s->duration || s->duration==AV_NOPTS_VALUE)){ + if(s->pb->seekable && (!s->duration || s->duration==AV_NOPTS_VALUE)){ int size; const int64_t pos= avio_tell(s->pb); const int64_t fsize= avio_size(s->pb); @@ -539,7 +539,7 @@ static int flv_read_seek2(AVFormatContext *s, int stream_index, if (ts - min_ts > (uint64_t)(max_ts - ts)) flags |= AVSEEK_FLAG_BACKWARD; - if (url_is_streamed(s->pb)) { + if (!s->pb->seekable) { if (stream_index < 0) { stream_index = av_find_default_stream_index(s); if (stream_index < 0) diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index a4dffda1ce..585e0eefaa 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -634,7 +634,7 @@ static int gxf_write_header(AVFormatContext *s) uint8_t tracks[255] = {0}; int i, media_info = 0; - if (url_is_streamed(pb)) { + if (!pb->seekable) { av_log(s, AV_LOG_ERROR, "gxf muxer does not support streamed output, patch welcome"); return -1; } diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c index 1f1df9cd02..d296ebbe57 100644 --- a/libavformat/id3v1.c +++ b/libavformat/id3v1.c @@ -229,7 +229,7 @@ void ff_id3v1_read(AVFormatContext *s) uint8_t buf[ID3v1_TAG_SIZE]; int64_t filesize, position = avio_tell(s->pb); - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* XXX: change that */ filesize = avio_size(s->pb); if (filesize > 128) { diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 61a77abdf8..fb8c3e9874 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1117,7 +1117,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) int i; // we should not do any seeking in the streaming case - if (url_is_streamed(matroska->ctx->pb) || + if (!matroska->ctx->pb->seekable || (matroska->ctx->flags & AVFMT_FLAG_IGNIDX)) return; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 4f9bf0a723..a06891d8b8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -848,7 +848,7 @@ static int mkv_write_header(AVFormatContext *s) if (ret < 0) return ret; } - if (url_is_streamed(s->pb)) + if (!s->pb->seekable) mkv_write_seekhead(pb, mkv->main_seekhead); mkv->cues = mkv_start_cues(mkv->segment_offset); @@ -1024,7 +1024,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt) return AVERROR(EINVAL); } - if (url_is_streamed(s->pb)) { + if (!s->pb->seekable) { if (!mkv->dyn_bc) url_open_dyn_buf(&mkv->dyn_bc); pb = mkv->dyn_bc; @@ -1076,16 +1076,16 @@ static int mkv_copy_packet(MatroskaMuxContext *mkv, const AVPacket *pkt) static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaMuxContext *mkv = s->priv_data; - AVIOContext *pb = url_is_streamed(s->pb) ? mkv->dyn_bc : s->pb; + AVIOContext *pb = s->pb->seekable ? s->pb : mkv->dyn_bc; AVCodecContext *codec = s->streams[pkt->stream_index]->codec; int ret, keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY); int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; - int cluster_size = avio_tell(pb) - (url_is_streamed(s->pb) ? 0 : mkv->cluster_pos); + int cluster_size = avio_tell(pb) - (s->pb->seekable ? mkv->cluster_pos : 0); // start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or // after 4k and on a keyframe if (mkv->cluster_pos && - ((url_is_streamed(s->pb) && (cluster_size > 32*1024 || ts > mkv->cluster_pts + 1000)) + ((!s->pb->seekable && (cluster_size > 32*1024 || ts > mkv->cluster_pts + 1000)) || cluster_size > 5*1024*1024 || ts > mkv->cluster_pts + 5000 || (codec->codec_type == AVMEDIA_TYPE_VIDEO && keyframe && cluster_size > 4*1024))) { av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64 @@ -1139,7 +1139,7 @@ static int mkv_write_trailer(AVFormatContext *s) end_ebml_master(pb, mkv->cluster); } - if (!url_is_streamed(pb)) { + if (pb->seekable) { cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams); ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES , cuespos); diff --git a/libavformat/mmf.c b/libavformat/mmf.c index d4247544c2..ec99c2d0dd 100644 --- a/libavformat/mmf.c +++ b/libavformat/mmf.c @@ -133,7 +133,7 @@ static int mmf_write_trailer(AVFormatContext *s) int64_t pos, size; int gatetime; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* Fill in length fields */ end_tag_be(pb, mmf->awapos); end_tag_be(pb, mmf->atrpos); diff --git a/libavformat/mov.c b/libavformat/mov.c index b57c1aab1c..2194dc929a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -304,7 +304,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (err < 0) return err; if (c->found_moov && c->found_mdat && - (url_is_streamed(pb) || start_pos + a.size == avio_size(pb))) + (!pb->seekable || start_pos + a.size == avio_size(pb))) return 0; left = a.size - avio_tell(pb) + start_pos; if (left > 0) /* skip garbage at atom end */ @@ -2354,7 +2354,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) mov->fc = s; /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ - if(!url_is_streamed(pb)) + if(pb->seekable) atom.size = avio_size(pb); else atom.size = INT64_MAX; @@ -2370,7 +2370,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) } av_dlog(mov->fc, "on_parse_exit_offset=%lld\n", avio_tell(pb)); - if (!url_is_streamed(pb) && mov->chapter_track > 0) + if (pb->seekable && mov->chapter_track > 0) mov_read_chapters(s); return 0; @@ -2388,8 +2388,8 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st) AVIndexEntry *current_sample = &avst->index_entries[msc->current_sample]; int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale); av_dlog(s, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts); - if (!sample || (url_is_streamed(s->pb) && current_sample->pos < sample->pos) || - (!url_is_streamed(s->pb) && + if (!sample || (!s->pb->seekable && current_sample->pos < sample->pos) || + (s->pb->seekable && ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) || (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) { @@ -2413,7 +2413,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sample = mov_find_next_sample(s, &st); if (!sample) { mov->found_mdat = 0; - if (!url_is_streamed(s->pb) || + if (s->pb->seekable|| mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || s->pb->eof_reached) return AVERROR_EOF; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 3191e67479..0c5de80d3c 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1955,7 +1955,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) unsigned int samplesInChunk = 0; int size= pkt->size; - if (url_is_streamed(s->pb)) return 0; /* Can't handle that */ + if (!s->pb->seekable) return 0; /* Can't handle that */ if (!size) return 0; /* Discard 0 sized packets */ if (enc->codec_id == CODEC_ID_AMR_NB) { @@ -2090,7 +2090,7 @@ static int mov_write_header(AVFormatContext *s) MOVMuxContext *mov = s->priv_data; int i, hint_track = 0; - if (url_is_streamed(s->pb)) { + if (!s->pb->seekable) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return -1; } diff --git a/libavformat/mpc.c b/libavformat/mpc.c index baee5775af..07c22990f6 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -93,7 +93,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) st->duration = c->fcount; /* try to read APE tags */ - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { int64_t pos = avio_tell(s->pb); ff_ape_parse_tag(s); if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 4a0c5f1400..68b685cc29 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -402,7 +402,7 @@ static int mpegps_read_pes_header(AVFormatContext *s, int i; for(i=0; inb_streams; i++){ if(startcode == s->streams[i]->id && - !url_is_streamed(s->pb) /* index useless on streams anyway */) { + s->pb->seekable /* index useless on streams anyway */) { ff_reduce_index(s, i); av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); } diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index f9b662555a..44052a0610 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1784,7 +1784,7 @@ static int mxf_write_footer(AVFormatContext *s) mxf_write_klv_fill(s); mxf_write_random_index_pack(s); - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { avio_seek(pb, 0, SEEK_SET); if (mxf->edit_unit_byte_count) { mxf_write_partition(s, 1, 2, header_closed_partition_key, 1); diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index ac17e86123..d3804f2993 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -653,7 +653,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) s->data_offset= pos-8; - if(!url_is_streamed(bc)){ + if(bc->seekable){ int64_t orig_pos= avio_tell(bc); find_and_decode_index(nut); avio_seek(bc, orig_pos, SEEK_SET); diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 76ef19ada3..cd866d4108 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -455,7 +455,7 @@ ogg_get_length (AVFormatContext * s) int i; int64_t size, end; - if(url_is_streamed(s->pb)) + if(!s->pb->seekable) return 0; // already set diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 60ac169a9c..e815fda930 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -177,7 +177,7 @@ static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap) s->data_offset = avio_tell(s->pb); av_dlog(s, "data offset %#llx\n", s->data_offset); - if (url_is_streamed(s->pb)) + if (!s->pb->seekable) return 0; // find REOB/REOF/REOS to load index avio_seek(s->pb, avio_size(s->pb)-48-8, SEEK_SET); diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index a68af18bdd..bcf55fddfa 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -481,7 +481,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!data_off) data_off = avio_tell(pb) - 18; - if (indx_off && !url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX) && + if (indx_off && pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) && avio_seek(pb, indx_off, SEEK_SET) >= 0) { rm_read_index(s); avio_seek(pb, data_off + 18, SEEK_SET); diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c index 6f8b0937f3..d64040c1a2 100644 --- a/libavformat/rmenc.c +++ b/libavformat/rmenc.c @@ -118,7 +118,7 @@ static int rv10_write_header(AVFormatContext *ctx, avio_wb32(s, 0); /* data offset : will be patched after */ avio_wb16(s, ctx->nb_streams); /* num streams */ flags = 1 | 2; /* save allowed & perfect play */ - if (url_is_streamed(s)) + if (!s->seekable) flags |= 4; /* live broadcast */ avio_wb16(s, flags); @@ -170,7 +170,7 @@ static int rv10_write_header(AVFormatContext *ctx, avio_wb32(s, 0); /* start time */ avio_wb32(s, BUFFER_DURATION); /* preroll */ /* duration */ - if (url_is_streamed(s) || !stream->total_frames) + if (!s->seekable || !stream->total_frames) avio_wb32(s, (int)(3600 * 1000)); else avio_wb32(s, (int)(stream->total_frames * 1000 / stream->frame_rate)); @@ -434,7 +434,7 @@ static int rm_write_trailer(AVFormatContext *s) int data_size, index_pos, i; AVIOContext *pb = s->pb; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* end of file: finish to write header */ index_pos = avio_tell(pb); data_size = index_pos - rm->data_pos; diff --git a/libavformat/rsoenc.c b/libavformat/rsoenc.c index cfa54f1142..338ecf0173 100644 --- a/libavformat/rsoenc.c +++ b/libavformat/rsoenc.c @@ -38,7 +38,7 @@ static int rso_write_header(AVFormatContext *s) return AVERROR_INVALIDDATA; } - if (url_is_streamed(s->pb)) { + if (!s->pb->seekable) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return AVERROR_INVALIDDATA; } diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index a2e496e8c2..cb71d73e9f 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -96,7 +96,7 @@ static int sox_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; AVCodecContext *enc = s->streams[0]->codec; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* update number of samples */ int64_t file_size = avio_tell(pb); int64_t num_samples = (file_size - sox->header_size - 4LL) >> 2LL; diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index 96e0c49362..4c5c3155ab 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -492,7 +492,7 @@ static int swf_write_trailer(AVFormatContext *s) avio_flush(s->pb); /* patch file size and number of frames if not streamed */ - if (!url_is_streamed(s->pb) && video_enc) { + if (s->pb->seekable && video_enc) { file_size = avio_tell(pb); avio_seek(pb, 4, SEEK_SET); avio_wl32(pb, file_size); diff --git a/libavformat/tty.c b/libavformat/tty.c index 821f2a6b0e..ea8d0c7ece 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -88,7 +88,7 @@ static int read_header(AVFormatContext *avctx, /* simulate tty display speed */ s->chars_per_frame = FFMAX(av_q2d(st->time_base) * (ap->sample_rate ? ap->sample_rate : LINE_RATE), 1); - if (!url_is_streamed(avctx->pb)) { + if (avctx->pb->seekable) { s->fsize = avio_size(avctx->pb); st->duration = (s->fsize + s->chars_per_frame - 1) / s->chars_per_frame; diff --git a/libavformat/utils.c b/libavformat/utils.c index ca0bf7ec05..31eddec12a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2019,7 +2019,7 @@ static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset) if ((!strcmp(ic->iformat->name, "mpeg") || !strcmp(ic->iformat->name, "mpegts")) && - file_size && !url_is_streamed(ic->pb)) { + file_size && ic->pb->seekable) { /* get accurate estimate from the PTSes */ av_estimate_timings_from_pts(ic, old_offset); } else if (av_has_duration(ic)) { diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c index bf6144849e..2b0728d248 100644 --- a/libavformat/vc1testenc.c +++ b/libavformat/vc1testenc.c @@ -73,7 +73,7 @@ static int vc1test_write_trailer(AVFormatContext *s) RCVContext *ctx = s->priv_data; AVIOContext *pb = s->pb; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { avio_seek(pb, 0, SEEK_SET); avio_wl24(pb, ctx->frames); avio_flush(pb); diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c index 48e3d10c0b..eaa2f25492 100644 --- a/libavformat/vocdec.c +++ b/libavformat/vocdec.c @@ -78,7 +78,7 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size) return AVERROR(EIO); voc->remaining_size = avio_rl24(pb); if (!voc->remaining_size) { - if (url_is_streamed(s->pb)) + if (!s->pb->seekable) return AVERROR(EIO); voc->remaining_size = avio_size(pb) - avio_tell(pb); } diff --git a/libavformat/wav.c b/libavformat/wav.c index 6c1dcf5369..47685d466a 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -58,7 +58,7 @@ static int wav_write_header(AVFormatContext *s) ff_end_tag(pb, fmt); if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */ - && !url_is_streamed(s->pb)) { + && s->pb->seekable) { fact = ff_start_tag(pb, "fact"); avio_wl32(pb, 0); ff_end_tag(pb, fact); @@ -98,7 +98,7 @@ static int wav_write_trailer(AVFormatContext *s) avio_flush(pb); - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { ff_end_tag(pb, wav->data); /* update file size */ diff --git a/libavformat/wv.c b/libavformat/wv.c index f48db2364d..7106735041 100644 --- a/libavformat/wv.c +++ b/libavformat/wv.c @@ -121,7 +121,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int appen } if((rate == -1 || !chan) && !wc->block_parsed){ int64_t block_end = avio_tell(pb) + wc->blksize - 24; - if(url_is_streamed(pb)){ + if(!pb->seekable){ av_log(ctx, AV_LOG_ERROR, "Cannot determine additional parameters\n"); return -1; } @@ -223,7 +223,7 @@ static int wv_read_header(AVFormatContext *s, st->start_time = 0; st->duration = wc->samples; - if(!url_is_streamed(s->pb)) { + if(s->pb->seekable) { int64_t cur = avio_tell(s->pb); ff_ape_parse_tag(s); if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) -- cgit v1.2.3 From b92c5452822f9f58d33daf933a0d2a5516866bc1 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 17 Mar 2011 08:13:34 +0100 Subject: avio: avio_ prefix for url_open_dyn_buf --- ffserver.c | 14 +++++++------- libavformat/asfenc.c | 6 +++--- libavformat/avc.c | 2 +- libavformat/avio.h | 5 +++-- libavformat/aviobuf.c | 8 ++++++-- libavformat/matroskaenc.c | 4 ++-- libavformat/movenc.c | 2 +- libavformat/movenchint.c | 2 +- libavformat/mp3enc.c | 2 +- libavformat/nutenc.c | 18 +++++++++--------- libavformat/oggenc.c | 2 +- libavformat/rtpdec.c | 6 +++--- libavformat/rtpdec_asf.c | 2 +- libavformat/rtpdec_latm.c | 2 +- libavformat/rtpdec_svq3.c | 2 +- libavformat/rtpdec_vp8.c | 2 +- libavformat/rtpdec_xiph.c | 2 +- 17 files changed, 43 insertions(+), 38 deletions(-) diff --git a/ffserver.c b/ffserver.c index bc056dd9f0..c4a9ddf10f 100644 --- a/ffserver.c +++ b/ffserver.c @@ -869,7 +869,7 @@ static void close_connection(HTTPContext *c) if (!c->last_packet_sent && c->state == HTTPSTATE_SEND_DATA_TRAILER) { if (ctx->oformat) { /* prepare header */ - if (url_open_dyn_buf(&ctx->pb) >= 0) { + if (avio_open_dyn_buf(&ctx->pb) >= 0) { av_write_trailer(ctx); av_freep(&c->pb_buffer); url_close_dyn_buf(ctx->pb, &c->pb_buffer); @@ -1873,7 +1873,7 @@ static void compute_status(HTTPContext *c) int i, len; AVIOContext *pb; - if (url_open_dyn_buf(&pb) < 0) { + if (avio_open_dyn_buf(&pb) < 0) { /* XXX: return an error ? */ c->buffer_ptr = c->buffer; c->buffer_end = c->buffer; @@ -2256,7 +2256,7 @@ static int http_prepare_data(HTTPContext *c) c->got_key_frame = 0; /* prepare header and save header data in a stream */ - if (url_open_dyn_buf(&c->fmt_ctx.pb) < 0) { + if (avio_open_dyn_buf(&c->fmt_ctx.pb) < 0) { /* XXX: potential leak */ return -1; } @@ -2391,7 +2391,7 @@ static int http_prepare_data(HTTPContext *c) max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]); ret = url_open_dyn_packet_buf(&ctx->pb, max_packet_size); } else { - ret = url_open_dyn_buf(&ctx->pb); + ret = avio_open_dyn_buf(&ctx->pb); } if (ret < 0) { /* XXX: potential leak */ @@ -2432,7 +2432,7 @@ static int http_prepare_data(HTTPContext *c) return -1; ctx = &c->fmt_ctx; /* prepare header */ - if (url_open_dyn_buf(&ctx->pb) < 0) { + if (avio_open_dyn_buf(&ctx->pb) < 0) { /* XXX: potential leak */ return -1; } @@ -2503,7 +2503,7 @@ static int http_send_data(HTTPContext *c) /* if already sending something, then wait. */ if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST) break; - if (url_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) goto fail1; interleaved_index = c->packet_stream_index * 2; /* RTCP packets are sent at odd indexes */ @@ -2850,7 +2850,7 @@ static int rtsp_parse_request(HTTPContext *c) av_strlcpy(c->url, url, sizeof(c->url)); av_strlcpy(c->protocol, protocol, sizeof(c->protocol)); - if (url_open_dyn_buf(&c->pb) < 0) { + if (avio_open_dyn_buf(&c->pb) < 0) { /* XXX: cannot do more */ c->pb = NULL; /* safety */ return -1; diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index c029c0e163..40ccc19a32 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -234,7 +234,7 @@ static void put_str16(AVIOContext *s, const char *tag) int len; uint8_t *pb; AVIOContext *dyn_buf; - if (url_open_dyn_buf(&dyn_buf) < 0) + if (avio_open_dyn_buf(&dyn_buf) < 0) return; avio_put_str16le(dyn_buf, tag); @@ -366,7 +366,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data uint8_t *buf; AVIOContext *dyn_buf; - if (url_open_dyn_buf(&dyn_buf) < 0) + if (avio_open_dyn_buf(&dyn_buf) < 0) return AVERROR(ENOMEM); hpos = put_header(pb, &ff_asf_comment_header); @@ -497,7 +497,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data else desc = p ? p->name : enc->codec_name; - if ( url_open_dyn_buf(&dyn_buf) < 0) + if ( avio_open_dyn_buf(&dyn_buf) < 0) return AVERROR(ENOMEM); avio_put_str16le(dyn_buf, desc); diff --git a/libavformat/avc.c b/libavformat/avc.c index 3b990015fe..274b490cf5 100644 --- a/libavformat/avc.c +++ b/libavformat/avc.c @@ -89,7 +89,7 @@ int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size) int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size) { AVIOContext *pb; - int ret = url_open_dyn_buf(&pb); + int ret = avio_open_dyn_buf(&pb); if(ret < 0) return ret; diff --git a/libavformat/avio.h b/libavformat/avio.h index 80446b4808..9e21057b85 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -447,6 +447,7 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) __att attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); #endif attribute_deprecated void put_flush_packet(AVIOContext *s); +attribute_deprecated int url_open_dyn_buf(AVIOContext **s); /** * @} */ @@ -680,7 +681,7 @@ attribute_deprecated int url_close_buf(AVIOContext *s); * @param s new IO context * @return zero if no error. */ -int url_open_dyn_buf(AVIOContext **s); +int avio_open_dyn_buf(AVIOContext **s); /** * Open a write only packetized memory stream with a maximum packet @@ -696,7 +697,7 @@ int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); /** * Return the written size and a pointer to the buffer. The buffer * must be freed with av_free(). If the buffer is opened with - * url_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is + * avio_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is * added; if opened with url_open_dyn_packet_buf, no padding is added. * * @param s IO context diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index dd997d73e2..53fce9e724 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -419,6 +419,10 @@ unsigned long get_checksum(AVIOContext *s) { return ffio_get_checksum(s); } +int url_open_dyn_buf(AVIOContext **s) +{ + return avio_open_dyn_buf(s); +} #endif int avio_put_str(AVIOContext *s, const char *str) @@ -1023,7 +1027,7 @@ int64_t ffio_read_seek(AVIOContext *s, int stream_index, return ret; } -/* url_open_dyn_buf and url_close_dyn_buf are used in rtp.c to send a response +/* avio_open_dyn_buf and url_close_dyn_buf are used in rtp.c to send a response * back to the server even if CONFIG_MUXERS is false. */ #if CONFIG_MUXERS || CONFIG_NETWORK /* buffer handling */ @@ -1147,7 +1151,7 @@ static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size) return ret; } -int url_open_dyn_buf(AVIOContext **s) +int avio_open_dyn_buf(AVIOContext **s) { return url_open_dyn_buf_internal(s, 0); } diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index a06891d8b8..f32ab92171 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -455,7 +455,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo uint8_t *codecpriv; int ret, codecpriv_size; - ret = url_open_dyn_buf(&dyn_cp); + ret = avio_open_dyn_buf(&dyn_cp); if(ret < 0) return ret; @@ -1026,7 +1026,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt) if (!s->pb->seekable) { if (!mkv->dyn_bc) - url_open_dyn_buf(&mkv->dyn_bc); + avio_open_dyn_buf(&mkv->dyn_bc); pb = mkv->dyn_bc; } diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0c5de80d3c..6b7da183d8 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1660,7 +1660,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, return 0; } - ret = url_open_dyn_buf(&pb_buf); + ret = avio_open_dyn_buf(&pb_buf); if(ret < 0) return ret; diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index 3db8d65f46..567197ee45 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -417,7 +417,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, goto done; /* Open a buffer for writing the hint */ - if ((ret = url_open_dyn_buf(&hintbuf)) < 0) + if ((ret = avio_open_dyn_buf(&hintbuf)) < 0) goto done; av_init_packet(&hint_pkt); count = write_hint_packets(hintbuf, buf, size, trk, &hint_pkt.dts); diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 8514ad1b51..2cbd5e224a 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -96,7 +96,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 uint8_t *pb; int (*put)(AVIOContext*, const char*); AVIOContext *dyn_buf; - if (url_open_dyn_buf(&dyn_buf) < 0) + if (avio_open_dyn_buf(&dyn_buf) < 0) return AVERROR(ENOMEM); /* check if the strings are ASCII-only and use UTF16 only if diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index a72e510d81..5463749a50 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -436,7 +436,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){ AVIOContext *dyn_bc; uint8_t *dyn_buf=NULL; int count=0, dyn_size; - int ret = url_open_dyn_buf(&dyn_bc); + int ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; @@ -462,7 +462,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){ AVIOContext *dyn_bc; uint8_t *dyn_buf=NULL; int count=0, dyn_size, i; - int ret = url_open_dyn_buf(&dyn_bc); + int ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; @@ -495,7 +495,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id) AVChapter *ch = nut->avf->chapters[id]; int ret, dyn_size, count = 0; - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if (ret < 0) return ret; @@ -522,14 +522,14 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ ff_metadata_conv_ctx(avctx, ff_nut_metadata_conv, NULL); - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; write_mainheader(nut, dyn_bc); put_packet(nut, bc, dyn_bc, 1, MAIN_STARTCODE); for (i=0; i < nut->avf->nb_streams; i++){ - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; if ((ret = write_streamheader(avctx, dyn_bc, nut->avf->streams[i], i)) < 0) @@ -537,14 +537,14 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ put_packet(nut, bc, dyn_bc, 1, STREAM_STARTCODE); } - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; write_globalinfo(nut, dyn_bc); put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE); for (i = 0; i < nut->avf->nb_streams; i++) { - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; ret = write_streaminfo(nut, dyn_bc, i); @@ -560,7 +560,7 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ } for (i = 0; i < nut->avf->nb_chapters; i++) { - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if (ret < 0) return ret; ret = write_chapter(nut, dyn_bc, i); @@ -728,7 +728,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){ NULL); nut->last_syncpoint_pos= avio_tell(bc); - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; put_tt(nut, nus->time_base, dyn_bc, pkt->dts); diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index e0dc5332ae..8a0fffb138 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -82,7 +82,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags) int ret, size; uint8_t *buf; - ret = url_open_dyn_buf(&pb); + ret = avio_open_dyn_buf(&pb); if (ret < 0) return ret; ffio_init_checksum(pb, ff_crc04C11DB7_update, 0); diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 0e4665b7ea..3d03b815c2 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -264,7 +264,7 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) return -1; s->last_octet_count = s->octet_count; - if (url_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return -1; // Receiver Report @@ -339,7 +339,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) int len; /* Send a small RTP packet */ - if (url_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return; avio_w8(pb, (RTP_VERSION << 6)); @@ -355,7 +355,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) av_free(buf); /* Send a minimal RTCP RR */ - if (url_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return; avio_w8(pb, (RTP_VERSION << 6)); diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 69fec8d683..ae9d53c2a3 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -208,7 +208,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, av_free(p); } if (!len_off && !asf->pktbuf && - (res = url_open_dyn_buf(&asf->pktbuf)) < 0) + (res = avio_open_dyn_buf(&asf->pktbuf)) < 0) return res; if (!asf->pktbuf) return AVERROR(EIO); diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index 14a547a114..e3f1604a54 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -65,7 +65,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, av_freep(&data->buf); data->timestamp = *timestamp; - if ((ret = url_open_dyn_buf(&data->dyn_buf)) < 0) + if ((ret = avio_open_dyn_buf(&data->dyn_buf)) < 0) return ret; } avio_write(data->dyn_buf, buf, len); diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c index 7a2fc9c686..e93e31c0e2 100644 --- a/libavformat/rtpdec_svq3.c +++ b/libavformat/rtpdec_svq3.c @@ -86,7 +86,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, url_close_dyn_buf(sv->pktbuf, &tmp); av_free(tmp); } - if ((res = url_open_dyn_buf(&sv->pktbuf)) < 0) + if ((res = avio_open_dyn_buf(&sv->pktbuf)) < 0) return res; sv->timestamp = *timestamp; } diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c index b0c59b9a85..f0ebb3173a 100644 --- a/libavformat/rtpdec_vp8.c +++ b/libavformat/rtpdec_vp8.c @@ -85,7 +85,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, // that for the next av_get_packet call ret = end_packet ? 1 : 0; } - if ((res = url_open_dyn_buf(&vp8->data)) < 0) + if ((res = avio_open_dyn_buf(&vp8->data)) < 0) return res; vp8->is_keyframe = *buf & 1; vp8->timestamp = ts; diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c index e42ee61fe3..9eb1ec2352 100644 --- a/libavformat/rtpdec_xiph.c +++ b/libavformat/rtpdec_xiph.c @@ -176,7 +176,7 @@ static int xiph_handle_packet(AVFormatContext * ctx, // end packet has been lost somewhere, so drop buffered data free_fragment_if_needed(data); - if((res = url_open_dyn_buf(&data->fragment)) < 0) + if((res = avio_open_dyn_buf(&data->fragment)) < 0) return res; avio_write(data->fragment, buf, pkt_len); -- cgit v1.2.3 From 6dc7d80de7236d04a6ee30f0e4cd03f055893bcf Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 17 Mar 2011 08:16:07 +0100 Subject: avio: avio_ prefix for url_close_dyn_buf --- ffserver.c | 16 ++++++++-------- libavformat/asfenc.c | 6 +++--- libavformat/avc.c | 2 +- libavformat/avio.h | 3 ++- libavformat/aviobuf.c | 8 ++++++-- libavformat/matroskaenc.c | 4 ++-- libavformat/movenc.c | 2 +- libavformat/movenchint.c | 6 +++--- libavformat/mp3enc.c | 2 +- libavformat/nutenc.c | 12 ++++++------ libavformat/oggenc.c | 2 +- libavformat/rtpdec.c | 6 +++--- libavformat/rtpdec_asf.c | 6 +++--- libavformat/rtpdec_latm.c | 6 +++--- libavformat/rtpdec_svq3.c | 6 +++--- libavformat/rtpdec_vp8.c | 4 ++-- libavformat/rtpdec_xiph.c | 4 ++-- libavformat/rtpenc_chain.c | 2 +- libavformat/rtsp.c | 2 +- libavformat/rtspenc.c | 2 +- 20 files changed, 53 insertions(+), 48 deletions(-) diff --git a/ffserver.c b/ffserver.c index c4a9ddf10f..0ee61e2e50 100644 --- a/ffserver.c +++ b/ffserver.c @@ -872,7 +872,7 @@ static void close_connection(HTTPContext *c) if (avio_open_dyn_buf(&ctx->pb) >= 0) { av_write_trailer(ctx); av_freep(&c->pb_buffer); - url_close_dyn_buf(ctx->pb, &c->pb_buffer); + avio_close_dyn_buf(ctx->pb, &c->pb_buffer); } } } @@ -2101,7 +2101,7 @@ static void compute_status(HTTPContext *c) avio_printf(pb, "
Generated at %s", p); avio_printf(pb, "\n\n"); - len = url_close_dyn_buf(pb, &c->pb_buffer); + len = avio_close_dyn_buf(pb, &c->pb_buffer); c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; } @@ -2277,7 +2277,7 @@ static int http_prepare_data(HTTPContext *c) } av_metadata_free(&c->fmt_ctx.metadata); - len = url_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer); + len = avio_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer); c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; @@ -2410,7 +2410,7 @@ static int http_prepare_data(HTTPContext *c) c->state = HTTPSTATE_SEND_DATA_TRAILER; } - len = url_close_dyn_buf(ctx->pb, &c->pb_buffer); + len = avio_close_dyn_buf(ctx->pb, &c->pb_buffer); c->cur_frame_bytes = len; c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; @@ -2438,7 +2438,7 @@ static int http_prepare_data(HTTPContext *c) } c->fmt_ctx.pb->seekable = 0; av_write_trailer(ctx); - len = url_close_dyn_buf(ctx->pb, &c->pb_buffer); + len = avio_close_dyn_buf(ctx->pb, &c->pb_buffer); c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; @@ -2518,7 +2518,7 @@ static int http_send_data(HTTPContext *c) /* write RTP packet data */ c->buffer_ptr += 4; avio_write(pb, c->buffer_ptr, len); - size = url_close_dyn_buf(pb, &c->packet_buffer); + size = avio_close_dyn_buf(pb, &c->packet_buffer); /* prepare asynchronous TCP sending */ rtsp_c->packet_buffer_ptr = c->packet_buffer; rtsp_c->packet_buffer_end = c->packet_buffer + size; @@ -2907,7 +2907,7 @@ static int rtsp_parse_request(HTTPContext *c) rtsp_reply_error(c, RTSP_STATUS_METHOD); the_end: - len = url_close_dyn_buf(c->pb, &c->pb_buffer); + len = avio_close_dyn_buf(c->pb, &c->pb_buffer); c->pb = NULL; /* safety */ if (len < 0) { /* XXX: cannot do more */ @@ -3456,7 +3456,7 @@ static int rtp_new_av_stream(HTTPContext *c, av_free(ctx); return -1; } - url_close_dyn_buf(ctx->pb, &dummy_buf); + avio_close_dyn_buf(ctx->pb, &dummy_buf); av_free(dummy_buf); c->rtp_ctx[stream_index] = ctx; diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 40ccc19a32..f9cc609eef 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -238,7 +238,7 @@ static void put_str16(AVIOContext *s, const char *tag) return; avio_put_str16le(dyn_buf, tag); - len = url_close_dyn_buf(dyn_buf, &pb); + len = avio_close_dyn_buf(dyn_buf, &pb); avio_wl16(s, len); avio_write(s, pb, len); av_freep(&pb); @@ -375,7 +375,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0; avio_wl16(pb, len); } - len = url_close_dyn_buf(dyn_buf, &buf); + len = avio_close_dyn_buf(dyn_buf, &buf); avio_write(pb, buf, len); av_freep(&buf); end_header(pb, hpos); @@ -501,7 +501,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data return AVERROR(ENOMEM); avio_put_str16le(dyn_buf, desc); - len = url_close_dyn_buf(dyn_buf, &buf); + len = avio_close_dyn_buf(dyn_buf, &buf); avio_wl16(pb, len / 2); // "number of characters" = length in bytes / 2 avio_write(pb, buf, len); diff --git a/libavformat/avc.c b/libavformat/avc.c index 274b490cf5..70a05ec5bc 100644 --- a/libavformat/avc.c +++ b/libavformat/avc.c @@ -96,7 +96,7 @@ int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size) ff_avc_parse_nal_units(pb, buf_in, *size); av_freep(buf); - *size = url_close_dyn_buf(pb, buf); + *size = avio_close_dyn_buf(pb, buf); return 0; } diff --git a/libavformat/avio.h b/libavformat/avio.h index 9e21057b85..5bc85827d1 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -448,6 +448,7 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); #endif attribute_deprecated void put_flush_packet(AVIOContext *s); attribute_deprecated int url_open_dyn_buf(AVIOContext **s); +attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); /** * @} */ @@ -704,7 +705,7 @@ int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); * @param pbuffer pointer to a byte buffer * @return the length of the byte buffer */ -int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); +int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); #if FF_API_UDP_GET_FILE int udp_get_file_handle(URLContext *h); diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 53fce9e724..cb5f2790f7 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -423,6 +423,10 @@ int url_open_dyn_buf(AVIOContext **s) { return avio_open_dyn_buf(s); } +int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) +{ + return avio_close_dyn_buf(s, pbuffer); +} #endif int avio_put_str(AVIOContext *s, const char *str) @@ -1027,7 +1031,7 @@ int64_t ffio_read_seek(AVIOContext *s, int stream_index, return ret; } -/* avio_open_dyn_buf and url_close_dyn_buf are used in rtp.c to send a response +/* avio_open_dyn_buf and avio_close_dyn_buf are used in rtp.c to send a response * back to the server even if CONFIG_MUXERS is false. */ #if CONFIG_MUXERS || CONFIG_NETWORK /* buffer handling */ @@ -1163,7 +1167,7 @@ int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) return url_open_dyn_buf_internal(s, max_packet_size); } -int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) +int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { DynBuffer *d = s->opaque; int size; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index f32ab92171..e28ac42a75 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -498,7 +498,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo ff_put_wav_header(dyn_cp, codec); } - codecpriv_size = url_close_dyn_buf(dyn_cp, &codecpriv); + codecpriv_size = avio_close_dyn_buf(dyn_cp, &codecpriv); if (codecpriv_size) put_ebml_binary(pb, MATROSKA_ID_CODECPRIVATE, codecpriv, codecpriv_size); av_free(codecpriv); @@ -1003,7 +1003,7 @@ static void mkv_flush_dynbuf(AVFormatContext *s) if (!mkv->dyn_bc) return; - bufsize = url_close_dyn_buf(mkv->dyn_bc, &dyn_buf); + bufsize = avio_close_dyn_buf(mkv->dyn_bc, &dyn_buf); avio_write(s->pb, dyn_buf, bufsize); av_free(dyn_buf); mkv->dyn_bc = NULL; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 6b7da183d8..0458844fc3 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1691,7 +1691,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, if (s->nb_chapters) mov_write_chpl_tag(pb_buf, s); - if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) { + if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) { avio_wb32(pb, size+8); ffio_wfourcc(pb, "udta"); avio_write(pb, buf, size); diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index 567197ee45..eb93ef8d7e 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -408,7 +408,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, /* Fetch the output from the RTP muxer, open a new output buffer * for next time. */ - size = url_close_dyn_buf(rtp_ctx->pb, &buf); + size = avio_close_dyn_buf(rtp_ctx->pb, &buf); if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb, RTP_MAX_PACKET_SIZE)) < 0) goto done; @@ -424,7 +424,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, av_freep(&buf); /* Write the hint data into the hint track */ - hint_pkt.size = size = url_close_dyn_buf(hintbuf, &buf); + hint_pkt.size = size = avio_close_dyn_buf(hintbuf, &buf); hint_pkt.data = buf; hint_pkt.pts = hint_pkt.dts; hint_pkt.stream_index = track_index; @@ -448,7 +448,7 @@ void ff_mov_close_hinting(MOVTrack *track) { return; if (rtp_ctx->pb) { av_write_trailer(rtp_ctx); - url_close_dyn_buf(rtp_ctx->pb, &ptr); + avio_close_dyn_buf(rtp_ctx->pb, &ptr); av_free(ptr); } avformat_free_context(rtp_ctx); diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 2cbd5e224a..d46e67b70c 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -115,7 +115,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 put(dyn_buf, str1); if (str2) put(dyn_buf, str2); - len = url_close_dyn_buf(dyn_buf, &pb); + len = avio_close_dyn_buf(dyn_buf, &pb); avio_wb32(s->pb, tag); id3v2_put_size(s, len); diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 5463749a50..c17a15dbf3 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -281,7 +281,7 @@ static inline void put_s_trace(AVIOContext *bc, int64_t v, char *file, char *fun //FIXME remove calculate_checksum static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, int calculate_checksum, uint64_t startcode){ uint8_t *dyn_buf=NULL; - int dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf); + int dyn_size= avio_close_dyn_buf(dyn_bc, &dyn_buf); int forw_ptr= dyn_size + 4*calculate_checksum; if(forw_ptr > 4096) @@ -450,7 +450,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){ ff_put_v(bc, count); - dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf); + dyn_size= avio_close_dyn_buf(dyn_bc, &dyn_buf); avio_write(bc, dyn_buf, dyn_size); av_free(dyn_buf); return 0; @@ -470,7 +470,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){ if (st->disposition & ff_nut_dispositions[i].flag) count += add_info(dyn_bc, "Disposition", ff_nut_dispositions[i].str); } - dyn_size = url_close_dyn_buf(dyn_bc, &dyn_buf); + dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf); if (count) { ff_put_v(bc, stream_id + 1); //stream_id_plus1 @@ -509,7 +509,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id) ff_put_v(bc, count); - dyn_size = url_close_dyn_buf(dyn_bc, &dyn_buf); + dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf); avio_write(bc, dyn_buf, dyn_size); av_freep(&dyn_buf); return 0; @@ -554,7 +554,7 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE); else { uint8_t* buf; - url_close_dyn_buf(dyn_bc, &buf); + avio_close_dyn_buf(dyn_bc, &buf); av_free(buf); } } @@ -566,7 +566,7 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ ret = write_chapter(nut, dyn_bc, i); if (ret < 0) { uint8_t *buf; - url_close_dyn_buf(dyn_bc, &buf); + avio_close_dyn_buf(dyn_bc, &buf); av_freep(&buf); return ret; } diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index 8a0fffb138..92c751c07a 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -101,7 +101,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags) ogg_update_checksum(s, pb, crc_offset); avio_flush(pb); - size = url_close_dyn_buf(pb, &buf); + size = avio_close_dyn_buf(pb, &buf); if (size < 0) return size; diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 3d03b815c2..bbd5f338ed 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -321,7 +321,7 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) } avio_flush(pb); - len = url_close_dyn_buf(pb, &buf); + len = avio_close_dyn_buf(pb, &buf); if ((len > 0) && buf) { int result; av_dlog(s->ic, "sending %d bytes of RR\n", len); @@ -349,7 +349,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) avio_wb32(pb, 0); /* SSRC */ avio_flush(pb); - len = url_close_dyn_buf(pb, &buf); + len = avio_close_dyn_buf(pb, &buf); if ((len > 0) && buf) url_write(rtp_handle, buf, len); av_free(buf); @@ -364,7 +364,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) avio_wb32(pb, 0); /* our own SSRC */ avio_flush(pb); - len = url_close_dyn_buf(pb, &buf); + len = avio_close_dyn_buf(pb, &buf); if ((len > 0) && buf) url_write(rtp_handle, buf, len); av_free(buf); diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index ae9d53c2a3..a8326cf123 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -203,7 +203,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, */ if (asf->pktbuf && len_off != avio_tell(asf->pktbuf)) { uint8_t *p; - url_close_dyn_buf(asf->pktbuf, &p); + avio_close_dyn_buf(asf->pktbuf, &p); asf->pktbuf = NULL; av_free(p); } @@ -217,7 +217,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, avio_skip(pb, len - off); if (!(flags & RTP_FLAG_MARKER)) return -1; - out_len = url_close_dyn_buf(asf->pktbuf, &asf->buf); + out_len = avio_close_dyn_buf(asf->pktbuf, &asf->buf); asf->pktbuf = NULL; } else { /** @@ -272,7 +272,7 @@ static void asfrtp_free_context(PayloadContext *asf) { if (asf->pktbuf) { uint8_t *p = NULL; - url_close_dyn_buf(asf->pktbuf, &p); + avio_close_dyn_buf(asf->pktbuf, &p); asf->pktbuf = NULL; av_free(p); } diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index e3f1604a54..5bf4c1964e 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -43,7 +43,7 @@ static void latm_free_context(PayloadContext *data) return; if (data->dyn_buf) { uint8_t *p; - url_close_dyn_buf(data->dyn_buf, &p); + avio_close_dyn_buf(data->dyn_buf, &p); av_free(p); } av_free(data->buf); @@ -60,7 +60,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, if (!data->dyn_buf || data->timestamp != *timestamp) { av_freep(&data->buf); if (data->dyn_buf) - url_close_dyn_buf(data->dyn_buf, &data->buf); + avio_close_dyn_buf(data->dyn_buf, &data->buf); data->dyn_buf = NULL; av_freep(&data->buf); @@ -73,7 +73,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, if (!(flags & RTP_FLAG_MARKER)) return AVERROR(EAGAIN); av_free(data->buf); - data->len = url_close_dyn_buf(data->dyn_buf, &data->buf); + data->len = avio_close_dyn_buf(data->dyn_buf, &data->buf); data->dyn_buf = NULL; data->pos = 0; } diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c index e93e31c0e2..8c0926212c 100644 --- a/libavformat/rtpdec_svq3.c +++ b/libavformat/rtpdec_svq3.c @@ -83,7 +83,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, if (sv->pktbuf) { uint8_t *tmp; - url_close_dyn_buf(sv->pktbuf, &tmp); + avio_close_dyn_buf(sv->pktbuf, &tmp); av_free(tmp); } if ((res = avio_open_dyn_buf(&sv->pktbuf)) < 0) @@ -100,7 +100,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, av_init_packet(pkt); pkt->stream_index = st->index; *timestamp = sv->timestamp; - pkt->size = url_close_dyn_buf(sv->pktbuf, &pkt->data); + pkt->size = avio_close_dyn_buf(sv->pktbuf, &pkt->data); pkt->destruct = av_destruct_packet; sv->pktbuf = NULL; return 0; @@ -118,7 +118,7 @@ static void svq3_extradata_free(PayloadContext *sv) { if (sv->pktbuf) { uint8_t *buf; - url_close_dyn_buf(sv->pktbuf, &buf); + avio_close_dyn_buf(sv->pktbuf, &buf); av_free(buf); } av_free(sv); diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c index f0ebb3173a..9e50cc44e1 100644 --- a/libavformat/rtpdec_vp8.c +++ b/libavformat/rtpdec_vp8.c @@ -41,7 +41,7 @@ static void prepare_packet(AVPacket *pkt, PayloadContext *vp8, int stream) av_init_packet(pkt); pkt->stream_index = stream; pkt->flags = vp8->is_keyframe ? AV_PKT_FLAG_KEY : 0; - pkt->size = url_close_dyn_buf(vp8->data, &pkt->data); + pkt->size = avio_close_dyn_buf(vp8->data, &pkt->data); pkt->destruct = av_destruct_packet; vp8->data = NULL; } @@ -138,7 +138,7 @@ static void vp8_free_context(PayloadContext *vp8) { if (vp8->data) { uint8_t *tmp; - url_close_dyn_buf(vp8->data, &tmp); + avio_close_dyn_buf(vp8->data, &tmp); av_free(tmp); } av_free(vp8); diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c index 9eb1ec2352..4d8e834813 100644 --- a/libavformat/rtpdec_xiph.c +++ b/libavformat/rtpdec_xiph.c @@ -57,7 +57,7 @@ static inline void free_fragment_if_needed(PayloadContext * data) { if (data->fragment) { uint8_t* p; - url_close_dyn_buf(data->fragment, &p); + avio_close_dyn_buf(data->fragment, &p); av_free(p); data->fragment = NULL; } @@ -203,7 +203,7 @@ static int xiph_handle_packet(AVFormatContext * ctx, if (fragmented == 3) { // end of xiph data packet av_init_packet(pkt); - pkt->size = url_close_dyn_buf(data->fragment, &pkt->data); + pkt->size = avio_close_dyn_buf(data->fragment, &pkt->data); if (pkt->size < 0) { av_log(ctx, AV_LOG_ERROR, diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index a22804130f..77633ed53e 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -63,7 +63,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, avio_close(rtpctx->pb); } else { uint8_t *ptr; - url_close_dyn_buf(rtpctx->pb, &ptr); + avio_close_dyn_buf(rtpctx->pb, &ptr); av_free(ptr); } avformat_free_context(rtpctx); diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 5b98a2846c..90073d63a2 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -495,7 +495,7 @@ void ff_rtsp_undo_setup(AVFormatContext *s) av_write_trailer(rtpctx); if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) { uint8_t *ptr; - url_close_dyn_buf(rtpctx->pb, &ptr); + avio_close_dyn_buf(rtpctx->pb, &ptr); av_free(ptr); } else { avio_close(rtpctx->pb); diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index 1f1fd32fc1..e3631c4290 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -135,7 +135,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) int size; uint8_t *interleave_header, *interleaved_packet; - size = url_close_dyn_buf(rtpctx->pb, &buf); + size = avio_close_dyn_buf(rtpctx->pb, &buf); ptr = buf; while (size > 4) { uint32_t packet_len = AV_RB32(ptr); -- cgit v1.2.3 From 403ee835e7913eb9536b22c2b22edfdd700166a9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 17 Mar 2011 08:19:54 +0100 Subject: avio: make url_open_dyn_packet_buf internal. It doesn't look fit to be a part of the public API. Adding a temporary hack to ffserver to be able to use it, should be cleaned up when somebody is up for it. --- ffserver.c | 6 ++++-- libavformat/avio.h | 17 +++-------------- libavformat/avio_internal.h | 11 +++++++++++ libavformat/aviobuf.c | 6 +++++- libavformat/movenchint.c | 3 ++- libavformat/rtpdec.c | 2 +- libavformat/rtpenc_chain.c | 3 ++- libavformat/rtspenc.c | 5 +++-- 8 files changed, 31 insertions(+), 22 deletions(-) diff --git a/ffserver.c b/ffserver.c index 0ee61e2e50..3ad40e9bfb 100644 --- a/ffserver.c +++ b/ffserver.c @@ -33,6 +33,8 @@ #include "libavformat/os_support.h" #include "libavformat/rtpdec.h" #include "libavformat/rtsp.h" +// XXX for ffio_open_dyn_packet_buffer, to be removed +#include "libavformat/avio_internal.h" #include "libavutil/avstring.h" #include "libavutil/lfg.h" #include "libavutil/random_seed.h" @@ -2389,7 +2391,7 @@ static int http_prepare_data(HTTPContext *c) max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; else max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]); - ret = url_open_dyn_packet_buf(&ctx->pb, max_packet_size); + ret = ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size); } else { ret = avio_open_dyn_buf(&ctx->pb); } @@ -3444,7 +3446,7 @@ static int rtp_new_av_stream(HTTPContext *c, c->stream->filename, stream_index, c->protocol); /* normally, no packets should be output here, but the packet size may be checked */ - if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { + if (ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { /* XXX: close stream */ goto fail; } diff --git a/libavformat/avio.h b/libavformat/avio.h index 5bc85827d1..69896d1404 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -448,6 +448,7 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); #endif attribute_deprecated void put_flush_packet(AVIOContext *s); attribute_deprecated int url_open_dyn_buf(AVIOContext **s); +attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); /** * @} @@ -684,22 +685,10 @@ attribute_deprecated int url_close_buf(AVIOContext *s); */ int avio_open_dyn_buf(AVIOContext **s); -/** - * Open a write only packetized memory stream with a maximum packet - * size of 'max_packet_size'. The stream is stored in a memory buffer - * with a big endian 4 byte header giving the packet size in bytes. - * - * @param s new IO context - * @param max_packet_size maximum packet size (must be > 0) - * @return zero if no error. - */ -int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); - /** * Return the written size and a pointer to the buffer. The buffer - * must be freed with av_free(). If the buffer is opened with - * avio_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is - * added; if opened with url_open_dyn_packet_buf, no padding is added. + * must be freed with av_free(). + * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. * * @param s IO context * @param pbuffer pointer to a byte buffer diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 916de8fcc7..29553ed614 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -81,4 +81,15 @@ unsigned long ffio_get_checksum(AVIOContext *s); unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len); +/** + * Open a write only packetized memory stream with a maximum packet + * size of 'max_packet_size'. The stream is stored in a memory buffer + * with a big endian 4 byte header giving the packet size in bytes. + * + * @param s new IO context + * @param max_packet_size maximum packet size (must be > 0) + * @return zero if no error. + */ +int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); + #endif // AVFORMAT_AVIO_INTERNAL_H diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index cb5f2790f7..73045e6599 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -423,6 +423,10 @@ int url_open_dyn_buf(AVIOContext **s) { return avio_open_dyn_buf(s); } +int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) +{ + return ffio_open_dyn_packet_buf(s, max_packet_size); +} int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { return avio_close_dyn_buf(s, pbuffer); @@ -1160,7 +1164,7 @@ int avio_open_dyn_buf(AVIOContext **s) return url_open_dyn_buf_internal(s, 0); } -int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) +int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) { if (max_packet_size <= 0) return -1; diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index eb93ef8d7e..615714627c 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "internal.h" #include "rtpenc_chain.h" +#include "avio_internal.h" int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index) { @@ -409,7 +410,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, /* Fetch the output from the RTP muxer, open a new output buffer * for next time. */ size = avio_close_dyn_buf(rtp_ctx->pb, &buf); - if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb, + if ((ret = ffio_open_dyn_packet_buf(&rtp_ctx->pb, RTP_MAX_PACKET_SIZE)) < 0) goto done; diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index bbd5f338ed..281f51c443 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -41,7 +41,7 @@ buffer to 'rtp_write_packet' contains all the packets for ONE frame. Each packet should have a four byte header containing the length in big endian format (same trick as - 'url_open_dyn_packet_buf') + 'ffio_open_dyn_packet_buf') */ static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = { diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index 77633ed53e..a923b2deb6 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -21,6 +21,7 @@ #include "avformat.h" #include "rtpenc_chain.h" +#include "avio_internal.h" AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, URLContext *handle, int packet_size) @@ -55,7 +56,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, if (handle) { url_fdopen(&rtpctx->pb, handle); } else - url_open_dyn_packet_buf(&rtpctx->pb, packet_size); + ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); ret = av_write_header(rtpctx); if (ret) { diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index e3631c4290..7f52b1fdb1 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -29,6 +29,7 @@ #include "os_support.h" #include "rtsp.h" #include "internal.h" +#include "avio_internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" @@ -142,7 +143,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) int id; /* The interleaving header is exactly 4 bytes, which happens to be * the same size as the packet length header from - * url_open_dyn_packet_buf. So by writing the interleaving header + * ffio_open_dyn_packet_buf. So by writing the interleaving header * over these bytes, we get a consecutive interleaved packet * that can be written in one call. */ interleaved_packet = interleave_header = ptr; @@ -162,7 +163,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) size -= packet_len; } av_free(buf); - url_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); + ffio_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); return 0; } -- cgit v1.2.3 From 724f6a0fa43f615dcebb2cb16ccb7c60ef7ec95c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 17 Mar 2011 08:44:44 +0100 Subject: avio: make url_fdopen internal. The unbuffered URLContext API will be made private, so there's no point in this function being public. --- libavformat/avio.h | 14 +------------- libavformat/avio_internal.h | 13 +++++++++++++ libavformat/aviobuf.c | 8 ++++++-- libavformat/rtpenc_chain.c | 3 ++- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 69896d1404..ce6429cef5 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -450,6 +450,7 @@ attribute_deprecated void put_flush_packet(AVIOContext *s); attribute_deprecated int url_open_dyn_buf(AVIOContext **s); attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); +attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h); /** * @} */ @@ -625,19 +626,6 @@ attribute_deprecated static inline int url_is_streamed(AVIOContext *s) } #endif -/** - * Create and initialize a AVIOContext for accessing the - * resource referenced by the URLContext h. - * @note When the URLContext h has been opened in read+write mode, the - * AVIOContext can be used only for writing. - * - * @param s Used to return the pointer to the created AVIOContext. - * In case of failure the pointed to value is set to NULL. - * @return 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure - */ -int url_fdopen(AVIOContext **s, URLContext *h); - #if FF_API_URL_RESETBUF /** Reset the buffer for reading or writing. * @note Will drop any data currently in the buffer without transmitting it. diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 29553ed614..b0f96cfa53 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -92,4 +92,17 @@ unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, */ int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); +/** + * Create and initialize a AVIOContext for accessing the + * resource referenced by the URLContext h. + * @note When the URLContext h has been opened in read+write mode, the + * AVIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created AVIOContext. + * In case of failure the pointed to value is set to NULL. + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int ffio_fdopen(AVIOContext **s, URLContext *h); + #endif // AVFORMAT_AVIO_INTERNAL_H diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 73045e6599..ad969ae72e 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -431,6 +431,10 @@ int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { return avio_close_dyn_buf(s, pbuffer); } +int url_fdopen(AVIOContext **s, URLContext *h) +{ + return ffio_fdopen(s, h); +} #endif int avio_put_str(AVIOContext *s, const char *str) @@ -818,7 +822,7 @@ uint64_t ffio_read_varlen(AVIOContext *bc){ return val; } -int url_fdopen(AVIOContext **s, URLContext *h) +int ffio_fdopen(AVIOContext **s, URLContext *h) { uint8_t *buffer; int buffer_size, max_packet_size; @@ -943,7 +947,7 @@ int avio_open(AVIOContext **s, const char *filename, int flags) err = url_open(&h, filename, flags); if (err < 0) return err; - err = url_fdopen(s, h); + err = ffio_fdopen(s, h); if (err < 0) { url_close(h); return err; diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index a923b2deb6..1727740f0f 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "avio_internal.h" #include "rtpenc_chain.h" #include "avio_internal.h" @@ -54,7 +55,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, avcodec_copy_context(rtpctx->streams[0]->codec, st->codec); if (handle) { - url_fdopen(&rtpctx->pb, handle); + ffio_fdopen(&rtpctx->pb, handle); } else ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); ret = av_write_header(rtpctx); -- cgit v1.2.3 From 8bea72f7ebcb57ab929657ff5e2dcd1f6f28f222 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 3 Apr 2011 22:55:31 +0200 Subject: avio: simplify url_open_dyn_buf_internal by using avio_alloc_context() --- libavformat/aviobuf.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index ad969ae72e..d126fa8b0f 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1136,7 +1136,6 @@ static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence) static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size) { DynBuffer *d; - int ret; unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024; if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size) @@ -1144,23 +1143,16 @@ static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size) d = av_mallocz(sizeof(DynBuffer) + io_buffer_size); if (!d) return AVERROR(ENOMEM); - *s = av_mallocz(sizeof(AVIOContext)); + d->io_buffer_size = io_buffer_size; + *s = avio_alloc_context(d->io_buffer, d->io_buffer_size, 1, d, NULL, + max_packet_size ? dyn_packet_buf_write : dyn_buf_write, + max_packet_size ? NULL : dyn_buf_seek); if(!*s) { av_free(d); return AVERROR(ENOMEM); } - d->io_buffer_size = io_buffer_size; - ret = ffio_init_context(*s, d->io_buffer, io_buffer_size, - 1, d, NULL, - max_packet_size ? dyn_packet_buf_write : dyn_buf_write, - max_packet_size ? NULL : dyn_buf_seek); - if (ret == 0) { - (*s)->max_packet_size = max_packet_size; - } else { - av_free(d); - av_freep(s); - } - return ret; + (*s)->max_packet_size = max_packet_size; + return 0; } int avio_open_dyn_buf(AVIOContext **s) -- cgit v1.2.3 From 4dcde00cfcf7914dec32683a8d511e281d0875fc Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 17 Mar 2011 13:42:45 +0100 Subject: lavf: bump minor version and add an APIChanges entry for avio changes --- doc/APIchanges | 40 ++++++++++++++++++++++++++++++++++++++++ libavformat/version.h | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index d242791c54..6f69e05264 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,46 @@ libavutil: 2009-03-08 API changes, most recent first: +2011-04-03 - lavf 52.105.0 - avio.h + Large-scale renaming/deprecating of AVIOContext-related functions: + 724f6a0 deprecate url_fdopen + 403ee83 deprecate url_open_dyn_packet_buf + 6dc7d80 rename url_close_dyn_buf -> avio_close_dyn_buf + b92c545 rename url_open_dyn_buf -> avio_open_dyn_buf + 8978fed introduce an AVIOContext.seekable field as a replacement for + AVIOContext.is_streamed and url_is_streamed() + b64030f deprecate get_checksum() + 4c4427a deprecate init_checksum() + 4ec153b deprecate udp_set_remote_url/get_local_port + 933e90a deprecate av_url_read_fseek/fpause + 8d9769a deprecate url_fileno + b7f2fdd rename put_flush_packet -> avio_flush + 35f1023 deprecate url_close_buf + 83fddae deprecate url_open_buf + d9d86e0 rename url_fprintf -> avio_printf + 59f65d9 deprecate url_setbufsize + 3e68b3b deprecate url_ferror + 66e5b1d deprecate url_feof + e8bb2e2 deprecate url_fget_max_packet_size + 76aa876 rename url_fsize -> avio_size + e519753 deprecate url_fgetc + 655e45e deprecate url_fgets + a2704c9 rename url_ftell -> avio_tell + e16ead0 deprecate get_strz() in favor of avio_get_str + 0300db8,2af07d3 rename url_fskip -> avio_skip + 6b4aa5d rename url_fseek -> avio_seek + 61840b4 deprecate put_tag + 22a3212 rename url_fopen/fclose -> avio_open/close. + 0ac8e2b deprecate put_nbyte + 77eb550 rename put_byte -> avio_w8 + put_[b/l]e -> avio_w[b/l] + put_buffer -> avio_write + b7effd4 rename get_byte -> avio_r8, + get_[b/l]e -> avio_r[b/l] + get_buffer -> avio_read + b3db9ce deprecate get_partial_buffer + 8d9ac96 rename av_alloc_put_byte -> avio_alloc_context + 2011-03-25 - 34b47d7 - lavc 52.115.0 - AVCodecContext.audio_service_type Add audio_service_type field to AVCodecContext. diff --git a/libavformat/version.h b/libavformat/version.h index 7d61bef3f6..58ef4b846f 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -24,7 +24,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 104 +#define LIBAVFORMAT_VERSION_MINOR 105 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- cgit v1.2.3 From dba9852935f31d81d16bf26ee21d164d5d5f5764 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 27 Mar 2011 10:26:58 +0100 Subject: ARM: NEON fixed-point FFT Signed-off-by: Mans Rullgard --- libavcodec/arm/Makefile | 2 + libavcodec/arm/fft_fixed_init_arm.c | 32 +++++ libavcodec/arm/fft_fixed_neon.S | 261 ++++++++++++++++++++++++++++++++++++ libavcodec/fft.c | 1 + libavcodec/fft.h | 4 + 5 files changed, 300 insertions(+) create mode 100644 libavcodec/arm/fft_fixed_init_arm.c create mode 100644 libavcodec/arm/fft_fixed_neon.S diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile index 3b77a5548d..2876e8f69c 100644 --- a/libavcodec/arm/Makefile +++ b/libavcodec/arm/Makefile @@ -16,6 +16,7 @@ OBJS-$(CONFIG_H264PRED) += arm/h264pred_init_arm.o OBJS += arm/dsputil_init_arm.o \ arm/dsputil_arm.o \ arm/fft_init_arm.o \ + arm/fft_fixed_init_arm.o \ arm/fmtconvert_init_arm.o \ arm/jrevdct_arm.o \ arm/mpegvideo_arm.o \ @@ -41,6 +42,7 @@ OBJS-$(HAVE_IWMMXT) += arm/dsputil_iwmmxt.o \ arm/mpegvideo_iwmmxt.o \ NEON-OBJS-$(CONFIG_FFT) += arm/fft_neon.o \ + arm/fft_fixed_neon.o \ NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o \ diff --git a/libavcodec/arm/fft_fixed_init_arm.c b/libavcodec/arm/fft_fixed_init_arm.c new file mode 100644 index 0000000000..916bf291ea --- /dev/null +++ b/libavcodec/arm/fft_fixed_init_arm.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2009 Mans Rullgard + * + * 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 + */ + +#define CONFIG_FFT_FLOAT 0 +#include "libavcodec/fft.h" + +void ff_fft_fixed_calc_neon(FFTContext *s, FFTComplex *z); + +av_cold void ff_fft_fixed_init_arm(FFTContext *s) +{ + if (HAVE_NEON) { + s->fft_permutation = FF_FFT_PERM_SWAP_LSBS; + s->fft_calc = ff_fft_fixed_calc_neon; + } +} diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S new file mode 100644 index 0000000000..14884d3736 --- /dev/null +++ b/libavcodec/arm/fft_fixed_neon.S @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2011 Mans Rullgard + * + * 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 "asm.S" + +.macro bflies d0, d1, r0, r1 + vrev64.32 \r0, \d1 @ t5, t6, t1, t2 + vhsub.s16 \r1, \d1, \r0 @ t1-t5, t2-t6, t5-t1, t6-t2 + vhadd.s16 \r0, \d1, \r0 @ t1+t5, t2+t6, t5+t1, t6+t2 + vext.16 \r1, \r1, \r1, #1 @ t2-t6, t5-t1, t6-t2, t1-t5 + vtrn.32 \r0, \r1 @ t1+t5, t2+t6, t2-t6, t5-t1 + @ t5, t6, t4, t3 + vhsub.s16 \d1, \d0, \r0 + vhadd.s16 \d0, \d0, \r0 +.endm + +.macro transform01 q0, q1, d3, c0, c1, r0, w0, w1 + vrev32.16 \r0, \d3 + vmull.s16 \w0, \d3, \c0 + vmlal.s16 \w0, \r0, \c1 + vshrn.s32 \d3, \w0, #15 + bflies \q0, \q1, \w0, \w1 +.endm + +.macro transform2 d0, d1, d2, d3, q0, q1, c0, c1, c2, c3, \ + r0, r1, w0, w1 + vrev32.16 \r0, \d1 + vrev32.16 \r1, \d3 + vmull.s16 \w0, \d1, \c0 + vmlal.s16 \w0, \r0, \c1 + vmull.s16 \w1, \d3, \c2 + vmlal.s16 \w1, \r1, \c3 + vshrn.s32 \d1, \w0, #15 + vshrn.s32 \d3, \w1, #15 + bflies \q0, \q1, \w0, \w1 +.endm + +.macro fft4 d0, d1, r0, r1 + vhsub.s16 \r0, \d0, \d1 @ t3, t4, t8, t7 + vhsub.s16 \r1, \d1, \d0 + vhadd.s16 \d0, \d0, \d1 @ t1, t2, t6, t5 + vmov.i64 \d1, #0xffff<<32 + vbit \r0, \r1, \d1 + vrev64.16 \r1, \r0 @ t7, t8, t4, t3 + vtrn.32 \r0, \r1 @ t3, t4, t7, t8 + vtrn.32 \d0, \r0 @ t1, t2, t3, t4, t6, t5, t8, t7 + vhsub.s16 \d1, \d0, \r0 @ r2, i2, r3, i1 + vhadd.s16 \d0, \d0, \r0 @ r0, i0, r1, i3 +.endm + +.macro fft8 d0, d1, d2, d3, q0, q1, c0, c1, r0, r1, w0, w1 + fft4 \d0, \d1, \r0, \r1 + vtrn.32 \d0, \d1 @ z0, z2, z1, z3 + vhadd.s16 \r0, \d2, \d3 @ t1, t2, t3, t4 + vhsub.s16 \d3, \d2, \d3 @ z5, z7 + vmov \d2, \r0 + transform01 \q0, \q1, \d3, \c0, \c1, \r0, \w0, \w1 +.endm + +function fft4_neon + vld1.16 {d0-d1}, [r0,:128] + fft4 d0, d1, d2, d3 + vst1.16 {d0-d1}, [r0,:128] + bx lr +endfunc + +function fft8_neon + vld1.16 {d0-d3}, [r0,:128] + movrel r1, coefs + vld1.16 {d30}, [r1,:64] + vdup.16 d31, d30[0] + fft8 d0, d1, d2, d3, q0, q1, d31, d30, d20, d21, q8, q9 + vtrn.32 d0, d1 + vtrn.32 d2, d3 + vst1.16 {d0-d3}, [r0,:128] + bx lr +endfunc + +function fft16_neon + vld1.16 {d0-d3}, [r0,:128]! + vld1.16 {d4-d7}, [r0,:128] + movrel r1, coefs + sub r0, r0, #32 + vld1.16 {d28-d31},[r1,:128] + vdup.16 d31, d28[0] + fft8 d0, d1, d2, d3, q0, q1, d31, d28, d20, d21, q8, q9 + vswp d5, d6 + fft4 q2, q3, q8, q9 + vswp d5, d6 + vtrn.32 q0, q1 @ z0, z4, z2, z6, z1, z5, z3, z7 + vtrn.32 q2, q3 @ z8, z12,z10,z14,z9, z13,z11,z15 + vswp d1, d2 + vdup.16 d31, d28[0] + transform01 q0, q2, d5, d31, d28, d20, q8, q9 + vdup.16 d26, d29[0] + vdup.16 d27, d30[0] + transform2 d2, d6, d3, d7, q1, q3, d26, d30, d27, d29, \ + d20, d21, q8, q9 + vtrn.32 q0, q1 + vtrn.32 q2, q3 + vst1.16 {d0-d3}, [r0,:128]! + vst1.16 {d4-d7}, [r0,:128] + bx lr +endfunc + +function fft_pass_neon + push {r4,lr} + movrel lr, coefs + 24 + vld1.16 {d30}, [lr,:64] + lsl r12, r2, #3 + vmov d31, d30 + add r3, r1, r2, lsl #2 + mov lr, #-8 + sub r3, r3, #2 + mov r4, r0 + vld1.16 {d27[]}, [r3,:16] + sub r3, r3, #6 + vld1.16 {q0}, [r4,:128], r12 + vld1.16 {q1}, [r4,:128], r12 + vld1.16 {q2}, [r4,:128], r12 + vld1.16 {q3}, [r4,:128], r12 + vld1.16 {d28}, [r1,:64]! + vld1.16 {d29}, [r3,:64], lr + vswp d1, d2 + vswp d5, d6 + vtrn.32 d0, d1 + vtrn.32 d4, d5 + vdup.16 d25, d28[1] + vmul.s16 d27, d27, d31 + transform01 q0, q2, d5, d25, d27, d20, q8, q9 + b 2f +1: + mov r4, r0 + vdup.16 d26, d29[0] + vld1.16 {q0}, [r4,:128], r12 + vld1.16 {q1}, [r4,:128], r12 + vld1.16 {q2}, [r4,:128], r12 + vld1.16 {q3}, [r4,:128], r12 + vld1.16 {d28}, [r1,:64]! + vld1.16 {d29}, [r3,:64], lr + vswp d1, d2 + vswp d5, d6 + vtrn.32 d0, d1 + vtrn.32 d4, d5 + vdup.16 d24, d28[0] + vdup.16 d25, d28[1] + vdup.16 d27, d29[3] + vmul.s16 q13, q13, q15 + transform2 d0, d4, d1, d5, q0, q2, d24, d26, d25, d27, \ + d16, d17, q9, q10 +2: + vtrn.32 d2, d3 + vtrn.32 d6, d7 + vdup.16 d24, d28[2] + vdup.16 d26, d29[2] + vdup.16 d25, d28[3] + vdup.16 d27, d29[1] + vmul.s16 q13, q13, q15 + transform2 d2, d6, d3, d7, q1, q3, d24, d26, d25, d27, \ + d16, d17, q9, q10 + vtrn.32 d0, d1 + vtrn.32 d2, d3 + vtrn.32 d4, d5 + vtrn.32 d6, d7 + vswp d1, d2 + vswp d5, d6 + mov r4, r0 + vst1.16 {q0}, [r4,:128], r12 + vst1.16 {q1}, [r4,:128], r12 + vst1.16 {q2}, [r4,:128], r12 + vst1.16 {q3}, [r4,:128], r12 + add r0, r0, #16 + subs r2, r2, #2 + bgt 1b + pop {r4,pc} +endfunc + +#define F_SQRT1_2 23170 +#define F_COS_16_1 30274 +#define F_COS_16_3 12540 + +const coefs, align=4 + .short F_SQRT1_2, -F_SQRT1_2, -F_SQRT1_2, F_SQRT1_2 + .short F_COS_16_1,-F_COS_16_1,-F_COS_16_1, F_COS_16_1 + .short F_COS_16_3,-F_COS_16_3,-F_COS_16_3, F_COS_16_3 + .short 1, -1, -1, 1 +endconst + +.macro def_fft n, n2, n4 +function fft\n\()_neon + push {r4, lr} + mov r4, r0 + bl fft\n2\()_neon + add r0, r4, #\n4*2*4 + bl fft\n4\()_neon + add r0, r4, #\n4*3*4 + bl fft\n4\()_neon + mov r0, r4 + pop {r4, lr} + movrel r1, X(ff_cos_\n\()_fixed) + mov r2, #\n4/2 + b fft_pass_neon +endfunc +.endm + + def_fft 32, 16, 8 + def_fft 64, 32, 16 + def_fft 128, 64, 32 + def_fft 256, 128, 64 + def_fft 512, 256, 128 + def_fft 1024, 512, 256 + def_fft 2048, 1024, 512 + def_fft 4096, 2048, 1024 + def_fft 8192, 4096, 2048 + def_fft 16384, 8192, 4096 + def_fft 32768, 16384, 8192 + def_fft 65536, 32768, 16384 + +function ff_fft_fixed_calc_neon, export=1 + ldr r2, [r0] + sub r2, r2, #2 + movrel r3, fft_fixed_tab_neon + ldr r3, [r3, r2, lsl #2] + mov r0, r1 + bx r3 +endfunc + +const fft_fixed_tab_neon + .word fft4_neon + .word fft8_neon + .word fft16_neon + .word fft32_neon + .word fft64_neon + .word fft128_neon + .word fft256_neon + .word fft512_neon + .word fft1024_neon + .word fft2048_neon + .word fft4096_neon + .word fft8192_neon + .word fft16384_neon + .word fft32768_neon + .word fft65536_neon +endconst diff --git a/libavcodec/fft.c b/libavcodec/fft.c index 19da4830a9..077f471ac8 100644 --- a/libavcodec/fft.c +++ b/libavcodec/fft.c @@ -126,6 +126,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) if (CONFIG_MDCT) s->mdct_calcw = s->mdct_calc; #else if (CONFIG_MDCT) s->mdct_calcw = ff_mdct_calcw_c; + if (ARCH_ARM) ff_fft_fixed_init_arm(s); #endif for(j=4; j<=nbits; j++) { diff --git a/libavcodec/fft.h b/libavcodec/fft.h index 0f324cf5a2..a4fee0033b 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -132,9 +132,13 @@ void ff_init_ff_cos_tabs(int index); */ int ff_fft_init(FFTContext *s, int nbits, int inverse); +#if CONFIG_FFT_FLOAT void ff_fft_init_altivec(FFTContext *s); void ff_fft_init_mmx(FFTContext *s); void ff_fft_init_arm(FFTContext *s); +#else +void ff_fft_fixed_init_arm(FFTContext *s); +#endif void ff_fft_end(FFTContext *s); -- cgit v1.2.3 From f7653904c8a136787d9dda97a02aecfe1746a465 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 28 Mar 2011 19:39:44 +0100 Subject: ARM: NEON fixed-point forward MDCT Signed-off-by: Mans Rullgard --- libavcodec/arm/Makefile | 1 + libavcodec/arm/fft_fixed_init_arm.c | 10 ++ libavcodec/arm/mdct_fixed_neon.S | 195 ++++++++++++++++++++++++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 libavcodec/arm/mdct_fixed_neon.S diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile index 2876e8f69c..a5abfdd128 100644 --- a/libavcodec/arm/Makefile +++ b/libavcodec/arm/Makefile @@ -45,6 +45,7 @@ NEON-OBJS-$(CONFIG_FFT) += arm/fft_neon.o \ arm/fft_fixed_neon.o \ NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o \ + arm/mdct_fixed_neon.o \ NEON-OBJS-$(CONFIG_RDFT) += arm/rdft_neon.o \ diff --git a/libavcodec/arm/fft_fixed_init_arm.c b/libavcodec/arm/fft_fixed_init_arm.c index 916bf291ea..be412cde05 100644 --- a/libavcodec/arm/fft_fixed_init_arm.c +++ b/libavcodec/arm/fft_fixed_init_arm.c @@ -22,11 +22,21 @@ #include "libavcodec/fft.h" void ff_fft_fixed_calc_neon(FFTContext *s, FFTComplex *z); +void ff_mdct_fixed_calc_neon(FFTContext *s, FFTSample *o, const FFTSample *i); +void ff_mdct_fixed_calcw_neon(FFTContext *s, FFTDouble *o, const FFTSample *i); av_cold void ff_fft_fixed_init_arm(FFTContext *s) { if (HAVE_NEON) { s->fft_permutation = FF_FFT_PERM_SWAP_LSBS; s->fft_calc = ff_fft_fixed_calc_neon; + +#if CONFIG_MDCT + if (!s->inverse && s->mdct_bits >= 5) { + s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE; + s->mdct_calc = ff_mdct_fixed_calc_neon; + s->mdct_calcw = ff_mdct_fixed_calcw_neon; + } +#endif } } diff --git a/libavcodec/arm/mdct_fixed_neon.S b/libavcodec/arm/mdct_fixed_neon.S new file mode 100644 index 0000000000..d219216a20 --- /dev/null +++ b/libavcodec/arm/mdct_fixed_neon.S @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2011 Mans Rullgard + * + * 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 "asm.S" + + preserve8 + +.macro prerot dst, rt + lsr r3, r6, #2 @ n4 + add \rt, r4, r6, lsr #1 @ revtab + n4 + add r9, r3, r3, lsl #1 @ n3 + add r8, r7, r6 @ tcos + n4 + add r3, r2, r6, lsr #1 @ in + n4 + add r9, r2, r9, lsl #1 @ in + n3 + sub r8, r8, #16 + sub r10, r3, #16 + sub r11, r9, #16 + mov r12, #-16 +1: + vld2.16 {d0,d1}, [r9, :128]! + vld2.16 {d2,d3}, [r11,:128], r12 + vld2.16 {d4,d5}, [r3, :128]! + vld2.16 {d6,d7}, [r10,:128], r12 + vld2.16 {d16,d17},[r7, :128]! @ cos, sin + vld2.16 {d18,d19},[r8, :128], r12 + vrev64.16 q1, q1 + vrev64.16 q3, q3 + vrev64.16 q9, q9 + vneg.s16 d0, d0 + vneg.s16 d2, d2 + vneg.s16 d16, d16 + vneg.s16 d18, d18 + vhsub.s16 d0, d0, d3 @ re + vhsub.s16 d4, d7, d4 @ im + vhsub.s16 d6, d6, d5 + vhsub.s16 d2, d2, d1 + vmull.s16 q10, d0, d16 + vmlsl.s16 q10, d4, d17 + vmull.s16 q11, d0, d17 + vmlal.s16 q11, d4, d16 + vmull.s16 q12, d6, d18 + vmlsl.s16 q12, d2, d19 + vmull.s16 q13, d6, d19 + vmlal.s16 q13, d2, d18 + vshrn.s32 d0, q10, #15 + vshrn.s32 d1, q11, #15 + vshrn.s32 d2, q12, #15 + vshrn.s32 d3, q13, #15 + vzip.16 d0, d1 + vzip.16 d2, d3 + ldrh lr, [r4], #2 + ldrh r2, [\rt, #-2]! + add lr, \dst, lr, lsl #2 + add r2, \dst, r2, lsl #2 + vst1.32 {d0[0]}, [lr,:32] + vst1.32 {d2[0]}, [r2,:32] + ldrh lr, [r4], #2 + ldrh r2, [\rt, #-2]! + add lr, \dst, lr, lsl #2 + add r2, \dst, r2, lsl #2 + vst1.32 {d0[1]}, [lr,:32] + vst1.32 {d2[1]}, [r2,:32] + ldrh lr, [r4], #2 + ldrh r2, [\rt, #-2]! + add lr, \dst, lr, lsl #2 + add r2, \dst, r2, lsl #2 + vst1.32 {d1[0]}, [lr,:32] + vst1.32 {d3[0]}, [r2,:32] + ldrh lr, [r4], #2 + ldrh r2, [\rt, #-2]! + add lr, \dst, lr, lsl #2 + add r2, \dst, r2, lsl #2 + vst1.32 {d1[1]}, [lr,:32] + vst1.32 {d3[1]}, [r2,:32] + subs r6, r6, #32 + bgt 1b +.endm + +function ff_mdct_fixed_calc_neon, export=1 + push {r1,r4-r11,lr} + + ldr r4, [r0, #8] @ revtab + ldr r6, [r0, #16] @ mdct_size; n + ldr r7, [r0, #24] @ tcos + + prerot r1, r5 + + mov r4, r0 + bl X(ff_fft_fixed_calc_neon) + + pop {r5} + mov r12, #-16 + ldr r6, [r4, #16] @ mdct_size; n + ldr r7, [r4, #24] @ tcos + add r5, r5, r6, lsr #1 + add r7, r7, r6, lsr #1 + sub r1, r5, #16 + sub r2, r7, #16 +1: + vld2.16 {d4,d5}, [r7,:128]! + vld2.16 {d6,d7}, [r2,:128], r12 + vld2.16 {d0,d1}, [r5,:128] + vld2.16 {d2,d3}, [r1,:128] + vrev64.16 q3, q3 + vrev64.16 q1, q1 + vneg.s16 q3, q3 + vneg.s16 q2, q2 + vmull.s16 q11, d2, d6 + vmlal.s16 q11, d3, d7 + vmull.s16 q8, d0, d5 + vmlsl.s16 q8, d1, d4 + vmull.s16 q9, d0, d4 + vmlal.s16 q9, d1, d5 + vmull.s16 q10, d2, d7 + vmlsl.s16 q10, d3, d6 + vshrn.s32 d0, q11, #15 + vshrn.s32 d1, q8, #15 + vshrn.s32 d2, q9, #15 + vshrn.s32 d3, q10, #15 + vrev64.16 q0, q0 + vst2.16 {d2,d3}, [r5,:128]! + vst2.16 {d0,d1}, [r1,:128], r12 + subs r6, r6, #32 + bgt 1b + + pop {r4-r11,pc} +endfunc + +function ff_mdct_fixed_calcw_neon, export=1 + push {r1,r4-r11,lr} + + ldrd r4, r5, [r0, #8] @ revtab, tmp_buf + ldr r6, [r0, #16] @ mdct_size; n + ldr r7, [r0, #24] @ tcos + + prerot r5, r1 + + mov r4, r0 + mov r1, r5 + bl X(ff_fft_fixed_calc_neon) + + pop {r7} + mov r12, #-16 + ldr r6, [r4, #16] @ mdct_size; n + ldr r9, [r4, #24] @ tcos + add r5, r5, r6, lsr #1 + add r7, r7, r6 + add r9, r9, r6, lsr #1 + sub r3, r5, #16 + sub r1, r7, #16 + sub r2, r9, #16 +1: + vld2.16 {d4,d5}, [r9,:128]! + vld2.16 {d6,d7}, [r2,:128], r12 + vld2.16 {d0,d1}, [r5,:128]! + vld2.16 {d2,d3}, [r3,:128], r12 + vrev64.16 q3, q3 + vrev64.16 q1, q1 + vneg.s16 q3, q3 + vneg.s16 q2, q2 + vmull.s16 q8, d2, d6 + vmlal.s16 q8, d3, d7 + vmull.s16 q9, d0, d5 + vmlsl.s16 q9, d1, d4 + vmull.s16 q10, d0, d4 + vmlal.s16 q10, d1, d5 + vmull.s16 q11, d2, d7 + vmlsl.s16 q11, d3, d6 + vrev64.32 q8, q8 + vrev64.32 q9, q9 + vst2.32 {q10,q11},[r7,:128]! + vst2.32 {d16,d18},[r1,:128], r12 + vst2.32 {d17,d19},[r1,:128], r12 + subs r6, r6, #32 + bgt 1b + + pop {r4-r11,pc} +endfunc -- cgit v1.2.3 From 906fd03070c7dc39b4c937befa2c3559bccf7ba7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Apr 2011 23:12:16 +0100 Subject: fate: fix partial run when no samples path is specified This restores the behaviour of running only the builtin regression tests when no path to external samples is given. aa3805a inadvertently broke this by always setting SAMPLES to something. Using := makes the ifdef test work as expected when the FATE_SAMPLES environment variable is empty. Signed-off-by: Mans Rullgard --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index dbcada5385..e86f193738 100755 --- a/configure +++ b/configure @@ -3270,7 +3270,7 @@ SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD} SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD} SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD} SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD} -SAMPLES=${samples:-\$(FATE_SAMPLES)} +SAMPLES:=${samples:-\$(FATE_SAMPLES)} EOF get_version(){ -- cgit v1.2.3