History

Merge remote branch 'qatar/master'

* qatar/master: fate: fix partial run when no samples path is specified ARM: NEON fixed-point forward MDCT ARM: NEON fixed-point FFT lavf: bump minor version and add an APIChanges entry for avio changes avio: simplify url_open_dyn_buf_internal by using avio_alloc_context() avio: make url_fdopen internal. avio: make url_open_dyn_packet_buf internal. avio: avio_ prefix for url_close_dyn_buf avio: avio_ prefix for url_open_dyn_buf avio: introduce an AVIOContext.seekable field ac3enc: use generic fixed-point mdct lavfi: add fade filter Change yadif to not use out of picture lines. lavc: deprecate AVCodecContext.antialias_algo lavc: mark mb_qmin/mb_qmax for removal on next major bump. Conflicts: doc/filters.texi libavcodec/ac3enc_fixed.h libavcodec/ac3enc_float.h libavfilter/Makefile libavfilter/allfilters.c libavfilter/vf_fade.c

Michael Niedermayer committed 15 years ago

Commit 2cae9802 parents 3c9bfb3 906fd0374 files · +833 −637Browse files

Unified · Split

74 files
  1. configure +1 −1
  2. doc/APIchanges +40 −0
  3. ffserver.c +23 −21
  4. libavcodec/ac3enc.c +17 −9
  5. libavcodec/ac3enc_fixed.c +4 −294
  6. libavcodec/ac3enc_fixed.h +0 −61
  7. libavcodec/ac3enc_float.c +0 −11
  8. libavcodec/ac3enc_float.h +0 −47
  9. libavcodec/arm/Makefile +3 −0
  10. libavcodec/arm/fft_fixed_init_arm.c +42 −0
  11. libavcodec/arm/fft_fixed_neon.S +261 −0
  12. libavcodec/arm/mdct_fixed_neon.S +195 −0
  13. libavcodec/avcodec.h +8 −3
  14. libavcodec/fft.c +1 −0
  15. libavcodec/fft.h +4 −0
  16. libavcodec/options.c +4 −0
  17. libavcodec/version.h +6 −0
  18. libavfilter/avfilter.h +1 −1
  19. libavformat/aiffdec.c +1 −1
  20. libavformat/aiffenc.c +1 −1
  21. libavformat/ape.c +1 −1
  22. libavformat/asfenc.c +8 −8
  23. libavformat/au.c +1 −1
  24. libavformat/avc.c +2 −2
  25. libavformat/avidec.c +2 −2
  26. libavformat/avienc.c +9 −9
  27. libavformat/avio.h +24 −32
  28. libavformat/avio_internal.h +24 −0
  29. libavformat/aviobuf.c +35 −21
  30. libavformat/bink.c +1 −1
  31. libavformat/cafdec.c +2 −2
  32. libavformat/ffmdec.c +1 −1
  33. libavformat/filmstripdec.c +1 −1
  34. libavformat/flacenc.c +1 −1
  35. libavformat/flvdec.c +2 −2
  36. libavformat/gxfenc.c +1 −1
  37. libavformat/id3v1.c +1 −1
  38. libavformat/matroskadec.c +1 −1
  39. libavformat/matroskaenc.c +10 −10
  40. libavformat/mmf.c +1 −1
  41. libavformat/mov.c +6 −6
  42. libavformat/movenc.c +4 −4
  43. libavformat/movenchint.c +6 −5
  44. libavformat/mp3enc.c +2 −2
  45. libavformat/mpc.c +1 −1
  46. libavformat/mpeg.c +1 −1
  47. libavformat/mxfenc.c +1 −1
  48. libavformat/nutdec.c +1 −1
  49. libavformat/nutenc.c +15 −15
  50. libavformat/oggdec.c +1 −1
  51. libavformat/oggenc.c +2 −2
  52. libavformat/r3d.c +1 −1
  53. libavformat/rmdec.c +1 −1
  54. libavformat/rmenc.c +3 −3
  55. libavformat/rsoenc.c +1 −1
  56. libavformat/rtpdec.c +7 −7
  57. libavformat/rtpdec_asf.c +4 −4
  58. libavformat/rtpdec_latm.c +4 −4
  59. libavformat/rtpdec_svq3.c +4 −4
  60. libavformat/rtpdec_vp8.c +3 −3
  61. libavformat/rtpdec_xiph.c +3 −3
  62. libavformat/rtpenc_chain.c +5 −3
  63. libavformat/rtsp.c +1 −1
  64. libavformat/rtspenc.c +4 −3
  65. libavformat/soxenc.c +1 −1
  66. libavformat/swfenc.c +1 −1
  67. libavformat/tty.c +1 −1
  68. libavformat/utils.c +1 −1
  69. libavformat/vc1testenc.c +1 −1
  70. libavformat/vocdec.c +1 −1
  71. libavformat/wav.c +2 −2
  72. libavformat/wv.c +2 −2
  73. tests/ref/acodec/ac3_fixed +1 −1
  74. tests/ref/lavf/rm +1 −1
configure+1−1
@@ -3314,7 +3314,7 @@ SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD} · 3313 unmodified lines
33143314 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
33153315 SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
33163316 SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
3317−SAMPLES=${samples:-\$(FATE_SAMPLES)}
3317+SAMPLES:=${samples:-\$(FATE_SAMPLES)}
33183318 EOF
33193319
33203320 get_version(){
doc/APIchanges+40−0
@@ -12,6 +12,46 @@ libavutil: 2009-03-08 · 11 unmodified lines
1212
1313 API changes, most recent first:
1414
15+2011-04-03 - lavf 52.105.0 - avio.h
16+ Large-scale renaming/deprecating of AVIOContext-related functions:
17+ 724f6a0 deprecate url_fdopen
18+ 403ee83 deprecate url_open_dyn_packet_buf
19+ 6dc7d80 rename url_close_dyn_buf -> avio_close_dyn_buf
20+ b92c545 rename url_open_dyn_buf -> avio_open_dyn_buf
21+ 8978fed introduce an AVIOContext.seekable field as a replacement for
22+ AVIOContext.is_streamed and url_is_streamed()
23+ b64030f deprecate get_checksum()
24+ 4c4427a deprecate init_checksum()
25+ 4ec153b deprecate udp_set_remote_url/get_local_port
26+ 933e90a deprecate av_url_read_fseek/fpause
27+ 8d9769a deprecate url_fileno
28+ b7f2fdd rename put_flush_packet -> avio_flush
29+ 35f1023 deprecate url_close_buf
30+ 83fddae deprecate url_open_buf
31+ d9d86e0 rename url_fprintf -> avio_printf
32+ 59f65d9 deprecate url_setbufsize
33+ 3e68b3b deprecate url_ferror
34+ 66e5b1d deprecate url_feof
35+ e8bb2e2 deprecate url_fget_max_packet_size
36+ 76aa876 rename url_fsize -> avio_size
37+ e519753 deprecate url_fgetc
38+ 655e45e deprecate url_fgets
39+ a2704c9 rename url_ftell -> avio_tell
40+ e16ead0 deprecate get_strz() in favor of avio_get_str
41+ 0300db8,2af07d3 rename url_fskip -> avio_skip
42+ 6b4aa5d rename url_fseek -> avio_seek
43+ 61840b4 deprecate put_tag
44+ 22a3212 rename url_fopen/fclose -> avio_open/close.
45+ 0ac8e2b deprecate put_nbyte
46+ 77eb550 rename put_byte -> avio_w8
47+ put_[b/l]e<type> -> avio_w[b/l]<type>
48+ put_buffer -> avio_write
49+ b7effd4 rename get_byte -> avio_r8,
50+ get_[b/l]e<type> -> avio_r[b/l]<type>
51+ get_buffer -> avio_read
52+ b3db9ce deprecate get_partial_buffer
53+ 8d9ac96 rename av_alloc_put_byte -> avio_alloc_context
54+
1555 2011-03-25 - 34b47d7 - lavc 52.115.0 - AVCodecContext.audio_service_type
1656 Add audio_service_type field to AVCodecContext.
1757
ffserver.c+23−21
@@ -33,6 +33,8 @@ · 32 unmodified lines
3333 #include "libavformat/os_support.h"
3434 #include "libavformat/rtpdec.h"
3535 #include "libavformat/rtsp.h"
36+// XXX for ffio_open_dyn_packet_buffer, to be removed
37+#include "libavformat/avio_internal.h"
3638 #include "libavutil/avstring.h"
3739 #include "libavutil/lfg.h"
3840 #include "libavutil/random_seed.h"
@@ -869,10 +871,10 @@ static void close_connection(HTTPContext *c) · 830 unmodified lines
869871 if (!c->last_packet_sent && c->state == HTTPSTATE_SEND_DATA_TRAILER) {
870872 if (ctx->oformat) {
871873 /* prepare header */
872− if (url_open_dyn_buf(&ctx->pb) >= 0) {
874+ if (avio_open_dyn_buf(&ctx->pb) >= 0) {
873875 av_write_trailer(ctx);
874876 av_freep(&c->pb_buffer);
875− url_close_dyn_buf(ctx->pb, &c->pb_buffer);
877+ avio_close_dyn_buf(ctx->pb, &c->pb_buffer);
876878 }
877879 }
878880 }
@@ -1873,7 +1875,7 @@ static void compute_status(HTTPContext *c) · 994 unmodified lines
18731875 int i, len;
18741876 AVIOContext *pb;
18751877
1876− if (url_open_dyn_buf(&pb) < 0) {
1878+ if (avio_open_dyn_buf(&pb) < 0) {
18771879 /* XXX: return an error ? */
18781880 c->buffer_ptr = c->buffer;
18791881 c->buffer_end = c->buffer;
@@ -2101,7 +2103,7 @@ static void compute_status(HTTPContext *c) · 221 unmodified lines
21012103 avio_printf(pb, "<hr size=1 noshade>Generated at %s", p);
21022104 avio_printf(pb, "</body>\n</html>\n");
21032105
2104− len = url_close_dyn_buf(pb, &c->pb_buffer);
2106+ len = avio_close_dyn_buf(pb, &c->pb_buffer);
21052107 c->buffer_ptr = c->pb_buffer;
21062108 c->buffer_end = c->pb_buffer + len;
21072109 }
@@ -2256,11 +2258,11 @@ static int http_prepare_data(HTTPContext *c) · 148 unmodified lines
22562258 c->got_key_frame = 0;
22572259
22582260 /* prepare header and save header data in a stream */
2259− if (url_open_dyn_buf(&c->fmt_ctx.pb) < 0) {
2261+ if (avio_open_dyn_buf(&c->fmt_ctx.pb) < 0) {
22602262 /* XXX: potential leak */
22612263 return -1;
22622264 }
2263− c->fmt_ctx.pb->is_streamed = 1;
2265+ c->fmt_ctx.pb->seekable = 0;
22642266
22652267 /*
22662268 * HACK to avoid mpeg ps muxer to spit many underflow errors
@@ -2277,7 +2279,7 @@ static int http_prepare_data(HTTPContext *c) · 10 unmodified lines
22772279 }
22782280 av_metadata_free(&c->fmt_ctx.metadata);
22792281
2280− len = url_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer);
2282+ len = avio_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer);
22812283 c->buffer_ptr = c->pb_buffer;
22822284 c->buffer_end = c->pb_buffer + len;
22832285
@@ -2389,9 +2391,9 @@ static int http_prepare_data(HTTPContext *c) · 105 unmodified lines
23892391 max_packet_size = RTSP_TCP_MAX_PACKET_SIZE;
23902392 else
23912393 max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]);
2392− ret = url_open_dyn_packet_buf(&ctx->pb, max_packet_size);
2394+ ret = ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size);
23932395 } else {
2394− ret = url_open_dyn_buf(&ctx->pb);
2396+ ret = avio_open_dyn_buf(&ctx->pb);
23952397 }
23962398 if (ret < 0) {
23972399 /* XXX: potential leak */
@@ -2399,7 +2401,7 @@ static int http_prepare_data(HTTPContext *c) · 1 unmodified line
23992401 }
24002402 ost = ctx->streams[pkt.stream_index];
24012403
2402− ctx->pb->is_streamed = 1;
2404+ ctx->pb->seekable = 0;
24032405 if (pkt.dts != AV_NOPTS_VALUE)
24042406 pkt.dts = av_rescale_q(pkt.dts, ist->time_base, ost->time_base);
24052407 if (pkt.pts != AV_NOPTS_VALUE)
@@ -2410,7 +2412,7 @@ static int http_prepare_data(HTTPContext *c) · 4 unmodified lines
24102412 c->state = HTTPSTATE_SEND_DATA_TRAILER;
24112413 }
24122414
2413− len = url_close_dyn_buf(ctx->pb, &c->pb_buffer);
2415+ len = avio_close_dyn_buf(ctx->pb, &c->pb_buffer);
24142416 c->cur_frame_bytes = len;
24152417 c->buffer_ptr = c->pb_buffer;
24162418 c->buffer_end = c->pb_buffer + len;
@@ -2432,13 +2434,13 @@ static int http_prepare_data(HTTPContext *c) · 15 unmodified lines
24322434 return -1;
24332435 ctx = &c->fmt_ctx;
24342436 /* prepare header */
2435− if (url_open_dyn_buf(&ctx->pb) < 0) {
2437+ if (avio_open_dyn_buf(&ctx->pb) < 0) {
24362438 /* XXX: potential leak */
24372439 return -1;
24382440 }
2439− c->fmt_ctx.pb->is_streamed = 1;
2441+ c->fmt_ctx.pb->seekable = 0;
24402442 av_write_trailer(ctx);
2441− len = url_close_dyn_buf(ctx->pb, &c->pb_buffer);
2443+ len = avio_close_dyn_buf(ctx->pb, &c->pb_buffer);
24422444 c->buffer_ptr = c->pb_buffer;
24432445 c->buffer_end = c->pb_buffer + len;
24442446
@@ -2503,7 +2505,7 @@ static int http_send_data(HTTPContext *c) · 58 unmodified lines
25032505 /* if already sending something, then wait. */
25042506 if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST)
25052507 break;
2506− if (url_open_dyn_buf(&pb) < 0)
2508+ if (avio_open_dyn_buf(&pb) < 0)
25072509 goto fail1;
25082510 interleaved_index = c->packet_stream_index * 2;
25092511 /* RTCP packets are sent at odd indexes */
@@ -2518,7 +2520,7 @@ static int http_send_data(HTTPContext *c) · 8 unmodified lines
25182520 /* write RTP packet data */
25192521 c->buffer_ptr += 4;
25202522 avio_write(pb, c->buffer_ptr, len);
2521− size = url_close_dyn_buf(pb, &c->packet_buffer);
2523+ size = avio_close_dyn_buf(pb, &c->packet_buffer);
25222524 /* prepare asynchronous TCP sending */
25232525 rtsp_c->packet_buffer_ptr = c->packet_buffer;
25242526 rtsp_c->packet_buffer_end = c->packet_buffer + size;
@@ -2723,7 +2725,7 @@ static int http_receive_data(HTTPContext *c) · 198 unmodified lines
27232725
27242726 pb = avio_alloc_context(c->buffer, c->buffer_end - c->buffer,
27252727 0, NULL, NULL, NULL, NULL);
2726− pb->is_streamed = 1;
2728+ pb->seekable = 0;
27272729
27282730 if (av_open_input_stream(&s, pb, c->stream->feed_filename, fmt_in, NULL) < 0) {
27292731 av_free(pb);
@@ -2850,7 +2852,7 @@ static int rtsp_parse_request(HTTPContext *c) · 120 unmodified lines
28502852 av_strlcpy(c->url, url, sizeof(c->url));
28512853 av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
28522854
2853− if (url_open_dyn_buf(&c->pb) < 0) {
2855+ if (avio_open_dyn_buf(&c->pb) < 0) {
28542856 /* XXX: cannot do more */
28552857 c->pb = NULL; /* safety */
28562858 return -1;
@@ -2907,7 +2909,7 @@ static int rtsp_parse_request(HTTPContext *c) · 50 unmodified lines
29072909 rtsp_reply_error(c, RTSP_STATUS_METHOD);
29082910
29092911 the_end:
2910− len = url_close_dyn_buf(c->pb, &c->pb_buffer);
2912+ len = avio_close_dyn_buf(c->pb, &c->pb_buffer);
29112913 c->pb = NULL; /* safety */
29122914 if (len < 0) {
29132915 /* XXX: cannot do more */
@@ -3444,7 +3446,7 @@ static int rtp_new_av_stream(HTTPContext *c, · 530 unmodified lines
34443446 c->stream->filename, stream_index, c->protocol);
34453447
34463448 /* normally, no packets should be output here, but the packet size may be checked */
3447− if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) {
3449+ if (ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) {
34483450 /* XXX: close stream */
34493451 goto fail;
34503452 }
@@ -3456,7 +3458,7 @@ static int rtp_new_av_stream(HTTPContext *c, · 5 unmodified lines
34563458 av_free(ctx);
34573459 return -1;
34583460 }
3459− url_close_dyn_buf(ctx->pb, &dummy_buf);
3461+ avio_close_dyn_buf(ctx->pb, &dummy_buf);
34603462 av_free(dummy_buf);
34613463
34623464 c->rtp_ctx[stream_index] = ctx;
libavcodec/ac3enc.c+17−9
@@ -29,6 +29,8 @@ · 28 unmodified lines
2929 //#define DEBUG
3030 //#define ASSERT_LEVEL 2
3131
32+#include <stdint.h>
33+
3234 #include "libavutil/audioconvert.h"
3335 #include "libavutil/avassert.h"
3436 #include "libavutil/crc.h"
@@ -39,6 +41,7 @@ · 4 unmodified lines
3941 #include "ac3dsp.h"
4042 #include "ac3.h"
4143 #include "audioconvert.h"
44+#include "fft.h"
4245
4346
4447 #ifndef CONFIG_AC3ENC_FLOAT
@@ -55,16 +58,22 @@ · 10 unmodified lines
5558 #define AC3_REMATRIXING_NONE 1
5659 #define AC3_REMATRIXING_ALWAYS 3
5760
58−/** Scale a float value by 2^bits and convert to an integer. */
59−#define SCALE_FLOAT(a, bits) lrintf((a) * (float)(1 << (bits)))
60−
61−
6261 #if CONFIG_AC3ENC_FLOAT
63−#include "ac3enc_float.h"
62+#define MAC_COEF(d,a,b) ((d)+=(a)*(b))
63+typedef float SampleType;
64+typedef float CoefType;
65+typedef float CoefSumType;
6466 #else
65−#include "ac3enc_fixed.h"
67+#define MAC_COEF(d,a,b) MAC64(d,a,b)
68+typedef int16_t SampleType;
69+typedef int32_t CoefType;
70+typedef int64_t CoefSumType;
6671 #endif
6772
73+typedef struct AC3MDCTContext {
74+ const SampleType *window; ///< MDCT window function
75+ FFTContext fft; ///< FFT context for MDCT calculation
76+} AC3MDCTContext;
6877
6978 /**
7079 * Encoding Options used by AVOption.
@@ -279,8 +288,6 @@ static av_cold void mdct_end(AC3MDCTContext *mdct); · 208 unmodified lines
279288 static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
280289 int nbits);
281290
282−static void mdct512(AC3MDCTContext *mdct, CoefType *out, SampleType *in);
283−
284291 static void apply_window(DSPContext *dsp, SampleType *output, const SampleType *input,
285292 const SampleType *window, unsigned int len);
286293
@@ -386,7 +393,8 @@ static void apply_mdct(AC3EncodeContext *s) · 99 unmodified lines
386393
387394 block->coeff_shift[ch] = normalize_samples(s);
388395
389− mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples);
396+ s->mdct.fft.mdct_calcw(&s->mdct.fft, block->mdct_coef[ch],
397+ s->windowed_samples);
390398 }
391399 }
392400 }
libavcodec/ac3enc_fixed.c+4−294
@@ -26,54 +26,17 @@ · 25 unmodified lines
2626 * fixed-point AC-3 encoder.
2727 */
2828
29+#define CONFIG_FFT_FLOAT 0
2930 #undef CONFIG_AC3ENC_FLOAT
3031 #include "ac3enc.c"
3132
3233
33−/** Scale a float value by 2^15, convert to an integer, and clip to range -32767..32767. */
34−#define FIX15(a) av_clip(SCALE_FLOAT(a, 15), -32767, 32767)
35−
36−
3734 /**
3835 * Finalize MDCT and free allocated memory.
3936 */
4037 static av_cold void mdct_end(AC3MDCTContext *mdct)
4138 {
42− mdct->nbits = 0;
43− av_freep(&mdct->costab);
44− av_freep(&mdct->sintab);
45− av_freep(&mdct->xcos1);
46− av_freep(&mdct->xsin1);
47− av_freep(&mdct->rot_tmp);
48− av_freep(&mdct->cplx_tmp);
49−}
50−
51−
52−/**
53− * Initialize FFT tables.
54− * @param ln log2(FFT size)
55− */
56−static av_cold int fft_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int ln)
57−{
58− int i, n, n2;
59− float alpha;
60−
61− n = 1 << ln;
62− n2 = n >> 1;
63−
64− FF_ALLOC_OR_GOTO(avctx, mdct->costab, n2 * sizeof(*mdct->costab), fft_alloc_fail);
65− FF_ALLOC_OR_GOTO(avctx, mdct->sintab, n2 * sizeof(*mdct->sintab), fft_alloc_fail);
66−
67− for (i = 0; i < n2; i++) {
68− alpha = 2.0 * M_PI * i / n;
69− mdct->costab[i] = FIX15(cos(alpha));
70− mdct->sintab[i] = FIX15(sin(alpha));
71− }
72−
73− return 0;
74−fft_alloc_fail:
75− mdct_end(mdct);
76− return AVERROR(ENOMEM);
39+ ff_fft_end(&mdct->fft);
7740 }
7841
7942
@@ -84,167 +47,9 @@ fft_alloc_fail: · 4 unmodified lines
8447 static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
8548 int nbits)
8649 {
87− int i, n, n4, ret;
88−
89− n = 1 << nbits;
90− n4 = n >> 2;
91−
92− mdct->nbits = nbits;
93−
94− ret = fft_init(avctx, mdct, nbits - 2);
95− if (ret)
96− return ret;
97−
50+ int ret = ff_mdct_init(&mdct->fft, nbits, 0, 1.0);
9851 mdct->window = ff_ac3_window;
99−
100− FF_ALLOC_OR_GOTO(avctx, mdct->xcos1, n4 * sizeof(*mdct->xcos1), mdct_alloc_fail);
101− FF_ALLOC_OR_GOTO(avctx, mdct->xsin1, n4 * sizeof(*mdct->xsin1), mdct_alloc_fail);
102− FF_ALLOC_OR_GOTO(avctx, mdct->rot_tmp, n * sizeof(*mdct->rot_tmp), mdct_alloc_fail);
103− FF_ALLOC_OR_GOTO(avctx, mdct->cplx_tmp, n4 * sizeof(*mdct->cplx_tmp), mdct_alloc_fail);
104−
105− for (i = 0; i < n4; i++) {
106− float alpha = 2.0 * M_PI * (i + 1.0 / 8.0) / n;
107− mdct->xcos1[i] = FIX15(-cos(alpha));
108− mdct->xsin1[i] = FIX15(-sin(alpha));
109− }
110−
111− return 0;
112−mdct_alloc_fail:
113− mdct_end(mdct);
114− return AVERROR(ENOMEM);
115−}
116−
117−
118−/** Butterfly op */
119−#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
120−{ \
121− int ax, ay, bx, by; \
122− bx = pre1; \
123− by = pim1; \
124− ax = qre1; \
125− ay = qim1; \
126− pre = (bx + ax) >> 1; \
127− pim = (by + ay) >> 1; \
128− qre = (bx - ax) >> 1; \
129− qim = (by - ay) >> 1; \
130−}
131−
132−
133−/** Complex multiply */
134−#define CMUL(pre, pim, are, aim, bre, bim, rshift) \
135−{ \
136− pre = (MUL16(are, bre) - MUL16(aim, bim)) >> rshift; \
137− pim = (MUL16(are, bim) + MUL16(bre, aim)) >> rshift; \
138−}
139−
140−
141−/**
142− * Calculate a 2^n point complex FFT on 2^ln points.
143− * @param z complex input/output samples
144− * @param ln log2(FFT size)
145− */
146−static void fft(AC3MDCTContext *mdct, IComplex *z, int ln)
147−{
148− int j, l, np, np2;
149− int nblocks, nloops;
150− register IComplex *p,*q;
151− int tmp_re, tmp_im;
152−
153− np = 1 << ln;
154−
155− /* reverse */
156− for (j = 0; j < np; j++) {
157− int k = av_reverse[j] >> (8 - ln);
158− if (k < j)
159− FFSWAP(IComplex, z[k], z[j]);
160− }
161−
162− /* pass 0 */
163−
164− p = &z[0];
165− j = np >> 1;
166− do {
167− BF(p[0].re, p[0].im, p[1].re, p[1].im,
168− p[0].re, p[0].im, p[1].re, p[1].im);
169− p += 2;
170− } while (--j);
171−
172− /* pass 1 */
173−
174− p = &z[0];
175− j = np >> 2;
176− do {
177− BF(p[0].re, p[0].im, p[2].re, p[2].im,
178− p[0].re, p[0].im, p[2].re, p[2].im);
179− BF(p[1].re, p[1].im, p[3].re, p[3].im,
180− p[1].re, p[1].im, p[3].im, -p[3].re);
181− p+=4;
182− } while (--j);
183−
184− /* pass 2 .. ln-1 */
185−
186− nblocks = np >> 3;
187− nloops = 1 << 2;
188− np2 = np >> 1;
189− do {
190− p = z;
191− q = z + nloops;
192− for (j = 0; j < nblocks; j++) {
193− BF(p->re, p->im, q->re, q->im,
194− p->re, p->im, q->re, q->im);
195− p++;
196− q++;
197− for(l = nblocks; l < np2; l += nblocks) {
198− CMUL(tmp_re, tmp_im, mdct->costab[l], -mdct->sintab[l], q->re, q->im, 15);
199− BF(p->re, p->im, q->re, q->im,
200− p->re, p->im, tmp_re, tmp_im);
201− p++;
202− q++;
203− }
204− p += nloops;
205− q += nloops;
206− }
207− nblocks = nblocks >> 1;
208− nloops = nloops << 1;
209− } while (nblocks);
210−}
211−
212−
213−/**
214− * Calculate a 512-point MDCT
215− * @param out 256 output frequency coefficients
216− * @param in 512 windowed input audio samples
217− */
218−static void mdct512(AC3MDCTContext *mdct, int32_t *out, int16_t *in)
219−{
220− int i, re, im, n, n2, n4;
221− int16_t *rot = mdct->rot_tmp;
222− IComplex *x = mdct->cplx_tmp;
223−
224− n = 1 << mdct->nbits;
225− n2 = n >> 1;
226− n4 = n >> 2;
227−
228− /* shift to simplify computations */
229− for (i = 0; i <n4; i++)
230− rot[i] = -in[i + 3*n4];
231− memcpy(&rot[n4], &in[0], 3*n4*sizeof(*in));
232−
233− /* pre rotation */
234− for (i = 0; i < n4; i++) {
235− re = ((int)rot[ 2*i] - (int)rot[ n-1-2*i]) >> 1;
236− im = -((int)rot[n2+2*i] - (int)rot[n2-1-2*i]) >> 1;
237− CMUL(x[i].re, x[i].im, re, im, -mdct->xcos1[i], mdct->xsin1[i], 15);
238− }
239−
240− fft(mdct, x, mdct->nbits - 2);
241−
242− /* post rotation */
243− for (i = 0; i < n4; i++) {
244− re = x[i].re;
245− im = x[i].im;
246− CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i], 0);
247− }
52+ return ret;
24853 }
24954
25055
@@ -304,101 +109,6 @@ static void scale_coefficients(AC3EncodeContext *s) · 53 unmodified lines
304109 }
305110
306111
307−#ifdef TEST
308−/*************************************************************************/
309−/* TEST */
310−
311−#include "libavutil/lfg.h"
312−
313−#define MDCT_NBITS 9
314−#define MDCT_SAMPLES (1 << MDCT_NBITS)
315−#define FN (MDCT_SAMPLES/4)
316−
317−
318−static void fft_test(AC3MDCTContext *mdct, AVLFG *lfg)
319−{
320− IComplex in[FN], in1[FN];
321− int k, n, i;
322− float sum_re, sum_im, a;
323−
324− for (i = 0; i < FN; i++) {
325− in[i].re = av_lfg_get(lfg) % 65535 - 32767;
326− in[i].im = av_lfg_get(lfg) % 65535 - 32767;
327− in1[i] = in[i];
328− }
329− fft(mdct, in, 7);
330−
331− /* do it by hand */
332− for (k = 0; k < FN; k++) {
333− sum_re = 0;
334− sum_im = 0;
335− for (n = 0; n < FN; n++) {
336− a = -2 * M_PI * (n * k) / FN;
337− sum_re += in1[n].re * cos(a) - in1[n].im * sin(a);
338− sum_im += in1[n].re * sin(a) + in1[n].im * cos(a);
339− }
340− av_log(NULL, AV_LOG_DEBUG, "%3d: %6d,%6d %6.0f,%6.0f\n",
341− k, in[k].re, in[k].im, sum_re / FN, sum_im / FN);
342− }
343−}
344−
345−
346−static void mdct_test(AC3MDCTContext *mdct, AVLFG *lfg)
347−{
348− int16_t input[MDCT_SAMPLES];
349− int32_t output[AC3_MAX_COEFS];
350− float input1[MDCT_SAMPLES];
351− float output1[AC3_MAX_COEFS];
352− float s, a, err, e, emax;
353− int i, k, n;
354−
355− for (i = 0; i < MDCT_SAMPLES; i++) {
356− input[i] = (av_lfg_get(lfg) % 65535 - 32767) * 9 / 10;
357− input1[i] = input[i];
358− }
359−
360− mdct512(mdct, output, input);
361−
362− /* do it by hand */
363− for (k = 0; k < AC3_MAX_COEFS; k++) {
364− s = 0;
365− for (n = 0; n < MDCT_SAMPLES; n++) {
366− a = (2*M_PI*(2*n+1+MDCT_SAMPLES/2)*(2*k+1) / (4 * MDCT_SAMPLES));
367− s += input1[n] * cos(a);
368− }
369− output1[k] = -2 * s / MDCT_SAMPLES;
370− }
371−
372− err = 0;
373− emax = 0;
374− for (i = 0; i < AC3_MAX_COEFS; i++) {
375− av_log(NULL, AV_LOG_DEBUG, "%3d: %7d %7.0f\n", i, output[i], output1[i]);
376− e = output[i] - output1[i];
377− if (e > emax)
378− emax = e;
379− err += e * e;
380− }
381− av_log(NULL, AV_LOG_DEBUG, "err2=%f emax=%f\n", err / AC3_MAX_COEFS, emax);
382−}
383−
384−
385−int main(void)
386−{
387− AVLFG lfg;
388− AC3MDCTContext mdct;
389−
390− mdct.avctx = NULL;
391− av_log_set_level(AV_LOG_DEBUG);
392− mdct_init(&mdct, 9);
393−
394− fft_test(&mdct, &lfg);
395− mdct_test(&mdct, &lfg);
396−
397− return 0;
398−}
399−#endif /* TEST */
400−
401−
402112 AVCodec ff_ac3_fixed_encoder = {
403113 "ac3_fixed",
404114 AVMEDIA_TYPE_AUDIO,
libavcodec/ac3enc_fixed.h+0−61
@@ -1,61 +0,0 @@
1−/*
2− * The simplest AC-3 encoder
3− * Copyright (c) 2000 Fabrice Bellard
4− * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
5− * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
6− *
7− * This file is part of FFmpeg.
8− *
9− * FFmpeg is free software; you can redistribute it and/or
10− * modify it under the terms of the GNU Lesser General Public
11− * License as published by the Free Software Foundation; either
12− * version 2.1 of the License, or (at your option) any later version.
13− *
14− * FFmpeg is distributed in the hope that it will be useful,
15− * but WITHOUT ANY WARRANTY; without even the implied warranty of
16− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17− * Lesser General Public License for more details.
18− *
19− * You should have received a copy of the GNU Lesser General Public
20− * License along with FFmpeg; if not, write to the Free Software
21− * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22− */
23−
24−/**
25− * @file
26− * fixed-point AC-3 encoder header.
27− */
28−
29−#ifndef AVCODEC_AC3ENC_FIXED_H
30−#define AVCODEC_AC3ENC_FIXED_H
31−
32−#include <stdint.h>
33−
34−
35−typedef int16_t SampleType;
36−typedef int32_t CoefType;
37−typedef int64_t CoefSumType;
38−
39−#define MAC_COEF(d,a,b) MAC64(d,a,b)
40−
41−
42−/**
43− * Compex number.
44− * Used in fixed-point MDCT calculation.
45− */
46−typedef struct IComplex {
47− int16_t re,im;
48−} IComplex;
49−
50−typedef struct AC3MDCTContext {
51− const int16_t *window; ///< MDCT window function
52− int nbits; ///< log2(transform size)
53− int16_t *costab; ///< FFT cos table
54− int16_t *sintab; ///< FFT sin table
55− int16_t *xcos1; ///< MDCT cos table
56− int16_t *xsin1; ///< MDCT sin table
57− int16_t *rot_tmp; ///< temp buffer for pre-rotated samples
58− IComplex *cplx_tmp; ///< temp buffer for complex pre-rotated samples
59−} AC3MDCTContext;
60−
61−#endif /* AVCODEC_AC3ENC_FIXED_H */
libavcodec/ac3enc_float.c+0−11
@@ -68,17 +68,6 @@ static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, · 67 unmodified lines
6868 }
6969
7070
71−/**
72− * Calculate a 512-point MDCT
73− * @param out 256 output frequency coefficients
74− * @param in 512 windowed input audio samples
75− */
76−static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
77−{
78− mdct->fft.mdct_calc(&mdct->fft, out, in);
79−}
80−
81−
8271 /**
8372 * Apply KBD window to input samples prior to MDCT.
8473 */
libavcodec/ac3enc_float.h+0−47
@@ -1,47 +0,0 @@
1−/*
2− * The simplest AC-3 encoder
3− * Copyright (c) 2000 Fabrice Bellard
4− * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
5− * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
6− *
7− * This file is part of FFmpeg.
8− *
9− * FFmpeg is free software; you can redistribute it and/or
10− * modify it under the terms of the GNU Lesser General Public
11− * License as published by the Free Software Foundation; either
12− * version 2.1 of the License, or (at your option) any later version.
13− *
14− * FFmpeg is distributed in the hope that it will be useful,
15− * but WITHOUT ANY WARRANTY; without even the implied warranty of
16− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17− * Lesser General Public License for more details.
18− *
19− * You should have received a copy of the GNU Lesser General Public
20− * License along with FFmpeg; if not, write to the Free Software
21− * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22− */
23−
24−/**
25− * @file
26− * floating-point AC-3 encoder header.
27− */
28−
29−#ifndef AVCODEC_AC3ENC_FLOAT_H
30−#define AVCODEC_AC3ENC_FLOAT_H
31−
32−#include "fft.h"
33−
34−
35−typedef float SampleType;
36−typedef float CoefType;
37−typedef float CoefSumType;
38−
39−#define MAC_COEF(d,a,b) ((d)+=(a)*(b))
40−
41−
42−typedef struct AC3MDCTContext {
43− const float *window; ///< MDCT window function
44− FFTContext fft; ///< FFT context for MDCT calculation
45−} AC3MDCTContext;
46−
47−#endif /* AVCODEC_AC3ENC_FLOAT_H */
libavcodec/arm/Makefile+3−0
@@ -16,6 +16,7 @@ OBJS-$(CONFIG_H264PRED) += arm/h264pred_init_arm.o · 15 unmodified lines
1616 OBJS += arm/dsputil_init_arm.o \
1717 arm/dsputil_arm.o \
1818 arm/fft_init_arm.o \
19+ arm/fft_fixed_init_arm.o \
1920 arm/fmtconvert_init_arm.o \
2021 arm/jrevdct_arm.o \
2122 arm/mpegvideo_arm.o \
@@ -41,8 +42,10 @@ OBJS-$(HAVE_IWMMXT) += arm/dsputil_iwmmxt.o \ · 19 unmodified lines
4142 arm/mpegvideo_iwmmxt.o \
4243
4344 NEON-OBJS-$(CONFIG_FFT) += arm/fft_neon.o \
45+ arm/fft_fixed_neon.o \
4446
4547 NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o \
48+ arm/mdct_fixed_neon.o \
4649
4750 NEON-OBJS-$(CONFIG_RDFT) += arm/rdft_neon.o \
4851
libavcodec/arm/fft_fixed_init_arm.c+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
3+ *
4+ * This file is part of FFmpeg.
5+ *
6+ * FFMpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#define CONFIG_FFT_FLOAT 0
22+#include "libavcodec/fft.h"
23+
24+void ff_fft_fixed_calc_neon(FFTContext *s, FFTComplex *z);
25+void ff_mdct_fixed_calc_neon(FFTContext *s, FFTSample *o, const FFTSample *i);
26+void ff_mdct_fixed_calcw_neon(FFTContext *s, FFTDouble *o, const FFTSample *i);
27+
28+av_cold void ff_fft_fixed_init_arm(FFTContext *s)
29+{
30+ if (HAVE_NEON) {
31+ s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
32+ s->fft_calc = ff_fft_fixed_calc_neon;
33+
34+#if CONFIG_MDCT
35+ if (!s->inverse && s->mdct_bits >= 5) {
36+ s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE;
37+ s->mdct_calc = ff_mdct_fixed_calc_neon;
38+ s->mdct_calcw = ff_mdct_fixed_calcw_neon;
39+ }
40+#endif
41+ }
42+}
libavcodec/arm/fft_fixed_neon.S+261−0
@@ -0,0 +1,261 @@
1+/*
2+ * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
3+ *
4+ * This file is part of Libav.
5+ *
6+ * Libav is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * Libav is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with Libav; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include "asm.S"
22+
23+.macro bflies d0, d1, r0, r1
24+ vrev64.32 \r0, \d1 @ t5, t6, t1, t2
25+ vhsub.s16 \r1, \d1, \r0 @ t1-t5, t2-t6, t5-t1, t6-t2
26+ vhadd.s16 \r0, \d1, \r0 @ t1+t5, t2+t6, t5+t1, t6+t2
27+ vext.16 \r1, \r1, \r1, #1 @ t2-t6, t5-t1, t6-t2, t1-t5
28+ vtrn.32 \r0, \r1 @ t1+t5, t2+t6, t2-t6, t5-t1
29+ @ t5, t6, t4, t3
30+ vhsub.s16 \d1, \d0, \r0
31+ vhadd.s16 \d0, \d0, \r0
32+.endm
33+
34+.macro transform01 q0, q1, d3, c0, c1, r0, w0, w1
35+ vrev32.16 \r0, \d3
36+ vmull.s16 \w0, \d3, \c0
37+ vmlal.s16 \w0, \r0, \c1
38+ vshrn.s32 \d3, \w0, #15
39+ bflies \q0, \q1, \w0, \w1
40+.endm
41+
42+.macro transform2 d0, d1, d2, d3, q0, q1, c0, c1, c2, c3, \
43+ r0, r1, w0, w1
44+ vrev32.16 \r0, \d1
45+ vrev32.16 \r1, \d3
46+ vmull.s16 \w0, \d1, \c0
47+ vmlal.s16 \w0, \r0, \c1
48+ vmull.s16 \w1, \d3, \c2
49+ vmlal.s16 \w1, \r1, \c3
50+ vshrn.s32 \d1, \w0, #15
51+ vshrn.s32 \d3, \w1, #15
52+ bflies \q0, \q1, \w0, \w1
53+.endm
54+
55+.macro fft4 d0, d1, r0, r1
56+ vhsub.s16 \r0, \d0, \d1 @ t3, t4, t8, t7
57+ vhsub.s16 \r1, \d1, \d0
58+ vhadd.s16 \d0, \d0, \d1 @ t1, t2, t6, t5
59+ vmov.i64 \d1, #0xffff<<32
60+ vbit \r0, \r1, \d1
61+ vrev64.16 \r1, \r0 @ t7, t8, t4, t3
62+ vtrn.32 \r0, \r1 @ t3, t4, t7, t8
63+ vtrn.32 \d0, \r0 @ t1, t2, t3, t4, t6, t5, t8, t7
64+ vhsub.s16 \d1, \d0, \r0 @ r2, i2, r3, i1
65+ vhadd.s16 \d0, \d0, \r0 @ r0, i0, r1, i3
66+.endm
67+
68+.macro fft8 d0, d1, d2, d3, q0, q1, c0, c1, r0, r1, w0, w1
69+ fft4 \d0, \d1, \r0, \r1
70+ vtrn.32 \d0, \d1 @ z0, z2, z1, z3
71+ vhadd.s16 \r0, \d2, \d3 @ t1, t2, t3, t4
72+ vhsub.s16 \d3, \d2, \d3 @ z5, z7
73+ vmov \d2, \r0
74+ transform01 \q0, \q1, \d3, \c0, \c1, \r0, \w0, \w1
75+.endm
76+
77+function fft4_neon
78+ vld1.16 {d0-d1}, [r0,:128]
79+ fft4 d0, d1, d2, d3
80+ vst1.16 {d0-d1}, [r0,:128]
81+ bx lr
82+endfunc
83+
84+function fft8_neon
85+ vld1.16 {d0-d3}, [r0,:128]
86+ movrel r1, coefs
87+ vld1.16 {d30}, [r1,:64]
88+ vdup.16 d31, d30[0]
89+ fft8 d0, d1, d2, d3, q0, q1, d31, d30, d20, d21, q8, q9
90+ vtrn.32 d0, d1
91+ vtrn.32 d2, d3
92+ vst1.16 {d0-d3}, [r0,:128]
93+ bx lr
94+endfunc
95+
96+function fft16_neon
97+ vld1.16 {d0-d3}, [r0,:128]!
98+ vld1.16 {d4-d7}, [r0,:128]
99+ movrel r1, coefs
100+ sub r0, r0, #32
101+ vld1.16 {d28-d31},[r1,:128]
102+ vdup.16 d31, d28[0]
103+ fft8 d0, d1, d2, d3, q0, q1, d31, d28, d20, d21, q8, q9
104+ vswp d5, d6
105+ fft4 q2, q3, q8, q9
106+ vswp d5, d6
107+ vtrn.32 q0, q1 @ z0, z4, z2, z6, z1, z5, z3, z7
108+ vtrn.32 q2, q3 @ z8, z12,z10,z14,z9, z13,z11,z15
109+ vswp d1, d2
110+ vdup.16 d31, d28[0]
111+ transform01 q0, q2, d5, d31, d28, d20, q8, q9
112+ vdup.16 d26, d29[0]
113+ vdup.16 d27, d30[0]
114+ transform2 d2, d6, d3, d7, q1, q3, d26, d30, d27, d29, \
115+ d20, d21, q8, q9
116+ vtrn.32 q0, q1
117+ vtrn.32 q2, q3
118+ vst1.16 {d0-d3}, [r0,:128]!
119+ vst1.16 {d4-d7}, [r0,:128]
120+ bx lr
121+endfunc
122+
123+function fft_pass_neon
124+ push {r4,lr}
125+ movrel lr, coefs + 24
126+ vld1.16 {d30}, [lr,:64]
127+ lsl r12, r2, #3
128+ vmov d31, d30
129+ add r3, r1, r2, lsl #2
130+ mov lr, #-8
131+ sub r3, r3, #2
132+ mov r4, r0
133+ vld1.16 {d27[]}, [r3,:16]
134+ sub r3, r3, #6
135+ vld1.16 {q0}, [r4,:128], r12
136+ vld1.16 {q1}, [r4,:128], r12
137+ vld1.16 {q2}, [r4,:128], r12
138+ vld1.16 {q3}, [r4,:128], r12
139+ vld1.16 {d28}, [r1,:64]!
140+ vld1.16 {d29}, [r3,:64], lr
141+ vswp d1, d2
142+ vswp d5, d6
143+ vtrn.32 d0, d1
144+ vtrn.32 d4, d5
145+ vdup.16 d25, d28[1]
146+ vmul.s16 d27, d27, d31
147+ transform01 q0, q2, d5, d25, d27, d20, q8, q9
148+ b 2f
149+1:
150+ mov r4, r0
151+ vdup.16 d26, d29[0]
152+ vld1.16 {q0}, [r4,:128], r12
153+ vld1.16 {q1}, [r4,:128], r12
154+ vld1.16 {q2}, [r4,:128], r12
155+ vld1.16 {q3}, [r4,:128], r12
156+ vld1.16 {d28}, [r1,:64]!
157+ vld1.16 {d29}, [r3,:64], lr
158+ vswp d1, d2
159+ vswp d5, d6
160+ vtrn.32 d0, d1
161+ vtrn.32 d4, d5
162+ vdup.16 d24, d28[0]
163+ vdup.16 d25, d28[1]
164+ vdup.16 d27, d29[3]
165+ vmul.s16 q13, q13, q15
166+ transform2 d0, d4, d1, d5, q0, q2, d24, d26, d25, d27, \
167+ d16, d17, q9, q10
168+2:
169+ vtrn.32 d2, d3
170+ vtrn.32 d6, d7
171+ vdup.16 d24, d28[2]
172+ vdup.16 d26, d29[2]
173+ vdup.16 d25, d28[3]
174+ vdup.16 d27, d29[1]
175+ vmul.s16 q13, q13, q15
176+ transform2 d2, d6, d3, d7, q1, q3, d24, d26, d25, d27, \
177+ d16, d17, q9, q10
178+ vtrn.32 d0, d1
179+ vtrn.32 d2, d3
180+ vtrn.32 d4, d5
181+ vtrn.32 d6, d7
182+ vswp d1, d2
183+ vswp d5, d6
184+ mov r4, r0
185+ vst1.16 {q0}, [r4,:128], r12
186+ vst1.16 {q1}, [r4,:128], r12
187+ vst1.16 {q2}, [r4,:128], r12
188+ vst1.16 {q3}, [r4,:128], r12
189+ add r0, r0, #16
190+ subs r2, r2, #2
191+ bgt 1b
192+ pop {r4,pc}
193+endfunc
194+
195+#define F_SQRT1_2 23170
196+#define F_COS_16_1 30274
197+#define F_COS_16_3 12540
198+
199+const coefs, align=4
200+ .short F_SQRT1_2, -F_SQRT1_2, -F_SQRT1_2, F_SQRT1_2
201+ .short F_COS_16_1,-F_COS_16_1,-F_COS_16_1, F_COS_16_1
202+ .short F_COS_16_3,-F_COS_16_3,-F_COS_16_3, F_COS_16_3
203+ .short 1, -1, -1, 1
204+endconst
205+
206+.macro def_fft n, n2, n4
207+function fft\n\()_neon
208+ push {r4, lr}
209+ mov r4, r0
210+ bl fft\n2\()_neon
211+ add r0, r4, #\n4*2*4
212+ bl fft\n4\()_neon
213+ add r0, r4, #\n4*3*4
214+ bl fft\n4\()_neon
215+ mov r0, r4
216+ pop {r4, lr}
217+ movrel r1, X(ff_cos_\n\()_fixed)
218+ mov r2, #\n4/2
219+ b fft_pass_neon
220+endfunc
221+.endm
222+
223+ def_fft 32, 16, 8
224+ def_fft 64, 32, 16
225+ def_fft 128, 64, 32
226+ def_fft 256, 128, 64
227+ def_fft 512, 256, 128
228+ def_fft 1024, 512, 256
229+ def_fft 2048, 1024, 512
230+ def_fft 4096, 2048, 1024
231+ def_fft 8192, 4096, 2048
232+ def_fft 16384, 8192, 4096
233+ def_fft 32768, 16384, 8192
234+ def_fft 65536, 32768, 16384
235+
236+function ff_fft_fixed_calc_neon, export=1
237+ ldr r2, [r0]
238+ sub r2, r2, #2
239+ movrel r3, fft_fixed_tab_neon
240+ ldr r3, [r3, r2, lsl #2]
241+ mov r0, r1
242+ bx r3
243+endfunc
244+
245+const fft_fixed_tab_neon
246+ .word fft4_neon
247+ .word fft8_neon
248+ .word fft16_neon
249+ .word fft32_neon
250+ .word fft64_neon
251+ .word fft128_neon
252+ .word fft256_neon
253+ .word fft512_neon
254+ .word fft1024_neon
255+ .word fft2048_neon
256+ .word fft4096_neon
257+ .word fft8192_neon
258+ .word fft16384_neon
259+ .word fft32768_neon
260+ .word fft65536_neon
261+endconst
libavcodec/arm/mdct_fixed_neon.S+195−0
@@ -0,0 +1,195 @@
1+/*
2+ * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
3+ *
4+ * This file is part of Libav.
5+ *
6+ * Libav is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * Libav is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with Libav; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include "asm.S"
22+
23+ preserve8
24+
25+.macro prerot dst, rt
26+ lsr r3, r6, #2 @ n4
27+ add \rt, r4, r6, lsr #1 @ revtab + n4
28+ add r9, r3, r3, lsl #1 @ n3
29+ add r8, r7, r6 @ tcos + n4
30+ add r3, r2, r6, lsr #1 @ in + n4
31+ add r9, r2, r9, lsl #1 @ in + n3
32+ sub r8, r8, #16
33+ sub r10, r3, #16
34+ sub r11, r9, #16
35+ mov r12, #-16
36+1:
37+ vld2.16 {d0,d1}, [r9, :128]!
38+ vld2.16 {d2,d3}, [r11,:128], r12
39+ vld2.16 {d4,d5}, [r3, :128]!
40+ vld2.16 {d6,d7}, [r10,:128], r12
41+ vld2.16 {d16,d17},[r7, :128]! @ cos, sin
42+ vld2.16 {d18,d19},[r8, :128], r12
43+ vrev64.16 q1, q1
44+ vrev64.16 q3, q3
45+ vrev64.16 q9, q9
46+ vneg.s16 d0, d0
47+ vneg.s16 d2, d2
48+ vneg.s16 d16, d16
49+ vneg.s16 d18, d18
50+ vhsub.s16 d0, d0, d3 @ re
51+ vhsub.s16 d4, d7, d4 @ im
52+ vhsub.s16 d6, d6, d5
53+ vhsub.s16 d2, d2, d1
54+ vmull.s16 q10, d0, d16
55+ vmlsl.s16 q10, d4, d17
56+ vmull.s16 q11, d0, d17
57+ vmlal.s16 q11, d4, d16
58+ vmull.s16 q12, d6, d18
59+ vmlsl.s16 q12, d2, d19
60+ vmull.s16 q13, d6, d19
61+ vmlal.s16 q13, d2, d18
62+ vshrn.s32 d0, q10, #15
63+ vshrn.s32 d1, q11, #15
64+ vshrn.s32 d2, q12, #15
65+ vshrn.s32 d3, q13, #15
66+ vzip.16 d0, d1
67+ vzip.16 d2, d3
68+ ldrh lr, [r4], #2
69+ ldrh r2, [\rt, #-2]!
70+ add lr, \dst, lr, lsl #2
71+ add r2, \dst, r2, lsl #2
72+ vst1.32 {d0[0]}, [lr,:32]
73+ vst1.32 {d2[0]}, [r2,:32]
74+ ldrh lr, [r4], #2
75+ ldrh r2, [\rt, #-2]!
76+ add lr, \dst, lr, lsl #2
77+ add r2, \dst, r2, lsl #2
78+ vst1.32 {d0[1]}, [lr,:32]
79+ vst1.32 {d2[1]}, [r2,:32]
80+ ldrh lr, [r4], #2
81+ ldrh r2, [\rt, #-2]!
82+ add lr, \dst, lr, lsl #2
83+ add r2, \dst, r2, lsl #2
84+ vst1.32 {d1[0]}, [lr,:32]
85+ vst1.32 {d3[0]}, [r2,:32]
86+ ldrh lr, [r4], #2
87+ ldrh r2, [\rt, #-2]!
88+ add lr, \dst, lr, lsl #2
89+ add r2, \dst, r2, lsl #2
90+ vst1.32 {d1[1]}, [lr,:32]
91+ vst1.32 {d3[1]}, [r2,:32]
92+ subs r6, r6, #32
93+ bgt 1b
94+.endm
95+
96+function ff_mdct_fixed_calc_neon, export=1
97+ push {r1,r4-r11,lr}
98+
99+ ldr r4, [r0, #8] @ revtab
100+ ldr r6, [r0, #16] @ mdct_size; n
101+ ldr r7, [r0, #24] @ tcos
102+
103+ prerot r1, r5
104+
105+ mov r4, r0
106+ bl X(ff_fft_fixed_calc_neon)
107+
108+ pop {r5}
109+ mov r12, #-16
110+ ldr r6, [r4, #16] @ mdct_size; n
111+ ldr r7, [r4, #24] @ tcos
112+ add r5, r5, r6, lsr #1
113+ add r7, r7, r6, lsr #1
114+ sub r1, r5, #16
115+ sub r2, r7, #16
116+1:
117+ vld2.16 {d4,d5}, [r7,:128]!
118+ vld2.16 {d6,d7}, [r2,:128], r12
119+ vld2.16 {d0,d1}, [r5,:128]
120+ vld2.16 {d2,d3}, [r1,:128]
121+ vrev64.16 q3, q3
122+ vrev64.16 q1, q1
123+ vneg.s16 q3, q3
124+ vneg.s16 q2, q2
125+ vmull.s16 q11, d2, d6
126+ vmlal.s16 q11, d3, d7
127+ vmull.s16 q8, d0, d5
128+ vmlsl.s16 q8, d1, d4
129+ vmull.s16 q9, d0, d4
130+ vmlal.s16 q9, d1, d5
131+ vmull.s16 q10, d2, d7
132+ vmlsl.s16 q10, d3, d6
133+ vshrn.s32 d0, q11, #15
134+ vshrn.s32 d1, q8, #15
135+ vshrn.s32 d2, q9, #15
136+ vshrn.s32 d3, q10, #15
137+ vrev64.16 q0, q0
138+ vst2.16 {d2,d3}, [r5,:128]!
139+ vst2.16 {d0,d1}, [r1,:128], r12
140+ subs r6, r6, #32
141+ bgt 1b
142+
143+ pop {r4-r11,pc}
144+endfunc
145+
146+function ff_mdct_fixed_calcw_neon, export=1
147+ push {r1,r4-r11,lr}
148+
149+ ldrd r4, r5, [r0, #8] @ revtab, tmp_buf
150+ ldr r6, [r0, #16] @ mdct_size; n
151+ ldr r7, [r0, #24] @ tcos
152+
153+ prerot r5, r1
154+
155+ mov r4, r0
156+ mov r1, r5
157+ bl X(ff_fft_fixed_calc_neon)
158+
159+ pop {r7}
160+ mov r12, #-16
161+ ldr r6, [r4, #16] @ mdct_size; n
162+ ldr r9, [r4, #24] @ tcos
163+ add r5, r5, r6, lsr #1
164+ add r7, r7, r6
165+ add r9, r9, r6, lsr #1
166+ sub r3, r5, #16
167+ sub r1, r7, #16
168+ sub r2, r9, #16
169+1:
170+ vld2.16 {d4,d5}, [r9,:128]!
171+ vld2.16 {d6,d7}, [r2,:128], r12
172+ vld2.16 {d0,d1}, [r5,:128]!
173+ vld2.16 {d2,d3}, [r3,:128], r12
174+ vrev64.16 q3, q3
175+ vrev64.16 q1, q1
176+ vneg.s16 q3, q3
177+ vneg.s16 q2, q2
178+ vmull.s16 q8, d2, d6
179+ vmlal.s16 q8, d3, d7
180+ vmull.s16 q9, d0, d5
181+ vmlsl.s16 q9, d1, d4
182+ vmull.s16 q10, d0, d4
183+ vmlal.s16 q10, d1, d5
184+ vmull.s16 q11, d2, d7
185+ vmlsl.s16 q11, d3, d6
186+ vrev64.32 q8, q8
187+ vrev64.32 q9, q9
188+ vst2.32 {q10,q11},[r7,:128]!
189+ vst2.32 {d16,d18},[r1,:128], r12
190+ vst2.32 {d17,d19},[r1,:128], r12
191+ subs r6, r6, #32
192+ bgt 1b
193+
194+ pop {r4-r11,pc}
195+endfunc
libavcodec/avcodec.h+8−3
@@ -1829,19 +1829,21 @@ typedef struct AVCodecContext { · 1828 unmodified lines
18291829 */
18301830 uint64_t error[4];
18311831
1832+#if FF_API_MB_Q
18321833 /**
18331834 * minimum MB quantizer
18341835 * - encoding: unused
18351836 * - decoding: unused
18361837 */
1837− int mb_qmin;
1838+ attribute_deprecated int mb_qmin;
18381839
18391840 /**
18401841 * maximum MB quantizer
18411842 * - encoding: unused
18421843 * - decoding: unused
18431844 */
1844− int mb_qmax;
1845+ attribute_deprecated int mb_qmax;
1846+#endif
18451847
18461848 /**
18471849 * motion estimation comparison function
@@ -2162,16 +2164,19 @@ typedef struct AVCodecContext { · 314 unmodified lines
21622164 */
21632165 int error_rate;
21642166
2167+#if FF_API_ANTIALIAS_ALGO
21652168 /**
21662169 * MP3 antialias algorithm, see FF_AA_* below.
21672170 * - encoding: unused
21682171 * - decoding: Set by user.
21692172 */
2170− int antialias_algo;
2173+ attribute_deprecated int antialias_algo;
21712174 #define FF_AA_AUTO 0
21722175 #define FF_AA_FASTINT 1 //not implemented yet
21732176 #define FF_AA_INT 2
21742177 #define FF_AA_FLOAT 3
2178+#endif
2179+
21752180 /**
21762181 * quantizer noise shaping
21772182 * - encoding: Set by user.
libavcodec/fft.c+1−0
@@ -126,6 +126,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) · 125 unmodified lines
126126 if (CONFIG_MDCT) s->mdct_calcw = s->mdct_calc;
127127 #else
128128 if (CONFIG_MDCT) s->mdct_calcw = ff_mdct_calcw_c;
129+ if (ARCH_ARM) ff_fft_fixed_init_arm(s);
129130 #endif
130131
131132 for(j=4; j<=nbits; j++) {
libavcodec/fft.h+4−0
@@ -132,9 +132,13 @@ void ff_init_ff_cos_tabs(int index); · 131 unmodified lines
132132 */
133133 int ff_fft_init(FFTContext *s, int nbits, int inverse);
134134
135+#if CONFIG_FFT_FLOAT
135136 void ff_fft_init_altivec(FFTContext *s);
136137 void ff_fft_init_mmx(FFTContext *s);
137138 void ff_fft_init_arm(FFTContext *s);
139+#else
140+void ff_fft_fixed_init_arm(FFTContext *s);
141+#endif
138142
139143 void ff_fft_end(FFTContext *s);
140144
libavcodec/options.c+4−0
@@ -259,8 +259,10 @@ static const AVOption options[]={ · 258 unmodified lines
259259 {"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"},
260260 {"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"},
261261 {"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"},
262+#if FF_API_MB_Q
262263 {"mb_qmin", "obsolete, use qmin", OFFSET(mb_qmin), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
263264 {"mb_qmax", "obsolete, use qmax", OFFSET(mb_qmax), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
265+#endif
264266 {"cmp", "full pel me compare function", OFFSET(me_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
265267 {"subcmp", "sub pel me compare function", OFFSET(me_sub_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
266268 {"mbcmp", "macroblock compare function", OFFSET(mb_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
@@ -317,7 +319,9 @@ static const AVOption options[]={ · 50 unmodified lines
317319 {"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
318320 {"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"},
319321 {"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
322+#if FF_API_ANTIALIAS_ALGO
320323 {"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"},
324+#endif
321325 {"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_AUTO, INT_MIN, INT_MAX, V|D, "aa"},
322326 {"fastint", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_FASTINT, INT_MIN, INT_MAX, V|D, "aa"},
323327 {"int", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_INT, INT_MIN, INT_MAX, V|D, "aa"},
libavcodec/version.h+6−0
@@ -77,5 +77,11 @@ · 76 unmodified lines
7777 #ifndef FF_API_RATE_EMU
7878 #define FF_API_RATE_EMU (LIBAVCODEC_VERSION_MAJOR < 53)
7979 #endif
80+#ifndef FF_API_MB_Q
81+#define FF_API_MB_Q (LIBAVCODEC_VERSION_MAJOR < 53)
82+#endif
83+#ifndef FF_API_ANTIALIAS_ALGO
84+#define FF_API_ANTIALIAS_ALGO (LIBAVCODEC_VERSION_MAJOR < 54)
85+#endif
8086
8187 #endif /* AVCODEC_VERSION_H */
libavfilter/avfilter.h+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626 #include "libavutil/samplefmt.h"
2727
2828 #define LIBAVFILTER_VERSION_MAJOR 1
29−#define LIBAVFILTER_VERSION_MINOR 76
29+#define LIBAVFILTER_VERSION_MINOR 77
3030 #define LIBAVFILTER_VERSION_MICRO 0
3131
3232 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
libavformat/aiffdec.c+1−1
@@ -238,7 +238,7 @@ static int aiff_read_header(AVFormatContext *s, · 237 unmodified lines
238238 offset += avio_tell(pb); /* Compute absolute data offset */
239239 if (st->codec->block_align) /* Assume COMM already parsed */
240240 goto got_sound;
241− if (url_is_streamed(pb)) {
241+ if (!pb->seekable) {
242242 av_log(s, AV_LOG_ERROR, "file is not seekable\n");
243243 return -1;
244244 }
libavformat/aiffenc.c+1−1
@@ -124,7 +124,7 @@ static int aiff_write_trailer(AVFormatContext *s) · 123 unmodified lines
124124 end_size++;
125125 }
126126
127− if (!url_is_streamed(s->pb)) {
127+ if (s->pb->seekable) {
128128 /* File length */
129129 avio_seek(pb, aiff->form, SEEK_SET);
130130 avio_wb32(pb, file_size - aiff->form - 4);
libavformat/ape.c+1−1
@@ -296,7 +296,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) · 295 unmodified lines
296296 ape_dumpinfo(s, ape);
297297
298298 /* try to read APE tags */
299− if (!url_is_streamed(pb)) {
299+ if (pb->seekable) {
300300 ff_ape_parse_tag(s);
301301 avio_seek(pb, 0, SEEK_SET);
302302 }
libavformat/asfenc.c+8−8
@@ -234,11 +234,11 @@ static void put_str16(AVIOContext *s, const char *tag) · 233 unmodified lines
234234 int len;
235235 uint8_t *pb;
236236 AVIOContext *dyn_buf;
237− if (url_open_dyn_buf(&dyn_buf) < 0)
237+ if (avio_open_dyn_buf(&dyn_buf) < 0)
238238 return;
239239
240240 avio_put_str16le(dyn_buf, tag);
241− len = url_close_dyn_buf(dyn_buf, &pb);
241+ len = avio_close_dyn_buf(dyn_buf, &pb);
242242 avio_wl16(s, len);
243243 avio_write(s, pb, len);
244244 av_freep(&pb);
@@ -347,7 +347,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data · 102 unmodified lines
347347 avio_wl64(pb, duration); /* end time stamp (in 100ns units) */
348348 avio_wl64(pb, asf->duration); /* duration (in 100ns units) */
349349 avio_wl64(pb, PREROLL_TIME); /* start time stamp */
350− avio_wl32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */
350+ avio_wl32(pb, (asf->is_streamed || !pb->seekable ) ? 3 : 2); /* ??? */
351351 avio_wl32(pb, s->packet_size); /* packet size */
352352 avio_wl32(pb, s->packet_size); /* packet size */
353353 avio_wl32(pb, bit_rate); /* Nominal data rate in bps */
@@ -366,7 +366,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data · 12 unmodified lines
366366 uint8_t *buf;
367367 AVIOContext *dyn_buf;
368368
369− if (url_open_dyn_buf(&dyn_buf) < 0)
369+ if (avio_open_dyn_buf(&dyn_buf) < 0)
370370 return AVERROR(ENOMEM);
371371
372372 hpos = put_header(pb, &ff_asf_comment_header);
@@ -375,7 +375,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data · 2 unmodified lines
375375 len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
376376 avio_wl16(pb, len);
377377 }
378− len = url_close_dyn_buf(dyn_buf, &buf);
378+ len = avio_close_dyn_buf(dyn_buf, &buf);
379379 avio_write(pb, buf, len);
380380 av_freep(&buf);
381381 end_header(pb, hpos);
@@ -497,11 +497,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data · 115 unmodified lines
497497 else
498498 desc = p ? p->name : enc->codec_name;
499499
500− if ( url_open_dyn_buf(&dyn_buf) < 0)
500+ if ( avio_open_dyn_buf(&dyn_buf) < 0)
501501 return AVERROR(ENOMEM);
502502
503503 avio_put_str16le(dyn_buf, desc);
504− len = url_close_dyn_buf(dyn_buf, &buf);
504+ len = avio_close_dyn_buf(dyn_buf, &buf);
505505 avio_wl16(pb, len / 2); // "number of characters" = length in bytes / 2
506506
507507 avio_write(pb, buf, len);
@@ -866,7 +866,7 @@ static int asf_write_trailer(AVFormatContext *s) · 358 unmodified lines
866866 }
867867 avio_flush(s->pb);
868868
869− if (asf->is_streamed || url_is_streamed(s->pb)) {
869+ if (asf->is_streamed || !s->pb->seekable) {
870870 put_chunk(s, 0x4524, 0, 0); /* end of stream */
871871 } else {
872872 /* rewrite an updated header */
libavformat/au.c+1−1
@@ -91,7 +91,7 @@ static int au_write_trailer(AVFormatContext *s) · 90 unmodified lines
9191 AVIOContext *pb = s->pb;
9292 int64_t file_size;
9393
94− if (!url_is_streamed(s->pb)) {
94+ if (s->pb->seekable) {
9595
9696 /* update file size */
9797 file_size = avio_tell(pb);
libavformat/avc.c+2−2
@@ -89,14 +89,14 @@ int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size) · 88 unmodified lines
8989 int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
9090 {
9191 AVIOContext *pb;
92− int ret = url_open_dyn_buf(&pb);
92+ int ret = avio_open_dyn_buf(&pb);
9393 if(ret < 0)
9494 return ret;
9595
9696 ff_avc_parse_nal_units(pb, buf_in, *size);
9797
9898 av_freep(buf);
99− *size = url_close_dyn_buf(pb, buf);
99+ *size = avio_close_dyn_buf(pb, buf);
100100 return 0;
101101 }
102102
libavformat/avidec.c+2−2
@@ -665,7 +665,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) · 664 unmodified lines
665665 break;
666666 case MKTAG('i', 'n', 'd', 'x'):
667667 i= avio_tell(pb);
668− if(!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX)){
668+ if(pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX)){
669669 read_braindead_odml_indx(s, 0);
670670 }
671671 avio_seek(pb, i+size, SEEK_SET);
@@ -721,7 +721,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) · 49 unmodified lines
721721 return -1;
722722 }
723723
724− if(!avi->index_loaded && !url_is_streamed(pb))
724+ if(!avi->index_loaded && pb->seekable)
725725 avi_load_index(s);
726726 avi->index_loaded = 1;
727727 avi->non_interleaved |= guess_ni_flag(s);
libavformat/avienc.c+9−9
@@ -197,7 +197,7 @@ static int avi_write_header(AVFormatContext *s) · 196 unmodified lines
197197 }
198198 avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */
199199 avio_wl32(pb, 0); /* padding */
200− if (url_is_streamed(pb))
200+ if (!pb->seekable)
201201 avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
202202 else
203203 avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
@@ -259,7 +259,7 @@ static int avi_write_header(AVFormatContext *s) · 55 unmodified lines
259259
260260 avio_wl32(pb, 0); /* start */
261261 avist->frames_hdr_strm = avio_tell(pb); /* remember this offset to fill later */
262− if (url_is_streamed(pb))
262+ if (!pb->seekable)
263263 avio_wl32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */
264264 else
265265 avio_wl32(pb, 0); /* length, XXX: filled later */
@@ -303,7 +303,7 @@ static int avi_write_header(AVFormatContext *s) · 37 unmodified lines
303303 }
304304 }
305305
306− if (!url_is_streamed(pb)) {
306+ if (pb->seekable) {
307307 unsigned char tag[5];
308308 int j;
309309
@@ -362,7 +362,7 @@ static int avi_write_header(AVFormatContext *s) · 52 unmodified lines
362362 ff_end_tag(pb, list2);
363363 }
364364
365− if (!url_is_streamed(pb)) {
365+ if (pb->seekable) {
366366 /* AVI could become an OpenDML one, if it grows beyond 2Gb range */
367367 avi->odml_list = ff_start_tag(pb, "JUNK");
368368 ffio_wfourcc(pb, "odml");
@@ -406,7 +406,7 @@ static int avi_write_ix(AVFormatContext *s) · 37 unmodified lines
406406 char ix_tag[] = "ix00";
407407 int i, j;
408408
409− assert(!url_is_streamed(pb));
409+ assert(pb->seekable);
410410
411411 if (avi->riff_id > AVI_MASTER_INDEX_SIZE)
412412 return -1;
@@ -464,7 +464,7 @@ static int avi_write_idx1(AVFormatContext *s) · 51 unmodified lines
464464 int i;
465465 char tag[5];
466466
467− if (!url_is_streamed(pb)) {
467+ if (pb->seekable) {
468468 AVIStream *avist;
469469 AVIIentry* ie = 0, *tie;
470470 int empty, stream_id = -1;
@@ -532,7 +532,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) · 61 unmodified lines
532532 avist->packet_count++;
533533
534534 // Make sure to put an OpenDML chunk when the file size exceeds the limits
535− if (!url_is_streamed(pb) &&
535+ if (pb->seekable &&
536536 (avio_tell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) {
537537
538538 avi_write_ix(s);
@@ -552,7 +552,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) · 13 unmodified lines
552552 avist->audio_strm_length += size;
553553 }
554554
555− if (!url_is_streamed(s->pb)) {
555+ if (s->pb->seekable) {
556556 AVIIndex* idx = &avist->indexes;
557557 int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE;
558558 int id = idx->entry % AVI_INDEX_CLUSTER_SIZE;
@@ -590,7 +590,7 @@ static int avi_write_trailer(AVFormatContext *s) · 31 unmodified lines
590590 int i, j, n, nb_frames;
591591 int64_t file_size;
592592
593− if (!url_is_streamed(pb)){
593+ if (pb->seekable){
594594 if (avi->riff_id == 1) {
595595 ff_end_tag(pb, avi->movi_list);
596596 res = avi_write_idx1(s);
libavformat/avio.h+24−32
@@ -332,6 +332,8 @@ attribute_deprecated int av_register_protocol(URLProtocol *protocol); · 331 unmodified lines
332332 */
333333 int av_register_protocol2(URLProtocol *protocol, int size);
334334
335+#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
336+
335337 /**
336338 * Bytestream IO Context.
337339 * New fields can be added to the end with minor version bumps.
@@ -351,7 +353,9 @@ typedef struct { · 13 unmodified lines
351353 int must_flush; /**< true if the next seek should flush */
352354 int eof_reached; /**< true if eof reached */
353355 int write_flag; /**< true if open for writing */
354− int is_streamed;
356+#if FF_API_OLD_AVIO
357+ attribute_deprecated int is_streamed;
358+#endif
355359 int max_packet_size;
356360 unsigned long checksum;
357361 unsigned char *checksum_ptr;
@@ -360,6 +364,10 @@ typedef struct { · 2 unmodified lines
360364 int (*read_pause)(void *opaque, int pause);
361365 int64_t (*read_seek)(void *opaque, int stream_index,
362366 int64_t timestamp, int flags);
367+ /**
368+ * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
369+ */
370+ int seekable;
363371 } AVIOContext;
364372
365373 #if FF_API_OLD_AVIO
@@ -439,6 +447,10 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) __att · 73 unmodified lines
439447 attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...);
440448 #endif
441449 attribute_deprecated void put_flush_packet(AVIOContext *s);
450+attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
451+attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
452+attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
453+attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
442454 /**
443455 * @}
444456 */
@@ -603,23 +615,15 @@ unsigned int avio_rb24(AVIOContext *s); · 158 unmodified lines
603615 unsigned int avio_rb32(AVIOContext *s);
604616 uint64_t avio_rb64(AVIOContext *s);
605617
606−static inline int url_is_streamed(AVIOContext *s)
607−{
608− return s->is_streamed;
609−}
610−
618+#if FF_API_OLD_AVIO
611619 /**
612− * Create and initialize a AVIOContext for accessing the
613− * resource referenced by the URLContext h.
614− * @note When the URLContext h has been opened in read+write mode, the
615− * AVIOContext can be used only for writing.
616− *
617− * @param s Used to return the pointer to the created AVIOContext.
618− * In case of failure the pointed to value is set to NULL.
619− * @return 0 in case of success, a negative value corresponding to an
620− * AVERROR code in case of failure
620+ * @deprecated Use AVIOContext.seekable field directly.
621621 */
622−int url_fdopen(AVIOContext **s, URLContext *h);
622+attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
623+{
624+ return !s->seekable;
625+}
626+#endif
623627
624628 #if FF_API_URL_RESETBUF
625629 /** Reset the buffer for reading or writing.
@@ -666,30 +670,18 @@ attribute_deprecated int url_close_buf(AVIOContext *s); · 40 unmodified lines
666670 * @param s new IO context
667671 * @return zero if no error.
668672 */
669−int url_open_dyn_buf(AVIOContext **s);
670−
671−/**
672− * Open a write only packetized memory stream with a maximum packet
673− * size of 'max_packet_size'. The stream is stored in a memory buffer
674− * with a big endian 4 byte header giving the packet size in bytes.
675− *
676− * @param s new IO context
677− * @param max_packet_size maximum packet size (must be > 0)
678− * @return zero if no error.
679− */
680−int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
673+int avio_open_dyn_buf(AVIOContext **s);
681674
682675 /**
683676 * Return the written size and a pointer to the buffer. The buffer
684− * must be freed with av_free(). If the buffer is opened with
685− * url_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is
686− * added; if opened with url_open_dyn_packet_buf, no padding is added.
677+ * must be freed with av_free().
678+ * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
687679 *
688680 * @param s IO context
689681 * @param pbuffer pointer to a byte buffer
690682 * @return the length of the byte buffer
691683 */
692−int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
684+int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
693685
694686 #if FF_API_UDP_GET_FILE
695687 int udp_get_file_handle(URLContext *h);
libavformat/avio_internal.h+24−0
@@ -81,4 +81,28 @@ unsigned long ffio_get_checksum(AVIOContext *s); · 80 unmodified lines
8181 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
8282 unsigned int len);
8383
84+/**
85+ * Open a write only packetized memory stream with a maximum packet
86+ * size of 'max_packet_size'. The stream is stored in a memory buffer
87+ * with a big endian 4 byte header giving the packet size in bytes.
88+ *
89+ * @param s new IO context
90+ * @param max_packet_size maximum packet size (must be > 0)
91+ * @return zero if no error.
92+ */
93+int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
94+
95+/**
96+ * Create and initialize a AVIOContext for accessing the
97+ * resource referenced by the URLContext h.
98+ * @note When the URLContext h has been opened in read+write mode, the
99+ * AVIOContext can be used only for writing.
100+ *
101+ * @param s Used to return the pointer to the created AVIOContext.
102+ * In case of failure the pointed to value is set to NULL.
103+ * @return 0 in case of success, a negative value corresponding to an
104+ * AVERROR code in case of failure
105+ */
106+int ffio_fdopen(AVIOContext **s, URLContext *h);
107+
84108 #endif // AVFORMAT_AVIO_INTERNAL_H
libavformat/aviobuf.c+35−21
@@ -62,7 +62,10 @@ int ffio_init_context(AVIOContext *s, · 61 unmodified lines
6262 s->must_flush = 0;
6363 s->eof_reached = 0;
6464 s->error = 0;
65+#if FF_API_OLD_AVIO
6566 s->is_streamed = 0;
67+#endif
68+ s->seekable = AVIO_SEEKABLE_NORMAL;
6669 s->max_packet_size = 0;
6770 s->update_checksum= NULL;
6871 if(!read_packet && !write_flag){
@@ -202,7 +205,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) · 133 unmodified lines
202205 offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {
203206 /* can do the seek inside the buffer */
204207 s->buf_ptr = s->buffer + offset1;
205− } else if ((s->is_streamed ||
208+ } else if ((!s->seekable ||
206209 offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) &&
207210 !s->write_flag && offset1 >= 0 &&
208211 (whence != SEEK_END || force)) {
@@ -425,6 +428,22 @@ unsigned long get_checksum(AVIOContext *s) · 216 unmodified lines
425428 {
426429 return ffio_get_checksum(s);
427430 }
431+int url_open_dyn_buf(AVIOContext **s)
432+{
433+ return avio_open_dyn_buf(s);
434+}
435+int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
436+{
437+ return ffio_open_dyn_packet_buf(s, max_packet_size);
438+}
439+int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
440+{
441+ return avio_close_dyn_buf(s, pbuffer);
442+}
443+int url_fdopen(AVIOContext **s, URLContext *h)
444+{
445+ return ffio_fdopen(s, h);
446+}
428447 #endif
429448
430449 int avio_put_str(AVIOContext *s, const char *str)
@@ -812,7 +831,7 @@ uint64_t ffio_read_varlen(AVIOContext *bc){ · 381 unmodified lines
812831 return val;
813832 }
814833
815−int url_fdopen(AVIOContext **s, URLContext *h)
834+int ffio_fdopen(AVIOContext **s, URLContext *h)
816835 {
817836 uint8_t *buffer;
818837 int buffer_size, max_packet_size;
@@ -840,7 +859,10 @@ int url_fdopen(AVIOContext **s, URLContext *h) · 21 unmodified lines
840859 av_freep(s);
841860 return AVERROR(EIO);
842861 }
862+#if FF_API_OLD_AVIO
843863 (*s)->is_streamed = h->is_streamed;
864+#endif
865+ (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
844866 (*s)->max_packet_size = max_packet_size;
845867 if(h->prot) {
846868 (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause;
@@ -934,7 +956,7 @@ int avio_open(AVIOContext **s, const char *filename, int flags) · 87 unmodified lines
934956 err = url_open(&h, filename, flags);
935957 if (err < 0)
936958 return err;
937− err = url_fdopen(s, h);
959+ err = ffio_fdopen(s, h);
938960 if (err < 0) {
939961 url_close(h);
940962 return err;
@@ -1026,7 +1048,7 @@ int64_t ffio_read_seek(AVIOContext *s, int stream_index, · 85 unmodified lines
10261048 return ret;
10271049 }
10281050
1029−/* url_open_dyn_buf and url_close_dyn_buf are used in rtp.c to send a response
1051+/* avio_open_dyn_buf and avio_close_dyn_buf are used in rtp.c to send a response
10301052 * back to the server even if CONFIG_MUXERS is false. */
10311053 #if CONFIG_MUXERS || CONFIG_NETWORK
10321054 /* buffer handling */
@@ -1123,7 +1145,6 @@ static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence) · 90 unmodified lines
11231145 static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
11241146 {
11251147 DynBuffer *d;
1126− int ret;
11271148 unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
11281149
11291150 if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size)
@@ -1131,38 +1152,31 @@ static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size) · 1 unmodified line
11311152 d = av_mallocz(sizeof(DynBuffer) + io_buffer_size);
11321153 if (!d)
11331154 return AVERROR(ENOMEM);
1134− *s = av_mallocz(sizeof(AVIOContext));
1155+ d->io_buffer_size = io_buffer_size;
1156+ *s = avio_alloc_context(d->io_buffer, d->io_buffer_size, 1, d, NULL,
1157+ max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
1158+ max_packet_size ? NULL : dyn_buf_seek);
11351159 if(!*s) {
11361160 av_free(d);
11371161 return AVERROR(ENOMEM);
11381162 }
1139− d->io_buffer_size = io_buffer_size;
1140− ret = ffio_init_context(*s, d->io_buffer, io_buffer_size,
1141− 1, d, NULL,
1142− max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
1143− max_packet_size ? NULL : dyn_buf_seek);
1144− if (ret == 0) {
1145− (*s)->max_packet_size = max_packet_size;
1146− } else {
1147− av_free(d);
1148− av_freep(s);
1149− }
1150− return ret;
1163+ (*s)->max_packet_size = max_packet_size;
1164+ return 0;
11511165 }
11521166
1153−int url_open_dyn_buf(AVIOContext **s)
1167+int avio_open_dyn_buf(AVIOContext **s)
11541168 {
11551169 return url_open_dyn_buf_internal(s, 0);
11561170 }
11571171
1158−int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
1172+int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
11591173 {
11601174 if (max_packet_size <= 0)
11611175 return -1;
11621176 return url_open_dyn_buf_internal(s, max_packet_size);
11631177 }
11641178
1165−int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
1179+int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
11661180 {
11671181 DynBuffer *d = s->opaque;
11681182 int size;
libavformat/bink.c+1−1
@@ -247,7 +247,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in · 246 unmodified lines
247247 BinkDemuxContext *bink = s->priv_data;
248248 AVStream *vst = s->streams[0];
249249
250− if (url_is_streamed(s->pb))
250+ if (!s->pb->seekable)
251251 return -1;
252252
253253 /* seek to the first frame */
libavformat/cafdec.c+2−2
@@ -223,7 +223,7 @@ static int read_header(AVFormatContext *s, · 222 unmodified lines
223223
224224 /* stop at data chunk if seeking is not supported or
225225 data chunk size is unknown */
226− if (found_data && (caf->data_size < 0 || url_is_streamed(pb)))
226+ if (found_data && (caf->data_size < 0 || !pb->seekable))
227227 break;
228228
229229 tag = avio_rb32(pb);
@@ -236,7 +236,7 @@ static int read_header(AVFormatContext *s, · 6 unmodified lines
236236 avio_skip(pb, 4); /* edit count */
237237 caf->data_start = avio_tell(pb);
238238 caf->data_size = size < 0 ? -1 : size - 4;
239− if (caf->data_size > 0 && !url_is_streamed(pb))
239+ if (caf->data_size > 0 && pb->seekable)
240240 avio_skip(pb, caf->data_size);
241241 found_data = 1;
242242 break;
libavformat/ffmdec.c+1−1
@@ -281,7 +281,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) · 280 unmodified lines
281281 goto fail;
282282 ffm->write_index = avio_rb64(pb);
283283 /* get also filesize */
284− if (!url_is_streamed(pb)) {
284+ if (pb->seekable) {
285285 ffm->file_size = avio_size(pb);
286286 if (ffm->write_index)
287287 adjust_write_index(s);
libavformat/filmstripdec.c+1−1
@@ -40,7 +40,7 @@ static int read_header(AVFormatContext *s, · 39 unmodified lines
4040 AVIOContext *pb = s->pb;
4141 AVStream *st;
4242
43− if (url_is_streamed(s->pb))
43+ if (!s->pb->seekable)
4444 return AVERROR(EIO);
4545
4646 avio_seek(pb, avio_size(pb) - 36, SEEK_SET);
libavformat/flacenc.c+1−1
@@ -98,7 +98,7 @@ static int flac_write_trailer(struct AVFormatContext *s) · 97 unmodified lines
9898 if (!ff_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo))
9999 return -1;
100100
101− if (!url_is_streamed(pb)) {
101+ if (pb->seekable) {
102102 /* rewrite the STREAMINFO header block data */
103103 file_size = avio_tell(pb);
104104 avio_seek(pb, 8, SEEK_SET);
libavformat/flvdec.c+2−2
@@ -428,7 +428,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) · 427 unmodified lines
428428 }
429429
430430 // if not streamed and no duration from metadata then seek to end to find the duration from the timestamps
431− if(!url_is_streamed(s->pb) && (!s->duration || s->duration==AV_NOPTS_VALUE)){
431+ if(s->pb->seekable && (!s->duration || s->duration==AV_NOPTS_VALUE)){
432432 int size;
433433 const int64_t pos= avio_tell(s->pb);
434434 const int64_t fsize= avio_size(s->pb);
@@ -530,7 +530,7 @@ static int flv_read_seek2(AVFormatContext *s, int stream_index, · 95 unmodified lines
530530
531531 if (ts - min_ts > (uint64_t)(max_ts - ts)) flags |= AVSEEK_FLAG_BACKWARD;
532532
533− if (url_is_streamed(s->pb)) {
533+ if (!s->pb->seekable) {
534534 if (stream_index < 0) {
535535 stream_index = av_find_default_stream_index(s);
536536 if (stream_index < 0)
libavformat/gxfenc.c+1−1
@@ -634,7 +634,7 @@ static int gxf_write_header(AVFormatContext *s) · 633 unmodified lines
634634 uint8_t tracks[255] = {0};
635635 int i, media_info = 0;
636636
637− if (url_is_streamed(pb)) {
637+ if (!pb->seekable) {
638638 av_log(s, AV_LOG_ERROR, "gxf muxer does not support streamed output, patch welcome");
639639 return -1;
640640 }
libavformat/id3v1.c+1−1
@@ -229,7 +229,7 @@ void ff_id3v1_read(AVFormatContext *s) · 228 unmodified lines
229229 uint8_t buf[ID3v1_TAG_SIZE];
230230 int64_t filesize, position = avio_tell(s->pb);
231231
232− if (!url_is_streamed(s->pb)) {
232+ if (s->pb->seekable) {
233233 /* XXX: change that */
234234 filesize = avio_size(s->pb);
235235 if (filesize > 128) {
libavformat/matroskadec.c+1−1
@@ -1120,7 +1120,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) · 1119 unmodified lines
11201120 int i;
11211121
11221122 // we should not do any seeking in the streaming case
1123− if (url_is_streamed(matroska->ctx->pb) ||
1123+ if (!matroska->ctx->pb->seekable ||
11241124 (matroska->ctx->flags & AVFMT_FLAG_IGNIDX))
11251125 return;
11261126
libavformat/matroskaenc.c+10−10
@@ -455,7 +455,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo · 454 unmodified lines
455455 uint8_t *codecpriv;
456456 int ret, codecpriv_size;
457457
458− ret = url_open_dyn_buf(&dyn_cp);
458+ ret = avio_open_dyn_buf(&dyn_cp);
459459 if(ret < 0)
460460 return ret;
461461
@@ -498,7 +498,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo · 36 unmodified lines
498498 ff_put_wav_header(dyn_cp, codec);
499499 }
500500
501− codecpriv_size = url_close_dyn_buf(dyn_cp, &codecpriv);
501+ codecpriv_size = avio_close_dyn_buf(dyn_cp, &codecpriv);
502502 if (codecpriv_size)
503503 put_ebml_binary(pb, MATROSKA_ID_CODECPRIVATE, codecpriv, codecpriv_size);
504504 av_free(codecpriv);
@@ -852,7 +852,7 @@ static int mkv_write_header(AVFormatContext *s) · 347 unmodified lines
852852 if (ret < 0) return ret;
853853 }
854854
855− if (url_is_streamed(s->pb))
855+ if (!s->pb->seekable)
856856 mkv_write_seekhead(pb, mkv->main_seekhead);
857857
858858 mkv->cues = mkv_start_cues(mkv->segment_offset);
@@ -1007,7 +1007,7 @@ static void mkv_flush_dynbuf(AVFormatContext *s) · 148 unmodified lines
10071007 if (!mkv->dyn_bc)
10081008 return;
10091009
1010− bufsize = url_close_dyn_buf(mkv->dyn_bc, &dyn_buf);
1010+ bufsize = avio_close_dyn_buf(mkv->dyn_bc, &dyn_buf);
10111011 avio_write(s->pb, dyn_buf, bufsize);
10121012 av_free(dyn_buf);
10131013 mkv->dyn_bc = NULL;
@@ -1028,9 +1028,9 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt) · 14 unmodified lines
10281028 return AVERROR(EINVAL);
10291029 }
10301030
1031− if (url_is_streamed(s->pb)) {
1031+ if (!s->pb->seekable) {
10321032 if (!mkv->dyn_bc)
1033− url_open_dyn_buf(&mkv->dyn_bc);
1033+ avio_open_dyn_buf(&mkv->dyn_bc);
10341034 pb = mkv->dyn_bc;
10351035 }
10361036
@@ -1080,16 +1080,16 @@ static int mkv_copy_packet(MatroskaMuxContext *mkv, const AVPacket *pkt) · 43 unmodified lines
10801080 static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
10811081 {
10821082 MatroskaMuxContext *mkv = s->priv_data;
1083− AVIOContext *pb = url_is_streamed(s->pb) ? mkv->dyn_bc : s->pb;
1083+ AVIOContext *pb = s->pb->seekable ? s->pb : mkv->dyn_bc;
10841084 AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
10851085 int ret, keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY);
10861086 int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
1087− int cluster_size = avio_tell(pb) - (url_is_streamed(s->pb) ? 0 : mkv->cluster_pos);
1087+ int cluster_size = avio_tell(pb) - (s->pb->seekable ? mkv->cluster_pos : 0);
10881088
10891089 // start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
10901090 // after 4k and on a keyframe
10911091 if (mkv->cluster_pos &&
1092− ((url_is_streamed(s->pb) && (cluster_size > 32*1024 || ts > mkv->cluster_pts + 1000))
1092+ ((!s->pb->seekable && (cluster_size > 32*1024 || ts > mkv->cluster_pts + 1000))
10931093 || cluster_size > 5*1024*1024 || ts > mkv->cluster_pts + 5000
10941094 || (codec->codec_type == AVMEDIA_TYPE_VIDEO && keyframe && cluster_size > 4*1024))) {
10951095 av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64
@@ -1143,7 +1143,7 @@ static int mkv_write_trailer(AVFormatContext *s) · 47 unmodified lines
11431143 end_ebml_master(pb, mkv->cluster);
11441144 }
11451145
1146− if (!url_is_streamed(pb)) {
1146+ if (pb->seekable) {
11471147 cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams);
11481148
11491149 ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES , cuespos);
libavformat/mmf.c+1−1
@@ -133,7 +133,7 @@ static int mmf_write_trailer(AVFormatContext *s) · 132 unmodified lines
133133 int64_t pos, size;
134134 int gatetime;
135135
136− if (!url_is_streamed(s->pb)) {
136+ if (s->pb->seekable) {
137137 /* Fill in length fields */
138138 end_tag_be(pb, mmf->awapos);
139139 end_tag_be(pb, mmf->atrpos);
libavformat/mov.c+6−6
@@ -304,7 +304,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 303 unmodified lines
304304 if (err < 0)
305305 return err;
306306 if (c->found_moov && c->found_mdat &&
307− (url_is_streamed(pb) || start_pos + a.size == avio_size(pb)))
307+ (!pb->seekable || start_pos + a.size == avio_size(pb)))
308308 return 0;
309309 left = a.size - avio_tell(pb) + start_pos;
310310 if (left > 0) /* skip garbage at atom end */
@@ -2354,7 +2354,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) · 2043 unmodified lines
23542354
23552355 mov->fc = s;
23562356 /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */
2357− if(!url_is_streamed(pb))
2357+ if(pb->seekable)
23582358 atom.size = avio_size(pb);
23592359 else
23602360 atom.size = INT64_MAX;
@@ -2370,7 +2370,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) · 9 unmodified lines
23702370 }
23712371 av_dlog(mov->fc, "on_parse_exit_offset=%lld\n", avio_tell(pb));
23722372
2373− if (!url_is_streamed(pb) && mov->chapter_track > 0)
2373+ if (pb->seekable && mov->chapter_track > 0)
23742374 mov_read_chapters(s);
23752375
23762376 return 0;
@@ -2388,8 +2388,8 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st) · 11 unmodified lines
23882388 AVIndexEntry *current_sample = &avst->index_entries[msc->current_sample];
23892389 int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale);
23902390 av_dlog(s, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts);
2391− if (!sample || (url_is_streamed(s->pb) && current_sample->pos < sample->pos) ||
2392− (!url_is_streamed(s->pb) &&
2391+ if (!sample || (!s->pb->seekable && current_sample->pos < sample->pos) ||
2392+ (s->pb->seekable &&
23932393 ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb &&
23942394 ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) ||
23952395 (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) {
@@ -2413,7 +2413,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) · 17 unmodified lines
24132413 sample = mov_find_next_sample(s, &st);
24142414 if (!sample) {
24152415 mov->found_mdat = 0;
2416− if (!url_is_streamed(s->pb) ||
2416+ if (s->pb->seekable||
24172417 mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 ||
24182418 url_feof(s->pb))
24192419 return AVERROR_EOF;
libavformat/movenc.c+4−4
@@ -1653,7 +1653,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, · 1652 unmodified lines
16531653 return 0;
16541654 }
16551655
1656− ret = url_open_dyn_buf(&pb_buf);
1656+ ret = avio_open_dyn_buf(&pb_buf);
16571657 if(ret < 0)
16581658 return ret;
16591659
@@ -1684,7 +1684,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, · 24 unmodified lines
16841684 if (s->nb_chapters)
16851685 mov_write_chpl_tag(pb_buf, s);
16861686
1687− if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) {
1687+ if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) {
16881688 avio_wb32(pb, size+8);
16891689 ffio_wfourcc(pb, "udta");
16901690 avio_write(pb, buf, size);
@@ -1948,7 +1948,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) · 257 unmodified lines
19481948 unsigned int samplesInChunk = 0;
19491949 int size= pkt->size;
19501950
1951− if (url_is_streamed(s->pb)) return 0; /* Can't handle that */
1951+ if (!s->pb->seekable) return 0; /* Can't handle that */
19521952 if (!size) return 0; /* Discard 0 sized packets */
19531953
19541954 if (enc->codec_id == CODEC_ID_AMR_NB) {
@@ -2083,7 +2083,7 @@ static int mov_write_header(AVFormatContext *s) · 128 unmodified lines
20832083 MOVMuxContext *mov = s->priv_data;
20842084 int i, hint_track = 0;
20852085
2086− if (url_is_streamed(s->pb)) {
2086+ if (!s->pb->seekable) {
20872087 av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");
20882088 return -1;
20892089 }
libavformat/movenchint.c+6−5
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "libavutil/intreadwrite.h"
2424 #include "internal.h"
2525 #include "rtpenc_chain.h"
26+#include "avio_internal.h"
2627
2728 int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
2829 {
@@ -408,8 +409,8 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, · 379 unmodified lines
408409
409410 /* Fetch the output from the RTP muxer, open a new output buffer
410411 * for next time. */
411− size = url_close_dyn_buf(rtp_ctx->pb, &buf);
412− if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb,
412+ size = avio_close_dyn_buf(rtp_ctx->pb, &buf);
413+ if ((ret = ffio_open_dyn_packet_buf(&rtp_ctx->pb,
413414 RTP_MAX_PACKET_SIZE)) < 0)
414415 goto done;
415416
@@ -417,14 +418,14 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, · 1 unmodified line
417418 goto done;
418419
419420 /* Open a buffer for writing the hint */
420− if ((ret = url_open_dyn_buf(&hintbuf)) < 0)
421+ if ((ret = avio_open_dyn_buf(&hintbuf)) < 0)
421422 goto done;
422423 av_init_packet(&hint_pkt);
423424 count = write_hint_packets(hintbuf, buf, size, trk, &hint_pkt.dts);
424425 av_freep(&buf);
425426
426427 /* Write the hint data into the hint track */
427− hint_pkt.size = size = url_close_dyn_buf(hintbuf, &buf);
428+ hint_pkt.size = size = avio_close_dyn_buf(hintbuf, &buf);
428429 hint_pkt.data = buf;
429430 hint_pkt.pts = hint_pkt.dts;
430431 hint_pkt.stream_index = track_index;
@@ -448,7 +449,7 @@ void ff_mov_close_hinting(MOVTrack *track) { · 17 unmodified lines
448449 return;
449450 if (rtp_ctx->pb) {
450451 av_write_trailer(rtp_ctx);
451− url_close_dyn_buf(rtp_ctx->pb, &ptr);
452+ avio_close_dyn_buf(rtp_ctx->pb, &ptr);
452453 av_free(ptr);
453454 }
454455 avformat_free_context(rtp_ctx);
libavformat/mp3enc.c+2−2
@@ -96,7 +96,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 · 95 unmodified lines
9696 uint8_t *pb;
9797 int (*put)(AVIOContext*, const char*);
9898 AVIOContext *dyn_buf;
99− if (url_open_dyn_buf(&dyn_buf) < 0)
99+ if (avio_open_dyn_buf(&dyn_buf) < 0)
100100 return AVERROR(ENOMEM);
101101
102102 /* check if the strings are ASCII-only and use UTF16 only if
@@ -115,7 +115,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 · 12 unmodified lines
115115 put(dyn_buf, str1);
116116 if (str2)
117117 put(dyn_buf, str2);
118− len = url_close_dyn_buf(dyn_buf, &pb);
118+ len = avio_close_dyn_buf(dyn_buf, &pb);
119119
120120 avio_wb32(s->pb, tag);
121121 id3v2_put_size(s, len);
libavformat/mpc.c+1−1
@@ -93,7 +93,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) · 92 unmodified lines
9393 st->duration = c->fcount;
9494
9595 /* try to read APE tags */
96− if (!url_is_streamed(s->pb)) {
96+ if (s->pb->seekable) {
9797 int64_t pos = avio_tell(s->pb);
9898 ff_ape_parse_tag(s);
9999 if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
libavformat/mpeg.c+1−1
@@ -403,7 +403,7 @@ static int mpegps_read_pes_header(AVFormatContext *s, · 402 unmodified lines
403403 int i;
404404 for(i=0; i<s->nb_streams; i++){
405405 if(startcode == s->streams[i]->id &&
406− !url_is_streamed(s->pb) /* index useless on streams anyway */) {
406+ s->pb->seekable /* index useless on streams anyway */) {
407407 ff_reduce_index(s, i);
408408 av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
409409 }
libavformat/mxfenc.c+1−1
@@ -1784,7 +1784,7 @@ static int mxf_write_footer(AVFormatContext *s) · 1783 unmodified lines
17841784 mxf_write_klv_fill(s);
17851785 mxf_write_random_index_pack(s);
17861786
1787− if (!url_is_streamed(s->pb)) {
1787+ if (s->pb->seekable) {
17881788 avio_seek(pb, 0, SEEK_SET);
17891789 if (mxf->edit_unit_byte_count) {
17901790 mxf_write_partition(s, 1, 2, header_closed_partition_key, 1);
libavformat/nutdec.c+1−1
@@ -653,7 +653,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) · 652 unmodified lines
653653
654654 s->data_offset= pos-8;
655655
656− if(!url_is_streamed(bc)){
656+ if(bc->seekable){
657657 int64_t orig_pos= avio_tell(bc);
658658 find_and_decode_index(nut);
659659 avio_seek(bc, orig_pos, SEEK_SET);
libavformat/nutenc.c+15−15
@@ -281,7 +281,7 @@ static inline void put_s_trace(AVIOContext *bc, int64_t v, char *file, char *fun · 280 unmodified lines
281281 //FIXME remove calculate_checksum
282282 static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, int calculate_checksum, uint64_t startcode){
283283 uint8_t *dyn_buf=NULL;
284− int dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf);
284+ int dyn_size= avio_close_dyn_buf(dyn_bc, &dyn_buf);
285285 int forw_ptr= dyn_size + 4*calculate_checksum;
286286
287287 if(forw_ptr > 4096)
@@ -436,7 +436,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){ · 148 unmodified lines
436436 AVIOContext *dyn_bc;
437437 uint8_t *dyn_buf=NULL;
438438 int count=0, dyn_size;
439− int ret = url_open_dyn_buf(&dyn_bc);
439+ int ret = avio_open_dyn_buf(&dyn_bc);
440440 if(ret < 0)
441441 return ret;
442442
@@ -450,7 +450,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){ · 7 unmodified lines
450450
451451 ff_put_v(bc, count);
452452
453− dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf);
453+ dyn_size= avio_close_dyn_buf(dyn_bc, &dyn_buf);
454454 avio_write(bc, dyn_buf, dyn_size);
455455 av_free(dyn_buf);
456456 return 0;
@@ -462,7 +462,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){ · 5 unmodified lines
462462 AVIOContext *dyn_bc;
463463 uint8_t *dyn_buf=NULL;
464464 int count=0, dyn_size, i;
465− int ret = url_open_dyn_buf(&dyn_bc);
465+ int ret = avio_open_dyn_buf(&dyn_bc);
466466 if(ret < 0)
467467 return ret;
468468
@@ -470,7 +470,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){ · 1 unmodified line
470470 if (st->disposition & ff_nut_dispositions[i].flag)
471471 count += add_info(dyn_bc, "Disposition", ff_nut_dispositions[i].str);
472472 }
473− dyn_size = url_close_dyn_buf(dyn_bc, &dyn_buf);
473+ dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
474474
475475 if (count) {
476476 ff_put_v(bc, stream_id + 1); //stream_id_plus1
@@ -495,7 +495,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id) · 18 unmodified lines
495495 AVChapter *ch = nut->avf->chapters[id];
496496 int ret, dyn_size, count = 0;
497497
498− ret = url_open_dyn_buf(&dyn_bc);
498+ ret = avio_open_dyn_buf(&dyn_bc);
499499 if (ret < 0)
500500 return ret;
501501
@@ -509,7 +509,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id) · 7 unmodified lines
509509
510510 ff_put_v(bc, count);
511511
512− dyn_size = url_close_dyn_buf(dyn_bc, &dyn_buf);
512+ dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
513513 avio_write(bc, dyn_buf, dyn_size);
514514 av_freep(&dyn_buf);
515515 return 0;
@@ -522,14 +522,14 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ · 6 unmodified lines
522522
523523 ff_metadata_conv_ctx(avctx, ff_nut_metadata_conv, NULL);
524524
525− ret = url_open_dyn_buf(&dyn_bc);
525+ ret = avio_open_dyn_buf(&dyn_bc);
526526 if(ret < 0)
527527 return ret;
528528 write_mainheader(nut, dyn_bc);
529529 put_packet(nut, bc, dyn_bc, 1, MAIN_STARTCODE);
530530
531531 for (i=0; i < nut->avf->nb_streams; i++){
532− ret = url_open_dyn_buf(&dyn_bc);
532+ ret = avio_open_dyn_buf(&dyn_bc);
533533 if(ret < 0)
534534 return ret;
535535 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){ · 1 unmodified line
537537 put_packet(nut, bc, dyn_bc, 1, STREAM_STARTCODE);
538538 }
539539
540− ret = url_open_dyn_buf(&dyn_bc);
540+ ret = avio_open_dyn_buf(&dyn_bc);
541541 if(ret < 0)
542542 return ret;
543543 write_globalinfo(nut, dyn_bc);
544544 put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
545545
546546 for (i = 0; i < nut->avf->nb_streams; i++) {
547− ret = url_open_dyn_buf(&dyn_bc);
547+ ret = avio_open_dyn_buf(&dyn_bc);
548548 if(ret < 0)
549549 return ret;
550550 ret = write_streaminfo(nut, dyn_bc, i);
@@ -554,19 +554,19 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ · 3 unmodified lines
554554 put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
555555 else {
556556 uint8_t* buf;
557− url_close_dyn_buf(dyn_bc, &buf);
557+ avio_close_dyn_buf(dyn_bc, &buf);
558558 av_free(buf);
559559 }
560560 }
561561
562562 for (i = 0; i < nut->avf->nb_chapters; i++) {
563− ret = url_open_dyn_buf(&dyn_bc);
563+ ret = avio_open_dyn_buf(&dyn_bc);
564564 if (ret < 0)
565565 return ret;
566566 ret = write_chapter(nut, dyn_bc, i);
567567 if (ret < 0) {
568568 uint8_t *buf;
569− url_close_dyn_buf(dyn_bc, &buf);
569+ avio_close_dyn_buf(dyn_bc, &buf);
570570 av_freep(&buf);
571571 return ret;
572572 }
@@ -728,7 +728,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){ · 155 unmodified lines
728728 NULL);
729729
730730 nut->last_syncpoint_pos= avio_tell(bc);
731− ret = url_open_dyn_buf(&dyn_bc);
731+ ret = avio_open_dyn_buf(&dyn_bc);
732732 if(ret < 0)
733733 return ret;
734734 put_tt(nut, nus->time_base, dyn_bc, pkt->dts);
libavformat/oggdec.c+1−1
@@ -455,7 +455,7 @@ ogg_get_length (AVFormatContext * s) · 454 unmodified lines
455455 int i;
456456 int64_t size, end;
457457
458− if(url_is_streamed(s->pb))
458+ if(!s->pb->seekable)
459459 return 0;
460460
461461 // already set
libavformat/oggenc.c+2−2
@@ -82,7 +82,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags) · 81 unmodified lines
8282 int ret, size;
8383 uint8_t *buf;
8484
85− ret = url_open_dyn_buf(&pb);
85+ ret = avio_open_dyn_buf(&pb);
8686 if (ret < 0)
8787 return ret;
8888 ffio_init_checksum(pb, ff_crc04C11DB7_update, 0);
@@ -101,7 +101,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags) · 12 unmodified lines
101101 ogg_update_checksum(s, pb, crc_offset);
102102 avio_flush(pb);
103103
104− size = url_close_dyn_buf(pb, &buf);
104+ size = avio_close_dyn_buf(pb, &buf);
105105 if (size < 0)
106106 return size;
107107
libavformat/r3d.c+1−1
@@ -177,7 +177,7 @@ static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap) · 176 unmodified lines
177177
178178 s->data_offset = avio_tell(s->pb);
179179 av_dlog(s, "data offset %#llx\n", s->data_offset);
180− if (url_is_streamed(s->pb))
180+ if (!s->pb->seekable)
181181 return 0;
182182 // find REOB/REOF/REOS to load index
183183 avio_seek(s->pb, avio_size(s->pb)-48-8, SEEK_SET);
libavformat/rmdec.c+1−1
@@ -481,7 +481,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) · 480 unmodified lines
481481
482482 if (!data_off)
483483 data_off = avio_tell(pb) - 18;
484− if (indx_off && !url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX) &&
484+ if (indx_off && pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) &&
485485 avio_seek(pb, indx_off, SEEK_SET) >= 0) {
486486 rm_read_index(s);
487487 avio_seek(pb, data_off + 18, SEEK_SET);
libavformat/rmenc.c+3−3
@@ -118,7 +118,7 @@ static int rv10_write_header(AVFormatContext *ctx, · 117 unmodified lines
118118 avio_wb32(s, 0); /* data offset : will be patched after */
119119 avio_wb16(s, ctx->nb_streams); /* num streams */
120120 flags = 1 | 2; /* save allowed & perfect play */
121− if (url_is_streamed(s))
121+ if (!s->seekable)
122122 flags |= 4; /* live broadcast */
123123 avio_wb16(s, flags);
124124
@@ -170,7 +170,7 @@ static int rv10_write_header(AVFormatContext *ctx, · 45 unmodified lines
170170 avio_wb32(s, 0); /* start time */
171171 avio_wb32(s, BUFFER_DURATION); /* preroll */
172172 /* duration */
173− if (url_is_streamed(s) || !stream->total_frames)
173+ if (!s->seekable || !stream->total_frames)
174174 avio_wb32(s, (int)(3600 * 1000));
175175 else
176176 avio_wb32(s, (int)(stream->total_frames * 1000 / stream->frame_rate));
@@ -434,7 +434,7 @@ static int rm_write_trailer(AVFormatContext *s) · 257 unmodified lines
434434 int data_size, index_pos, i;
435435 AVIOContext *pb = s->pb;
436436
437− if (!url_is_streamed(s->pb)) {
437+ if (s->pb->seekable) {
438438 /* end of file: finish to write header */
439439 index_pos = avio_tell(pb);
440440 data_size = index_pos - rm->data_pos;
libavformat/rsoenc.c+1−1
@@ -38,7 +38,7 @@ static int rso_write_header(AVFormatContext *s) · 37 unmodified lines
3838 return AVERROR_INVALIDDATA;
3939 }
4040
41− if (url_is_streamed(s->pb)) {
41+ if (!s->pb->seekable) {
4242 av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");
4343 return AVERROR_INVALIDDATA;
4444 }
libavformat/rtpdec.c+7−7
@@ -41,7 +41,7 @@ · 40 unmodified lines
4141 buffer to 'rtp_write_packet' contains all the packets for ONE
4242 frame. Each packet should have a four byte header containing
4343 the length in big endian format (same trick as
44− 'url_open_dyn_packet_buf')
44+ 'ffio_open_dyn_packet_buf')
4545 */
4646
4747 static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = {
@@ -264,7 +264,7 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) · 216 unmodified lines
264264 return -1;
265265 s->last_octet_count = s->octet_count;
266266
267− if (url_open_dyn_buf(&pb) < 0)
267+ if (avio_open_dyn_buf(&pb) < 0)
268268 return -1;
269269
270270 // Receiver Report
@@ -321,7 +321,7 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) · 50 unmodified lines
321321 }
322322
323323 avio_flush(pb);
324− len = url_close_dyn_buf(pb, &buf);
324+ len = avio_close_dyn_buf(pb, &buf);
325325 if ((len > 0) && buf) {
326326 int result;
327327 av_dlog(s->ic, "sending %d bytes of RR\n", len);
@@ -339,7 +339,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) · 11 unmodified lines
339339 int len;
340340
341341 /* Send a small RTP packet */
342− if (url_open_dyn_buf(&pb) < 0)
342+ if (avio_open_dyn_buf(&pb) < 0)
343343 return;
344344
345345 avio_w8(pb, (RTP_VERSION << 6));
@@ -349,13 +349,13 @@ void rtp_send_punch_packets(URLContext* rtp_handle) · 3 unmodified lines
349349 avio_wb32(pb, 0); /* SSRC */
350350
351351 avio_flush(pb);
352− len = url_close_dyn_buf(pb, &buf);
352+ len = avio_close_dyn_buf(pb, &buf);
353353 if ((len > 0) && buf)
354354 url_write(rtp_handle, buf, len);
355355 av_free(buf);
356356
357357 /* Send a minimal RTCP RR */
358− if (url_open_dyn_buf(&pb) < 0)
358+ if (avio_open_dyn_buf(&pb) < 0)
359359 return;
360360
361361 avio_w8(pb, (RTP_VERSION << 6));
@@ -364,7 +364,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) · 2 unmodified lines
364364 avio_wb32(pb, 0); /* our own SSRC */
365365
366366 avio_flush(pb);
367− len = url_close_dyn_buf(pb, &buf);
367+ len = avio_close_dyn_buf(pb, &buf);
368368 if ((len > 0) && buf)
369369 url_write(rtp_handle, buf, len);
370370 av_free(buf);
libavformat/rtpdec_asf.c+4−4
@@ -203,12 +203,12 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, · 202 unmodified lines
203203 */
204204 if (asf->pktbuf && len_off != avio_tell(asf->pktbuf)) {
205205 uint8_t *p;
206− url_close_dyn_buf(asf->pktbuf, &p);
206+ avio_close_dyn_buf(asf->pktbuf, &p);
207207 asf->pktbuf = NULL;
208208 av_free(p);
209209 }
210210 if (!len_off && !asf->pktbuf &&
211− (res = url_open_dyn_buf(&asf->pktbuf)) < 0)
211+ (res = avio_open_dyn_buf(&asf->pktbuf)) < 0)
212212 return res;
213213 if (!asf->pktbuf)
214214 return AVERROR(EIO);
@@ -217,7 +217,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, · 2 unmodified lines
217217 avio_skip(pb, len - off);
218218 if (!(flags & RTP_FLAG_MARKER))
219219 return -1;
220− out_len = url_close_dyn_buf(asf->pktbuf, &asf->buf);
220+ out_len = avio_close_dyn_buf(asf->pktbuf, &asf->buf);
221221 asf->pktbuf = NULL;
222222 } else {
223223 /**
@@ -272,7 +272,7 @@ static void asfrtp_free_context(PayloadContext *asf) · 48 unmodified lines
272272 {
273273 if (asf->pktbuf) {
274274 uint8_t *p = NULL;
275− url_close_dyn_buf(asf->pktbuf, &p);
275+ avio_close_dyn_buf(asf->pktbuf, &p);
276276 asf->pktbuf = NULL;
277277 av_free(p);
278278 }
libavformat/rtpdec_latm.c+4−4
@@ -43,7 +43,7 @@ static void latm_free_context(PayloadContext *data) · 42 unmodified lines
4343 return;
4444 if (data->dyn_buf) {
4545 uint8_t *p;
46− url_close_dyn_buf(data->dyn_buf, &p);
46+ avio_close_dyn_buf(data->dyn_buf, &p);
4747 av_free(p);
4848 }
4949 av_free(data->buf);
@@ -60,12 +60,12 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, · 10 unmodified lines
6060 if (!data->dyn_buf || data->timestamp != *timestamp) {
6161 av_freep(&data->buf);
6262 if (data->dyn_buf)
63− url_close_dyn_buf(data->dyn_buf, &data->buf);
63+ avio_close_dyn_buf(data->dyn_buf, &data->buf);
6464 data->dyn_buf = NULL;
6565 av_freep(&data->buf);
6666
6767 data->timestamp = *timestamp;
68− if ((ret = url_open_dyn_buf(&data->dyn_buf)) < 0)
68+ if ((ret = avio_open_dyn_buf(&data->dyn_buf)) < 0)
6969 return ret;
7070 }
7171 avio_write(data->dyn_buf, buf, len);
@@ -73,7 +73,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, · 1 unmodified line
7373 if (!(flags & RTP_FLAG_MARKER))
7474 return AVERROR(EAGAIN);
7575 av_free(data->buf);
76− data->len = url_close_dyn_buf(data->dyn_buf, &data->buf);
76+ data->len = avio_close_dyn_buf(data->dyn_buf, &data->buf);
7777 data->dyn_buf = NULL;
7878 data->pos = 0;
7979 }
libavformat/rtpdec_svq3.c+4−4
@@ -83,10 +83,10 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, · 82 unmodified lines
8383
8484 if (sv->pktbuf) {
8585 uint8_t *tmp;
86− url_close_dyn_buf(sv->pktbuf, &tmp);
86+ avio_close_dyn_buf(sv->pktbuf, &tmp);
8787 av_free(tmp);
8888 }
89− if ((res = url_open_dyn_buf(&sv->pktbuf)) < 0)
89+ if ((res = avio_open_dyn_buf(&sv->pktbuf)) < 0)
9090 return res;
9191 sv->timestamp = *timestamp;
9292 }
@@ -100,7 +100,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, · 7 unmodified lines
100100 av_init_packet(pkt);
101101 pkt->stream_index = st->index;
102102 *timestamp = sv->timestamp;
103− pkt->size = url_close_dyn_buf(sv->pktbuf, &pkt->data);
103+ pkt->size = avio_close_dyn_buf(sv->pktbuf, &pkt->data);
104104 pkt->destruct = av_destruct_packet;
105105 sv->pktbuf = NULL;
106106 return 0;
@@ -118,7 +118,7 @@ static void svq3_extradata_free(PayloadContext *sv) · 11 unmodified lines
118118 {
119119 if (sv->pktbuf) {
120120 uint8_t *buf;
121− url_close_dyn_buf(sv->pktbuf, &buf);
121+ avio_close_dyn_buf(sv->pktbuf, &buf);
122122 av_free(buf);
123123 }
124124 av_free(sv);
libavformat/rtpdec_vp8.c+3−3
@@ -41,7 +41,7 @@ static void prepare_packet(AVPacket *pkt, PayloadContext *vp8, int stream) · 40 unmodified lines
4141 av_init_packet(pkt);
4242 pkt->stream_index = stream;
4343 pkt->flags = vp8->is_keyframe ? AV_PKT_FLAG_KEY : 0;
44− pkt->size = url_close_dyn_buf(vp8->data, &pkt->data);
44+ pkt->size = avio_close_dyn_buf(vp8->data, &pkt->data);
4545 pkt->destruct = av_destruct_packet;
4646 vp8->data = NULL;
4747 }
@@ -85,7 +85,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, · 37 unmodified lines
8585 // that for the next av_get_packet call
8686 ret = end_packet ? 1 : 0;
8787 }
88− if ((res = url_open_dyn_buf(&vp8->data)) < 0)
88+ if ((res = avio_open_dyn_buf(&vp8->data)) < 0)
8989 return res;
9090 vp8->is_keyframe = *buf & 1;
9191 vp8->timestamp = ts;
@@ -138,7 +138,7 @@ static void vp8_free_context(PayloadContext *vp8) · 46 unmodified lines
138138 {
139139 if (vp8->data) {
140140 uint8_t *tmp;
141− url_close_dyn_buf(vp8->data, &tmp);
141+ avio_close_dyn_buf(vp8->data, &tmp);
142142 av_free(tmp);
143143 }
144144 av_free(vp8);
libavformat/rtpdec_xiph.c+3−3
@@ -57,7 +57,7 @@ static inline void free_fragment_if_needed(PayloadContext * data) · 56 unmodified lines
5757 {
5858 if (data->fragment) {
5959 uint8_t* p;
60− url_close_dyn_buf(data->fragment, &p);
60+ avio_close_dyn_buf(data->fragment, &p);
6161 av_free(p);
6262 data->fragment = NULL;
6363 }
@@ -176,7 +176,7 @@ static int xiph_handle_packet(AVFormatContext * ctx, · 112 unmodified lines
176176 // end packet has been lost somewhere, so drop buffered data
177177 free_fragment_if_needed(data);
178178
179− if((res = url_open_dyn_buf(&data->fragment)) < 0)
179+ if((res = avio_open_dyn_buf(&data->fragment)) < 0)
180180 return res;
181181
182182 avio_write(data->fragment, buf, pkt_len);
@@ -203,7 +203,7 @@ static int xiph_handle_packet(AVFormatContext * ctx, · 20 unmodified lines
203203 if (fragmented == 3) {
204204 // end of xiph data packet
205205 av_init_packet(pkt);
206− pkt->size = url_close_dyn_buf(data->fragment, &pkt->data);
206+ pkt->size = avio_close_dyn_buf(data->fragment, &pkt->data);
207207
208208 if (pkt->size < 0) {
209209 av_log(ctx, AV_LOG_ERROR,
libavformat/rtpenc_chain.c+5−3
@@ -20,7 +20,9 @@ · 19 unmodified lines
2020 */
2121
2222 #include "avformat.h"
23+#include "avio_internal.h"
2324 #include "rtpenc_chain.h"
25+#include "avio_internal.h"
2426
2527 AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
2628 URLContext *handle, int packet_size)
@@ -53,9 +55,9 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, · 26 unmodified lines
5355 avcodec_copy_context(rtpctx->streams[0]->codec, st->codec);
5456
5557 if (handle) {
56− url_fdopen(&rtpctx->pb, handle);
58+ ffio_fdopen(&rtpctx->pb, handle);
5759 } else
58− url_open_dyn_packet_buf(&rtpctx->pb, packet_size);
60+ ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size);
5961 ret = av_write_header(rtpctx);
6062
6163 if (ret) {
@@ -63,7 +65,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, · 1 unmodified line
6365 avio_close(rtpctx->pb);
6466 } else {
6567 uint8_t *ptr;
66− url_close_dyn_buf(rtpctx->pb, &ptr);
68+ avio_close_dyn_buf(rtpctx->pb, &ptr);
6769 av_free(ptr);
6870 }
6971 avformat_free_context(rtpctx);
libavformat/rtsp.c+1−1
@@ -495,7 +495,7 @@ void ff_rtsp_undo_setup(AVFormatContext *s) · 494 unmodified lines
495495 av_write_trailer(rtpctx);
496496 if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
497497 uint8_t *ptr;
498− url_close_dyn_buf(rtpctx->pb, &ptr);
498+ avio_close_dyn_buf(rtpctx->pb, &ptr);
499499 av_free(ptr);
500500 } else {
501501 avio_close(rtpctx->pb);
libavformat/rtspenc.c+4−3
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "os_support.h"
3030 #include "rtsp.h"
3131 #include "internal.h"
32+#include "avio_internal.h"
3233 #include "libavutil/intreadwrite.h"
3334 #include "libavutil/avstring.h"
3435
@@ -135,14 +136,14 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) · 100 unmodified lines
135136 int size;
136137 uint8_t *interleave_header, *interleaved_packet;
137138
138− size = url_close_dyn_buf(rtpctx->pb, &buf);
139+ size = avio_close_dyn_buf(rtpctx->pb, &buf);
139140 ptr = buf;
140141 while (size > 4) {
141142 uint32_t packet_len = AV_RB32(ptr);
142143 int id;
143144 /* The interleaving header is exactly 4 bytes, which happens to be
144145 * the same size as the packet length header from
145− * url_open_dyn_packet_buf. So by writing the interleaving header
146+ * ffio_open_dyn_packet_buf. So by writing the interleaving header
146147 * over these bytes, we get a consecutive interleaved packet
147148 * that can be written in one call. */
148149 interleaved_packet = interleave_header = ptr;
@@ -162,7 +163,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) · 13 unmodified lines
162163 size -= packet_len;
163164 }
164165 av_free(buf);
165− url_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE);
166+ ffio_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE);
166167 return 0;
167168 }
168169
libavformat/soxenc.c+1−1
@@ -96,7 +96,7 @@ static int sox_write_trailer(AVFormatContext *s) · 95 unmodified lines
9696 AVIOContext *pb = s->pb;
9797 AVCodecContext *enc = s->streams[0]->codec;
9898
99− if (!url_is_streamed(s->pb)) {
99+ if (s->pb->seekable) {
100100 /* update number of samples */
101101 int64_t file_size = avio_tell(pb);
102102 int64_t num_samples = (file_size - sox->header_size - 4LL) >> 2LL;
libavformat/swfenc.c+1−1
@@ -492,7 +492,7 @@ static int swf_write_trailer(AVFormatContext *s) · 491 unmodified lines
492492 avio_flush(s->pb);
493493
494494 /* patch file size and number of frames if not streamed */
495− if (!url_is_streamed(s->pb) && video_enc) {
495+ if (s->pb->seekable && video_enc) {
496496 file_size = avio_tell(pb);
497497 avio_seek(pb, 4, SEEK_SET);
498498 avio_wl32(pb, file_size);
libavformat/tty.c+1−1
@@ -88,7 +88,7 @@ static int read_header(AVFormatContext *avctx, · 87 unmodified lines
8888 /* simulate tty display speed */
8989 s->chars_per_frame = FFMAX(av_q2d(st->time_base) * (ap->sample_rate ? ap->sample_rate : LINE_RATE), 1);
9090
91− if (!url_is_streamed(avctx->pb)) {
91+ if (avctx->pb->seekable) {
9292 s->fsize = avio_size(avctx->pb);
9393 st->duration = (s->fsize + s->chars_per_frame - 1) / s->chars_per_frame;
9494
libavformat/utils.c+1−1
@@ -2037,7 +2037,7 @@ static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset) · 2036 unmodified lines
20372037
20382038 if ((!strcmp(ic->iformat->name, "mpeg") ||
20392039 !strcmp(ic->iformat->name, "mpegts")) &&
2040− file_size && !url_is_streamed(ic->pb)) {
2040+ file_size && ic->pb->seekable) {
20412041 /* get accurate estimate from the PTSes */
20422042 av_estimate_timings_from_pts(ic, old_offset);
20432043 } else if (av_has_duration(ic)) {
libavformat/vc1testenc.c+1−1
@@ -73,7 +73,7 @@ static int vc1test_write_trailer(AVFormatContext *s) · 72 unmodified lines
7373 RCVContext *ctx = s->priv_data;
7474 AVIOContext *pb = s->pb;
7575
76− if (!url_is_streamed(s->pb)) {
76+ if (s->pb->seekable) {
7777 avio_seek(pb, 0, SEEK_SET);
7878 avio_wl24(pb, ctx->frames);
7979 avio_flush(pb);
libavformat/vocdec.c+1−1
@@ -78,7 +78,7 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size) · 77 unmodified lines
7878 return AVERROR(EIO);
7979 voc->remaining_size = avio_rl24(pb);
8080 if (!voc->remaining_size) {
81− if (url_is_streamed(s->pb))
81+ if (!s->pb->seekable)
8282 return AVERROR(EIO);
8383 voc->remaining_size = avio_size(pb) - avio_tell(pb);
8484 }
libavformat/wav.c+2−2
@@ -57,7 +57,7 @@ static int wav_write_header(AVFormatContext *s) · 56 unmodified lines
5757 ff_end_tag(pb, fmt);
5858
5959 if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */
60− && !url_is_streamed(s->pb)) {
60+ && s->pb->seekable) {
6161 fact = ff_start_tag(pb, "fact");
6262 avio_wl32(pb, 0);
6363 ff_end_tag(pb, fact);
@@ -97,7 +97,7 @@ static int wav_write_trailer(AVFormatContext *s) · 33 unmodified lines
9797
9898 avio_flush(pb);
9999
100− if (!url_is_streamed(s->pb)) {
100+ if (s->pb->seekable) {
101101 ff_end_tag(pb, wav->data);
102102
103103 /* update file size */
libavformat/wv.c+2−2
@@ -121,7 +121,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int appen · 120 unmodified lines
121121 }
122122 if((rate == -1 || !chan) && !wc->block_parsed){
123123 int64_t block_end = avio_tell(pb) + wc->blksize - 24;
124− if(url_is_streamed(pb)){
124+ if(!pb->seekable){
125125 av_log(ctx, AV_LOG_ERROR, "Cannot determine additional parameters\n");
126126 return -1;
127127 }
@@ -223,7 +223,7 @@ static int wv_read_header(AVFormatContext *s, · 95 unmodified lines
223223 st->start_time = 0;
224224 st->duration = wc->samples;
225225
226− if(!url_is_streamed(s->pb)) {
226+ if(s->pb->seekable) {
227227 int64_t cur = avio_tell(s->pb);
228228 ff_ape_parse_tag(s);
229229 if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
tests/ref/acodec/ac3_fixed+1−1
@@ -1,2 +1,2 @@
1−346073c97eada69330f61e103a170ca1 *./tests/data/acodec/ac3.rm
1+408f47ee5a60866fc751f7bc2314cbd6 *./tests/data/acodec/ac3.rm
22 98751 ./tests/data/acodec/ac3.rm
tests/ref/lavf/rm+1−1
@@ -1,2 +1,2 @@
1−7b7ede9548a09346675edad36acfbf19 *./tests/data/lavf/lavf.rm
1+da74fe749c2eb21bbead7de81d2f3078 *./tests/data/lavf/lavf.rm
22 346706 ./tests/data/lavf/lavf.rm

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t