History

Merge remote-tracking branch 'qatar/master'

* qatar/master: aac_latm: reconfigure decoder on audio specific config changes latmdec: fix audio specific config parsing Add avcodec_decode_audio4(). avcodec: change number of plane pointers from 4 to 8 at next major bump. Update developers documentation with coding conventions. svq1dec: avoid undefined get_bits(0) call ARM: h264dsp_neon cosmetics ARM: make some NEON macros reusable Do not memcpy raw video frames when using null muxer fate: update asf seektest vp8: flush buffers on size changes. doc: improve general documentation for MacOSX asf: use packet dts as approximation of pts asf: do not call av_read_frame rtsp: Initialize the media_type_mask in the rtp guessing demuxer Cleaned up alacenc.c Conflicts: doc/APIchanges doc/developer.texi libavcodec/8svx.c libavcodec/aacdec.c libavcodec/ac3dec.c libavcodec/avcodec.h libavcodec/nellymoserdec.c libavcodec/tta.c libavcodec/utils.c libavcodec/version.h libavcodec/wmadec.c libavformat/asfdec.c tests/ref/seek/lavf_asf

Michael Niedermayer committed 14 years ago

Commit e4de7162 parents 1280434 d268b7987 files · +2227 −1308Browse files

Unified · Split

87 files
  1. avconv.c +3 −2
  2. doc/APIchanges +13 −0
  3. doc/developer.texi +68 −32
  4. doc/general.texi +11 −2
  5. ffmpeg.c +3 −2
  6. libavcodec/8svx.c +23 −11
  7. libavcodec/aac.h +1 −0
  8. libavcodec/aacdec.c +61 −45
  9. libavcodec/ac3dec.c +24 −16
  10. libavcodec/ac3dec.h +1 −0
  11. libavcodec/adpcm.c +25 −17
  12. libavcodec/adx.h +1 −0
  13. libavcodec/adxdec.c +27 −14
  14. libavcodec/alac.c +28 −17
  15. libavcodec/alacenc.c +54 −47
  16. libavcodec/alsdec.c +25 −20
  17. libavcodec/amrnbdec.c +19 −6
  18. libavcodec/amrwbdec.c +20 −7
  19. libavcodec/apedec.c +22 −15
  20. libavcodec/arm/h264dsp_neon.S +314 −353
  21. libavcodec/arm/neon.S +59 −0
  22. libavcodec/arm/vp8dsp_neon.S +5 −21
  23. libavcodec/atrac1.c +17 −9
  24. libavcodec/atrac3.c +21 −13
  25. libavcodec/avcodec.h +149 −19
  26. libavcodec/binkaudio.c +21 −13
  27. libavcodec/cook.c +30 −13
  28. libavcodec/dca.c +20 −12
  29. libavcodec/dpcm.c +19 −9
  30. libavcodec/dsicinav.c +18 −12
  31. libavcodec/flacdec.c +21 −16
  32. libavcodec/g722.h +2 −0
  33. libavcodec/g722dec.c +17 −8
  34. libavcodec/g726.c +19 −10
  35. libavcodec/gsmdec.c +22 −10
  36. libavcodec/gsmdec_data.h +2 −0
  37. libavcodec/huffyuv.c +4 −3
  38. libavcodec/imc.c +19 −10
  39. libavcodec/internal.h +6 −3
  40. libavcodec/libgsm.c +40 −18
  41. libavcodec/libopencore-amr.c +35 −17
  42. libavcodec/libspeexdec.c +21 −15
  43. libavcodec/mace.c +21 −12
  44. libavcodec/mlpdec.c +25 −14
  45. libavcodec/mpc.h +1 −0
  46. libavcodec/mpc7.c +18 −11
  47. libavcodec/mpc8.c +17 −10
  48. libavcodec/mpeg4audio.c +4 −3
  49. libavcodec/mpeg4audio.h +5 −2
  50. libavcodec/mpegaudiodec.c +57 −32
  51. libavcodec/mpegaudiodec_float.c +13 −4
  52. libavcodec/mpegvideo.c +6 −6
  53. libavcodec/nellymoserdec.c +26 −14
  54. libavcodec/pcm.c +25 −17
  55. libavcodec/qcelpdec.c +17 −9
  56. libavcodec/qdm2.c +18 −14
  57. libavcodec/ra144.h +1 −0
  58. libavcodec/ra144dec.c +20 −11
  59. libavcodec/ra288.c +18 −9
  60. libavcodec/s302m.c +36 −10
  61. libavcodec/shorten.c +26 −19
  62. libavcodec/sipr.c +19 −15
  63. libavcodec/smacker.c +31 −10
  64. libavcodec/svq1dec.c +2 −1
  65. libavcodec/truespeech.c +18 −11
  66. libavcodec/tta.c +18 −12
  67. libavcodec/twinvq.c +25 −11
  68. libavcodec/utils.c +224 −33
  69. libavcodec/version.h +8 −3
  70. libavcodec/vmdav.c +23 −12
  71. libavcodec/vorbisdec.c +20 −13
  72. libavcodec/vp3.c +4 −3
  73. libavcodec/vp8.c +5 −3
  74. libavcodec/wavpack.c +44 −72
  75. libavcodec/wma.h +1 −0
  76. libavcodec/wmadec.c +19 −12
  77. libavcodec/wmaprodec.c +36 −27
  78. libavcodec/wmavoice.c +26 −20
  79. libavcodec/ws-snd1.c +29 −9
  80. libavformat/adtsenc.c +1 −1
  81. libavformat/asfdec.c +1 −1
  82. libavformat/flvdec.c +1 −1
  83. libavformat/isom.c +1 −1
  84. libavformat/latmenc.c +1 −1
  85. libavformat/matroskaenc.c +2 −1
  86. libavformat/nullenc.c +1 −1
  87. libavformat/rtsp.c +3 −0
avconv.c+3−2
@@ -1267,7 +1267,8 @@ static void do_video_out(AVFormatContext *s, · 1266 unmodified lines
12671267 av_init_packet(&pkt);
12681268 pkt.stream_index= ost->index;
12691269
1270− if (s->oformat->flags & AVFMT_RAWPICTURE) {
1270+ if (s->oformat->flags & AVFMT_RAWPICTURE &&
1271+ enc->codec->id == CODEC_ID_RAWVIDEO) {
12711272 /* raw pictures are written as AVPicture structure to
12721273 avoid any copies. We support temporarily the older
12731274 method. */
@@ -1528,7 +1529,7 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams) · 254 unmodified lines
15281529
15291530 if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)
15301531 continue;
1531− if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))
1532+ if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == CODEC_ID_RAWVIDEO)
15321533 continue;
15331534
15341535 for(;;) {
doc/APIchanges+13−0
@@ -22,6 +22,19 @@ API changes, most recent first: · 21 unmodified lines
2222 2011-10-20 - b35e9e1 - lavu 51.22.0
2323 Add av_strtok() to avstring.h.
2424
25+2011-xx-xx - xxxxxxx - lavc 53.25.0
26+ Add nb_samples and extended_data fields to AVFrame.
27+ Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE.
28+ Deprecate avcodec_decode_audio3() in favor of avcodec_decode_audio4().
29+ avcodec_decode_audio4() writes output samples to an AVFrame, which allows
30+ audio decoders to use get_buffer().
31+
32+2011-xx-xx - xxxxxxx - lavc 53.24.0
33+ Change AVFrame.data[4]/base[4]/linesize[4]/error[4] to [8] at next major bump.
34+ Change AVPicture.data[4]/linesize[4] to [8] at next major bump.
35+ Change AVCodecContext.error[4] to [8] at next major bump.
36+ Add AV_NUM_DATA_POINTERS to simplify the bump transition.
37+
2538 2011-11-23 - bbb46f3 - lavu 51.18.0
2639 Add av_samples_get_buffer_size(), av_samples_fill_arrays(), and
2740 av_samples_alloc(), to samplefmt.h.
doc/developer.texi+68−32
@@ -53,48 +53,26 @@ and should try to fix issues their commit causes. · 52 unmodified lines
5353 @anchor{Coding Rules}
5454 @section Coding Rules
5555
56−FFmpeg is programmed in the ISO C90 language with a few additional
57−features from ISO C99, namely:
58−@itemize @bullet
59−@item
60−the @samp{inline} keyword;
61−@item
62−@samp{//} comments;
63−@item
64−designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
65−@item
66−compound literals (@samp{x = (struct s) @{ 17, 23 @};})
67−@end itemize
68−
69−These features are supported by all compilers we care about, so we will not
70−accept patches to remove their use unless they absolutely do not impair
71−clarity and performance.
56+@subsection Code formatting conventions
7257
73−All code must compile with recent versions of GCC and a number of other
74−currently supported compilers. To ensure compatibility, please do not use
75−additional C99 features or GCC extensions. Especially watch out for:
58+There are the following guidelines regarding the indentation in files:
7659 @itemize @bullet
7760 @item
78−mixing statements and declarations;
79−@item
80−@samp{long long} (use @samp{int64_t} instead);
81−@item
82−@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
83−@item
84−GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
85−@end itemize
86−
8761 Indent size is 4.
88−The presentation is one inspired by 'indent -i4 -kr -nut'.
62+@item
8963 The TAB character is forbidden outside of Makefiles as is any
9064 form of trailing whitespace. Commits containing either will be
9165 rejected by the git repository.
66+@item
67+You should try to limit your code lines to 80 characters; however, do so if and only if this improves readability.
68+@end itemize
69+The presentation is one inspired by 'indent -i4 -kr -nut'.
9270
9371 The main priority in FFmpeg is simplicity and small code size in order to
9472 minimize the bug count.
9573
96−Comments: Use the JavaDoc/Doxygen
97−format (see examples below) so that code documentation
74+@subsection Comments
75+Use the JavaDoc/Doxygen format (see examples below) so that code documentation
9876 can be generated automatically. All nontrivial functions should have a comment
9977 above them explaining what the function does, even if it is just one sentence.
10078 All structures and their member variables should be documented, too.
@@ -128,11 +106,69 @@ int myfunc(int my_parameter) · 27 unmodified lines
128106 ...
129107 @end example
130108
109+@subsection C language features
110+
111+FFmpeg is programmed in the ISO C90 language with a few additional
112+features from ISO C99, namely:
113+@itemize @bullet
114+@item
115+the @samp{inline} keyword;
116+@item
117+@samp{//} comments;
118+@item
119+designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
120+@item
121+compound literals (@samp{x = (struct s) @{ 17, 23 @};})
122+@end itemize
123+
124+These features are supported by all compilers we care about, so we will not
125+accept patches to remove their use unless they absolutely do not impair
126+clarity and performance.
127+
128+All code must compile with recent versions of GCC and a number of other
129+currently supported compilers. To ensure compatibility, please do not use
130+additional C99 features or GCC extensions. Especially watch out for:
131+@itemize @bullet
132+@item
133+mixing statements and declarations;
134+@item
135+@samp{long long} (use @samp{int64_t} instead);
136+@item
137+@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
138+@item
139+GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
140+@end itemize
141+
142+@subsection Naming conventions
143+All names are using underscores (_), not CamelCase. For example, @samp{avfilter_get_video_buffer} is
144+a valid function name and @samp{AVFilterGetVideo} is not. The only exception from this are structure names;
145+they should always be in the CamelCase
146+
147+There are following conventions for naming variables and functions:
148+@itemize @bullet
149+@item
150+For local variables no prefix is required.
151+@item
152+For variables and functions declared as @code{static} no prefixes are required.
153+@item
154+For variables and functions used internally by the library, @code{ff_} prefix should be used.
155+For example, @samp{ff_w64_demuxer}.
156+@item
157+For variables and functions used internally across multiple libraries, use @code{avpriv_}. For example,
158+@samp{avpriv_aac_parse_header}.
159+@item
160+For exported names, each library has its own prefixes. Just check the existing code and name accordingly.
161+@end itemize
162+
163+@subsection Miscellanous conventions
164+@itemize @bullet
165+@item
131166 fprintf and printf are forbidden in libavformat and libavcodec,
132167 please use av_log() instead.
133−
168+@item
134169 Casts should be used only when necessary. Unneeded parentheses
135170 should also be avoided if they don't make the code easier to understand.
171+@end itemize
136172
137173 @section Development Policy
138174
doc/general.texi+11−2
@@ -840,13 +840,22 @@ bash directly to work around this: · 839 unmodified lines
840840 bash ./configure
841841 @end example
842842
843−@subsection Darwin (MacOS X, iPhone)
843+@anchor{Darwin}
844+@subsection Darwin (OSX, iPhone)
844845
845−MacOS X on PowerPC or ARM (iPhone) requires a preprocessor from
846+The toolchain provided with Xcode is sufficient to build the basic
847+unacelerated code.
848+
849+OSX on PowerPC or ARM (iPhone) requires a preprocessor from
846850 @url{http://github.com/yuvi/gas-preprocessor} to build the optimized
847851 assembler functions. Just download the Perl script and put it somewhere
848852 in your PATH, FFmpeg's configure will pick it up automatically.
849853
854+OSX on amd64 and x86 requires @command{yasm} to build most of the
855+optimized assembler functions @url{http://mxcl.github.com/homebrew/, Homebrew},
856+@url{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix}
857+or @url{http://www.macports.org, MacPorts} can easily provide it.
858+
850859 @section Windows
851860
852861 To get help and instructions for building FFmpeg under Windows, check out
ffmpeg.c+3−2
@@ -1295,7 +1295,8 @@ static void do_video_out(AVFormatContext *s, · 1294 unmodified lines
12951295 av_init_packet(&pkt);
12961296 pkt.stream_index= ost->index;
12971297
1298− if (s->oformat->flags & AVFMT_RAWPICTURE) {
1298+ if (s->oformat->flags & AVFMT_RAWPICTURE &&
1299+ enc->codec->id == CODEC_ID_RAWVIDEO) {
12991300 /* raw pictures are written as AVPicture structure to
13001301 avoid any copies. We support temporarily the older
13011302 method. */
@@ -1560,7 +1561,7 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams) · 258 unmodified lines
15601561
15611562 if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)
15621563 continue;
1563− if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))
1564+ if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == CODEC_ID_RAWVIDEO)
15641565 continue;
15651566
15661567 for(;;) {
libavcodec/8svx.c+23−11
@@ -41,6 +41,7 @@ · 40 unmodified lines
4141
4242 /** decoder context */
4343 typedef struct EightSvxContext {
44+ AVFrame frame;
4445 const int8_t *table;
4546
4647 /* buffer used to store the whole audio decoded/interleaved chunk,
@@ -99,11 +100,13 @@ static int delta_decode(int8_t *dst, const uint8_t *src, int src_size, · 52 unmodified lines
99100 return dst-dst0;
100101 }
101102
102−static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
103− AVPacket *avpkt)
103+/** decode a frame */
104+static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
105+ int *got_frame_ptr, AVPacket *avpkt)
104106 {
105107 EightSvxContext *esc = avctx->priv_data;
106− int out_data_size, n;
108+ int n, out_data_size, ret;
109+ uint8_t *out_date;
107110 uint8_t *src, *dst;
108111
109112 /* decode and interleave the first packet */
@@ -145,19 +148,22 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_si · 35 unmodified lines
145148 memcpy(esc->samples, deinterleaved_samples, esc->samples_size);
146149 }
147150
148− /* return single packed with fixed size */
149− out_data_size = FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx);
150− if (*data_size < out_data_size) {
151− av_log(avctx, AV_LOG_ERROR, "Provided buffer with size %d is too small.\n", *data_size);
152− return AVERROR(EINVAL);
151+ /* get output buffer */
152+ esc->frame.nb_samples = (FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx) +avctx->channels-1) / avctx->channels;
153+ if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) {
154+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
155+ return ret;
153156 }
154157
155− *data_size = out_data_size;
156− dst = data;
158+ *got_frame_ptr = 1;
159+ *(AVFrame *)data = esc->frame;
160+
161+ dst = esc->frame.data[0];
157162 src = esc->samples + esc->samples_idx;
163+ out_data_size = esc->frame.nb_samples * avctx->channels;
158164 for (n = out_data_size; n > 0; n--)
159165 *dst++ = *src++ + 128;
160− esc->samples_idx += *data_size;
166+ esc->samples_idx += out_data_size;
161167
162168 return avctx->codec->id == CODEC_ID_8SVX_FIB || avctx->codec->id == CODEC_ID_8SVX_EXP ?
163169 (avctx->frame_number == 0)*2 + out_data_size / 2 :
@@ -184,6 +190,9 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx) · 20 unmodified lines
184190 }
185191 avctx->sample_fmt = AV_SAMPLE_FMT_U8;
186192
193+ avcodec_get_frame_defaults(&esc->frame);
194+ avctx->coded_frame = &esc->frame;
195+
187196 return 0;
188197 }
189198
@@ -206,6 +215,7 @@ AVCodec ff_eightsvx_fib_decoder = { · 16 unmodified lines
206215 .init = eightsvx_decode_init,
207216 .decode = eightsvx_decode_frame,
208217 .close = eightsvx_decode_close,
218+ .capabilities = CODEC_CAP_DR1,
209219 .long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
210220 };
211221
@@ -217,6 +227,7 @@ AVCodec ff_eightsvx_exp_decoder = { · 5 unmodified lines
217227 .init = eightsvx_decode_init,
218228 .decode = eightsvx_decode_frame,
219229 .close = eightsvx_decode_close,
230+ .capabilities = CODEC_CAP_DR1,
220231 .long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),
221232 };
222233
@@ -228,5 +239,6 @@ AVCodec ff_pcm_s8_planar_decoder = { · 5 unmodified lines
228239 .init = eightsvx_decode_init,
229240 .close = eightsvx_decode_close,
230241 .decode = eightsvx_decode_frame,
242+ .capabilities = CODEC_CAP_DR1,
231243 .long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
232244 };
libavcodec/aac.h+1−0
@@ -251,6 +251,7 @@ typedef struct { · 250 unmodified lines
251251 */
252252 typedef struct {
253253 AVCodecContext *avctx;
254+ AVFrame frame;
254255
255256 MPEG4AudioConfig m4ac;
256257
libavcodec/aacdec.c+61−45
@@ -471,15 +471,17 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, · 470 unmodified lines
471471 * @param ac pointer to AACContext, may be null
472472 * @param avctx pointer to AVCCodecContext, used for logging
473473 * @param m4ac pointer to MPEG4AudioConfig, used for parsing
474− * @param data pointer to AVCodecContext extradata
475− * @param data_size size of AVCCodecContext extradata
474+ * @param data pointer to buffer holding an audio specific config
475+ * @param bit_size size of audio specific config or data in bits
476+ * @param sync_extension look for an appended sync extension
476477 *
477478 * @return Returns error status or number of consumed bits. <0 - error
478479 */
479480 static int decode_audio_specific_config(AACContext *ac,
480481 AVCodecContext *avctx,
481482 MPEG4AudioConfig *m4ac,
482− const uint8_t *data, int data_size, int asclen)
483+ const uint8_t *data, int bit_size,
484+ int sync_extension)
483485 {
484486 GetBitContext gb;
485487 int i;
@@ -489,9 +491,9 @@ static int decode_audio_specific_config(AACContext *ac, · 3 unmodified lines
489491 av_dlog(avctx, "%02x ", avctx->extradata[i]);
490492 av_dlog(avctx, "\n");
491493
492− init_get_bits(&gb, data, data_size * 8);
494+ init_get_bits(&gb, data, bit_size);
493495
494− if ((i = avpriv_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0)
496+ if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, sync_extension)) < 0)
495497 return -1;
496498 if (m4ac->sampling_index > 12) {
497499 av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);
@@ -591,7 +593,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) · 93 unmodified lines
591593 if (avctx->extradata_size > 0) {
592594 if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
593595 avctx->extradata,
594− avctx->extradata_size, 8*avctx->extradata_size) < 0)
596+ avctx->extradata_size*8, 1) < 0)
595597 return -1;
596598 } else {
597599 int sr, i;
@@ -665,6 +667,9 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) · 67 unmodified lines
665667
666668 cbrt_tableinit();
667669
670+ avcodec_get_frame_defaults(&ac->frame);
671+ avctx->coded_frame = &ac->frame;
672+
668673 return 0;
669674 }
670675
@@ -2132,12 +2137,12 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) · 1461 unmodified lines
21322137 }
21332138
21342139 static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
2135− int *data_size, GetBitContext *gb)
2140+ int *got_frame_ptr, GetBitContext *gb)
21362141 {
21372142 AACContext *ac = avctx->priv_data;
21382143 ChannelElement *che = NULL, *che_prev = NULL;
21392144 enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;
2140− int err, elem_id, data_size_tmp;
2145+ int err, elem_id;
21412146 int samples = 0, multiplier, audio_found = 0;
21422147
21432148 if (show_bits(gb, 12) == 0xfff) {
@@ -2250,24 +2255,26 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, · 106 unmodified lines
22502255 avctx->frame_size = samples;
22512256 }
22522257
2253− data_size_tmp = samples * avctx->channels *
2254− av_get_bytes_per_sample(avctx->sample_fmt);
2255− if (*data_size < data_size_tmp) {
2256− av_log(avctx, AV_LOG_ERROR,
2257− "Output buffer too small (%d) or trying to output too many samples (%d) for this frame.\n",
2258− *data_size, data_size_tmp);
2259− return -1;
2260− }
2261− *data_size = data_size_tmp;
2262−
22632258 if (samples) {
2259+ /* get output buffer */
2260+ ac->frame.nb_samples = samples;
2261+ if ((err = avctx->get_buffer(avctx, &ac->frame)) < 0) {
2262+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
2263+ return err;
2264+ }
2265+
22642266 if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT)
2265− ac->fmt_conv.float_interleave(data, (const float **)ac->output_data,
2267+ ac->fmt_conv.float_interleave((float *)ac->frame.data[0],
2268+ (const float **)ac->output_data,
22662269 samples, avctx->channels);
22672270 else
2268− ac->fmt_conv.float_to_int16_interleave(data, (const float **)ac->output_data,
2271+ ac->fmt_conv.float_to_int16_interleave((int16_t *)ac->frame.data[0],
2272+ (const float **)ac->output_data,
22692273 samples, avctx->channels);
2274+
2275+ *(AVFrame *)data = ac->frame;
22702276 }
2277+ *got_frame_ptr = !!samples;
22712278
22722279 if (ac->output_configured && audio_found)
22732280 ac->output_configured = OC_LOCKED;
@@ -2276,7 +2283,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, · 2 unmodified lines
22762283 }
22772284
22782285 static int aac_decode_frame(AVCodecContext *avctx, void *data,
2279− int *data_size, AVPacket *avpkt)
2286+ int *got_frame_ptr, AVPacket *avpkt)
22802287 {
22812288 const uint8_t *buf = avpkt->data;
22822289 int buf_size = avpkt->size;
@@ -2287,7 +2294,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines
22872294
22882295 init_get_bits(&gb, buf, buf_size * 8);
22892296
2290− if ((err = aac_decode_frame_int(avctx, data, data_size, &gb)) < 0)
2297+ if ((err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb)) < 0)
22912298 return err;
22922299
22932300 buf_consumed = (get_bits_count(&gb) + 7) >> 3;
@@ -2340,30 +2347,40 @@ static inline uint32_t latm_get_value(GetBitContext *b) · 46 unmodified lines
23402347 static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
23412348 GetBitContext *gb, int asclen)
23422349 {
2343− AVCodecContext *avctx = latmctx->aac_ctx.avctx;
2344− AACContext *ac= &latmctx->aac_ctx;
2345− MPEG4AudioConfig m4ac=ac->m4ac;
2346− int config_start_bit = get_bits_count(gb);
2347− int bits_consumed, esize;
2350+ AACContext *ac = &latmctx->aac_ctx;
2351+ AVCodecContext *avctx = ac->avctx;
2352+ MPEG4AudioConfig m4ac = {0};
2353+ int config_start_bit = get_bits_count(gb);
2354+ int sync_extension = 0;
2355+ int bits_consumed, esize;
2356+
2357+ if (asclen) {
2358+ sync_extension = 1;
2359+ asclen = FFMIN(asclen, get_bits_left(gb));
2360+ } else
2361+ asclen = get_bits_left(gb);
23482362
23492363 if (config_start_bit % 8) {
23502364 av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific "
23512365 "config not byte aligned.\n", 1);
23522366 return AVERROR_INVALIDDATA;
2353− } else {
2354− bits_consumed =
2355− decode_audio_specific_config(ac, avctx, &m4ac,
2367+ }
2368+ bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
23562369 gb->buffer + (config_start_bit / 8),
2357− get_bits_left(gb) / 8, asclen);
2370+ asclen, sync_extension);
23582371
2359− if (bits_consumed < 0)
2360− return AVERROR_INVALIDDATA;
2361− if(ac->m4ac.sample_rate != m4ac.sample_rate || m4ac.chan_config != ac->m4ac.chan_config)
2362− ac->m4ac= m4ac;
2372+ if (bits_consumed < 0)
2373+ return AVERROR_INVALIDDATA;
2374+
2375+ if (ac->m4ac.sample_rate != m4ac.sample_rate ||
2376+ ac->m4ac.chan_config != m4ac.chan_config) {
2377+
2378+ av_log(avctx, AV_LOG_INFO, "audio config changed\n");
2379+ latmctx->initialized = 0;
23632380
23642381 esize = (bits_consumed+7) / 8;
23652382
2366− if (avctx->extradata_size <= esize) {
2383+ if (avctx->extradata_size < esize) {
23672384 av_free(avctx->extradata);
23682385 avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);
23692386 if (!avctx->extradata)
@@ -2373,9 +2390,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 3 unmodified lines
23732390 avctx->extradata_size = esize;
23742391 memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
23752392 memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
2376−
2377− skip_bits_long(gb, bits_consumed);
23782393 }
2394+ skip_bits_long(gb, bits_consumed);
23792395
23802396 return bits_consumed;
23812397 }
@@ -2512,8 +2528,8 @@ static int read_audio_mux_element(struct LATMContext *latmctx, · 130 unmodified lines
25122528 }
25132529
25142530
2515−static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size,
2516− AVPacket *avpkt)
2531+static int latm_decode_frame(AVCodecContext *avctx, void *out,
2532+ int *got_frame_ptr, AVPacket *avpkt)
25172533 {
25182534 struct LATMContext *latmctx = avctx->priv_data;
25192535 int muxlength, err;
@@ -2535,12 +2551,12 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, · 15 unmodified lines
25352551
25362552 if (!latmctx->initialized) {
25372553 if (!avctx->extradata) {
2538− *out_size = 0;
2554+ *got_frame_ptr = 0;
25392555 return avpkt->size;
25402556 } else {
25412557 if ((err = decode_audio_specific_config(
25422558 &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.m4ac,
2543− avctx->extradata, avctx->extradata_size, 8*avctx->extradata_size)) < 0)
2559+ avctx->extradata, avctx->extradata_size*8, 1)) < 0)
25442560 return err;
25452561 latmctx->initialized = 1;
25462562 }
@@ -2553,7 +2569,7 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, · 6 unmodified lines
25532569 return AVERROR_INVALIDDATA;
25542570 }
25552571
2556− if ((err = aac_decode_frame_int(avctx, out, out_size, &gb)) < 0)
2572+ if ((err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb)) < 0)
25572573 return err;
25582574
25592575 return muxlength;
@@ -2583,7 +2599,7 @@ AVCodec ff_aac_decoder = { · 23 unmodified lines
25832599 .sample_fmts = (const enum AVSampleFormat[]) {
25842600 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
25852601 },
2586− .capabilities = CODEC_CAP_CHANNEL_CONF,
2602+ .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
25872603 .channel_layouts = aac_channel_layout,
25882604 };
25892605
@@ -2604,7 +2620,7 @@ AVCodec ff_aac_latm_decoder = { · 14 unmodified lines
26042620 .sample_fmts = (const enum AVSampleFormat[]) {
26052621 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
26062622 },
2607− .capabilities = CODEC_CAP_CHANNEL_CONF,
2623+ .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
26082624 .channel_layouts = aac_channel_layout,
26092625 .flush = flush,
26102626 };
libavcodec/ac3dec.c+24−16
@@ -208,6 +208,9 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) · 207 unmodified lines
208208 }
209209 s->downmixed = 1;
210210
211+ avcodec_get_frame_defaults(&s->frame);
212+ avctx->coded_frame = &s->frame;
213+
211214 return 0;
212215 }
213216
@@ -1296,16 +1299,15 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) · 1082 unmodified lines
12961299 /**
12971300 * Decode a single AC-3 frame.
12981301 */
1299−static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
1300− AVPacket *avpkt)
1302+static int ac3_decode_frame(AVCodecContext * avctx, void *data,
1303+ int *got_frame_ptr, AVPacket *avpkt)
13011304 {
13021305 const uint8_t *buf = avpkt->data;
13031306 int buf_size = avpkt->size;
13041307 AC3DecodeContext *s = avctx->priv_data;
1305− float *out_samples_flt = data;
1306− int16_t *out_samples_s16 = data;
1307− int blk, ch, err;
1308− int data_size_orig, data_size_tmp;
1308+ float *out_samples_flt;
1309+ int16_t *out_samples_s16;
1310+ int blk, ch, err, ret;
13091311 const uint8_t *channel_map;
13101312 const float *output[AC3_MAX_CHANNELS];
13111313
@@ -1322,8 +1324,6 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 10 unmodified lines
13221324 init_get_bits(&s->gbc, buf, buf_size * 8);
13231325
13241326 /* parse the syncinfo */
1325− data_size_orig = *data_size;
1326− *data_size = 0;
13271327 err = parse_frame_header(s);
13281328
13291329 if (err) {
@@ -1345,6 +1345,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 15 unmodified lines
13451345 /* TODO: add support for substreams and dependent frames */
13461346 if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
13471347 av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n");
1348+ *got_frame_ptr = 0;
13481349 return s->frame_size;
13491350 } else {
13501351 av_log(avctx, AV_LOG_ERROR, "invalid frame type\n");
@@ -1406,21 +1407,24 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 55 unmodified lines
14061407 if (s->bitstream_mode == 0x7 && s->channels > 1)
14071408 avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
14081409
1410+ /* get output buffer */
1411+ s->frame.nb_samples = s->num_blocks * 256;
1412+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
1413+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1414+ return ret;
1415+ }
1416+ out_samples_flt = (float *)s->frame.data[0];
1417+ out_samples_s16 = (int16_t *)s->frame.data[0];
1418+
14091419 /* decode the audio blocks */
14101420 channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
14111421 for (ch = 0; ch < s->out_channels; ch++)
14121422 output[ch] = s->output[channel_map[ch]];
1413− data_size_tmp = s->num_blocks * 256 * avctx->channels;
1414− data_size_tmp *= avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? sizeof(*out_samples_flt) : sizeof(*out_samples_s16);
1415− if (data_size_orig < data_size_tmp)
1416− return -1;
1417− *data_size = data_size_tmp;
14181423 for (blk = 0; blk < s->num_blocks; blk++) {
14191424 if (!err && decode_audio_block(s, blk)) {
14201425 av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
14211426 err = 1;
14221427 }
1423−
14241428 if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
14251429 s->fmt_conv.float_interleave(out_samples_flt, output, 256,
14261430 s->out_channels);
@@ -1431,8 +1435,10 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 4 unmodified lines
14311435 out_samples_s16 += 256 * s->out_channels;
14321436 }
14331437 }
1434− *data_size = s->num_blocks * 256 * avctx->channels *
1435− av_get_bytes_per_sample(avctx->sample_fmt);
1438+
1439+ *got_frame_ptr = 1;
1440+ *(AVFrame *)data = s->frame;
1441+
14361442 return FFMIN(buf_size, s->frame_size);
14371443 }
14381444
@@ -1477,6 +1483,7 @@ AVCodec ff_ac3_decoder = { · 38 unmodified lines
14771483 .init = ac3_decode_init,
14781484 .close = ac3_decode_end,
14791485 .decode = ac3_decode_frame,
1486+ .capabilities = CODEC_CAP_DR1,
14801487 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
14811488 .sample_fmts = (const enum AVSampleFormat[]) {
14821489 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
@@ -1499,6 +1506,7 @@ AVCodec ff_eac3_decoder = { · 16 unmodified lines
14991506 .init = ac3_decode_init,
15001507 .close = ac3_decode_end,
15011508 .decode = ac3_decode_frame,
1509+ .capabilities = CODEC_CAP_DR1,
15021510 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
15031511 .sample_fmts = (const enum AVSampleFormat[]) {
15041512 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
libavcodec/ac3dec.h+1−0
@@ -68,6 +68,7 @@ · 67 unmodified lines
6868 typedef struct {
6969 AVClass *class; ///< class for AVOptions
7070 AVCodecContext *avctx; ///< parent context
71+ AVFrame frame; ///< AVFrame for decoded output
7172 GetBitContext gbc; ///< bitstream reader
7273
7374 ///@name Bit stream information
libavcodec/adpcm.c+25−17
@@ -84,6 +84,7 @@ static const int swf_index_tables[4][16] = { · 83 unmodified lines
8484 /* end of tables */
8585
8686 typedef struct ADPCMDecodeContext {
87+ AVFrame frame;
8788 ADPCMChannelStatus status[6];
8889 } ADPCMDecodeContext;
8990
@@ -124,6 +125,10 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 34 unmodified lines
124125 break;
125126 }
126127 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
128+
129+ avcodec_get_frame_defaults(&c->frame);
130+ avctx->coded_frame = &c->frame;
131+
127132 return 0;
128133 }
129134
@@ -501,9 +506,8 @@ static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf, · 371 unmodified lines
501506 decode_top_nibble_next = 1; \
502507 }
503508
504−static int adpcm_decode_frame(AVCodecContext *avctx,
505− void *data, int *data_size,
506− AVPacket *avpkt)
509+static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
510+ int *got_frame_ptr, AVPacket *avpkt)
507511 {
508512 const uint8_t *buf = avpkt->data;
509513 int buf_size = avpkt->size;
@@ -514,7 +518,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 4 unmodified lines
514518 const uint8_t *src;
515519 int st; /* stereo */
516520 int count1, count2;
517− int nb_samples, coded_samples, out_bps, out_size;
521+ int nb_samples, coded_samples, ret;
518522
519523 nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples);
520524 if (nb_samples <= 0) {
@@ -522,22 +526,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 1 unmodified line
522526 return AVERROR_INVALIDDATA;
523527 }
524528
525− out_bps = av_get_bytes_per_sample(avctx->sample_fmt);
526− out_size = nb_samples * avctx->channels * out_bps;
527− if (*data_size < out_size) {
528− av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
529− return AVERROR(EINVAL);
529+ /* get output buffer */
530+ c->frame.nb_samples = nb_samples;
531+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
532+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
533+ return ret;
530534 }
535+ samples = (short *)c->frame.data[0];
536+
531537 /* use coded_samples when applicable */
532538 /* it is always <= nb_samples, so the output buffer will be large enough */
533539 if (coded_samples) {
534540 if (coded_samples != nb_samples)
535541 av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
536− nb_samples = coded_samples;
537− out_size = nb_samples * avctx->channels * out_bps;
542+ c->frame.nb_samples = nb_samples = coded_samples;
538543 }
539544
540− samples = data;
541545 src = buf;
542546
543547 st = avctx->channels == 2 ? 1 : 0;
@@ -576,7 +580,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 32 unmodified lines
576580 cs->step_index = 88;
577581 }
578582
579− samples = (short*)data + channel;
583+ samples = (short *)c->frame.data[0] + channel;
580584
581585 for (m = 0; m < 32; m++) {
582586 *samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3);
@@ -628,7 +632,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 45 unmodified lines
628632 }
629633
630634 for (i = 0; i < avctx->channels; i++) {
631− samples = (short*)data + i;
635+ samples = (short *)c->frame.data[0] + i;
632636 cs = &c->status[i];
633637 for (n = nb_samples >> 1; n > 0; n--, src++) {
634638 uint8_t v = *src;
@@ -965,7 +969,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 330 unmodified lines
965969 }
966970 }
967971
968− out_size = count * 28 * avctx->channels * out_bps;
972+ c->frame.nb_samples = count * 28;
969973 src = src_end;
970974 break;
971975 }
@@ -1144,7 +1148,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 172 unmodified lines
11441148 prev[0][i] = (int16_t)bytestream_get_be16(&src);
11451149
11461150 for (ch = 0; ch <= st; ch++) {
1147− samples = (unsigned short *) data + ch;
1151+ samples = (short *)c->frame.data[0] + ch;
11481152
11491153 /* Read in every sample for this channel. */
11501154 for (i = 0; i < nb_samples / 14; i++) {
@@ -1177,7 +1181,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 26 unmodified lines
11771181 default:
11781182 return -1;
11791183 }
1180− *data_size = out_size;
1184+
1185+ *got_frame_ptr = 1;
1186+ *(AVFrame *)data = c->frame;
1187+
11811188 return src - buf;
11821189 }
11831190
@@ -1190,6 +1197,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 6 unmodified lines
11901197 .priv_data_size = sizeof(ADPCMDecodeContext), \
11911198 .init = adpcm_decode_init, \
11921199 .decode = adpcm_decode_frame, \
1200+ .capabilities = CODEC_CAP_DR1, \
11931201 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
11941202 }
11951203
libavcodec/adx.h+1−0
@@ -40,6 +40,7 @@ typedef struct { · 39 unmodified lines
4040 } ADXChannelState;
4141
4242 typedef struct {
43+ AVFrame frame;
4344 int channels;
4445 ADXChannelState prev[2];
4546 int header_parsed;
libavcodec/adxdec.c+27−14
@@ -50,6 +50,10 @@ static av_cold int adx_decode_init(AVCodecContext *avctx) · 49 unmodified lines
5050 c->channels = avctx->channels;
5151
5252 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
53+
54+ avcodec_get_frame_defaults(&c->frame);
55+ avctx->coded_frame = &c->frame;
56+
5357 return 0;
5458 }
5559
@@ -89,36 +93,42 @@ static int adx_decode(ADXContext *c, int16_t *out, const uint8_t *in, int ch) · 33 unmodified lines
8993 return 0;
9094 }
9195
92−static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
93− AVPacket *avpkt)
96+static int adx_decode_frame(AVCodecContext *avctx, void *data,
97+ int *got_frame_ptr, AVPacket *avpkt)
9498 {
9599 int buf_size = avpkt->size;
96100 ADXContext *c = avctx->priv_data;
97− int16_t *samples = data;
101+ int16_t *samples;
98102 const uint8_t *buf = avpkt->data;
99− int num_blocks, ch;
103+ int num_blocks, ch, ret;
100104
101105 if (c->eof) {
102− *data_size = 0;
106+ *got_frame_ptr = 0;
103107 return buf_size;
104108 }
105109
106− /* 18 bytes of data are expanded into 32*2 bytes of audio,
107− so guard against buffer overflows */
110+ /* calculate number of blocks in the packet */
108111 num_blocks = buf_size / (BLOCK_SIZE * c->channels);
109− if (num_blocks > *data_size / (BLOCK_SAMPLES * c->channels)) {
110− buf_size = (*data_size / (BLOCK_SAMPLES * c->channels)) * BLOCK_SIZE;
111− num_blocks = buf_size / (BLOCK_SIZE * c->channels);
112− }
113− if (!buf_size || buf_size % (BLOCK_SIZE * avctx->channels)) {
112+
113+ /* if the packet is not an even multiple of BLOCK_SIZE, check for an EOF
114+ packet */
115+ if (!num_blocks || buf_size % (BLOCK_SIZE * avctx->channels)) {
114116 if (buf_size >= 4 && (AV_RB16(buf) & 0x8000)) {
115117 c->eof = 1;
116− *data_size = 0;
118+ *got_frame_ptr = 0;
117119 return avpkt->size;
118120 }
119121 return AVERROR_INVALIDDATA;
120122 }
121123
124+ /* get output buffer */
125+ c->frame.nb_samples = num_blocks * BLOCK_SAMPLES;
126+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
127+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
128+ return ret;
129+ }
130+ samples = (int16_t *)c->frame.data[0];
131+
122132 while (num_blocks--) {
123133 for (ch = 0; ch < c->channels; ch++) {
124134 if (adx_decode(c, samples + ch, buf, ch)) {
@@ -132,7 +142,9 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 7 unmodified lines
132142 samples += BLOCK_SAMPLES * c->channels;
133143 }
134144
135− *data_size = (uint8_t*)samples - (uint8_t*)data;
145+ *got_frame_ptr = 1;
146+ *(AVFrame *)data = c->frame;
147+
136148 return buf - avpkt->data;
137149 }
138150
@@ -143,5 +155,6 @@ AVCodec ff_adpcm_adx_decoder = { · 4 unmodified lines
143155 .priv_data_size = sizeof(ADXContext),
144156 .init = adx_decode_init,
145157 .decode = adx_decode_frame,
158+ .capabilities = CODEC_CAP_DR1,
146159 .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
147160 };
libavcodec/alac.c+28−17
@@ -62,10 +62,10 @@ · 61 unmodified lines
6262 typedef struct {
6363
6464 AVCodecContext *avctx;
65+ AVFrame frame;
6566 GetBitContext gb;
6667
6768 int numchannels;
68− int bytespersample;
6969
7070 /* buffers */
7171 int32_t *predicterror_buffer[MAX_CHANNELS];
@@ -351,9 +351,8 @@ static void interleave_stereo_24(int32_t *buffer[MAX_CHANNELS], · 279 unmodified lines
351351 }
352352 }
353353
354−static int alac_decode_frame(AVCodecContext *avctx,
355− void *outbuffer, int *outputsize,
356− AVPacket *avpkt)
354+static int alac_decode_frame(AVCodecContext *avctx, void *data,
355+ int *got_frame_ptr, AVPacket *avpkt)
357356 {
358357 const uint8_t *inbuffer = avpkt->data;
359358 int input_buffer_size = avpkt->size;
@@ -366,7 +365,7 @@ static int alac_decode_frame(AVCodecContext *avctx, · 6 unmodified lines
366365 int isnotcompressed;
367366 uint8_t interlacing_shift;
368367 uint8_t interlacing_leftweight;
369− int i, ch;
368+ int i, ch, ret;
370369
371370 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
372371
@@ -401,14 +400,17 @@ static int alac_decode_frame(AVCodecContext *avctx, · 28 unmodified lines
401400 } else
402401 outputsamples = alac->setinfo_max_samples_per_frame;
403402
404− alac->bytespersample = channels * av_get_bytes_per_sample(avctx->sample_fmt);
405−
406− if(outputsamples > *outputsize / alac->bytespersample){
407− av_log(avctx, AV_LOG_ERROR, "sample buffer too small\n");
408− return -1;
403+ /* get output buffer */
404+ if (outputsamples > INT32_MAX) {
405+ av_log(avctx, AV_LOG_ERROR, "unsupported block size: %u\n", outputsamples);
406+ return AVERROR_INVALIDDATA;
407+ }
408+ alac->frame.nb_samples = outputsamples;
409+ if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) {
410+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
411+ return ret;
409412 }
410413
411− *outputsize = outputsamples * alac->bytespersample;
412414 readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1;
413415 if (readsamplesize > MIN_CACHE_BITS) {
414416 av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize);
@@ -501,21 +503,23 @@ static int alac_decode_frame(AVCodecContext *avctx, · 86 unmodified lines
501503 switch(alac->setinfo_sample_size) {
502504 case 16:
503505 if (channels == 2) {
504− interleave_stereo_16(alac->outputsamples_buffer, outbuffer,
505− outputsamples);
506+ interleave_stereo_16(alac->outputsamples_buffer,
507+ (int16_t *)alac->frame.data[0], outputsamples);
506508 } else {
509+ int16_t *outbuffer = (int16_t *)alac->frame.data[0];
507510 for (i = 0; i < outputsamples; i++) {
508− ((int16_t*)outbuffer)[i] = alac->outputsamples_buffer[0][i];
511+ outbuffer[i] = alac->outputsamples_buffer[0][i];
509512 }
510513 }
511514 break;
512515 case 24:
513516 if (channels == 2) {
514− interleave_stereo_24(alac->outputsamples_buffer, outbuffer,
515− outputsamples);
517+ interleave_stereo_24(alac->outputsamples_buffer,
518+ (int32_t *)alac->frame.data[0], outputsamples);
516519 } else {
520+ int32_t *outbuffer = (int32_t *)alac->frame.data[0];
517521 for (i = 0; i < outputsamples; i++)
518− ((int32_t *)outbuffer)[i] = alac->outputsamples_buffer[0][i] << 8;
522+ outbuffer[i] = alac->outputsamples_buffer[0][i] << 8;
519523 }
520524 break;
521525 }
@@ -523,6 +527,9 @@ static int alac_decode_frame(AVCodecContext *avctx, · 1 unmodified line
523527 if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)
524528 av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));
525529
530+ *got_frame_ptr = 1;
531+ *(AVFrame *)data = alac->frame;
532+
526533 return input_buffer_size;
527534 }
528535
@@ -637,6 +644,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx) · 108 unmodified lines
637644 return ret;
638645 }
639646
647+ avcodec_get_frame_defaults(&alac->frame);
648+ avctx->coded_frame = &alac->frame;
649+
640650 return 0;
641651 }
642652
@@ -648,5 +658,6 @@ AVCodec ff_alac_decoder = { · 5 unmodified lines
648658 .init = alac_decode_init,
649659 .close = alac_decode_close,
650660 .decode = alac_decode_frame,
661+ .capabilities = CODEC_CAP_DR1,
651662 .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
652663 };
libavcodec/alacenc.c+54−47
@@ -75,20 +75,22 @@ typedef struct AlacEncodeContext { · 74 unmodified lines
7575 } AlacEncodeContext;
7676
7777
78−static void init_sample_buffers(AlacEncodeContext *s, const int16_t *input_samples)
78+static void init_sample_buffers(AlacEncodeContext *s,
79+ const int16_t *input_samples)
7980 {
8081 int ch, i;
8182
82− for(ch=0;ch<s->avctx->channels;ch++) {
83+ for (ch = 0; ch < s->avctx->channels; ch++) {
8384 const int16_t *sptr = input_samples + ch;
84− for(i=0;i<s->avctx->frame_size;i++) {
85+ for (i = 0; i < s->avctx->frame_size; i++) {
8586 s->sample_buf[ch][i] = *sptr;
8687 sptr += s->avctx->channels;
8788 }
8889 }
8990 }
9091
91−static void encode_scalar(AlacEncodeContext *s, int x, int k, int write_sample_size)
92+static void encode_scalar(AlacEncodeContext *s, int x,
93+ int k, int write_sample_size)
9294 {
9395 int divisor, q, r;
9496
@@ -97,17 +99,17 @@ static void encode_scalar(AlacEncodeContext *s, int x, int k, int write_sample_s · 2 unmodified lines
9799 q = x / divisor;
98100 r = x % divisor;
99101
100− if(q > 8) {
102+ if (q > 8) {
101103 // write escape code and sample value directly
102104 put_bits(&s->pbctx, 9, ALAC_ESCAPE_CODE);
103105 put_bits(&s->pbctx, write_sample_size, x);
104106 } else {
105− if(q)
107+ if (q)
106108 put_bits(&s->pbctx, q, (1<<q) - 1);
107109 put_bits(&s->pbctx, 1, 0);
108110
109− if(k != 1) {
110− if(r > 0)
111+ if (k != 1) {
112+ if (r > 0)
111113 put_bits(&s->pbctx, k, r+1);
112114 else
113115 put_bits(&s->pbctx, k-1, 0);
@@ -164,7 +166,7 @@ static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n) · 50 unmodified lines
164166
165167 /* calculate sum of 2nd order residual for each channel */
166168 sum[0] = sum[1] = sum[2] = sum[3] = 0;
167− for(i=2; i<n; i++) {
169+ for (i = 2; i < n; i++) {
168170 lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2];
169171 rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2];
170172 sum[2] += FFABS((lt + rt) >> 1);
@@ -181,8 +183,8 @@ static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n) · 10 unmodified lines
181183
182184 /* return mode with lowest score */
183185 best = 0;
184− for(i=1; i<4; i++) {
185− if(score[i] < score[best]) {
186+ for (i = 1; i < 4; i++) {
187+ if (score[i] < score[best]) {
186188 best = i;
187189 }
188190 }
@@ -205,7 +207,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 16 unmodified lines
205207 break;
206208
207209 case ALAC_CHMODE_LEFT_SIDE:
208− for(i=0; i<n; i++) {
210+ for (i = 0; i < n; i++) {
209211 right[i] = left[i] - right[i];
210212 }
211213 s->interlacing_leftweight = 1;
@@ -213,7 +215,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 1 unmodified line
213215 break;
214216
215217 case ALAC_CHMODE_RIGHT_SIDE:
216− for(i=0; i<n; i++) {
218+ for (i = 0; i < n; i++) {
217219 tmp = right[i];
218220 right[i] = left[i] - right[i];
219221 left[i] = tmp + (right[i] >> 31);
@@ -223,7 +225,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 3 unmodified lines
223225 break;
224226
225227 default:
226− for(i=0; i<n; i++) {
228+ for (i = 0; i < n; i++) {
227229 tmp = left[i];
228230 left[i] = (tmp + right[i]) >> 1;
229231 right[i] = tmp - right[i];
@@ -239,10 +241,10 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) · 9 unmodified lines
239241 int i;
240242 AlacLPCContext lpc = s->lpc[ch];
241243
242− if(lpc.lpc_order == 31) {
244+ if (lpc.lpc_order == 31) {
243245 s->predictor_buf[0] = s->sample_buf[ch][0];
244246
245− for(i=1; i<s->avctx->frame_size; i++)
247+ for (i = 1; i < s->avctx->frame_size; i++)
246248 s->predictor_buf[i] = s->sample_buf[ch][i] - s->sample_buf[ch][i-1];
247249
248250 return;
@@ -250,17 +252,17 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) · 1 unmodified line
250252
251253 // generalised linear predictor
252254
253− if(lpc.lpc_order > 0) {
255+ if (lpc.lpc_order > 0) {
254256 int32_t *samples = s->sample_buf[ch];
255257 int32_t *residual = s->predictor_buf;
256258
257259 // generate warm-up samples
258260 residual[0] = samples[0];
259− for(i=1;i<=lpc.lpc_order;i++)
261+ for (i = 1; i <= lpc.lpc_order; i++)
260262 residual[i] = samples[i] - samples[i-1];
261263
262264 // perform lpc on remaining samples
263− for(i = lpc.lpc_order + 1; i < s->avctx->frame_size; i++) {
265+ for (i = lpc.lpc_order + 1; i < s->avctx->frame_size; i++) {
264266 int sum = 1 << (lpc.lpc_quant - 1), res_val, j;
265267
266268 for (j = 0; j < lpc.lpc_order; j++) {
@@ -303,7 +305,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 36 unmodified lines
303305 int sign_modifier = 0, i, k;
304306 int32_t *samples = s->predictor_buf;
305307
306− for(i=0;i < s->avctx->frame_size;) {
308+ for (i = 0; i < s->avctx->frame_size;) {
307309 int x;
308310
309311 k = av_log2((history >> 9) + 3);
@@ -320,15 +322,15 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 10 unmodified lines
320322 - ((history * s->rc.history_mult) >> 9);
321323
322324 sign_modifier = 0;
323− if(x > 0xFFFF)
325+ if (x > 0xFFFF)
324326 history = 0xFFFF;
325327
326− if((history < 128) && (i < s->avctx->frame_size)) {
328+ if (history < 128 && i < s->avctx->frame_size) {
327329 unsigned int block_size = 0;
328330
329331 k = 7 - av_log2(history) + ((history + 16) >> 6);
330332
331− while((*samples == 0) && (i < s->avctx->frame_size)) {
333+ while (*samples == 0 && i < s->avctx->frame_size) {
332334 samples++;
333335 i++;
334336 block_size++;
@@ -347,12 +349,12 @@ static void write_compressed_frame(AlacEncodeContext *s) · 12 unmodified lines
347349 {
348350 int i, j;
349351
350− if(s->avctx->channels == 2)
352+ if (s->avctx->channels == 2)
351353 alac_stereo_decorrelation(s);
352354 put_bits(&s->pbctx, 8, s->interlacing_shift);
353355 put_bits(&s->pbctx, 8, s->interlacing_leftweight);
354356
355− for(i=0;i<s->avctx->channels;i++) {
357+ for (i = 0; i < s->avctx->channels; i++) {
356358
357359 calc_predictor_params(s, i);
358360
@@ -362,14 +364,14 @@ static void write_compressed_frame(AlacEncodeContext *s) · 3 unmodified lines
362364 put_bits(&s->pbctx, 3, s->rc.rice_modifier);
363365 put_bits(&s->pbctx, 5, s->lpc[i].lpc_order);
364366 // predictor coeff. table
365− for(j=0;j<s->lpc[i].lpc_order;j++) {
367+ for (j = 0; j < s->lpc[i].lpc_order; j++) {
366368 put_sbits(&s->pbctx, 16, s->lpc[i].lpc_coeff[j]);
367369 }
368370 }
369371
370372 // apply lpc and entropy coding to audio samples
371373
372− for(i=0;i<s->avctx->channels;i++) {
374+ for (i = 0; i < s->avctx->channels; i++) {
373375 alac_linear_predictor(s, i);
374376 alac_entropy_coder(s);
375377 }
@@ -384,7 +386,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 8 unmodified lines
384386 avctx->frame_size = DEFAULT_FRAME_SIZE;
385387 avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;
386388
387− if(avctx->sample_fmt != AV_SAMPLE_FMT_S16) {
389+ if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) {
388390 av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n");
389391 return -1;
390392 }
@@ -395,7 +397,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 4 unmodified lines
395397 }
396398
397399 // Set default compression level
398− if(avctx->compression_level == FF_COMPRESSION_DEFAULT)
400+ if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
399401 s->compression_level = 2;
400402 else
401403 s->compression_level = av_clip(avctx->compression_level, 0, 2);
@@ -416,21 +418,23 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 14 unmodified lines
416418 AV_WB8 (alac_extradata+17, avctx->bits_per_coded_sample);
417419 AV_WB8 (alac_extradata+21, avctx->channels);
418420 AV_WB32(alac_extradata+24, s->max_coded_frame_size);
419− AV_WB32(alac_extradata+28, avctx->sample_rate*avctx->channels*avctx->bits_per_coded_sample); // average bitrate
421+ AV_WB32(alac_extradata+28,
422+ avctx->sample_rate * avctx->channels * avctx->bits_per_coded_sample); // average bitrate
420423 AV_WB32(alac_extradata+32, avctx->sample_rate);
421424
422425 // Set relevant extradata fields
423− if(s->compression_level > 0) {
426+ if (s->compression_level > 0) {
424427 AV_WB8(alac_extradata+18, s->rc.history_mult);
425428 AV_WB8(alac_extradata+19, s->rc.initial_history);
426429 AV_WB8(alac_extradata+20, s->rc.k_modifier);
427430 }
428431
429432 s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;
430− if(avctx->min_prediction_order >= 0) {
431− if(avctx->min_prediction_order < MIN_LPC_ORDER ||
433+ if (avctx->min_prediction_order >= 0) {
434+ if (avctx->min_prediction_order < MIN_LPC_ORDER ||
432435 avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {
433− av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", avctx->min_prediction_order);
436+ av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
437+ avctx->min_prediction_order);
434438 return -1;
435439 }
436440
@@ -438,18 +442,20 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 1 unmodified line
438442 }
439443
440444 s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;
441− if(avctx->max_prediction_order >= 0) {
442− if(avctx->max_prediction_order < MIN_LPC_ORDER ||
443− avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {
444− av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", avctx->max_prediction_order);
445+ if (avctx->max_prediction_order >= 0) {
446+ if (avctx->max_prediction_order < MIN_LPC_ORDER ||
447+ avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {
448+ av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
449+ avctx->max_prediction_order);
445450 return -1;
446451 }
447452
448453 s->max_prediction_order = avctx->max_prediction_order;
449454 }
450455
451− if(s->max_prediction_order < s->min_prediction_order) {
452− av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n",
456+ if (s->max_prediction_order < s->min_prediction_order) {
457+ av_log(avctx, AV_LOG_ERROR,
458+ "invalid prediction orders: min=%d max=%d\n",
453459 s->min_prediction_order, s->max_prediction_order);
454460 return -1;
455461 }
@@ -474,12 +480,12 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 18 unmodified lines
474480 PutBitContext *pb = &s->pbctx;
475481 int i, out_bytes, verbatim_flag = 0;
476482
477− if(avctx->frame_size > DEFAULT_FRAME_SIZE) {
483+ if (avctx->frame_size > DEFAULT_FRAME_SIZE) {
478484 av_log(avctx, AV_LOG_ERROR, "input frame size exceeded\n");
479485 return -1;
480486 }
481487
482− if(buf_size < 2*s->max_coded_frame_size) {
488+ if (buf_size < 2 * s->max_coded_frame_size) {
483489 av_log(avctx, AV_LOG_ERROR, "buffer size is too small\n");
484490 return -1;
485491 }
@@ -487,11 +493,11 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 1 unmodified line
487493 verbatim:
488494 init_put_bits(pb, frame, buf_size);
489495
490− if((s->compression_level == 0) || verbatim_flag) {
496+ if (s->compression_level == 0 || verbatim_flag) {
491497 // Verbatim mode
492498 const int16_t *samples = data;
493499 write_frame_header(s, 1);
494− for(i=0; i<avctx->frame_size*avctx->channels; i++) {
500+ for (i = 0; i < avctx->frame_size * avctx->channels; i++) {
495501 put_sbits(pb, 16, *samples++);
496502 }
497503 } else {
@@ -504,9 +510,9 @@ verbatim: · 6 unmodified lines
504510 flush_put_bits(pb);
505511 out_bytes = put_bits_count(pb) >> 3;
506512
507− if(out_bytes > s->max_coded_frame_size) {
513+ if (out_bytes > s->max_coded_frame_size) {
508514 /* frame too large. use verbatim mode */
509− if(verbatim_flag || (s->compression_level == 0)) {
515+ if (verbatim_flag || s->compression_level == 0) {
510516 /* still too large. must be an error. */
511517 av_log(avctx, AV_LOG_ERROR, "error encoding frame\n");
512518 return -1;
@@ -537,6 +543,7 @@ AVCodec ff_alac_encoder = { · 24 unmodified lines
537543 .encode = alac_encode_frame,
538544 .close = alac_encode_close,
539545 .capabilities = CODEC_CAP_SMALL_LAST_FRAME,
540− .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE},
546+ .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
547+ AV_SAMPLE_FMT_NONE },
541548 .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
542549 };
libavcodec/alsdec.c+25−20
@@ -191,6 +191,7 @@ typedef struct { · 190 unmodified lines
191191
192192 typedef struct {
193193 AVCodecContext *avctx;
194+ AVFrame frame;
194195 ALSSpecificConfig sconf;
195196 GetBitContext gb;
196197 DSPContext dsp;
@@ -290,7 +291,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 93 unmodified lines
290291 init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8);
291292
292293 config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata,
293− avctx->extradata_size);
294+ avctx->extradata_size * 8, 1);
294295
295296 if (config_offset < 0)
296297 return -1;
@@ -1415,15 +1416,14 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 1118 unmodified lines
14151416
14161417 /** Decode an ALS frame.
14171418 */
1418−static int decode_frame(AVCodecContext *avctx,
1419− void *data, int *data_size,
1419+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
14201420 AVPacket *avpkt)
14211421 {
14221422 ALSDecContext *ctx = avctx->priv_data;
14231423 ALSSpecificConfig *sconf = &ctx->sconf;
14241424 const uint8_t *buffer = avpkt->data;
14251425 int buffer_size = avpkt->size;
1426− int invalid_frame, size;
1426+ int invalid_frame, ret;
14271427 unsigned int c, sample, ra_frame, bytes_read, shift;
14281428
14291429 init_get_bits(&ctx->gb, buffer, buffer_size * 8);
@@ -1448,21 +1448,17 @@ static int decode_frame(AVCodecContext *avctx, · 18 unmodified lines
14481448
14491449 ctx->frame_id++;
14501450
1451− // check for size of decoded data
1452− size = ctx->cur_frame_length * avctx->channels *
1453− av_get_bytes_per_sample(avctx->sample_fmt);
1454−
1455− if (size > *data_size) {
1456− av_log(avctx, AV_LOG_ERROR, "Decoded data exceeds buffer size.\n");
1457− return -1;
1451+ /* get output buffer */
1452+ ctx->frame.nb_samples = ctx->cur_frame_length;
1453+ if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
1454+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1455+ return ret;
14581456 }
14591457
1460− *data_size = size;
1461−
14621458 // transform decoded frame into output format
14631459 #define INTERLEAVE_OUTPUT(bps) \
14641460 { \
1465− int##bps##_t *dest = (int##bps##_t*) data; \
1461+ int##bps##_t *dest = (int##bps##_t*)ctx->frame.data[0]; \
14661462 shift = bps - ctx->avctx->bits_per_raw_sample; \
14671463 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
14681464 for (c = 0; c < avctx->channels; c++) \
@@ -1480,7 +1476,7 @@ static int decode_frame(AVCodecContext *avctx, · 11 unmodified lines
14801476 int swap = HAVE_BIGENDIAN != sconf->msb_first;
14811477
14821478 if (ctx->avctx->bits_per_raw_sample == 24) {
1483− int32_t *src = data;
1479+ int32_t *src = (int32_t *)ctx->frame.data[0];
14841480
14851481 for (sample = 0;
14861482 sample < ctx->cur_frame_length * avctx->channels;
@@ -1501,22 +1497,25 @@ static int decode_frame(AVCodecContext *avctx, · 14 unmodified lines
15011497
15021498 if (swap) {
15031499 if (ctx->avctx->bits_per_raw_sample <= 16) {
1504− int16_t *src = (int16_t*) data;
1500+ int16_t *src = (int16_t*) ctx->frame.data[0];
15051501 int16_t *dest = (int16_t*) ctx->crc_buffer;
15061502 for (sample = 0;
15071503 sample < ctx->cur_frame_length * avctx->channels;
15081504 sample++)
15091505 *dest++ = av_bswap16(src[sample]);
15101506 } else {
1511− ctx->dsp.bswap_buf((uint32_t*)ctx->crc_buffer, data,
1507+ ctx->dsp.bswap_buf((uint32_t*)ctx->crc_buffer,
1508+ (uint32_t *)ctx->frame.data[0],
15121509 ctx->cur_frame_length * avctx->channels);
15131510 }
15141511 crc_source = ctx->crc_buffer;
15151512 } else {
1516− crc_source = data;
1513+ crc_source = ctx->frame.data[0];
15171514 }
15181515
1519− ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source, size);
1516+ ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source,
1517+ ctx->cur_frame_length * avctx->channels *
1518+ av_get_bytes_per_sample(avctx->sample_fmt));
15201519 }
15211520
15221521
@@ -1527,6 +1526,9 @@ static int decode_frame(AVCodecContext *avctx, · 4 unmodified lines
15271526 }
15281527 }
15291528
1529+ *got_frame_ptr = 1;
1530+ *(AVFrame *)data = ctx->frame;
1531+
15301532
15311533 bytes_read = invalid_frame ? buffer_size :
15321534 (get_bits_count(&ctx->gb) + 7) >> 3;
@@ -1724,6 +1726,9 @@ static av_cold int decode_init(AVCodecContext *avctx) · 191 unmodified lines
17241726
17251727 dsputil_init(&ctx->dsp, avctx);
17261728
1729+ avcodec_get_frame_defaults(&ctx->frame);
1730+ avctx->coded_frame = &ctx->frame;
1731+
17271732 return 0;
17281733 }
17291734
@@ -1747,7 +1752,7 @@ AVCodec ff_als_decoder = { · 17 unmodified lines
17471752 .close = decode_end,
17481753 .decode = decode_frame,
17491754 .flush = flush,
1750− .capabilities = CODEC_CAP_SUBFRAMES,
1755+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
17511756 .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"),
17521757 };
17531758
libavcodec/amrnbdec.c+19−6
@@ -95,6 +95,7 @@ · 94 unmodified lines
9595 #define AMR_AGC_ALPHA 0.9
9696
9797 typedef struct AMRContext {
98+ AVFrame avframe; ///< AVFrame for decoded samples
9899 AMRNBFrame frame; ///< decoded AMR parameters (lsf coefficients, codebook indexes, etc)
99100 uint8_t bad_frame_indicator; ///< bad frame ? 1 : 0
100101 enum Mode cur_frame_mode;
@@ -167,6 +168,9 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx) · 66 unmodified lines
167168 for (i = 0; i < 4; i++)
168169 p->prediction_error[i] = MIN_ENERGY;
169170
171+ avcodec_get_frame_defaults(&p->avframe);
172+ avctx->coded_frame = &p->avframe;
173+
170174 return 0;
171175 }
172176
@@ -919,21 +923,29 @@ static void postfilter(AMRContext *p, float *lpc, float *buf_out) · 746 unmodified lines
919923
920924 /// @}
921925
922−static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
923− AVPacket *avpkt)
926+static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
927+ int *got_frame_ptr, AVPacket *avpkt)
924928 {
925929
926930 AMRContext *p = avctx->priv_data; // pointer to private data
927931 const uint8_t *buf = avpkt->data;
928932 int buf_size = avpkt->size;
929− float *buf_out = data; // pointer to the output data buffer
930− int i, subframe;
933+ float *buf_out; // pointer to the output data buffer
934+ int i, subframe, ret;
931935 float fixed_gain_factor;
932936 AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing
933937 float spare_vector[AMR_SUBFRAME_SIZE]; // extra stack space to hold result from anti-sparseness processing
934938 float synth_fixed_gain; // the fixed gain that synthesis should use
935939 const float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use
936940
941+ /* get output buffer */
942+ p->avframe.nb_samples = AMR_BLOCK_SIZE;
943+ if ((ret = avctx->get_buffer(avctx, &p->avframe)) < 0) {
944+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
945+ return ret;
946+ }
947+ buf_out = (float *)p->avframe.data[0];
948+
937949 p->cur_frame_mode = unpack_bitstream(p, buf, buf_size);
938950 if (p->cur_frame_mode == MODE_DTX) {
939951 av_log_missing_feature(avctx, "dtx mode", 0);
@@ -1029,8 +1041,8 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 89 unmodified lines
10291041 ff_weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3],
10301042 0.84, 0.16, LP_FILTER_ORDER);
10311043
1032− /* report how many samples we got */
1033− *data_size = AMR_BLOCK_SIZE * sizeof(float);
1044+ *got_frame_ptr = 1;
1045+ *(AVFrame *)data = p->avframe;
10341046
10351047 /* return the amount of bytes consumed if everything was OK */
10361048 return frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC
@@ -1044,6 +1056,7 @@ AVCodec ff_amrnb_decoder = { · 7 unmodified lines
10441056 .priv_data_size = sizeof(AMRContext),
10451057 .init = amrnb_decode_init,
10461058 .decode = amrnb_decode_frame,
1059+ .capabilities = CODEC_CAP_DR1,
10471060 .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate NarrowBand"),
10481061 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
10491062 };
libavcodec/amrwbdec.c+20−7
@@ -41,6 +41,7 @@ · 40 unmodified lines
4141 #include "amrwbdata.h"
4242
4343 typedef struct {
44+ AVFrame avframe; ///< AVFrame for decoded samples
4445 AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream
4546 enum Mode fr_cur_mode; ///< mode index of current frame
4647 uint8_t fr_quality; ///< frame quality index (FQI)
@@ -102,6 +103,9 @@ static av_cold int amrwb_decode_init(AVCodecContext *avctx) · 55 unmodified lines
102103 for (i = 0; i < 4; i++)
103104 ctx->prediction_error[i] = MIN_ENERGY;
104105
106+ avcodec_get_frame_defaults(&ctx->avframe);
107+ avctx->coded_frame = &ctx->avframe;
108+
105109 return 0;
106110 }
107111
@@ -1062,15 +1066,15 @@ static void update_sub_state(AMRWBContext *ctx) · 954 unmodified lines
10621066 LP_ORDER_16k * sizeof(float));
10631067 }
10641068
1065−static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
1066− AVPacket *avpkt)
1069+static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
1070+ int *got_frame_ptr, AVPacket *avpkt)
10671071 {
10681072 AMRWBContext *ctx = avctx->priv_data;
10691073 AMRWBFrame *cf = &ctx->frame;
10701074 const uint8_t *buf = avpkt->data;
10711075 int buf_size = avpkt->size;
10721076 int expected_fr_size, header_size;
1073− float *buf_out = data;
1077+ float *buf_out;
10741078 float spare_vector[AMRWB_SFR_SIZE]; // extra stack space to hold result from anti-sparseness processing
10751079 float fixed_gain_factor; // fixed gain correction factor (gamma)
10761080 float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use
@@ -1080,7 +1084,15 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 3 unmodified lines
10801084 float hb_exc[AMRWB_SFR_SIZE_16k]; // excitation for the high frequency band
10811085 float hb_samples[AMRWB_SFR_SIZE_16k]; // filtered high-band samples from synthesis
10821086 float hb_gain;
1083− int sub, i;
1087+ int sub, i, ret;
1088+
1089+ /* get output buffer */
1090+ ctx->avframe.nb_samples = 4 * AMRWB_SFR_SIZE_16k;
1091+ if ((ret = avctx->get_buffer(avctx, &ctx->avframe)) < 0) {
1092+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1093+ return ret;
1094+ }
1095+ buf_out = (float *)ctx->avframe.data[0];
10841096
10851097 header_size = decode_mime_header(ctx, buf);
10861098 expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1;
@@ -1088,7 +1100,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 1 unmodified line
10881100 if (buf_size < expected_fr_size) {
10891101 av_log(avctx, AV_LOG_ERROR,
10901102 "Frame too small (%d bytes). Truncated file?\n", buf_size);
1091− *data_size = 0;
1103+ *got_frame_ptr = 0;
10921104 return buf_size;
10931105 }
10941106
@@ -1219,8 +1231,8 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 124 unmodified lines
12191231 memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));
12201232 memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float));
12211233
1222− /* report how many samples we got */
1223− *data_size = 4 * AMRWB_SFR_SIZE_16k * sizeof(float);
1234+ *got_frame_ptr = 1;
1235+ *(AVFrame *)data = ctx->avframe;
12241236
12251237 return expected_fr_size;
12261238 }
@@ -1232,6 +1244,7 @@ AVCodec ff_amrwb_decoder = { · 5 unmodified lines
12321244 .priv_data_size = sizeof(AMRWBContext),
12331245 .init = amrwb_decode_init,
12341246 .decode = amrwb_decode_frame,
1247+ .capabilities = CODEC_CAP_DR1,
12351248 .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"),
12361249 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
12371250 };
libavcodec/apedec.c+22−15
@@ -129,6 +129,7 @@ typedef struct APEPredictor { · 128 unmodified lines
129129 /** Decoder context */
130130 typedef struct APEContext {
131131 AVCodecContext *avctx;
132+ AVFrame frame;
132133 DSPContext dsp;
133134 int channels;
134135 int samples; ///< samples left to decode in current frame
@@ -215,6 +216,10 @@ static av_cold int ape_decode_init(AVCodecContext *avctx) · 80 unmodified lines
215216 dsputil_init(&s->dsp, avctx);
216217 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
217218 avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
219+
220+ avcodec_get_frame_defaults(&s->frame);
221+ avctx->coded_frame = &s->frame;
222+
218223 return 0;
219224 filter_alloc_fail:
220225 ape_decode_close(avctx);
@@ -805,16 +810,15 @@ static void ape_unpack_stereo(APEContext *ctx, int count) · 584 unmodified lines
805810 }
806811 }
807812
808−static int ape_decode_frame(AVCodecContext *avctx,
809− void *data, int *data_size,
810− AVPacket *avpkt)
813+static int ape_decode_frame(AVCodecContext *avctx, void *data,
814+ int *got_frame_ptr, AVPacket *avpkt)
811815 {
812816 const uint8_t *buf = avpkt->data;
813817 int buf_size = avpkt->size;
814818 APEContext *s = avctx->priv_data;
815− int16_t *samples = data;
816− int i;
817− int blockstodecode, out_size;
819+ int16_t *samples;
820+ int i, ret;
821+ int blockstodecode;
818822 int bytes_used = 0;
819823
820824 /* this should never be negative, but bad things will happen if it is, so
@@ -826,7 +830,7 @@ static int ape_decode_frame(AVCodecContext *avctx, · 5 unmodified lines
826830 void *tmp_data;
827831
828832 if (!buf_size) {
829− *data_size = 0;
833+ *got_frame_ptr = 0;
830834 return 0;
831835 }
832836 if (buf_size < 8) {
@@ -874,18 +878,19 @@ static int ape_decode_frame(AVCodecContext *avctx, · 41 unmodified lines
874878 }
875879
876880 if (!s->data) {
877− *data_size = 0;
881+ *got_frame_ptr = 0;
878882 return buf_size;
879883 }
880884
881885 blockstodecode = FFMIN(BLOCKS_PER_LOOP, s->samples);
882886
883− out_size = blockstodecode * avctx->channels *
884− av_get_bytes_per_sample(avctx->sample_fmt);
885− if (*data_size < out_size) {
886− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small.\n");
887− return AVERROR(EINVAL);
887+ /* get output buffer */
888+ s->frame.nb_samples = blockstodecode;
889+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
890+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
891+ return ret;
888892 }
893+ samples = (int16_t *)s->frame.data[0];
889894
890895 s->error=0;
891896
@@ -909,7 +914,9 @@ static int ape_decode_frame(AVCodecContext *avctx, · 17 unmodified lines
909914
910915 s->samples -= blockstodecode;
911916
912− *data_size = out_size;
917+ *got_frame_ptr = 1;
918+ *(AVFrame *)data = s->frame;
919+
913920 return bytes_used;
914921 }
915922
@@ -927,7 +934,7 @@ AVCodec ff_ape_decoder = { · 11 unmodified lines
927934 .init = ape_decode_init,
928935 .close = ape_decode_close,
929936 .decode = ape_decode_frame,
930− .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY,
937+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1,
931938 .flush = ape_flush,
932939 .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
933940 };
libavcodec/arm/h264dsp_neon.S+314−353
@@ -19,55 +19,16 @@ · 18 unmodified lines
1919 */
2020
2121 #include "asm.S"
22−
23− .macro transpose_8x8 r0 r1 r2 r3 r4 r5 r6 r7
24− vtrn.32 \r0, \r4
25− vtrn.32 \r1, \r5
26− vtrn.32 \r2, \r6
27− vtrn.32 \r3, \r7
28− vtrn.16 \r0, \r2
29− vtrn.16 \r1, \r3
30− vtrn.16 \r4, \r6
31− vtrn.16 \r5, \r7
32− vtrn.8 \r0, \r1
33− vtrn.8 \r2, \r3
34− vtrn.8 \r4, \r5
35− vtrn.8 \r6, \r7
36− .endm
37−
38− .macro transpose_4x4 r0 r1 r2 r3
39− vtrn.16 \r0, \r2
40− vtrn.16 \r1, \r3
41− vtrn.8 \r0, \r1
42− vtrn.8 \r2, \r3
43− .endm
44−
45− .macro swap4 r0 r1 r2 r3 r4 r5 r6 r7
46− vswp \r0, \r4
47− vswp \r1, \r5
48− vswp \r2, \r6
49− vswp \r3, \r7
50− .endm
51−
52− .macro transpose16_4x4 r0 r1 r2 r3 r4 r5 r6 r7
53− vtrn.32 \r0, \r2
54− vtrn.32 \r1, \r3
55− vtrn.32 \r4, \r6
56− vtrn.32 \r5, \r7
57− vtrn.16 \r0, \r1
58− vtrn.16 \r2, \r3
59− vtrn.16 \r4, \r5
60− vtrn.16 \r6, \r7
61− .endm
22+#include "neon.S"
6223
6324 /* chroma_mc8(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */
64− .macro h264_chroma_mc8 type
25+.macro h264_chroma_mc8 type
6526 function ff_\type\()_h264_chroma_mc8_neon, export=1
6627 push {r4-r7, lr}
6728 ldrd r4, [sp, #20]
68−.ifc \type,avg
29+ .ifc \type,avg
6930 mov lr, r0
70−.endif
31+ .endif
7132 pld [r1]
7233 pld [r1, r2]
7334
@@ -75,7 +36,7 @@ A muls r7, r4, r5 · 1 unmodified line
7536 T mul r7, r4, r5
7637 T cmp r7, #0
7738 rsb r6, r7, r5, lsl #3
78− rsb ip, r7, r4, lsl #3
39+ rsb r12, r7, r4, lsl #3
7940 sub r4, r7, r4, lsl #3
8041 sub r4, r4, r5, lsl #3
8142 add r4, r4, #64
@@ -86,10 +47,10 @@ T cmp r7, #0 · 4 unmodified lines
8647
8748 vdup.8 d0, r4
8849 lsl r4, r2, #1
89− vdup.8 d1, ip
90− vld1.64 {d4, d5}, [r1], r4
50+ vdup.8 d1, r12
51+ vld1.8 {d4, d5}, [r1], r4
9152 vdup.8 d2, r6
92− vld1.64 {d6, d7}, [r5], r4
53+ vld1.8 {d6, d7}, [r5], r4
9354 vdup.8 d3, r7
9455
9556 vext.8 d5, d4, d5, #1
@@ -98,7 +59,7 @@ T cmp r7, #0 · 2 unmodified lines
9859 1: pld [r5]
9960 vmull.u8 q8, d4, d0
10061 vmlal.u8 q8, d5, d1
101− vld1.64 {d4, d5}, [r1], r4
62+ vld1.8 {d4, d5}, [r1], r4
10263 vmlal.u8 q8, d6, d2
10364 vext.8 d5, d4, d5, #1
10465 vmlal.u8 q8, d7, d3
@@ -108,57 +69,57 @@ T cmp r7, #0 · 3 unmodified lines
10869 vmlal.u8 q9, d4, d2
10970 vmlal.u8 q9, d5, d3
11071 vrshrn.u16 d16, q8, #6
111− vld1.64 {d6, d7}, [r5], r4
72+ vld1.8 {d6, d7}, [r5], r4
11273 pld [r1]
11374 vrshrn.u16 d17, q9, #6
114−.ifc \type,avg
115− vld1.64 {d20}, [lr,:64], r2
116− vld1.64 {d21}, [lr,:64], r2
75+ .ifc \type,avg
76+ vld1.8 {d20}, [lr,:64], r2
77+ vld1.8 {d21}, [lr,:64], r2
11778 vrhadd.u8 q8, q8, q10
118−.endif
79+ .endif
11980 vext.8 d7, d6, d7, #1
120− vst1.64 {d16}, [r0,:64], r2
121− vst1.64 {d17}, [r0,:64], r2
81+ vst1.8 {d16}, [r0,:64], r2
82+ vst1.8 {d17}, [r0,:64], r2
12283 bgt 1b
12384
12485 pop {r4-r7, pc}
12586
12687 2: tst r6, r6
127− add ip, ip, r6
88+ add r12, r12, r6
12889 vdup.8 d0, r4
129− vdup.8 d1, ip
90+ vdup.8 d1, r12
13091
13192 beq 4f
13293
13394 add r5, r1, r2
13495 lsl r4, r2, #1
135− vld1.64 {d4}, [r1], r4
136− vld1.64 {d6}, [r5], r4
96+ vld1.8 {d4}, [r1], r4
97+ vld1.8 {d6}, [r5], r4
13798
13899 3: pld [r5]
139100 vmull.u8 q8, d4, d0
140101 vmlal.u8 q8, d6, d1
141− vld1.64 {d4}, [r1], r4
102+ vld1.8 {d4}, [r1], r4
142103 vmull.u8 q9, d6, d0
143104 vmlal.u8 q9, d4, d1
144− vld1.64 {d6}, [r5], r4
105+ vld1.8 {d6}, [r5], r4
145106 vrshrn.u16 d16, q8, #6
146107 vrshrn.u16 d17, q9, #6
147−.ifc \type,avg
148− vld1.64 {d20}, [lr,:64], r2
149− vld1.64 {d21}, [lr,:64], r2
108+ .ifc \type,avg
109+ vld1.8 {d20}, [lr,:64], r2
110+ vld1.8 {d21}, [lr,:64], r2
150111 vrhadd.u8 q8, q8, q10
151−.endif
112+ .endif
152113 subs r3, r3, #2
153114 pld [r1]
154− vst1.64 {d16}, [r0,:64], r2
155− vst1.64 {d17}, [r0,:64], r2
115+ vst1.8 {d16}, [r0,:64], r2
116+ vst1.8 {d17}, [r0,:64], r2
156117 bgt 3b
157118
158119 pop {r4-r7, pc}
159120
160−4: vld1.64 {d4, d5}, [r1], r2
161− vld1.64 {d6, d7}, [r1], r2
121+4: vld1.8 {d4, d5}, [r1], r2
122+ vld1.8 {d6, d7}, [r1], r2
162123 vext.8 d5, d4, d5, #1
163124 vext.8 d7, d6, d7, #1
164125
@@ -166,36 +127,36 @@ T cmp r7, #0 · 1 unmodified line
166127 subs r3, r3, #2
167128 vmull.u8 q8, d4, d0
168129 vmlal.u8 q8, d5, d1
169− vld1.64 {d4, d5}, [r1], r2
130+ vld1.8 {d4, d5}, [r1], r2
170131 vmull.u8 q9, d6, d0
171132 vmlal.u8 q9, d7, d1
172133 pld [r1]
173134 vext.8 d5, d4, d5, #1
174135 vrshrn.u16 d16, q8, #6
175136 vrshrn.u16 d17, q9, #6
176−.ifc \type,avg
177− vld1.64 {d20}, [lr,:64], r2
178− vld1.64 {d21}, [lr,:64], r2
137+ .ifc \type,avg
138+ vld1.8 {d20}, [lr,:64], r2
139+ vld1.8 {d21}, [lr,:64], r2
179140 vrhadd.u8 q8, q8, q10
180−.endif
181− vld1.64 {d6, d7}, [r1], r2
141+ .endif
142+ vld1.8 {d6, d7}, [r1], r2
182143 vext.8 d7, d6, d7, #1
183− vst1.64 {d16}, [r0,:64], r2
184− vst1.64 {d17}, [r0,:64], r2
144+ vst1.8 {d16}, [r0,:64], r2
145+ vst1.8 {d17}, [r0,:64], r2
185146 bgt 5b
186147
187148 pop {r4-r7, pc}
188149 endfunc
189− .endm
150+.endm
190151
191152 /* chroma_mc4(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */
192− .macro h264_chroma_mc4 type
153+.macro h264_chroma_mc4 type
193154 function ff_\type\()_h264_chroma_mc4_neon, export=1
194155 push {r4-r7, lr}
195156 ldrd r4, [sp, #20]
196−.ifc \type,avg
157+ .ifc \type,avg
197158 mov lr, r0
198−.endif
159+ .endif
199160 pld [r1]
200161 pld [r1, r2]
201162
@@ -203,7 +164,7 @@ A muls r7, r4, r5 · 1 unmodified line
203164 T mul r7, r4, r5
204165 T cmp r7, #0
205166 rsb r6, r7, r5, lsl #3
206− rsb ip, r7, r4, lsl #3
167+ rsb r12, r7, r4, lsl #3
207168 sub r4, r7, r4, lsl #3
208169 sub r4, r4, r5, lsl #3
209170 add r4, r4, #64
@@ -214,10 +175,10 @@ T cmp r7, #0 · 4 unmodified lines
214175
215176 vdup.8 d0, r4
216177 lsl r4, r2, #1
217− vdup.8 d1, ip
218− vld1.64 {d4}, [r1], r4
178+ vdup.8 d1, r12
179+ vld1.8 {d4}, [r1], r4
219180 vdup.8 d2, r6
220− vld1.64 {d6}, [r5], r4
181+ vld1.8 {d6}, [r5], r4
221182 vdup.8 d3, r7
222183
223184 vext.8 d5, d4, d5, #1
@@ -231,22 +192,22 @@ T cmp r7, #0 · 7 unmodified lines
231192 1: pld [r5]
232193 vmull.u8 q8, d4, d0
233194 vmlal.u8 q8, d6, d2
234− vld1.64 {d4}, [r1], r4
195+ vld1.8 {d4}, [r1], r4
235196 vext.8 d5, d4, d5, #1
236197 vtrn.32 d4, d5
237198 vmull.u8 q9, d6, d0
238199 vmlal.u8 q9, d4, d2
239− vld1.64 {d6}, [r5], r4
200+ vld1.8 {d6}, [r5], r4
240201 vadd.i16 d16, d16, d17
241202 vadd.i16 d17, d18, d19
242203 vrshrn.u16 d16, q8, #6
243204 subs r3, r3, #2
244205 pld [r1]
245−.ifc \type,avg
206+ .ifc \type,avg
246207 vld1.32 {d20[0]}, [lr,:32], r2
247208 vld1.32 {d20[1]}, [lr,:32], r2
248209 vrhadd.u8 d16, d16, d20
249−.endif
210+ .endif
250211 vext.8 d7, d6, d7, #1
251212 vtrn.32 d6, d7
252213 vst1.32 {d16[0]}, [r0,:32], r2
@@ -256,9 +217,9 @@ T cmp r7, #0 · 3 unmodified lines
256217 pop {r4-r7, pc}
257218
258219 2: tst r6, r6
259− add ip, ip, r6
220+ add r12, r12, r6
260221 vdup.8 d0, r4
261− vdup.8 d1, ip
222+ vdup.8 d1, r12
262223 vtrn.32 d0, d1
263224
264225 beq 4f
@@ -277,11 +238,11 @@ T cmp r7, #0 · 12 unmodified lines
277238 vadd.i16 d16, d16, d17
278239 vadd.i16 d17, d18, d19
279240 vrshrn.u16 d16, q8, #6
280−.ifc \type,avg
241+ .ifc \type,avg
281242 vld1.32 {d20[0]}, [lr,:32], r2
282243 vld1.32 {d20[1]}, [lr,:32], r2
283244 vrhadd.u8 d16, d16, d20
284−.endif
245+ .endif
285246 subs r3, r3, #2
286247 pld [r1]
287248 vst1.32 {d16[0]}, [r0,:32], r2
@@ -290,8 +251,8 @@ T cmp r7, #0 · 2 unmodified lines
290251
291252 pop {r4-r7, pc}
292253
293−4: vld1.64 {d4}, [r1], r2
294− vld1.64 {d6}, [r1], r2
254+4: vld1.8 {d4}, [r1], r2
255+ vld1.8 {d6}, [r1], r2
295256 vext.8 d5, d4, d5, #1
296257 vext.8 d7, d6, d7, #1
297258 vtrn.32 d4, d5
@@ -300,19 +261,19 @@ T cmp r7, #0 · 2 unmodified lines
300261 5: vmull.u8 q8, d4, d0
301262 vmull.u8 q9, d6, d0
302263 subs r3, r3, #2
303− vld1.64 {d4}, [r1], r2
264+ vld1.8 {d4}, [r1], r2
304265 vext.8 d5, d4, d5, #1
305266 vtrn.32 d4, d5
306267 vadd.i16 d16, d16, d17
307268 vadd.i16 d17, d18, d19
308269 pld [r1]
309270 vrshrn.u16 d16, q8, #6
310−.ifc \type,avg
271+ .ifc \type,avg
311272 vld1.32 {d20[0]}, [lr,:32], r2
312273 vld1.32 {d20[1]}, [lr,:32], r2
313274 vrhadd.u8 d16, d16, d20
314−.endif
315− vld1.64 {d6}, [r1], r2
275+ .endif
276+ vld1.8 {d6}, [r1], r2
316277 vext.8 d7, d6, d7, #1
317278 vtrn.32 d6, d7
318279 pld [r1]
@@ -322,9 +283,9 @@ T cmp r7, #0 · 3 unmodified lines
322283
323284 pop {r4-r7, pc}
324285 endfunc
325− .endm
286+.endm
326287
327− .macro h264_chroma_mc2 type
288+.macro h264_chroma_mc2 type
328289 function ff_\type\()_h264_chroma_mc2_neon, export=1
329290 push {r4-r6, lr}
330291 ldr r4, [sp, #16]
@@ -354,29 +315,29 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 · 23 unmodified lines
354315 vtrn.16 q2, q3
355316 vmull.u8 q8, d4, d0
356317 vmlal.u8 q8, d5, d1
357−.ifc \type,avg
318+ .ifc \type,avg
358319 vld1.16 {d18[0]}, [r0,:16], r2
359320 vld1.16 {d18[1]}, [r0,:16]
360321 sub r0, r0, r2
361−.endif
322+ .endif
362323 vtrn.32 d16, d17
363324 vadd.i16 d16, d16, d17
364325 vrshrn.u16 d16, q8, #6
365−.ifc \type,avg
326+ .ifc \type,avg
366327 vrhadd.u8 d16, d16, d18
367−.endif
328+ .endif
368329 vst1.16 {d16[0]}, [r0,:16], r2
369330 vst1.16 {d16[1]}, [r0,:16], r2
370331 subs r3, r3, #2
371332 bgt 1b
372333 pop {r4-r6, pc}
373334 2:
374−.ifc \type,put
335+ .ifc \type,put
375336 ldrh_post r5, r1, r2
376337 strh_post r5, r0, r2
377338 ldrh_post r6, r1, r2
378339 strh_post r6, r0, r2
379−.else
340+ .else
380341 vld1.16 {d16[0]}, [r1], r2
381342 vld1.16 {d16[1]}, [r1], r2
382343 vld1.16 {d18[0]}, [r0,:16], r2
@@ -385,7 +346,7 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 · 2 unmodified lines
385346 vrhadd.u8 d16, d16, d18
386347 vst1.16 {d16[0]}, [r0,:16], r2
387348 vst1.16 {d16[1]}, [r0,:16], r2
388−.endif
349+ .endif
389350 subs r3, r3, #2
390351 bgt 2b
391352 pop {r4-r6, pc}
@@ -401,22 +362,22 @@ endfunc · 9 unmodified lines
401362
402363 /* H.264 loop filter */
403364
404− .macro h264_loop_filter_start
405− ldr ip, [sp]
365+.macro h264_loop_filter_start
366+ ldr r12, [sp]
406367 tst r2, r2
407− ldr ip, [ip]
368+ ldr r12, [r12]
408369 it ne
409370 tstne r3, r3
410− vmov.32 d24[0], ip
411− and ip, ip, ip, lsl #16
371+ vmov.32 d24[0], r12
372+ and r12, r12, r12, lsl #16
412373 it eq
413374 bxeq lr
414− ands ip, ip, ip, lsl #8
375+ ands r12, r12, r12, lsl #8
415376 it lt
416377 bxlt lr
417− .endm
378+.endm
418379
419− .macro h264_loop_filter_luma
380+.macro h264_loop_filter_luma
420381 vdup.8 q11, r2 @ alpha
421382 vmovl.u8 q12, d24
422383 vabd.u8 q6, q8, q0 @ abs(p0 - q0)
@@ -482,29 +443,29 @@ endfunc · 59 unmodified lines
482443 vqmovun.s16 d17, q6
483444 vqmovun.s16 d0, q11
484445 vqmovun.s16 d1, q12
485− .endm
446+.endm
486447
487448 function ff_h264_v_loop_filter_luma_neon, export=1
488449 h264_loop_filter_start
489450
490− vld1.64 {d0, d1}, [r0,:128], r1
491− vld1.64 {d2, d3}, [r0,:128], r1
492− vld1.64 {d4, d5}, [r0,:128], r1
451+ vld1.8 {d0, d1}, [r0,:128], r1
452+ vld1.8 {d2, d3}, [r0,:128], r1
453+ vld1.8 {d4, d5}, [r0,:128], r1
493454 sub r0, r0, r1, lsl #2
494455 sub r0, r0, r1, lsl #1
495− vld1.64 {d20,d21}, [r0,:128], r1
496− vld1.64 {d18,d19}, [r0,:128], r1
497− vld1.64 {d16,d17}, [r0,:128], r1
456+ vld1.8 {d20,d21}, [r0,:128], r1
457+ vld1.8 {d18,d19}, [r0,:128], r1
458+ vld1.8 {d16,d17}, [r0,:128], r1
498459
499460 vpush {d8-d15}
500461
501462 h264_loop_filter_luma
502463
503464 sub r0, r0, r1, lsl #1
504− vst1.64 {d8, d9}, [r0,:128], r1
505− vst1.64 {d16,d17}, [r0,:128], r1
506− vst1.64 {d0, d1}, [r0,:128], r1
507− vst1.64 {d10,d11}, [r0,:128]
465+ vst1.8 {d8, d9}, [r0,:128], r1
466+ vst1.8 {d16,d17}, [r0,:128], r1
467+ vst1.8 {d0, d1}, [r0,:128], r1
468+ vst1.8 {d10,d11}, [r0,:128]
508469
509470 vpop {d8-d15}
510471 bx lr
@@ -514,22 +475,22 @@ function ff_h264_h_loop_filter_luma_neon, export=1 · 3 unmodified lines
514475 h264_loop_filter_start
515476
516477 sub r0, r0, #4
517− vld1.64 {d6}, [r0], r1
518− vld1.64 {d20}, [r0], r1
519− vld1.64 {d18}, [r0], r1
520− vld1.64 {d16}, [r0], r1
521− vld1.64 {d0}, [r0], r1
522− vld1.64 {d2}, [r0], r1
523− vld1.64 {d4}, [r0], r1
524− vld1.64 {d26}, [r0], r1
525− vld1.64 {d7}, [r0], r1
526− vld1.64 {d21}, [r0], r1
527− vld1.64 {d19}, [r0], r1
528− vld1.64 {d17}, [r0], r1
529− vld1.64 {d1}, [r0], r1
530− vld1.64 {d3}, [r0], r1
531− vld1.64 {d5}, [r0], r1
532− vld1.64 {d27}, [r0], r1
478+ vld1.8 {d6}, [r0], r1
479+ vld1.8 {d20}, [r0], r1
480+ vld1.8 {d18}, [r0], r1
481+ vld1.8 {d16}, [r0], r1
482+ vld1.8 {d0}, [r0], r1
483+ vld1.8 {d2}, [r0], r1
484+ vld1.8 {d4}, [r0], r1
485+ vld1.8 {d26}, [r0], r1
486+ vld1.8 {d7}, [r0], r1
487+ vld1.8 {d21}, [r0], r1
488+ vld1.8 {d19}, [r0], r1
489+ vld1.8 {d17}, [r0], r1
490+ vld1.8 {d1}, [r0], r1
491+ vld1.8 {d3}, [r0], r1
492+ vld1.8 {d5}, [r0], r1
493+ vld1.8 {d27}, [r0], r1
533494
534495 transpose_8x8 q3, q10, q9, q8, q0, q1, q2, q13
535496
@@ -562,7 +523,7 @@ function ff_h264_h_loop_filter_luma_neon, export=1 · 26 unmodified lines
562523 bx lr
563524 endfunc
564525
565− .macro h264_loop_filter_chroma
526+.macro h264_loop_filter_chroma
566527 vdup.8 d22, r2 @ alpha
567528 vmovl.u8 q12, d24
568529 vabd.u8 d26, d16, d0 @ abs(p0 - q0)
@@ -591,22 +552,22 @@ endfunc · 22 unmodified lines
591552 vsubw.s8 q11, q11, d4
592553 vqmovun.s16 d16, q14
593554 vqmovun.s16 d0, q11
594− .endm
555+.endm
595556
596557 function ff_h264_v_loop_filter_chroma_neon, export=1
597558 h264_loop_filter_start
598559
599560 sub r0, r0, r1, lsl #1
600− vld1.64 {d18}, [r0,:64], r1
601− vld1.64 {d16}, [r0,:64], r1
602− vld1.64 {d0}, [r0,:64], r1
603− vld1.64 {d2}, [r0,:64]
561+ vld1.8 {d18}, [r0,:64], r1
562+ vld1.8 {d16}, [r0,:64], r1
563+ vld1.8 {d0}, [r0,:64], r1
564+ vld1.8 {d2}, [r0,:64]
604565
605566 h264_loop_filter_chroma
606567
607568 sub r0, r0, r1, lsl #1
608− vst1.64 {d16}, [r0,:64], r1
609− vst1.64 {d0}, [r0,:64], r1
569+ vst1.8 {d16}, [r0,:64], r1
570+ vst1.8 {d0}, [r0,:64], r1
610571
611572 bx lr
612573 endfunc
@@ -651,20 +612,20 @@ endfunc · 38 unmodified lines
651612
652613 /* H.264 qpel MC */
653614
654− .macro lowpass_const r
615+.macro lowpass_const r
655616 movw \r, #5
656617 movt \r, #20
657618 vmov.32 d6[0], \r
658− .endm
619+.endm
659620
660− .macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1
661−.if \narrow
621+.macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1
622+ .if \narrow
662623 t0 .req q0
663624 t1 .req q8
664−.else
625+ .else
665626 t0 .req \d0
666627 t1 .req \d1
667−.endif
628+ .endif
668629 vext.8 d2, \r0, \r1, #2
669630 vext.8 d3, \r0, \r1, #3
670631 vaddl.u8 q1, d2, d3
@@ -685,20 +646,20 @@ endfunc · 14 unmodified lines
685646 vaddl.u8 t1, \r2, d31
686647 vmla.i16 t1, q9, d6[1]
687648 vmls.i16 t1, q10, d6[0]
688−.if \narrow
649+ .if \narrow
689650 vqrshrun.s16 \d0, t0, #5
690651 vqrshrun.s16 \d1, t1, #5
691−.endif
652+ .endif
692653 .unreq t0
693654 .unreq t1
694− .endm
655+.endm
695656
696− .macro lowpass_8_1 r0, r1, d0, narrow=1
697−.if \narrow
657+.macro lowpass_8_1 r0, r1, d0, narrow=1
658+ .if \narrow
698659 t0 .req q0
699−.else
660+ .else
700661 t0 .req \d0
701−.endif
662+ .endif
702663 vext.8 d2, \r0, \r1, #2
703664 vext.8 d3, \r0, \r1, #3
704665 vaddl.u8 q1, d2, d3
@@ -709,13 +670,13 @@ endfunc · 4 unmodified lines
709670 vaddl.u8 t0, \r0, d30
710671 vmla.i16 t0, q1, d6[1]
711672 vmls.i16 t0, q2, d6[0]
712−.if \narrow
673+ .if \narrow
713674 vqrshrun.s16 \d0, t0, #5
714−.endif
675+ .endif
715676 .unreq t0
716− .endm
677+.endm
717678
718− .macro lowpass_8.16 r0, r1, l0, h0, l1, h1, d
679+.macro lowpass_8.16 r0, r1, l0, h0, l1, h1, d
719680 vext.16 q1, \r0, \r1, #2
720681 vext.16 q0, \r0, \r1, #3
721682 vaddl.s16 q9, d2, d0
@@ -750,59 +711,59 @@ endfunc · 28 unmodified lines
750711 vrshrn.s32 d19, q1, #10
751712
752713 vqmovun.s16 \d, q9
753− .endm
714+.endm
754715
755716 function put_h264_qpel16_h_lowpass_neon_packed
756717 mov r4, lr
757− mov ip, #16
718+ mov r12, #16
758719 mov r3, #8
759720 bl put_h264_qpel8_h_lowpass_neon
760721 sub r1, r1, r2, lsl #4
761722 add r1, r1, #8
762− mov ip, #16
723+ mov r12, #16
763724 mov lr, r4
764725 b put_h264_qpel8_h_lowpass_neon
765726 endfunc
766727
767− .macro h264_qpel_h_lowpass type
728+.macro h264_qpel_h_lowpass type
768729 function \type\()_h264_qpel16_h_lowpass_neon
769730 push {lr}
770− mov ip, #16
731+ mov r12, #16
771732 bl \type\()_h264_qpel8_h_lowpass_neon
772733 sub r0, r0, r3, lsl #4
773734 sub r1, r1, r2, lsl #4
774735 add r0, r0, #8
775736 add r1, r1, #8
776− mov ip, #16
737+ mov r12, #16
777738 pop {lr}
778739 endfunc
779740
780741 function \type\()_h264_qpel8_h_lowpass_neon
781−1: vld1.64 {d0, d1}, [r1], r2
782− vld1.64 {d16,d17}, [r1], r2
783− subs ip, ip, #2
742+1: vld1.8 {d0, d1}, [r1], r2
743+ vld1.8 {d16,d17}, [r1], r2
744+ subs r12, r12, #2
784745 lowpass_8 d0, d1, d16, d17, d0, d16
785−.ifc \type,avg
746+ .ifc \type,avg
786747 vld1.8 {d2}, [r0,:64], r3
787748 vrhadd.u8 d0, d0, d2
788749 vld1.8 {d3}, [r0,:64]
789750 vrhadd.u8 d16, d16, d3
790751 sub r0, r0, r3
791−.endif
792− vst1.64 {d0}, [r0,:64], r3
793− vst1.64 {d16}, [r0,:64], r3
752+ .endif
753+ vst1.8 {d0}, [r0,:64], r3
754+ vst1.8 {d16}, [r0,:64], r3
794755 bne 1b
795756 bx lr
796757 endfunc
797− .endm
758+.endm
798759
799760 h264_qpel_h_lowpass put
800761 h264_qpel_h_lowpass avg
801762
802− .macro h264_qpel_h_lowpass_l2 type
763+.macro h264_qpel_h_lowpass_l2 type
803764 function \type\()_h264_qpel16_h_lowpass_l2_neon
804765 push {lr}
805− mov ip, #16
766+ mov r12, #16
806767 bl \type\()_h264_qpel8_h_lowpass_l2_neon
807768 sub r0, r0, r2, lsl #4
808769 sub r1, r1, r2, lsl #4
@@ -810,31 +771,31 @@ function \type\()_h264_qpel16_h_lowpass_l2_neon · 1 unmodified line
810771 add r0, r0, #8
811772 add r1, r1, #8
812773 add r3, r3, #8
813− mov ip, #16
774+ mov r12, #16
814775 pop {lr}
815776 endfunc
816777
817778 function \type\()_h264_qpel8_h_lowpass_l2_neon
818−1: vld1.64 {d0, d1}, [r1], r2
819− vld1.64 {d16,d17}, [r1], r2
820− vld1.64 {d28}, [r3], r2
821− vld1.64 {d29}, [r3], r2
822− subs ip, ip, #2
779+1: vld1.8 {d0, d1}, [r1], r2
780+ vld1.8 {d16,d17}, [r1], r2
781+ vld1.8 {d28}, [r3], r2
782+ vld1.8 {d29}, [r3], r2
783+ subs r12, r12, #2
823784 lowpass_8 d0, d1, d16, d17, d0, d1
824785 vrhadd.u8 q0, q0, q14
825−.ifc \type,avg
786+ .ifc \type,avg
826787 vld1.8 {d2}, [r0,:64], r2
827788 vrhadd.u8 d0, d0, d2
828789 vld1.8 {d3}, [r0,:64]
829790 vrhadd.u8 d1, d1, d3
830791 sub r0, r0, r2
831−.endif
832− vst1.64 {d0}, [r0,:64], r2
833− vst1.64 {d1}, [r0,:64], r2
792+ .endif
793+ vst1.8 {d0}, [r0,:64], r2
794+ vst1.8 {d1}, [r0,:64], r2
834795 bne 1b
835796 bx lr
836797 endfunc
837− .endm
798+.endm
838799
839800 h264_qpel_h_lowpass_l2 put
840801 h264_qpel_h_lowpass_l2 avg
@@ -854,7 +815,7 @@ function put_h264_qpel16_v_lowpass_neon_packed · 13 unmodified lines
854815 b put_h264_qpel8_v_lowpass_neon
855816 endfunc
856817
857− .macro h264_qpel_v_lowpass type
818+.macro h264_qpel_v_lowpass type
858819 function \type\()_h264_qpel16_v_lowpass_neon
859820 mov r4, lr
860821 bl \type\()_h264_qpel8_v_lowpass_neon
@@ -871,19 +832,19 @@ function \type\()_h264_qpel16_v_lowpass_neon · 10 unmodified lines
871832 endfunc
872833
873834 function \type\()_h264_qpel8_v_lowpass_neon
874− vld1.64 {d8}, [r1], r3
875− vld1.64 {d10}, [r1], r3
876− vld1.64 {d12}, [r1], r3
877− vld1.64 {d14}, [r1], r3
878− vld1.64 {d22}, [r1], r3
879− vld1.64 {d24}, [r1], r3
880− vld1.64 {d26}, [r1], r3
881− vld1.64 {d28}, [r1], r3
882− vld1.64 {d9}, [r1], r3
883− vld1.64 {d11}, [r1], r3
884− vld1.64 {d13}, [r1], r3
885− vld1.64 {d15}, [r1], r3
886− vld1.64 {d23}, [r1]
835+ vld1.8 {d8}, [r1], r3
836+ vld1.8 {d10}, [r1], r3
837+ vld1.8 {d12}, [r1], r3
838+ vld1.8 {d14}, [r1], r3
839+ vld1.8 {d22}, [r1], r3
840+ vld1.8 {d24}, [r1], r3
841+ vld1.8 {d26}, [r1], r3
842+ vld1.8 {d28}, [r1], r3
843+ vld1.8 {d9}, [r1], r3
844+ vld1.8 {d11}, [r1], r3
845+ vld1.8 {d13}, [r1], r3
846+ vld1.8 {d15}, [r1], r3
847+ vld1.8 {d23}, [r1]
887848
888849 transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14
889850 lowpass_8 d8, d9, d10, d11, d8, d10
@@ -892,7 +853,7 @@ function \type\()_h264_qpel8_v_lowpass_neon · 2 unmodified lines
892853 lowpass_8 d26, d27, d28, d29, d26, d28
893854 transpose_8x8 d8, d10, d12, d14, d22, d24, d26, d28
894855
895−.ifc \type,avg
856+ .ifc \type,avg
896857 vld1.8 {d9}, [r0,:64], r2
897858 vrhadd.u8 d8, d8, d9
898859 vld1.8 {d11}, [r0,:64], r2
@@ -910,34 +871,34 @@ function \type\()_h264_qpel8_v_lowpass_neon · 11 unmodified lines
910871 vld1.8 {d29}, [r0,:64], r2
911872 vrhadd.u8 d28, d28, d29
912873 sub r0, r0, r2, lsl #3
913−.endif
874+ .endif
914875
915− vst1.64 {d8}, [r0,:64], r2
916− vst1.64 {d10}, [r0,:64], r2
917− vst1.64 {d12}, [r0,:64], r2
918− vst1.64 {d14}, [r0,:64], r2
919− vst1.64 {d22}, [r0,:64], r2
920− vst1.64 {d24}, [r0,:64], r2
921− vst1.64 {d26}, [r0,:64], r2
922− vst1.64 {d28}, [r0,:64], r2
876+ vst1.8 {d8}, [r0,:64], r2
877+ vst1.8 {d10}, [r0,:64], r2
878+ vst1.8 {d12}, [r0,:64], r2
879+ vst1.8 {d14}, [r0,:64], r2
880+ vst1.8 {d22}, [r0,:64], r2
881+ vst1.8 {d24}, [r0,:64], r2
882+ vst1.8 {d26}, [r0,:64], r2
883+ vst1.8 {d28}, [r0,:64], r2
923884
924885 bx lr
925886 endfunc
926− .endm
887+.endm
927888
928889 h264_qpel_v_lowpass put
929890 h264_qpel_v_lowpass avg
930891
931− .macro h264_qpel_v_lowpass_l2 type
892+.macro h264_qpel_v_lowpass_l2 type
932893 function \type\()_h264_qpel16_v_lowpass_l2_neon
933894 mov r4, lr
934895 bl \type\()_h264_qpel8_v_lowpass_l2_neon
935896 sub r1, r1, r3, lsl #2
936897 bl \type\()_h264_qpel8_v_lowpass_l2_neon
937898 sub r0, r0, r3, lsl #4
938− sub ip, ip, r2, lsl #4
899+ sub r12, r12, r2, lsl #4
939900 add r0, r0, #8
940− add ip, ip, #8
901+ add r12, r12, #8
941902 sub r1, r1, r3, lsl #4
942903 sub r1, r1, r3, lsl #2
943904 add r1, r1, #8
@@ -947,19 +908,19 @@ function \type\()_h264_qpel16_v_lowpass_l2_neon · 3 unmodified lines
947908 endfunc
948909
949910 function \type\()_h264_qpel8_v_lowpass_l2_neon
950− vld1.64 {d8}, [r1], r3
951− vld1.64 {d10}, [r1], r3
952− vld1.64 {d12}, [r1], r3
953− vld1.64 {d14}, [r1], r3
954− vld1.64 {d22}, [r1], r3
955− vld1.64 {d24}, [r1], r3
956− vld1.64 {d26}, [r1], r3
957− vld1.64 {d28}, [r1], r3
958− vld1.64 {d9}, [r1], r3
959− vld1.64 {d11}, [r1], r3
960− vld1.64 {d13}, [r1], r3
961− vld1.64 {d15}, [r1], r3
962− vld1.64 {d23}, [r1]
911+ vld1.8 {d8}, [r1], r3
912+ vld1.8 {d10}, [r1], r3
913+ vld1.8 {d12}, [r1], r3
914+ vld1.8 {d14}, [r1], r3
915+ vld1.8 {d22}, [r1], r3
916+ vld1.8 {d24}, [r1], r3
917+ vld1.8 {d26}, [r1], r3
918+ vld1.8 {d28}, [r1], r3
919+ vld1.8 {d9}, [r1], r3
920+ vld1.8 {d11}, [r1], r3
921+ vld1.8 {d13}, [r1], r3
922+ vld1.8 {d15}, [r1], r3
923+ vld1.8 {d23}, [r1]
963924
964925 transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14
965926 lowpass_8 d8, d9, d10, d11, d8, d9
@@ -968,20 +929,20 @@ function \type\()_h264_qpel8_v_lowpass_l2_neon · 2 unmodified lines
968929 lowpass_8 d26, d27, d28, d29, d26, d27
969930 transpose_8x8 d8, d9, d12, d13, d22, d23, d26, d27
970931
971− vld1.64 {d0}, [ip], r2
972− vld1.64 {d1}, [ip], r2
973− vld1.64 {d2}, [ip], r2
974− vld1.64 {d3}, [ip], r2
975− vld1.64 {d4}, [ip], r2
932+ vld1.8 {d0}, [r12], r2
933+ vld1.8 {d1}, [r12], r2
934+ vld1.8 {d2}, [r12], r2
935+ vld1.8 {d3}, [r12], r2
936+ vld1.8 {d4}, [r12], r2
976937 vrhadd.u8 q0, q0, q4
977− vld1.64 {d5}, [ip], r2
938+ vld1.8 {d5}, [r12], r2
978939 vrhadd.u8 q1, q1, q6
979− vld1.64 {d10}, [ip], r2
940+ vld1.8 {d10}, [r12], r2
980941 vrhadd.u8 q2, q2, q11
981− vld1.64 {d11}, [ip], r2
942+ vld1.8 {d11}, [r12], r2
982943 vrhadd.u8 q5, q5, q13
983944
984−.ifc \type,avg
945+ .ifc \type,avg
985946 vld1.8 {d16}, [r0,:64], r3
986947 vrhadd.u8 d0, d0, d16
987948 vld1.8 {d17}, [r0,:64], r3
@@ -999,51 +960,51 @@ function \type\()_h264_qpel8_v_lowpass_l2_neon · 11 unmodified lines
999960 vld1.8 {d17}, [r0,:64], r3
1000961 vrhadd.u8 d11, d11, d17
1001962 sub r0, r0, r3, lsl #3
1002−.endif
963+ .endif
1003964
1004− vst1.64 {d0}, [r0,:64], r3
1005− vst1.64 {d1}, [r0,:64], r3
1006− vst1.64 {d2}, [r0,:64], r3
1007− vst1.64 {d3}, [r0,:64], r3
1008− vst1.64 {d4}, [r0,:64], r3
1009− vst1.64 {d5}, [r0,:64], r3
1010− vst1.64 {d10}, [r0,:64], r3
1011− vst1.64 {d11}, [r0,:64], r3
965+ vst1.8 {d0}, [r0,:64], r3
966+ vst1.8 {d1}, [r0,:64], r3
967+ vst1.8 {d2}, [r0,:64], r3
968+ vst1.8 {d3}, [r0,:64], r3
969+ vst1.8 {d4}, [r0,:64], r3
970+ vst1.8 {d5}, [r0,:64], r3
971+ vst1.8 {d10}, [r0,:64], r3
972+ vst1.8 {d11}, [r0,:64], r3
1012973
1013974 bx lr
1014975 endfunc
1015− .endm
976+.endm
1016977
1017978 h264_qpel_v_lowpass_l2 put
1018979 h264_qpel_v_lowpass_l2 avg
1019980
1020981 function put_h264_qpel8_hv_lowpass_neon_top
1021− lowpass_const ip
1022− mov ip, #12
1023−1: vld1.64 {d0, d1}, [r1], r3
1024− vld1.64 {d16,d17}, [r1], r3
1025− subs ip, ip, #2
982+ lowpass_const r12
983+ mov r12, #12
984+1: vld1.8 {d0, d1}, [r1], r3
985+ vld1.8 {d16,d17}, [r1], r3
986+ subs r12, r12, #2
1026987 lowpass_8 d0, d1, d16, d17, q11, q12, narrow=0
1027− vst1.64 {d22-d25}, [r4,:128]!
988+ vst1.8 {d22-d25}, [r4,:128]!
1028989 bne 1b
1029990
1030− vld1.64 {d0, d1}, [r1]
991+ vld1.8 {d0, d1}, [r1]
1031992 lowpass_8_1 d0, d1, q12, narrow=0
1032993
1033− mov ip, #-16
1034− add r4, r4, ip
1035− vld1.64 {d30,d31}, [r4,:128], ip
1036− vld1.64 {d20,d21}, [r4,:128], ip
1037− vld1.64 {d18,d19}, [r4,:128], ip
1038− vld1.64 {d16,d17}, [r4,:128], ip
1039− vld1.64 {d14,d15}, [r4,:128], ip
1040− vld1.64 {d12,d13}, [r4,:128], ip
1041− vld1.64 {d10,d11}, [r4,:128], ip
1042− vld1.64 {d8, d9}, [r4,:128], ip
1043− vld1.64 {d6, d7}, [r4,:128], ip
1044− vld1.64 {d4, d5}, [r4,:128], ip
1045− vld1.64 {d2, d3}, [r4,:128], ip
1046− vld1.64 {d0, d1}, [r4,:128]
994+ mov r12, #-16
995+ add r4, r4, r12
996+ vld1.8 {d30,d31}, [r4,:128], r12
997+ vld1.8 {d20,d21}, [r4,:128], r12
998+ vld1.8 {d18,d19}, [r4,:128], r12
999+ vld1.8 {d16,d17}, [r4,:128], r12
1000+ vld1.8 {d14,d15}, [r4,:128], r12
1001+ vld1.8 {d12,d13}, [r4,:128], r12
1002+ vld1.8 {d10,d11}, [r4,:128], r12
1003+ vld1.8 {d8, d9}, [r4,:128], r12
1004+ vld1.8 {d6, d7}, [r4,:128], r12
1005+ vld1.8 {d4, d5}, [r4,:128], r12
1006+ vld1.8 {d2, d3}, [r4,:128], r12
1007+ vld1.8 {d0, d1}, [r4,:128]
10471008
10481009 swap4 d1, d3, d5, d7, d8, d10, d12, d14
10491010 transpose16_4x4 q0, q1, q2, q3, q4, q5, q6, q7
@@ -1051,31 +1012,31 @@ function put_h264_qpel8_hv_lowpass_neon_top · 1 unmodified line
10511012 swap4 d17, d19, d21, d31, d24, d26, d28, d22
10521013 transpose16_4x4 q8, q9, q10, q15, q12, q13, q14, q11
10531014
1054− vst1.64 {d30,d31}, [r4,:128]!
1055− vst1.64 {d6, d7}, [r4,:128]!
1056− vst1.64 {d20,d21}, [r4,:128]!
1057− vst1.64 {d4, d5}, [r4,:128]!
1058− vst1.64 {d18,d19}, [r4,:128]!
1059− vst1.64 {d2, d3}, [r4,:128]!
1060− vst1.64 {d16,d17}, [r4,:128]!
1061− vst1.64 {d0, d1}, [r4,:128]
1015+ vst1.8 {d30,d31}, [r4,:128]!
1016+ vst1.8 {d6, d7}, [r4,:128]!
1017+ vst1.8 {d20,d21}, [r4,:128]!
1018+ vst1.8 {d4, d5}, [r4,:128]!
1019+ vst1.8 {d18,d19}, [r4,:128]!
1020+ vst1.8 {d2, d3}, [r4,:128]!
1021+ vst1.8 {d16,d17}, [r4,:128]!
1022+ vst1.8 {d0, d1}, [r4,:128]
10621023
10631024 lowpass_8.16 q4, q12, d8, d9, d24, d25, d8
10641025 lowpass_8.16 q5, q13, d10, d11, d26, d27, d9
10651026 lowpass_8.16 q6, q14, d12, d13, d28, d29, d10
10661027 lowpass_8.16 q7, q11, d14, d15, d22, d23, d11
10671028
1068− vld1.64 {d16,d17}, [r4,:128], ip
1069− vld1.64 {d30,d31}, [r4,:128], ip
1029+ vld1.8 {d16,d17}, [r4,:128], r12
1030+ vld1.8 {d30,d31}, [r4,:128], r12
10701031 lowpass_8.16 q8, q15, d16, d17, d30, d31, d12
1071− vld1.64 {d16,d17}, [r4,:128], ip
1072− vld1.64 {d30,d31}, [r4,:128], ip
1032+ vld1.8 {d16,d17}, [r4,:128], r12
1033+ vld1.8 {d30,d31}, [r4,:128], r12
10731034 lowpass_8.16 q8, q15, d16, d17, d30, d31, d13
1074− vld1.64 {d16,d17}, [r4,:128], ip
1075− vld1.64 {d30,d31}, [r4,:128], ip
1035+ vld1.8 {d16,d17}, [r4,:128], r12
1036+ vld1.8 {d30,d31}, [r4,:128], r12
10761037 lowpass_8.16 q8, q15, d16, d17, d30, d31, d14
1077− vld1.64 {d16,d17}, [r4,:128], ip
1078− vld1.64 {d30,d31}, [r4,:128]
1038+ vld1.8 {d16,d17}, [r4,:128], r12
1039+ vld1.8 {d30,d31}, [r4,:128]
10791040 lowpass_8.16 q8, q15, d16, d17, d30, d31, d15
10801041
10811042 transpose_8x8 d12, d13, d14, d15, d8, d9, d10, d11
@@ -1083,11 +1044,11 @@ function put_h264_qpel8_hv_lowpass_neon_top · 1 unmodified line
10831044 bx lr
10841045 endfunc
10851046
1086− .macro h264_qpel8_hv_lowpass type
1047+.macro h264_qpel8_hv_lowpass type
10871048 function \type\()_h264_qpel8_hv_lowpass_neon
10881049 mov r10, lr
10891050 bl put_h264_qpel8_hv_lowpass_neon_top
1090−.ifc \type,avg
1051+ .ifc \type,avg
10911052 vld1.8 {d0}, [r0,:64], r2
10921053 vrhadd.u8 d12, d12, d0
10931054 vld1.8 {d1}, [r0,:64], r2
@@ -1105,39 +1066,39 @@ function \type\()_h264_qpel8_hv_lowpass_neon · 11 unmodified lines
11051066 vld1.8 {d7}, [r0,:64], r2
11061067 vrhadd.u8 d11, d11, d7
11071068 sub r0, r0, r2, lsl #3
1108−.endif
1069+ .endif
11091070
1110− vst1.64 {d12}, [r0,:64], r2
1111− vst1.64 {d13}, [r0,:64], r2
1112− vst1.64 {d14}, [r0,:64], r2
1113− vst1.64 {d15}, [r0,:64], r2
1114− vst1.64 {d8}, [r0,:64], r2
1115− vst1.64 {d9}, [r0,:64], r2
1116− vst1.64 {d10}, [r0,:64], r2
1117− vst1.64 {d11}, [r0,:64], r2
1071+ vst1.8 {d12}, [r0,:64], r2
1072+ vst1.8 {d13}, [r0,:64], r2
1073+ vst1.8 {d14}, [r0,:64], r2
1074+ vst1.8 {d15}, [r0,:64], r2
1075+ vst1.8 {d8}, [r0,:64], r2
1076+ vst1.8 {d9}, [r0,:64], r2
1077+ vst1.8 {d10}, [r0,:64], r2
1078+ vst1.8 {d11}, [r0,:64], r2
11181079
11191080 mov lr, r10
11201081 bx lr
11211082 endfunc
1122− .endm
1083+.endm
11231084
11241085 h264_qpel8_hv_lowpass put
11251086 h264_qpel8_hv_lowpass avg
11261087
1127− .macro h264_qpel8_hv_lowpass_l2 type
1088+.macro h264_qpel8_hv_lowpass_l2 type
11281089 function \type\()_h264_qpel8_hv_lowpass_l2_neon
11291090 mov r10, lr
11301091 bl put_h264_qpel8_hv_lowpass_neon_top
11311092
1132− vld1.64 {d0, d1}, [r2,:128]!
1133− vld1.64 {d2, d3}, [r2,:128]!
1093+ vld1.8 {d0, d1}, [r2,:128]!
1094+ vld1.8 {d2, d3}, [r2,:128]!
11341095 vrhadd.u8 q0, q0, q6
1135− vld1.64 {d4, d5}, [r2,:128]!
1096+ vld1.8 {d4, d5}, [r2,:128]!
11361097 vrhadd.u8 q1, q1, q7
1137− vld1.64 {d6, d7}, [r2,:128]!
1098+ vld1.8 {d6, d7}, [r2,:128]!
11381099 vrhadd.u8 q2, q2, q4
11391100 vrhadd.u8 q3, q3, q5
1140−.ifc \type,avg
1101+ .ifc \type,avg
11411102 vld1.8 {d16}, [r0,:64], r3
11421103 vrhadd.u8 d0, d0, d16
11431104 vld1.8 {d17}, [r0,:64], r3
@@ -1155,25 +1116,25 @@ function \type\()_h264_qpel8_hv_lowpass_l2_neon · 11 unmodified lines
11551116 vld1.8 {d23}, [r0,:64], r3
11561117 vrhadd.u8 d7, d7, d23
11571118 sub r0, r0, r3, lsl #3
1158−.endif
1159− vst1.64 {d0}, [r0,:64], r3
1160− vst1.64 {d1}, [r0,:64], r3
1161− vst1.64 {d2}, [r0,:64], r3
1162− vst1.64 {d3}, [r0,:64], r3
1163− vst1.64 {d4}, [r0,:64], r3
1164− vst1.64 {d5}, [r0,:64], r3
1165− vst1.64 {d6}, [r0,:64], r3
1166− vst1.64 {d7}, [r0,:64], r3
1119+ .endif
1120+ vst1.8 {d0}, [r0,:64], r3
1121+ vst1.8 {d1}, [r0,:64], r3
1122+ vst1.8 {d2}, [r0,:64], r3
1123+ vst1.8 {d3}, [r0,:64], r3
1124+ vst1.8 {d4}, [r0,:64], r3
1125+ vst1.8 {d5}, [r0,:64], r3
1126+ vst1.8 {d6}, [r0,:64], r3
1127+ vst1.8 {d7}, [r0,:64], r3
11671128
11681129 mov lr, r10
11691130 bx lr
11701131 endfunc
1171− .endm
1132+.endm
11721133
11731134 h264_qpel8_hv_lowpass_l2 put
11741135 h264_qpel8_hv_lowpass_l2 avg
11751136
1176− .macro h264_qpel16_hv type
1137+.macro h264_qpel16_hv type
11771138 function \type\()_h264_qpel16_hv_lowpass_neon
11781139 mov r9, lr
11791140 bl \type\()_h264_qpel8_hv_lowpass_neon
@@ -1206,17 +1167,17 @@ function \type\()_h264_qpel16_hv_lowpass_l2_neon · 26 unmodified lines
12061167 mov lr, r9
12071168 b \type\()_h264_qpel8_hv_lowpass_l2_neon
12081169 endfunc
1209− .endm
1170+.endm
12101171
12111172 h264_qpel16_hv put
12121173 h264_qpel16_hv avg
12131174
1214− .macro h264_qpel8 type
1175+.macro h264_qpel8 type
12151176 function ff_\type\()_h264_qpel8_mc10_neon, export=1
12161177 lowpass_const r3
12171178 mov r3, r1
12181179 sub r1, r1, #2
1219− mov ip, #8
1180+ mov r12, #8
12201181 b \type\()_h264_qpel8_h_lowpass_l2_neon
12211182 endfunc
12221183
@@ -1224,7 +1185,7 @@ function ff_\type\()_h264_qpel8_mc20_neon, export=1 · 1 unmodified line
12241185 lowpass_const r3
12251186 sub r1, r1, #2
12261187 mov r3, r2
1227− mov ip, #8
1188+ mov r12, #8
12281189 b \type\()_h264_qpel8_h_lowpass_neon
12291190 endfunc
12301191
@@ -1232,13 +1193,13 @@ function ff_\type\()_h264_qpel8_mc30_neon, export=1 · 1 unmodified line
12321193 lowpass_const r3
12331194 add r3, r1, #1
12341195 sub r1, r1, #2
1235− mov ip, #8
1196+ mov r12, #8
12361197 b \type\()_h264_qpel8_h_lowpass_l2_neon
12371198 endfunc
12381199
12391200 function ff_\type\()_h264_qpel8_mc01_neon, export=1
12401201 push {lr}
1241− mov ip, r1
1202+ mov r12, r1
12421203 \type\()_h264_qpel8_mc01:
12431204 lowpass_const r3
12441205 mov r3, r2
@@ -1261,12 +1222,12 @@ T mov sp, r0 · 16 unmodified lines
12611222 mov r0, sp
12621223 sub r1, r1, #2
12631224 mov r3, #8
1264− mov ip, #8
1225+ mov r12, #8
12651226 vpush {d8-d15}
12661227 bl put_h264_qpel8_h_lowpass_neon
12671228 ldrd r0, [r11], #8
12681229 mov r3, r2
1269− add ip, sp, #64
1230+ add r12, sp, #64
12701231 sub r1, r1, r2, lsl #1
12711232 mov r2, #8
12721233 bl \type\()_h264_qpel8_v_lowpass_l2_neon
@@ -1287,7 +1248,7 @@ T mov sp, r0 · 14 unmodified lines
12871248 sub r1, r1, #2
12881249 mov r3, #8
12891250 mov r0, sp
1290− mov ip, #8
1251+ mov r12, #8
12911252 vpush {d8-d15}
12921253 bl put_h264_qpel8_h_lowpass_neon
12931254 mov r4, r0
@@ -1372,7 +1333,7 @@ endfunc · 78 unmodified lines
13721333
13731334 function ff_\type\()_h264_qpel8_mc03_neon, export=1
13741335 push {lr}
1375− add ip, r1, r2
1336+ add r12, r1, r2
13761337 b \type\()_h264_qpel8_mc01
13771338 endfunc
13781339
@@ -1395,12 +1356,12 @@ function ff_\type\()_h264_qpel8_mc33_neon, export=1 · 16 unmodified lines
13951356 sub r1, r1, #1
13961357 b \type\()_h264_qpel8_mc11
13971358 endfunc
1398− .endm
1359+.endm
13991360
14001361 h264_qpel8 put
14011362 h264_qpel8 avg
14021363
1403− .macro h264_qpel16 type
1364+.macro h264_qpel16 type
14041365 function ff_\type\()_h264_qpel16_mc10_neon, export=1
14051366 lowpass_const r3
14061367 mov r3, r1
@@ -1424,7 +1385,7 @@ endfunc · 17 unmodified lines
14241385
14251386 function ff_\type\()_h264_qpel16_mc01_neon, export=1
14261387 push {r4, lr}
1427− mov ip, r1
1388+ mov r12, r1
14281389 \type\()_h264_qpel16_mc01:
14291390 lowpass_const r3
14301391 mov r3, r2
@@ -1451,7 +1412,7 @@ T mov sp, r0 · 20 unmodified lines
14511412 bl put_h264_qpel16_h_lowpass_neon
14521413 ldrd r0, [r11], #8
14531414 mov r3, r2
1454− add ip, sp, #64
1415+ add r12, sp, #64
14551416 sub r1, r1, r2, lsl #1
14561417 mov r2, #16
14571418 bl \type\()_h264_qpel16_v_lowpass_l2_neon
@@ -1554,7 +1515,7 @@ endfunc · 96 unmodified lines
15541515
15551516 function ff_\type\()_h264_qpel16_mc03_neon, export=1
15561517 push {r4, lr}
1557− add ip, r1, r2
1518+ add r12, r1, r2
15581519 b \type\()_h264_qpel16_mc01
15591520 endfunc
15601521
@@ -1577,14 +1538,14 @@ function ff_\type\()_h264_qpel16_mc33_neon, export=1 · 16 unmodified lines
15771538 sub r1, r1, #1
15781539 b \type\()_h264_qpel16_mc11
15791540 endfunc
1580− .endm
1541+.endm
15811542
15821543 h264_qpel16 put
15831544 h264_qpel16 avg
15841545
15851546 @ Biweighted prediction
15861547
1587− .macro biweight_16 macs, macd
1548+.macro biweight_16 macs, macd
15881549 vdup.8 d0, r4
15891550 vdup.8 d1, r5
15901551 vmov q2, q8
@@ -1622,9 +1583,9 @@ endfunc · 31 unmodified lines
16221583 vst1.8 {d24-d25},[r6,:128], r2
16231584 bne 1b
16241585 pop {r4-r6, pc}
1625− .endm
1586+.endm
16261587
1627− .macro biweight_8 macs, macd
1588+.macro biweight_8 macs, macd
16281589 vdup.8 d0, r4
16291590 vdup.8 d1, r5
16301591 vmov q1, q8
@@ -1652,9 +1613,9 @@ endfunc · 21 unmodified lines
16521613 vst1.8 {d4},[r6,:64], r2
16531614 bne 1b
16541615 pop {r4-r6, pc}
1655− .endm
1616+.endm
16561617
1657− .macro biweight_4 macs, macd
1618+.macro biweight_4 macs, macd
16581619 vdup.8 d0, r4
16591620 vdup.8 d1, r5
16601621 vmov q1, q8
@@ -1694,9 +1655,9 @@ endfunc · 33 unmodified lines
16941655 vst1.32 {d2[0]},[r6,:32], r2
16951656 vst1.32 {d2[1]},[r6,:32], r2
16961657 pop {r4-r6, pc}
1697− .endm
1658+.endm
16981659
1699− .macro biweight_func w
1660+.macro biweight_func w
17001661 function ff_biweight_h264_pixels_\w\()_neon, export=1
17011662 push {r4-r6, lr}
17021663 ldr r12, [sp, #16]
@@ -1726,7 +1687,7 @@ function ff_biweight_h264_pixels_\w\()_neon, export=1 · 23 unmodified lines
17261687 40: rsb r5, r5, #0
17271688 biweight_\w vmlsl.u8, vmlal.u8
17281689 endfunc
1729− .endm
1690+.endm
17301691
17311692 biweight_func 16
17321693 biweight_func 8
@@ -1734,7 +1695,7 @@ endfunc · 1 unmodified line
17341695
17351696 @ Weighted prediction
17361697
1737− .macro weight_16 add
1698+.macro weight_16 add
17381699 vdup.8 d0, r12
17391700 1: subs r2, r2, #2
17401701 vld1.8 {d20-d21},[r0,:128], r1
@@ -1761,9 +1722,9 @@ endfunc · 20 unmodified lines
17611722 vst1.8 {d24-d25},[r4,:128], r1
17621723 bne 1b
17631724 pop {r4, pc}
1764− .endm
1725+.endm
17651726
1766− .macro weight_8 add
1727+.macro weight_8 add
17671728 vdup.8 d0, r12
17681729 1: subs r2, r2, #2
17691730 vld1.8 {d4},[r0,:64], r1
@@ -1782,9 +1743,9 @@ endfunc · 12 unmodified lines
17821743 vst1.8 {d4},[r4,:64], r1
17831744 bne 1b
17841745 pop {r4, pc}
1785− .endm
1746+.endm
17861747
1787− .macro weight_4 add
1748+.macro weight_4 add
17881749 vdup.8 d0, r12
17891750 vmov q1, q8
17901751 vmov q10, q8
@@ -1818,9 +1779,9 @@ endfunc · 27 unmodified lines
18181779 vst1.32 {d2[0]},[r4,:32], r1
18191780 vst1.32 {d2[1]},[r4,:32], r1
18201781 pop {r4, pc}
1821− .endm
1782+.endm
18221783
1823− .macro weight_func w
1784+.macro weight_func w
18241785 function ff_weight_h264_pixels_\w\()_neon, export=1
18251786 push {r4, lr}
18261787 ldr r12, [sp, #8]
@@ -1845,7 +1806,7 @@ function ff_weight_h264_pixels_\w\()_neon, export=1 · 18 unmodified lines
18451806 10: rsb r12, r12, #0
18461807 weight_\w vsub.s16
18471808 endfunc
1848− .endm
1809+.endm
18491810
18501811 weight_func 16
18511812 weight_func 8
libavcodec/arm/neon.S+59−0
@@ -0,0 +1,59 @@
1+/*
2+ * Copyright (c) 2008 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+.macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7
22+ vtrn.32 \r0, \r4
23+ vtrn.32 \r1, \r5
24+ vtrn.32 \r2, \r6
25+ vtrn.32 \r3, \r7
26+ vtrn.16 \r0, \r2
27+ vtrn.16 \r1, \r3
28+ vtrn.16 \r4, \r6
29+ vtrn.16 \r5, \r7
30+ vtrn.8 \r0, \r1
31+ vtrn.8 \r2, \r3
32+ vtrn.8 \r4, \r5
33+ vtrn.8 \r6, \r7
34+.endm
35+
36+.macro transpose_4x4 r0, r1, r2, r3
37+ vtrn.16 \r0, \r2
38+ vtrn.16 \r1, \r3
39+ vtrn.8 \r0, \r1
40+ vtrn.8 \r2, \r3
41+.endm
42+
43+.macro swap4 r0, r1, r2, r3, r4, r5, r6, r7
44+ vswp \r0, \r4
45+ vswp \r1, \r5
46+ vswp \r2, \r6
47+ vswp \r3, \r7
48+.endm
49+
50+.macro transpose16_4x4 r0, r1, r2, r3, r4, r5, r6, r7
51+ vtrn.32 \r0, \r2
52+ vtrn.32 \r1, \r3
53+ vtrn.32 \r4, \r6
54+ vtrn.32 \r5, \r7
55+ vtrn.16 \r0, \r1
56+ vtrn.16 \r2, \r3
57+ vtrn.16 \r4, \r5
58+ vtrn.16 \r6, \r7
59+.endm
libavcodec/arm/vp8dsp_neon.S+5−21
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 */
2323
2424 #include "asm.S"
25+#include "neon.S"
2526
2627 function ff_vp8_luma_dc_wht_neon, export=1
2728 vld1.16 {q0-q1}, [r1,:128]
@@ -442,23 +443,6 @@ endfunc · 414 unmodified lines
442443 .endif
443444 .endm
444445
445−.macro transpose8x16matrix
446− vtrn.32 q0, q4
447− vtrn.32 q1, q5
448− vtrn.32 q2, q6
449− vtrn.32 q3, q7
450−
451− vtrn.16 q0, q2
452− vtrn.16 q1, q3
453− vtrn.16 q4, q6
454− vtrn.16 q5, q7
455−
456− vtrn.8 q0, q1
457− vtrn.8 q2, q3
458− vtrn.8 q4, q5
459− vtrn.8 q6, q7
460−.endm
461−
462446 .macro vp8_v_loop_filter16 name, inner=0, simple=0
463447 function ff_vp8_v_loop_filter16\name\()_neon, export=1
464448 vpush {q4-q7}
@@ -593,7 +577,7 @@ function ff_vp8_h_loop_filter16\name\()_neon, export=1 · 128 unmodified lines
593577 vld1.8 {d13}, [r0], r1
594578 vld1.8 {d15}, [r0], r1
595579
596− transpose8x16matrix
580+ transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7
597581
598582 vdup.8 q14, r2 @ flim_E
599583 .if !\simple
@@ -604,7 +588,7 @@ function ff_vp8_h_loop_filter16\name\()_neon, export=1 · 4 unmodified lines
604588
605589 sub r0, r0, r1, lsl #4 @ backup 16 rows
606590
607− transpose8x16matrix
591+ transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7
608592
609593 @ Store pixels:
610594 vst1.8 {d0}, [r0], r1
@@ -658,7 +642,7 @@ function ff_vp8_h_loop_filter8uv\name\()_neon, export=1 · 47 unmodified lines
658642 vld1.8 {d14}, [r0], r2
659643 vld1.8 {d15}, [r1], r2
660644
661− transpose8x16matrix
645+ transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7
662646
663647 vdup.8 q14, r3 @ flim_E
664648 vdup.8 q15, r12 @ flim_I
@@ -669,7 +653,7 @@ function ff_vp8_h_loop_filter8uv\name\()_neon, export=1 · 4 unmodified lines
669653 sub r0, r0, r2, lsl #3 @ backup u 8 rows
670654 sub r1, r1, r2, lsl #3 @ backup v 8 rows
671655
672− transpose8x16matrix
656+ transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7
673657
674658 @ Store pixels:
675659 vst1.8 {d0}, [r0], r2
libavcodec/atrac1.c+17−9
@@ -72,6 +72,7 @@ typedef struct { · 71 unmodified lines
7272 * The atrac1 context, holds all needed parameters for decoding
7373 */
7474 typedef struct {
75+ AVFrame frame;
7576 AT1SUCtx SUs[AT1_MAX_CHANNELS]; ///< channel sound unit
7677 DECLARE_ALIGNED(32, float, spec)[AT1_SU_SAMPLES]; ///< the mdct spectrum buffer
7778
@@ -273,14 +274,14 @@ static void at1_subband_synthesis(AT1Ctx *q, AT1SUCtx* su, float *pOut) · 195 unmodified lines
273274
274275
275276 static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
276− int *data_size, AVPacket *avpkt)
277+ int *got_frame_ptr, AVPacket *avpkt)
277278 {
278279 const uint8_t *buf = avpkt->data;
279280 int buf_size = avpkt->size;
280281 AT1Ctx *q = avctx->priv_data;
281− int ch, ret, out_size;
282+ int ch, ret;
282283 GetBitContext gb;
283− float* samples = data;
284+ float *samples;
284285
285286
286287 if (buf_size < 212 * q->channels) {
@@ -288,12 +289,13 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data, · 1 unmodified line
288289 return AVERROR_INVALIDDATA;
289290 }
290291
291− out_size = q->channels * AT1_SU_SAMPLES *
292− av_get_bytes_per_sample(avctx->sample_fmt);
293− if (*data_size < out_size) {
294− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
295− return AVERROR(EINVAL);
292+ /* get output buffer */
293+ q->frame.nb_samples = AT1_SU_SAMPLES;
294+ if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
295+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
296+ return ret;
296297 }
298+ samples = (float *)q->frame.data[0];
297299
298300 for (ch = 0; ch < q->channels; ch++) {
299301 AT1SUCtx* su = &q->SUs[ch];
@@ -321,7 +323,9 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data, · 21 unmodified lines
321323 AT1_SU_SAMPLES, 2);
322324 }
323325
324− *data_size = out_size;
326+ *got_frame_ptr = 1;
327+ *(AVFrame *)data = q->frame;
328+
325329 return avctx->block_align;
326330 }
327331
@@ -389,6 +393,9 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) · 61 unmodified lines
389393 q->SUs[1].spectrum[0] = q->SUs[1].spec1;
390394 q->SUs[1].spectrum[1] = q->SUs[1].spec2;
391395
396+ avcodec_get_frame_defaults(&q->frame);
397+ avctx->coded_frame = &q->frame;
398+
392399 return 0;
393400 }
394401
@@ -401,5 +408,6 @@ AVCodec ff_atrac1_decoder = { · 6 unmodified lines
401408 .init = atrac1_decode_init,
402409 .close = atrac1_decode_end,
403410 .decode = atrac1_decode_frame,
411+ .capabilities = CODEC_CAP_DR1,
404412 .long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Coding)"),
405413 };
libavcodec/atrac3.c+21−13
@@ -86,6 +86,7 @@ typedef struct { · 85 unmodified lines
8686 } channel_unit;
8787
8888 typedef struct {
89+ AVFrame frame;
8990 GetBitContext gb;
9091 //@{
9192 /** stream data */
@@ -823,16 +824,16 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, · 731 unmodified lines
823824 * @param avctx pointer to the AVCodecContext
824825 */
825826
826−static int atrac3_decode_frame(AVCodecContext *avctx,
827− void *data, int *data_size,
828− AVPacket *avpkt) {
827+static int atrac3_decode_frame(AVCodecContext *avctx, void *data,
828+ int *got_frame_ptr, AVPacket *avpkt)
829+{
829830 const uint8_t *buf = avpkt->data;
830831 int buf_size = avpkt->size;
831832 ATRAC3Context *q = avctx->priv_data;
832− int result = 0, out_size;
833+ int result;
833834 const uint8_t* databuf;
834− float *samples_flt = data;
835− int16_t *samples_s16 = data;
835+ float *samples_flt;
836+ int16_t *samples_s16;
836837
837838 if (buf_size < avctx->block_align) {
838839 av_log(avctx, AV_LOG_ERROR,
@@ -840,12 +841,14 @@ static int atrac3_decode_frame(AVCodecContext *avctx, · 1 unmodified line
840841 return AVERROR_INVALIDDATA;
841842 }
842843
843− out_size = SAMPLES_PER_FRAME * q->channels *
844− av_get_bytes_per_sample(avctx->sample_fmt);
845− if (*data_size < out_size) {
846− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
847− return AVERROR(EINVAL);
844+ /* get output buffer */
845+ q->frame.nb_samples = SAMPLES_PER_FRAME;
846+ if ((result = avctx->get_buffer(avctx, &q->frame)) < 0) {
847+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
848+ return result;
848849 }
850+ samples_flt = (float *)q->frame.data[0];
851+ samples_s16 = (int16_t *)q->frame.data[0];
849852
850853 /* Check if we need to descramble and what buffer to pass on. */
851854 if (q->scrambled_stream) {
@@ -875,7 +878,9 @@ static int atrac3_decode_frame(AVCodecContext *avctx, · 23 unmodified lines
875878 (const float **)q->outSamples,
876879 SAMPLES_PER_FRAME, q->channels);
877880 }
878− *data_size = out_size;
881+
882+ *got_frame_ptr = 1;
883+ *(AVFrame *)data = q->frame;
879884
880885 return avctx->block_align;
881886 }
@@ -1047,6 +1052,9 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 165 unmodified lines
10471052 }
10481053 }
10491054
1055+ avcodec_get_frame_defaults(&q->frame);
1056+ avctx->coded_frame = &q->frame;
1057+
10501058 return 0;
10511059 }
10521060
@@ -1060,6 +1068,6 @@ AVCodec ff_atrac3_decoder = · 7 unmodified lines
10601068 .init = atrac3_decode_init,
10611069 .close = atrac3_decode_close,
10621070 .decode = atrac3_decode_frame,
1063− .capabilities = CODEC_CAP_SUBFRAMES,
1071+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
10641072 .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),
10651073 };
libavcodec/avcodec.h+149−19
@@ -491,8 +491,10 @@ enum CodecID { · 490 unmodified lines
491491 #define CH_LAYOUT_STEREO_DOWNMIX AV_CH_LAYOUT_STEREO_DOWNMIX
492492 #endif
493493
494+#if FF_API_OLD_DECODE_AUDIO
494495 /* in bytes */
495496 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
497+#endif
496498
497499 /**
498500 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@@ -947,21 +949,37 @@ typedef struct AVPacket { · 448 unmodified lines
947949 * sizeof(AVFrame) must not be used outside libav*.
948950 */
949951 typedef struct AVFrame {
952+#if FF_API_DATA_POINTERS
953+#define AV_NUM_DATA_POINTERS 4
954+#else
955+#define AV_NUM_DATA_POINTERS 8
956+#endif
950957 /**
951− * pointer to the picture planes.
958+ * pointer to the picture/channel planes.
952959 * This might be different from the first allocated byte
953− * - encoding:
954− * - decoding:
960+ * - encoding: Set by user
961+ * - decoding: set by AVCodecContext.get_buffer()
962+ */
963+ uint8_t *data[AV_NUM_DATA_POINTERS];
964+
965+ /**
966+ * Size, in bytes, of the data for each picture/channel plane.
967+ *
968+ * For audio, only linesize[0] may be set. For planar audio, each channel
969+ * plane must be the same size.
970+ *
971+ * - encoding: Set by user (video only)
972+ * - decoding: set by AVCodecContext.get_buffer()
955973 */
956− uint8_t *data[4];
957− int linesize[4];
974+ int linesize[AV_NUM_DATA_POINTERS];
975+
958976 /**
959977 * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
960978 * This isn't used by libavcodec unless the default get/release_buffer() is used.
961979 * - encoding:
962980 * - decoding:
963981 */
964− uint8_t *base[4];
982+ uint8_t *base[AV_NUM_DATA_POINTERS];
965983 /**
966984 * 1 -> keyframe, 0-> not
967985 * - encoding: Set by libavcodec.
@@ -1008,7 +1026,7 @@ typedef struct AVFrame { · 40 unmodified lines
10081026 * buffer age (1->was last buffer and dint change, 2->..., ...).
10091027 * Set to INT_MAX if the buffer has not been used yet.
10101028 * - encoding: unused
1011− * - decoding: MUST be set by get_buffer().
1029+ * - decoding: MUST be set by get_buffer() for video.
10121030 */
10131031 int age;
10141032
@@ -1085,7 +1103,7 @@ typedef struct AVFrame { · 70 unmodified lines
10851103 * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
10861104 * - decoding: unused
10871105 */
1088− uint64_t error[4];
1106+ uint64_t error[AV_NUM_DATA_POINTERS];
10891107
10901108 /**
10911109 * type of the buffer (to keep track of who has to deallocate data[*])
@@ -1206,6 +1224,33 @@ typedef struct AVFrame { · 114 unmodified lines
12061224 */
12071225 void *thread_opaque;
12081226
1227+ /**
1228+ * number of audio samples (per channel) described by this frame
1229+ * - encoding: unused
1230+ * - decoding: Set by libavcodec
1231+ */
1232+ int nb_samples;
1233+
1234+ /**
1235+ * pointers to the data planes/channels.
1236+ *
1237+ * For video, this should simply point to data[].
1238+ *
1239+ * For planar audio, each channel has a separate data pointer, and
1240+ * linesize[0] contains the size of each channel buffer.
1241+ * For packed audio, there is just one data pointer, and linesize[0]
1242+ * contains the total size of the buffer for all channels.
1243+ *
1244+ * Note: Both data and extended_data will always be set by get_buffer(),
1245+ * but for planar audio with more channels that can fit in data,
1246+ * extended_data must be used by the decoder in order to access all
1247+ * channels.
1248+ *
1249+ * encoding: unused
1250+ * decoding: set by AVCodecContext.get_buffer()
1251+ */
1252+ uint8_t **extended_data;
1253+
12091254 /**
12101255 * frame timestamp estimated using various heuristics, in stream time base
12111256 * - encoding: unused
@@ -1379,7 +1424,7 @@ typedef struct AVCodecContext { · 167 unmodified lines
13791424 * @param offset offset into the AVFrame.data from which the slice should be read
13801425 */
13811426 void (*draw_horiz_band)(struct AVCodecContext *s,
1382− const AVFrame *src, int offset[4],
1427+ const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
13831428 int y, int type, int height);
13841429
13851430 /* audio only */
@@ -1602,15 +1647,56 @@ typedef struct AVCodecContext { · 216 unmodified lines
16021647
16031648 /**
16041649 * Called at the beginning of each frame to get a buffer for it.
1605− * If pic.reference is set then the frame will be read later by libavcodec.
1606− * avcodec_align_dimensions2() should be used to find the required width and
1607− * height, as they normally need to be rounded up to the next multiple of 16.
1650+ *
1651+ * The function will set AVFrame.data[], AVFrame.linesize[].
1652+ * AVFrame.extended_data[] must also be set, but it should be the same as
1653+ * AVFrame.data[] except for planar audio with more channels than can fit
1654+ * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
1655+ * many data pointers as it can hold.
1656+ *
16081657 * if CODEC_CAP_DR1 is not set then get_buffer() must call
16091658 * avcodec_default_get_buffer() instead of providing buffers allocated by
16101659 * some other means.
1660+ *
1661+ * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
1662+ * need it. avcodec_default_get_buffer() aligns the output buffer properly,
1663+ * but if get_buffer() is overridden then alignment considerations should
1664+ * be taken into account.
1665+ *
1666+ * @see avcodec_default_get_buffer()
1667+ *
1668+ * Video:
1669+ *
1670+ * If pic.reference is set then the frame will be read later by libavcodec.
1671+ * avcodec_align_dimensions2() should be used to find the required width and
1672+ * height, as they normally need to be rounded up to the next multiple of 16.
1673+ *
16111674 * If frame multithreading is used and thread_safe_callbacks is set,
1612− * it may be called from a different thread, but not from more than one at once.
1613− * Does not need to be reentrant.
1675+ * it may be called from a different thread, but not from more than one at
1676+ * once. Does not need to be reentrant.
1677+ *
1678+ * @see release_buffer(), reget_buffer()
1679+ * @see avcodec_align_dimensions2()
1680+ *
1681+ * Audio:
1682+ *
1683+ * Decoders request a buffer of a particular size by setting
1684+ * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
1685+ * however, utilize only part of the buffer by setting AVFrame.nb_samples
1686+ * to a smaller value in the output frame.
1687+ *
1688+ * Decoders cannot use the buffer after returning from
1689+ * avcodec_decode_audio4(), so they will not call release_buffer(), as it
1690+ * is assumed to be released immediately upon return.
1691+ *
1692+ * As a convenience, av_samples_get_buffer_size() and
1693+ * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
1694+ * functions to find the required data size and to fill data pointers and
1695+ * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
1696+ * since all planes must be the same size.
1697+ *
1698+ * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
1699+ *
16141700 * - encoding: unused
16151701 * - decoding: Set by libavcodec, user can override.
16161702 */
@@ -1929,7 +2015,7 @@ typedef struct AVCodecContext { · 312 unmodified lines
19292015 * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
19302016 * - decoding: unused
19312017 */
1932− uint64_t error[4];
2018+ uint64_t error[AV_NUM_DATA_POINTERS];
19332019
19342020 /**
19352021 * motion estimation comparison function
@@ -3253,8 +3339,8 @@ typedef struct AVHWAccel { · 1317 unmodified lines
32533339 * the last component is alpha
32543340 */
32553341 typedef struct AVPicture {
3256− uint8_t *data[4];
3257− int linesize[4]; ///< number of bytes per line
3342+ uint8_t *data[AV_NUM_DATA_POINTERS];
3343+ int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
32583344 } AVPicture;
32593345
32603346 #define AVPALETTE_SIZE 1024
@@ -3922,7 +4008,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); · 661 unmodified lines
39224008 * according to avcodec_get_edge_width() before.
39234009 */
39244010 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
3925− int linesize_align[4]);
4011+ int linesize_align[AV_NUM_DATA_POINTERS]);
39264012
39274013 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
39284014
@@ -4005,7 +4091,12 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec); · 76 unmodified lines
40054091 */
40064092 int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options);
40074093
4094+#if FF_API_OLD_DECODE_AUDIO
40084095 /**
4096+ * Wrapper function which calls avcodec_decode_audio4.
4097+ *
4098+ * @deprecated Use avcodec_decode_audio4 instead.
4099+ *
40094100 * Decode the audio frame of size avpkt->size from avpkt->data into samples.
40104101 * Some decoders may support multiple frames in a single AVPacket, such
40114102 * decoders would then just decode the first frame. In this case,
@@ -4040,6 +4131,8 @@ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) · 28 unmodified lines
40404131 *
40414132 * @param avctx the codec context
40424133 * @param[out] samples the output buffer, sample type in avctx->sample_fmt
4134+ * If the sample format is planar, each channel plane will
4135+ * be the same size, with no padding between channels.
40434136 * @param[in,out] frame_size_ptr the output buffer size in bytes
40444137 * @param[in] avpkt The input AVPacket containing the input buffer.
40454138 * You can create such packet with av_init_packet() and by then setting
@@ -4048,9 +4141,46 @@ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) · 2 unmodified lines
40484141 * @return On error a negative value is returned, otherwise the number of bytes
40494142 * used or zero if no frame data was decompressed (used) from the input AVPacket.
40504143 */
4051−int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
4144+attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
40524145 int *frame_size_ptr,
40534146 AVPacket *avpkt);
4147+#endif
4148+
4149+/**
4150+ * Decode the audio frame of size avpkt->size from avpkt->data into frame.
4151+ *
4152+ * Some decoders may support multiple frames in a single AVPacket. Such
4153+ * decoders would then just decode the first frame. In this case,
4154+ * avcodec_decode_audio4 has to be called again with an AVPacket containing
4155+ * the remaining data in order to decode the second frame, etc...
4156+ * Even if no frames are returned, the packet needs to be fed to the decoder
4157+ * with remaining data until it is completely consumed or an error occurs.
4158+ *
4159+ * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
4160+ * larger than the actual read bytes because some optimized bitstream
4161+ * readers read 32 or 64 bits at once and could read over the end.
4162+ *
4163+ * @note You might have to align the input buffer. The alignment requirements
4164+ * depend on the CPU and the decoder.
4165+ *
4166+ * @param avctx the codec context
4167+ * @param[out] frame The AVFrame in which to store decoded audio samples.
4168+ * Decoders request a buffer of a particular size by setting
4169+ * AVFrame.nb_samples prior to calling get_buffer(). The
4170+ * decoder may, however, only utilize part of the buffer by
4171+ * setting AVFrame.nb_samples to a smaller value in the
4172+ * output frame.
4173+ * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
4174+ * non-zero.
4175+ * @param[in] avpkt The input AVPacket containing the input buffer.
4176+ * At least avpkt->data and avpkt->size should be set. Some
4177+ * decoders might also require additional fields to be set.
4178+ * @return A negative error code is returned if an error occurred during
4179+ * decoding, otherwise the number of bytes consumed from the input
4180+ * AVPacket is returned.
4181+ */
4182+int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
4183+ int *got_frame_ptr, AVPacket *avpkt);
40544184
40554185 /**
40564186 * Decode the video frame of size avpkt->size from avpkt->data into picture.
libavcodec/binkaudio.c+21−13
@@ -45,6 +45,7 @@ static float quant_table[96]; · 44 unmodified lines
4545 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
4646
4747 typedef struct {
48+ AVFrame frame;
4849 GetBitContext gb;
4950 DSPContext dsp;
5051 FmtConvertContext fmt_conv;
@@ -147,6 +148,9 @@ static av_cold int decode_init(AVCodecContext *avctx) · 96 unmodified lines
147148 else
148149 return -1;
149150
151+ avcodec_get_frame_defaults(&s->frame);
152+ avctx->coded_frame = &s->frame;
153+
150154 return 0;
151155 }
152156
@@ -293,6 +297,7 @@ static av_cold int decode_end(AVCodecContext *avctx) · 140 unmodified lines
293297 ff_rdft_end(&s->trans.rdft);
294298 else if (CONFIG_BINKAUDIO_DCT_DECODER)
295299 ff_dct_end(&s->trans.dct);
300+
296301 return 0;
297302 }
298303
@@ -302,20 +307,19 @@ static void get_bits_align32(GetBitContext *s) · 3 unmodified lines
302307 if (n) skip_bits(s, n);
303308 }
304309
305−static int decode_frame(AVCodecContext *avctx,
306− void *data, int *data_size,
307− AVPacket *avpkt)
310+static int decode_frame(AVCodecContext *avctx, void *data,
311+ int *got_frame_ptr, AVPacket *avpkt)
308312 {
309313 BinkAudioContext *s = avctx->priv_data;
310− int16_t *samples = data;
314+ int16_t *samples;
311315 GetBitContext *gb = &s->gb;
312− int out_size, consumed = 0;
316+ int ret, consumed = 0;
313317
314318 if (!get_bits_left(gb)) {
315319 uint8_t *buf;
316320 /* handle end-of-stream */
317321 if (!avpkt->size) {
318− *data_size = 0;
322+ *got_frame_ptr = 0;
319323 return 0;
320324 }
321325 if (avpkt->size < 4) {
@@ -334,11 +338,13 @@ static int decode_frame(AVCodecContext *avctx, · 12 unmodified lines
334338 skip_bits_long(gb, 32);
335339 }
336340
337− out_size = s->block_size * av_get_bytes_per_sample(avctx->sample_fmt);
338− if (*data_size < out_size) {
339− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
340− return AVERROR(EINVAL);
341+ /* get output buffer */
342+ s->frame.nb_samples = s->block_size / avctx->channels;
343+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
344+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
345+ return ret;
341346 }
347+ samples = (int16_t *)s->frame.data[0];
342348
343349 if (decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT)) {
344350 av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n");
@@ -346,7 +352,9 @@ static int decode_frame(AVCodecContext *avctx, · 1 unmodified line
346352 }
347353 get_bits_align32(gb);
348354
349− *data_size = out_size;
355+ *got_frame_ptr = 1;
356+ *(AVFrame *)data = s->frame;
357+
350358 return consumed;
351359 }
352360
@@ -358,7 +366,7 @@ AVCodec ff_binkaudio_rdft_decoder = { · 5 unmodified lines
358366 .init = decode_init,
359367 .close = decode_end,
360368 .decode = decode_frame,
361− .capabilities = CODEC_CAP_DELAY,
369+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
362370 .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)")
363371 };
364372
@@ -370,6 +378,6 @@ AVCodec ff_binkaudio_dct_decoder = { · 5 unmodified lines
370378 .init = decode_init,
371379 .close = decode_end,
372380 .decode = decode_frame,
373− .capabilities = CODEC_CAP_DELAY,
381+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
374382 .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)")
375383 };
libavcodec/cook.c+30−13
@@ -122,6 +122,7 @@ typedef struct cook { · 121 unmodified lines
122122 void (* saturate_output) (struct cook *q, int chan, float *out);
123123
124124 AVCodecContext* avctx;
125+ AVFrame frame;
125126 GetBitContext gb;
126127 /* stream data */
127128 int nb_channels;
@@ -131,6 +132,7 @@ typedef struct cook { · 3 unmodified lines
131132 int samples_per_channel;
132133 /* states */
133134 AVLFG random_state;
135+ int discarded_packets;
134136
135137 /* transform data */
136138 FFTContext mdct_ctx;
@@ -896,7 +898,8 @@ mlt_compensate_output(COOKContext *q, float *decode_buffer, · 759 unmodified lines
896898 float *out, int chan)
897899 {
898900 imlt_gain(q, decode_buffer, gains_ptr, previous_buffer);
899− q->saturate_output (q, chan, out);
901+ if (out)
902+ q->saturate_output(q, chan, out);
900903 }
901904
902905
@@ -953,24 +956,28 @@ static void decode_subpacket(COOKContext *q, COOKSubpacket *p, · 50 unmodified lines
953956 * @param avctx pointer to the AVCodecContext
954957 */
955958
956−static int cook_decode_frame(AVCodecContext *avctx,
957− void *data, int *data_size,
958− AVPacket *avpkt) {
959+static int cook_decode_frame(AVCodecContext *avctx, void *data,
960+ int *got_frame_ptr, AVPacket *avpkt)
961+{
959962 const uint8_t *buf = avpkt->data;
960963 int buf_size = avpkt->size;
961964 COOKContext *q = avctx->priv_data;
962− int i, out_size;
965+ float *samples = NULL;
966+ int i, ret;
963967 int offset = 0;
964968 int chidx = 0;
965969
966970 if (buf_size < avctx->block_align)
967971 return buf_size;
968972
969− out_size = q->nb_channels * q->samples_per_channel *
970− av_get_bytes_per_sample(avctx->sample_fmt);
971− if (*data_size < out_size) {
972− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
973− return AVERROR(EINVAL);
973+ /* get output buffer */
974+ if (q->discarded_packets >= 2) {
975+ q->frame.nb_samples = q->samples_per_channel;
976+ if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
977+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
978+ return ret;
979+ }
980+ samples = (float *)q->frame.data[0];
974981 }
975982
976983 /* estimate subpacket sizes */
@@ -990,15 +997,21 @@ static int cook_decode_frame(AVCodecContext *avctx, · 13 unmodified lines
990997 q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv;
991998 q->subpacket[i].ch_idx = chidx;
992999 av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align);
993− decode_subpacket(q, &q->subpacket[i], buf + offset, data);
1000+ decode_subpacket(q, &q->subpacket[i], buf + offset, samples);
9941001 offset += q->subpacket[i].size;
9951002 chidx += q->subpacket[i].num_channels;
9961003 av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb));
9971004 }
998− *data_size = out_size;
9991005
10001006 /* Discard the first two frames: no valid audio. */
1001− if (avctx->frame_number < 2) *data_size = 0;
1007+ if (q->discarded_packets < 2) {
1008+ q->discarded_packets++;
1009+ *got_frame_ptr = 0;
1010+ return avctx->block_align;
1011+ }
1012+
1013+ *got_frame_ptr = 1;
1014+ *(AVFrame *)data = q->frame;
10021015
10031016 return avctx->block_align;
10041017 }
@@ -1246,6 +1259,9 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 241 unmodified lines
12461259 else
12471260 avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
12481261
1262+ avcodec_get_frame_defaults(&q->frame);
1263+ avctx->coded_frame = &q->frame;
1264+
12491265 #ifdef DEBUG
12501266 dump_cook_context(q);
12511267 #endif
@@ -1262,5 +1278,6 @@ AVCodec ff_cook_decoder = · 10 unmodified lines
12621278 .init = cook_decode_init,
12631279 .close = cook_decode_close,
12641280 .decode = cook_decode_frame,
1281+ .capabilities = CODEC_CAP_DR1,
12651282 .long_name = NULL_IF_CONFIG_SMALL("COOK"),
12661283 };
libavcodec/dca.c+20−12
@@ -261,6 +261,7 @@ static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int id · 260 unmodified lines
261261
262262 typedef struct {
263263 AVCodecContext *avctx;
264+ AVFrame frame;
264265 /* Frame header */
265266 int frame_type; ///< type of the current frame
266267 int samples_deficit; ///< deficit sample count
@@ -1634,9 +1635,8 @@ static void dca_exss_parse_header(DCAContext *s) · 1367 unmodified lines
16341635 * Main frame decoding function
16351636 * FIXME add arguments
16361637 */
1637−static int dca_decode_frame(AVCodecContext * avctx,
1638− void *data, int *data_size,
1639− AVPacket *avpkt)
1638+static int dca_decode_frame(AVCodecContext *avctx, void *data,
1639+ int *got_frame_ptr, AVPacket *avpkt)
16401640 {
16411641 const uint8_t *buf = avpkt->data;
16421642 int buf_size = avpkt->size;
@@ -1644,9 +1644,8 @@ static int dca_decode_frame(AVCodecContext * avctx, · 1 unmodified line
16441644 int lfe_samples;
16451645 int num_core_channels = 0;
16461646 int i, ret;
1647− float *samples_flt = data;
1648− int16_t *samples_s16 = data;
1649− int out_size;
1647+ float *samples_flt;
1648+ int16_t *samples_s16;
16501649 DCAContext *s = avctx->priv_data;
16511650 int channels;
16521651 int core_ss_end;
@@ -1832,11 +1831,14 @@ static int dca_decode_frame(AVCodecContext * avctx, · 179 unmodified lines
18321831 avctx->channels = channels;
18331832 }
18341833
1835− out_size = 256 / 8 * s->sample_blocks * channels *
1836− av_get_bytes_per_sample(avctx->sample_fmt);
1837− if (*data_size < out_size)
1838− return AVERROR(EINVAL);
1839− *data_size = out_size;
1834+ /* get output buffer */
1835+ s->frame.nb_samples = 256 * (s->sample_blocks / 8);
1836+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
1837+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1838+ return ret;
1839+ }
1840+ samples_flt = (float *)s->frame.data[0];
1841+ samples_s16 = (int16_t *)s->frame.data[0];
18401842
18411843 /* filter to get final output */
18421844 for (i = 0; i < (s->sample_blocks / 8); i++) {
@@ -1870,6 +1872,9 @@ static int dca_decode_frame(AVCodecContext * avctx, · 27 unmodified lines
18701872 s->lfe_data[i] = s->lfe_data[i + lfe_samples];
18711873 }
18721874
1875+ *got_frame_ptr = 1;
1876+ *(AVFrame *)data = s->frame;
1877+
18731878 return buf_size;
18741879 }
18751880
@@ -1912,6 +1917,9 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) · 36 unmodified lines
19121917 avctx->channels = avctx->request_channels;
19131918 }
19141919
1920+ avcodec_get_frame_defaults(&s->frame);
1921+ avctx->coded_frame = &s->frame;
1922+
19151923 return 0;
19161924 }
19171925
@@ -1940,7 +1948,7 @@ AVCodec ff_dca_decoder = { · 22 unmodified lines
19401948 .decode = dca_decode_frame,
19411949 .close = dca_decode_end,
19421950 .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
1943− .capabilities = CODEC_CAP_CHANNEL_CONF,
1951+ .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
19441952 .sample_fmts = (const enum AVSampleFormat[]) {
19451953 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
19461954 },
libavcodec/dpcm.c+19−9
@@ -42,6 +42,7 @@ · 41 unmodified lines
4242 #include "bytestream.h"
4343
4444 typedef struct DPCMContext {
45+ AVFrame frame;
4546 int channels;
4647 int16_t roq_square_array[256];
4748 int sample[2]; ///< previous sample (for SOL_DPCM)
@@ -162,22 +163,25 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx) · 114 unmodified lines
162163 else
163164 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
164165
166+ avcodec_get_frame_defaults(&s->frame);
167+ avctx->coded_frame = &s->frame;
168+
165169 return 0;
166170 }
167171
168172
169−static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
170− AVPacket *avpkt)
173+static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
174+ int *got_frame_ptr, AVPacket *avpkt)
171175 {
172176 const uint8_t *buf = avpkt->data;
173177 int buf_size = avpkt->size;
174178 const uint8_t *buf_end = buf + buf_size;
175179 DPCMContext *s = avctx->priv_data;
176− int out = 0;
180+ int out = 0, ret;
177181 int predictor[2];
178182 int ch = 0;
179183 int stereo = s->channels - 1;
180− int16_t *output_samples = data;
184+ int16_t *output_samples;
181185
182186 /* calculate output size */
183187 switch(avctx->codec->id) {
@@ -197,15 +201,18 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 13 unmodified lines
197201 out = buf_size;
198202 break;
199203 }
200− out *= av_get_bytes_per_sample(avctx->sample_fmt);
201204 if (out <= 0) {
202205 av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
203206 return AVERROR(EINVAL);
204207 }
205− if (*data_size < out) {
206− av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
207− return AVERROR(EINVAL);
208+
209+ /* get output buffer */
210+ s->frame.nb_samples = out / s->channels;
211+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
212+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
213+ return ret;
208214 }
215+ output_samples = (int16_t *)s->frame.data[0];
209216
210217 switch(avctx->codec->id) {
211218
@@ -307,7 +314,9 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 95 unmodified lines
307314 break;
308315 }
309316
310− *data_size = out;
317+ *got_frame_ptr = 1;
318+ *(AVFrame *)data = s->frame;
319+
311320 return buf_size;
312321 }
313322
@@ -319,6 +328,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 5 unmodified lines
319328 .priv_data_size = sizeof(DPCMContext), \
320329 .init = dpcm_decode_init, \
321330 .decode = dpcm_decode_frame, \
331+ .capabilities = CODEC_CAP_DR1, \
322332 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
323333 }
324334
libavcodec/dsicinav.c+18−12
@@ -44,6 +44,7 @@ typedef struct CinVideoContext { · 43 unmodified lines
4444 } CinVideoContext;
4545
4646 typedef struct CinAudioContext {
47+ AVFrame frame;
4748 int initial_decode_frame;
4849 int delta;
4950 } CinAudioContext;
@@ -318,25 +319,28 @@ static av_cold int cinaudio_decode_init(AVCodecContext *avctx) · 268 unmodified lines
318319 cin->delta = 0;
319320 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
320321
322+ avcodec_get_frame_defaults(&cin->frame);
323+ avctx->coded_frame = &cin->frame;
324+
321325 return 0;
322326 }
323327
324−static int cinaudio_decode_frame(AVCodecContext *avctx,
325− void *data, int *data_size,
326− AVPacket *avpkt)
328+static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
329+ int *got_frame_ptr, AVPacket *avpkt)
327330 {
328331 const uint8_t *buf = avpkt->data;
329332 CinAudioContext *cin = avctx->priv_data;
330333 const uint8_t *buf_end = buf + avpkt->size;
331− int16_t *samples = data;
332− int delta, out_size;
333−
334− out_size = (avpkt->size - cin->initial_decode_frame) *
335− av_get_bytes_per_sample(avctx->sample_fmt);
336− if (*data_size < out_size) {
337− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
338− return AVERROR(EINVAL);
334+ int16_t *samples;
335+ int delta, ret;
336+
337+ /* get output buffer */
338+ cin->frame.nb_samples = avpkt->size - cin->initial_decode_frame;
339+ if ((ret = avctx->get_buffer(avctx, &cin->frame)) < 0) {
340+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
341+ return ret;
339342 }
343+ samples = (int16_t *)cin->frame.data[0];
340344
341345 delta = cin->delta;
342346 if (cin->initial_decode_frame) {
@@ -352,7 +356,8 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, · 9 unmodified lines
352356 }
353357 cin->delta = delta;
354358
355− *data_size = out_size;
359+ *got_frame_ptr = 1;
360+ *(AVFrame *)data = cin->frame;
356361
357362 return avpkt->size;
358363 }
@@ -377,5 +382,6 @@ AVCodec ff_dsicinaudio_decoder = { · 18 unmodified lines
377382 .priv_data_size = sizeof(CinAudioContext),
378383 .init = cinaudio_decode_init,
379384 .decode = cinaudio_decode_frame,
385+ .capabilities = CODEC_CAP_DR1,
380386 .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"),
381387 };
libavcodec/flacdec.c+21−16
@@ -49,6 +49,7 @@ typedef struct FLACContext { · 48 unmodified lines
4949 FLACSTREAMINFO
5050
5151 AVCodecContext *avctx; ///< parent AVCodecContext
52+ AVFrame frame;
5253 GetBitContext gb; ///< GetBitContext initialized to start at the current frame
5354
5455 int blocksize; ///< number of samples in the current frame
@@ -116,6 +117,9 @@ static av_cold int flac_decode_init(AVCodecContext *avctx) · 61 unmodified lines
116117 allocate_buffers(s);
117118 s->got_streaminfo = 1;
118119
120+ avcodec_get_frame_defaults(&s->frame);
121+ avctx->coded_frame = &s->frame;
122+
119123 return 0;
120124 }
121125
@@ -542,20 +546,18 @@ static int decode_frame(FLACContext *s) · 420 unmodified lines
542546 return 0;
543547 }
544548
545−static int flac_decode_frame(AVCodecContext *avctx,
546− void *data, int *data_size,
547− AVPacket *avpkt)
549+static int flac_decode_frame(AVCodecContext *avctx, void *data,
550+ int *got_frame_ptr, AVPacket *avpkt)
548551 {
549552 const uint8_t *buf = avpkt->data;
550553 int buf_size = avpkt->size;
551554 FLACContext *s = avctx->priv_data;
552555 int i, j = 0, bytes_read = 0;
553− int16_t *samples_16 = data;
554− int32_t *samples_32 = data;
555− int alloc_data_size= *data_size;
556− int output_size;
556+ int16_t *samples_16;
557+ int32_t *samples_32;
558+ int ret;
557559
558− *data_size=0;
560+ *got_frame_ptr = 0;
559561
560562 if (s->max_framesize == 0) {
561563 s->max_framesize =
@@ -586,15 +588,14 @@ static int flac_decode_frame(AVCodecContext *avctx, · 24 unmodified lines
586588 }
587589 bytes_read = (get_bits_count(&s->gb)+7)/8;
588590
589− /* check if allocated data size is large enough for output */
590− output_size = s->blocksize * s->channels *
591− av_get_bytes_per_sample(avctx->sample_fmt);
592− if (output_size > alloc_data_size) {
593− av_log(s->avctx, AV_LOG_ERROR, "output data size is larger than "
594− "allocated data size\n");
595− return -1;
591+ /* get output buffer */
592+ s->frame.nb_samples = s->blocksize;
593+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
594+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
595+ return ret;
596596 }
597− *data_size = output_size;
597+ samples_16 = (int16_t *)s->frame.data[0];
598+ samples_32 = (int32_t *)s->frame.data[0];
598599
599600 #define DECORRELATE(left, right)\
600601 assert(s->channels == 2);\
@@ -639,6 +640,9 @@ static int flac_decode_frame(AVCodecContext *avctx, · 38 unmodified lines
639640 buf_size - bytes_read, buf_size);
640641 }
641642
643+ *got_frame_ptr = 1;
644+ *(AVFrame *)data = s->frame;
645+
642646 return bytes_read;
643647 }
644648
@@ -662,5 +666,6 @@ AVCodec ff_flac_decoder = { · 17 unmodified lines
662666 .init = flac_decode_init,
663667 .close = flac_decode_close,
664668 .decode = flac_decode_frame,
669+ .capabilities = CODEC_CAP_DR1,
665670 .long_name= NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
666671 };
libavcodec/g722.h+2−0
@@ -26,10 +26,12 @@ · 25 unmodified lines
2626 #define AVCODEC_G722_H
2727
2828 #include <stdint.h>
29+#include "avcodec.h"
2930
3031 #define PREV_SAMPLES_BUF_SIZE 1024
3132
3233 typedef struct {
34+ AVFrame frame;
3335 int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples
3436 int prev_samples_pos; ///< the number of values in prev_samples
3537
libavcodec/g722dec.c+17−8
@@ -66,6 +66,9 @@ static av_cold int g722_decode_init(AVCodecContext * avctx) · 65 unmodified lines
6666 c->band[1].scale_factor = 2;
6767 c->prev_samples_pos = 22;
6868
69+ avcodec_get_frame_defaults(&c->frame);
70+ avctx->coded_frame = &c->frame;
71+
6972 return 0;
7073 }
7174
@@ -81,20 +84,22 @@ static const int16_t *low_inv_quants[3] = { ff_g722_low_inv_quant6, · 9 unmodified lines
8184 ff_g722_low_inv_quant4 };
8285
8386 static int g722_decode_frame(AVCodecContext *avctx, void *data,
84− int *data_size, AVPacket *avpkt)
87+ int *got_frame_ptr, AVPacket *avpkt)
8588 {
8689 G722Context *c = avctx->priv_data;
87− int16_t *out_buf = data;
88− int j, out_len;
90+ int16_t *out_buf;
91+ int j, ret;
8992 const int skip = 8 - avctx->bits_per_coded_sample;
9093 const int16_t *quantizer_table = low_inv_quants[skip];
9194 GetBitContext gb;
9295
93− out_len = avpkt->size * 2 * av_get_bytes_per_sample(avctx->sample_fmt);
94− if (*data_size < out_len) {
95− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
96− return AVERROR(EINVAL);
96+ /* get output buffer */
97+ c->frame.nb_samples = avpkt->size * 2;
98+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
99+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
100+ return ret;
97101 }
102+ out_buf = (int16_t *)c->frame.data[0];
98103
99104 init_get_bits(&gb, avpkt->data, avpkt->size * 8);
100105
@@ -128,7 +133,10 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data, · 27 unmodified lines
128133 c->prev_samples_pos = 22;
129134 }
130135 }
131− *data_size = out_len;
136+
137+ *got_frame_ptr = 1;
138+ *(AVFrame *)data = c->frame;
139+
132140 return avpkt->size;
133141 }
134142
@@ -139,5 +147,6 @@ AVCodec ff_adpcm_g722_decoder = { · 4 unmodified lines
139147 .priv_data_size = sizeof(G722Context),
140148 .init = g722_decode_init,
141149 .decode = g722_decode_frame,
150+ .capabilities = CODEC_CAP_DR1,
142151 .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
143152 };
libavcodec/g726.c+19−10
@@ -75,6 +75,7 @@ typedef struct G726Tables { · 74 unmodified lines
7575
7676 typedef struct G726Context {
7777 AVClass *class;
78+ AVFrame frame;
7879 G726Tables tbls; /**< static tables needed for computation */
7980
8081 Float11 sr[2]; /**< prev. reconstructed samples */
@@ -427,26 +428,31 @@ static av_cold int g726_decode_init(AVCodecContext *avctx) · 346 unmodified lines
427428
428429 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
429430
431+ avcodec_get_frame_defaults(&c->frame);
432+ avctx->coded_frame = &c->frame;
433+
430434 return 0;
431435 }
432436
433−static int g726_decode_frame(AVCodecContext *avctx,
434− void *data, int *data_size,
435− AVPacket *avpkt)
437+static int g726_decode_frame(AVCodecContext *avctx, void *data,
438+ int *got_frame_ptr, AVPacket *avpkt)
436439 {
437440 const uint8_t *buf = avpkt->data;
438441 int buf_size = avpkt->size;
439442 G726Context *c = avctx->priv_data;
440− int16_t *samples = data;
443+ int16_t *samples;
441444 GetBitContext gb;
442− int out_samples, out_size;
445+ int out_samples, ret;
443446
444447 out_samples = buf_size * 8 / c->code_size;
445− out_size = out_samples * av_get_bytes_per_sample(avctx->sample_fmt);
446− if (*data_size < out_size) {
447− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
448− return AVERROR(EINVAL);
448+
449+ /* get output buffer */
450+ c->frame.nb_samples = out_samples;
451+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
452+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
453+ return ret;
449454 }
455+ samples = (int16_t *)c->frame.data[0];
450456
451457 init_get_bits(&gb, buf, buf_size * 8);
452458
@@ -456,7 +462,9 @@ static int g726_decode_frame(AVCodecContext *avctx, · 3 unmodified lines
456462 if (get_bits_left(&gb) > 0)
457463 av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n");
458464
459− *data_size = out_size;
465+ *got_frame_ptr = 1;
466+ *(AVFrame *)data = c->frame;
467+
460468 return buf_size;
461469 }
462470
@@ -474,6 +482,7 @@ AVCodec ff_adpcm_g726_decoder = { · 11 unmodified lines
474482 .init = g726_decode_init,
475483 .decode = g726_decode_frame,
476484 .flush = g726_decode_flush,
485+ .capabilities = CODEC_CAP_DR1,
477486 .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"),
478487 };
479488 #endif
libavcodec/gsmdec.c+22−10
@@ -32,6 +32,8 @@ · 31 unmodified lines
3232
3333 static av_cold int gsm_init(AVCodecContext *avctx)
3434 {
35+ GSMContext *s = avctx->priv_data;
36+
3537 avctx->channels = 1;
3638 if (!avctx->sample_rate)
3739 avctx->sample_rate = 8000;
@@ -47,30 +49,35 @@ static av_cold int gsm_init(AVCodecContext *avctx) · 9 unmodified lines
4749 avctx->block_align = GSM_MS_BLOCK_SIZE;
4850 }
4951
52+ avcodec_get_frame_defaults(&s->frame);
53+ avctx->coded_frame = &s->frame;
54+
5055 return 0;
5156 }
5257
5358 static int gsm_decode_frame(AVCodecContext *avctx, void *data,
54− int *data_size, AVPacket *avpkt)
59+ int *got_frame_ptr, AVPacket *avpkt)
5560 {
61+ GSMContext *s = avctx->priv_data;
5662 int res;
5763 GetBitContext gb;
5864 const uint8_t *buf = avpkt->data;
5965 int buf_size = avpkt->size;
60− int16_t *samples = data;
61− int frame_bytes = avctx->frame_size *
62− av_get_bytes_per_sample(avctx->sample_fmt);
63−
64− if (*data_size < frame_bytes) {
65− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
66− return AVERROR(EINVAL);
67− }
66+ int16_t *samples;
6867
6968 if (buf_size < avctx->block_align) {
7069 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
7170 return AVERROR_INVALIDDATA;
7271 }
7372
73+ /* get output buffer */
74+ s->frame.nb_samples = avctx->frame_size;
75+ if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
76+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
77+ return res;
78+ }
79+ samples = (int16_t *)s->frame.data[0];
80+
7481 switch (avctx->codec_id) {
7582 case CODEC_ID_GSM:
7683 init_get_bits(&gb, buf, buf_size * 8);
@@ -85,7 +92,10 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data, · 8 unmodified lines
8592 if (res < 0)
8693 return res;
8794 }
88− *data_size = frame_bytes;
95+
96+ *got_frame_ptr = 1;
97+ *(AVFrame *)data = s->frame;
98+
8999 return avctx->block_align;
90100 }
91101
@@ -103,6 +113,7 @@ AVCodec ff_gsm_decoder = { · 11 unmodified lines
103113 .init = gsm_init,
104114 .decode = gsm_decode_frame,
105115 .flush = gsm_flush,
116+ .capabilities = CODEC_CAP_DR1,
106117 .long_name = NULL_IF_CONFIG_SMALL("GSM"),
107118 };
108119
@@ -114,5 +125,6 @@ AVCodec ff_gsm_ms_decoder = { · 5 unmodified lines
114125 .init = gsm_init,
115126 .decode = gsm_decode_frame,
116127 .flush = gsm_flush,
128+ .capabilities = CODEC_CAP_DR1,
117129 .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"),
118130 };
libavcodec/gsmdec_data.h+2−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #define AVCODEC_GSMDEC_DATA
2424
2525 #include <stdint.h>
26+#include "avcodec.h"
2627
2728 // input and output sizes in byte
2829 #define GSM_BLOCK_SIZE 33
@@ -30,6 +31,7 @@ · 1 unmodified line
3031 #define GSM_FRAME_SIZE 160
3132
3233 typedef struct {
34+ AVFrame frame;
3335 // Contains first 120 elements from the previous frame
3436 // (used by long_term_synth according to the "lag"),
3537 // then in the following 160 elements the current
libavcodec/huffyuv.c+4−3
@@ -956,8 +956,8 @@ static inline int encode_bgra_bitstream(HYuvContext *s, int count, int planes){ · 955 unmodified lines
956956
957957 #if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER
958958 static void draw_slice(HYuvContext *s, int y){
959− int h, cy;
960− int offset[4];
959+ int h, cy, i;
960+ int offset[AV_NUM_DATA_POINTERS];
961961
962962 if(s->avctx->draw_horiz_band==NULL)
963963 return;
@@ -974,7 +974,8 @@ static void draw_slice(HYuvContext *s, int y){ · 10 unmodified lines
974974 offset[0] = s->picture.linesize[0]*y;
975975 offset[1] = s->picture.linesize[1]*cy;
976976 offset[2] = s->picture.linesize[2]*cy;
977− offset[3] = 0;
977+ for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
978+ offset[i] = 0;
978979 emms_c();
979980
980981 s->avctx->draw_horiz_band(s->avctx, &s->picture, offset, y, 3, h);
libavcodec/imc.c+19−10
@@ -51,6 +51,8 @@ · 50 unmodified lines
5151 #define COEFFS 256
5252
5353 typedef struct {
54+ AVFrame frame;
55+
5456 float old_floor[BANDS];
5557 float flcoeffs1[BANDS];
5658 float flcoeffs2[BANDS];
@@ -168,6 +170,10 @@ static av_cold int imc_decode_init(AVCodecContext * avctx) · 111 unmodified lines
168170 dsputil_init(&q->dsp, avctx);
169171 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
170172 avctx->channel_layout = AV_CH_LAYOUT_MONO;
173+
174+ avcodec_get_frame_defaults(&q->frame);
175+ avctx->coded_frame = &q->frame;
176+
171177 return 0;
172178 }
173179
@@ -649,9 +655,8 @@ static int imc_get_coeffs (IMCContext* q) { · 475 unmodified lines
649655 return 0;
650656 }
651657
652−static int imc_decode_frame(AVCodecContext * avctx,
653− void *data, int *data_size,
654− AVPacket *avpkt)
658+static int imc_decode_frame(AVCodecContext * avctx, void *data,
659+ int *got_frame_ptr, AVPacket *avpkt)
655660 {
656661 const uint8_t *buf = avpkt->data;
657662 int buf_size = avpkt->size;
@@ -659,7 +664,7 @@ static int imc_decode_frame(AVCodecContext * avctx, · 1 unmodified line
659664 IMCContext *q = avctx->priv_data;
660665
661666 int stream_format_code;
662− int imc_hdr, i, j, out_size, ret;
667+ int imc_hdr, i, j, ret;
663668 int flag;
664669 int bits, summer;
665670 int counter, bitscount;
@@ -670,15 +675,16 @@ static int imc_decode_frame(AVCodecContext * avctx, · 4 unmodified lines
670675 return AVERROR_INVALIDDATA;
671676 }
672677
673− out_size = COEFFS * av_get_bytes_per_sample(avctx->sample_fmt);
674− if (*data_size < out_size) {
675− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
676− return AVERROR(EINVAL);
678+ /* get output buffer */
679+ q->frame.nb_samples = COEFFS;
680+ if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
681+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
682+ return ret;
677683 }
684+ q->out_samples = (float *)q->frame.data[0];
678685
679686 q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2);
680687
681− q->out_samples = data;
682688 init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
683689
684690 /* Check the frame header */
@@ -823,7 +829,8 @@ static int imc_decode_frame(AVCodecContext * avctx, · 138 unmodified lines
823829
824830 imc_imdct256(q);
825831
826− *data_size = out_size;
832+ *got_frame_ptr = 1;
833+ *(AVFrame *)data = q->frame;
827834
828835 return IMC_BLOCK_SIZE;
829836 }
@@ -834,6 +841,7 @@ static av_cold int imc_decode_close(AVCodecContext * avctx) · 4 unmodified lines
834841 IMCContext *q = avctx->priv_data;
835842
836843 ff_fft_end(&q->fft);
844+
837845 return 0;
838846 }
839847
@@ -846,5 +854,6 @@ AVCodec ff_imc_decoder = { · 6 unmodified lines
846854 .init = imc_decode_init,
847855 .close = imc_decode_close,
848856 .decode = imc_decode_frame,
857+ .capabilities = CODEC_CAP_DR1,
849858 .long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"),
850859 };
libavcodec/internal.h+6−3
@@ -31,12 +31,15 @@ · 30 unmodified lines
3131
3232 typedef struct InternalBuffer {
3333 int last_pic_num;
34− uint8_t *base[4];
35− uint8_t *data[4];
36− int linesize[4];
34+ uint8_t *base[AV_NUM_DATA_POINTERS];
35+ uint8_t *data[AV_NUM_DATA_POINTERS];
36+ int linesize[AV_NUM_DATA_POINTERS];
3737 int width;
3838 int height;
3939 enum PixelFormat pix_fmt;
40+ uint8_t **extended_data;
41+ int audio_data_size;
42+ int nb_channels;
4043 } InternalBuffer;
4144
4245 typedef struct AVCodecInternal {
libavcodec/libgsm.c+40−18
@@ -124,7 +124,14 @@ AVCodec ff_libgsm_ms_encoder = { · 123 unmodified lines
124124 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
125125 };
126126
127+typedef struct LibGSMDecodeContext {
128+ AVFrame frame;
129+ struct gsm_state *state;
130+} LibGSMDecodeContext;
131+
127132 static av_cold int libgsm_decode_init(AVCodecContext *avctx) {
133+ LibGSMDecodeContext *s = avctx->priv_data;
134+
128135 if (avctx->channels > 1) {
129136 av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n",
130137 avctx->channels);
@@ -139,7 +146,7 @@ static av_cold int libgsm_decode_init(AVCodecContext *avctx) { · 8 unmodified lines
139146
140147 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
141148
142− avctx->priv_data = gsm_create();
149+ s->state = gsm_create();
143150
144151 switch(avctx->codec_id) {
145152 case CODEC_ID_GSM:
@@ -154,59 +161,72 @@ static av_cold int libgsm_decode_init(AVCodecContext *avctx) { · 8 unmodified lines
154161 }
155162 }
156163
164+ avcodec_get_frame_defaults(&s->frame);
165+ avctx->coded_frame = &s->frame;
166+
157167 return 0;
158168 }
159169
160170 static av_cold int libgsm_decode_close(AVCodecContext *avctx) {
161− gsm_destroy(avctx->priv_data);
162− avctx->priv_data = NULL;
171+ LibGSMDecodeContext *s = avctx->priv_data;
172+
173+ gsm_destroy(s->state);
174+ s->state = NULL;
163175 return 0;
164176 }
165177
166−static int libgsm_decode_frame(AVCodecContext *avctx,
167− void *data, int *data_size,
168− AVPacket *avpkt) {
178+static int libgsm_decode_frame(AVCodecContext *avctx, void *data,
179+ int *got_frame_ptr, AVPacket *avpkt)
180+{
169181 int i, ret;
170− struct gsm_state *s = avctx->priv_data;
182+ LibGSMDecodeContext *s = avctx->priv_data;
171183 uint8_t *buf = avpkt->data;
172184 int buf_size = avpkt->size;
173− int16_t *samples = data;
174− int out_size = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt);
175−
176− if (*data_size < out_size) {
177− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
178− return AVERROR(EINVAL);
179− }
185+ int16_t *samples;
180186
181187 if (buf_size < avctx->block_align) {
182188 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
183189 return AVERROR_INVALIDDATA;
184190 }
185191
192+ /* get output buffer */
193+ s->frame.nb_samples = avctx->frame_size;
194+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
195+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
196+ return ret;
197+ }
198+ samples = (int16_t *)s->frame.data[0];
199+
186200 for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) {
187− if ((ret = gsm_decode(s, buf, samples)) < 0)
201+ if ((ret = gsm_decode(s->state, buf, samples)) < 0)
188202 return -1;
189203 buf += GSM_BLOCK_SIZE;
190204 samples += GSM_FRAME_SIZE;
191205 }
192206
193− *data_size = out_size;
207+ *got_frame_ptr = 1;
208+ *(AVFrame *)data = s->frame;
209+
194210 return avctx->block_align;
195211 }
196212
197213 static void libgsm_flush(AVCodecContext *avctx) {
198− gsm_destroy(avctx->priv_data);
199− avctx->priv_data = gsm_create();
214+ LibGSMDecodeContext *s = avctx->priv_data;
215+
216+ gsm_destroy(s->state);
217+ s->state = gsm_create();
200218 }
201219
202220 AVCodec ff_libgsm_decoder = {
203221 .name = "libgsm",
204222 .type = AVMEDIA_TYPE_AUDIO,
205223 .id = CODEC_ID_GSM,
224+ .priv_data_size = sizeof(LibGSMDecodeContext),
206225 .init = libgsm_decode_init,
207226 .close = libgsm_decode_close,
208227 .decode = libgsm_decode_frame,
209228 .flush = libgsm_flush,
229+ .capabilities = CODEC_CAP_DR1,
210230 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
211231 };
212232
@@ -214,9 +234,11 @@ AVCodec ff_libgsm_ms_decoder = { · 1 unmodified line
214234 .name = "libgsm_ms",
215235 .type = AVMEDIA_TYPE_AUDIO,
216236 .id = CODEC_ID_GSM_MS,
237+ .priv_data_size = sizeof(LibGSMDecodeContext),
217238 .init = libgsm_decode_init,
218239 .close = libgsm_decode_close,
219240 .decode = libgsm_decode_frame,
220241 .flush = libgsm_flush,
242+ .capabilities = CODEC_CAP_DR1,
221243 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
222244 };
libavcodec/libopencore-amr.c+35−17
@@ -79,6 +79,7 @@ static int get_bitrate_mode(int bitrate, void *log_ctx) · 78 unmodified lines
7979
8080 typedef struct AMRContext {
8181 AVClass *av_class;
82+ AVFrame frame;
8283 void *dec_state;
8384 void *enc_state;
8485 int enc_bitrate;
@@ -112,6 +113,9 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx) · 27 unmodified lines
112113 return AVERROR(ENOSYS);
113114 }
114115
116+ avcodec_get_frame_defaults(&s->frame);
117+ avctx->coded_frame = &s->frame;
118+
115119 return 0;
116120 }
117121
@@ -120,26 +124,28 @@ static av_cold int amr_nb_decode_close(AVCodecContext *avctx) · 2 unmodified lines
120124 AMRContext *s = avctx->priv_data;
121125
122126 Decoder_Interface_exit(s->dec_state);
127+
123128 return 0;
124129 }
125130
126131 static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
127− int *data_size, AVPacket *avpkt)
132+ int *got_frame_ptr, AVPacket *avpkt)
128133 {
129134 const uint8_t *buf = avpkt->data;
130135 int buf_size = avpkt->size;
131136 AMRContext *s = avctx->priv_data;
132137 static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
133138 enum Mode dec_mode;
134− int packet_size, out_size;
139+ int packet_size, ret;
135140
136141 av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n",
137142 buf, buf_size, avctx->frame_number);
138143
139− out_size = 160 * av_get_bytes_per_sample(avctx->sample_fmt);
140− if (*data_size < out_size) {
141− av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
142− return AVERROR(EINVAL);
144+ /* get output buffer */
145+ s->frame.nb_samples = 160;
146+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
147+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
148+ return ret;
143149 }
144150
145151 dec_mode = (buf[0] >> 3) & 0x000F;
@@ -154,8 +160,10 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data, · 8 unmodified lines
154160 av_dlog(avctx, "packet_size=%d buf= 0x%X %X %X %X\n",
155161 packet_size, buf[0], buf[1], buf[2], buf[3]);
156162 /* call decoder */
157− Decoder_Interface_Decode(s->dec_state, buf, data, 0);
158− *data_size = out_size;
163+ Decoder_Interface_Decode(s->dec_state, buf, (short *)s->frame.data[0], 0);
164+
165+ *got_frame_ptr = 1;
166+ *(AVFrame *)data = s->frame;
159167
160168 return packet_size;
161169 }
@@ -168,6 +176,7 @@ AVCodec ff_libopencore_amrnb_decoder = { · 6 unmodified lines
168176 .init = amr_nb_decode_init,
169177 .close = amr_nb_decode_close,
170178 .decode = amr_nb_decode_frame,
179+ .capabilities = CODEC_CAP_DR1,
171180 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),
172181 };
173182
@@ -251,6 +260,7 @@ AVCodec ff_libopencore_amrnb_encoder = { · 77 unmodified lines
251260 #include <opencore-amrwb/if_rom.h>
252261
253262 typedef struct AMRWBContext {
263+ AVFrame frame;
254264 void *state;
255265 } AMRWBContext;
256266
@@ -267,23 +277,27 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx) · 10 unmodified lines
267277 return AVERROR(ENOSYS);
268278 }
269279
280+ avcodec_get_frame_defaults(&s->frame);
281+ avctx->coded_frame = &s->frame;
282+
270283 return 0;
271284 }
272285
273286 static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
274− int *data_size, AVPacket *avpkt)
287+ int *got_frame_ptr, AVPacket *avpkt)
275288 {
276289 const uint8_t *buf = avpkt->data;
277290 int buf_size = avpkt->size;
278291 AMRWBContext *s = avctx->priv_data;
279− int mode;
280− int packet_size, out_size;
292+ int mode, ret;
293+ int packet_size;
281294 static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
282295
283− out_size = 320 * av_get_bytes_per_sample(avctx->sample_fmt);
284− if (*data_size < out_size) {
285− av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
286− return AVERROR(EINVAL);
296+ /* get output buffer */
297+ s->frame.nb_samples = 320;
298+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
299+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
300+ return ret;
287301 }
288302
289303 mode = (buf[0] >> 3) & 0x000F;
@@ -295,8 +309,11 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data, · 5 unmodified lines
295309 return AVERROR_INVALIDDATA;
296310 }
297311
298− D_IF_decode(s->state, buf, data, _good_frame);
299− *data_size = out_size;
312+ D_IF_decode(s->state, buf, (short *)s->frame.data[0], _good_frame);
313+
314+ *got_frame_ptr = 1;
315+ *(AVFrame *)data = s->frame;
316+
300317 return packet_size;
301318 }
302319
@@ -316,6 +333,7 @@ AVCodec ff_libopencore_amrwb_decoder = { · 13 unmodified lines
316333 .init = amr_wb_decode_init,
317334 .close = amr_wb_decode_close,
318335 .decode = amr_wb_decode_frame,
336+ .capabilities = CODEC_CAP_DR1,
319337 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"),
320338 };
321339
libavcodec/libspeexdec.c+21−15
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "avcodec.h"
2626
2727 typedef struct {
28+ AVFrame frame;
2829 SpeexBits bits;
2930 SpeexStereoState stereo;
3031 void *dec_state;
@@ -89,26 +90,29 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx) · 58 unmodified lines
8990 s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
9091 speex_decoder_ctl(s->dec_state, SPEEX_SET_HANDLER, &callback);
9192 }
93+
94+ avcodec_get_frame_defaults(&s->frame);
95+ avctx->coded_frame = &s->frame;
96+
9297 return 0;
9398 }
9499
95−static int libspeex_decode_frame(AVCodecContext *avctx,
96− void *data, int *data_size,
97− AVPacket *avpkt)
100+static int libspeex_decode_frame(AVCodecContext *avctx, void *data,
101+ int *got_frame_ptr, AVPacket *avpkt)
98102 {
99103 uint8_t *buf = avpkt->data;
100104 int buf_size = avpkt->size;
101105 LibSpeexContext *s = avctx->priv_data;
102− int16_t *output = data;
103− int out_size, ret, consumed = 0;
104−
105− /* check output buffer size */
106− out_size = s->frame_size * avctx->channels *
107− av_get_bytes_per_sample(avctx->sample_fmt);
108− if (*data_size < out_size) {
109− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
110− return AVERROR(EINVAL);
106+ int16_t *output;
107+ int ret, consumed = 0;
108+
109+ /* get output buffer */
110+ s->frame.nb_samples = s->frame_size;
111+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
112+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
113+ return ret;
111114 }
115+ output = (int16_t *)s->frame.data[0];
112116
113117 /* if there is not enough data left for the smallest possible frame,
114118 reset the libspeex buffer using the current packet, otherwise ignore
@@ -116,7 +120,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx, · 1 unmodified line
116120 if (speex_bits_remaining(&s->bits) < 43) {
117121 /* check for flush packet */
118122 if (!buf || !buf_size) {
119− *data_size = 0;
123+ *got_frame_ptr = 0;
120124 return buf_size;
121125 }
122126 /* set new buffer */
@@ -133,7 +137,9 @@ static int libspeex_decode_frame(AVCodecContext *avctx, · 10 unmodified lines
133137 if (avctx->channels == 2)
134138 speex_decode_stereo_int(output, s->frame_size, &s->stereo);
135139
136− *data_size = out_size;
140+ *got_frame_ptr = 1;
141+ *(AVFrame *)data = s->frame;
142+
137143 return consumed;
138144 }
139145
@@ -163,6 +169,6 @@ AVCodec ff_libspeex_decoder = { · 23 unmodified lines
163169 .close = libspeex_decode_close,
164170 .decode = libspeex_decode_frame,
165171 .flush = libspeex_decode_flush,
166− .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY,
172+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1,
167173 .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"),
168174 };
libavcodec/mace.c+21−12
@@ -153,6 +153,7 @@ typedef struct ChannelData { · 152 unmodified lines
153153 } ChannelData;
154154
155155 typedef struct MACEContext {
156+ AVFrame frame;
156157 ChannelData chd[2];
157158 } MACEContext;
158159
@@ -228,30 +229,35 @@ static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, · 69 unmodified lines
228229
229230 static av_cold int mace_decode_init(AVCodecContext * avctx)
230231 {
232+ MACEContext *ctx = avctx->priv_data;
233+
231234 if (avctx->channels > 2)
232235 return -1;
233236 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
237+
238+ avcodec_get_frame_defaults(&ctx->frame);
239+ avctx->coded_frame = &ctx->frame;
240+
234241 return 0;
235242 }
236243
237−static int mace_decode_frame(AVCodecContext *avctx,
238− void *data, int *data_size,
239− AVPacket *avpkt)
244+static int mace_decode_frame(AVCodecContext *avctx, void *data,
245+ int *got_frame_ptr, AVPacket *avpkt)
240246 {
241247 const uint8_t *buf = avpkt->data;
242248 int buf_size = avpkt->size;
243− int16_t *samples = data;
249+ int16_t *samples;
244250 MACEContext *ctx = avctx->priv_data;
245− int i, j, k, l;
246− int out_size;
251+ int i, j, k, l, ret;
247252 int is_mace3 = (avctx->codec_id == CODEC_ID_MACE3);
248253
249− out_size = 3 * (buf_size << (1 - is_mace3)) *
250− av_get_bytes_per_sample(avctx->sample_fmt);
251− if (*data_size < out_size) {
252− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
253− return AVERROR(EINVAL);
254+ /* get output buffer */
255+ ctx->frame.nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
256+ if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
257+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
258+ return ret;
254259 }
260+ samples = (int16_t *)ctx->frame.data[0];
255261
256262 for(i = 0; i < avctx->channels; i++) {
257263 int16_t *output = samples + i;
@@ -277,7 +283,8 @@ static int mace_decode_frame(AVCodecContext *avctx, · 19 unmodified lines
277283 }
278284 }
279285
280− *data_size = out_size;
286+ *got_frame_ptr = 1;
287+ *(AVFrame *)data = ctx->frame;
281288
282289 return buf_size;
283290 }
@@ -289,6 +296,7 @@ AVCodec ff_mace3_decoder = { · 5 unmodified lines
289296 .priv_data_size = sizeof(MACEContext),
290297 .init = mace_decode_init,
291298 .decode = mace_decode_frame,
299+ .capabilities = CODEC_CAP_DR1,
292300 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),
293301 };
294302
@@ -299,6 +307,7 @@ AVCodec ff_mace6_decoder = { · 4 unmodified lines
299307 .priv_data_size = sizeof(MACEContext),
300308 .init = mace_decode_init,
301309 .decode = mace_decode_frame,
310+ .capabilities = CODEC_CAP_DR1,
302311 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"),
303312 };
304313
libavcodec/mlpdec.c+25−14
@@ -120,6 +120,7 @@ typedef struct SubStream { · 119 unmodified lines
120120
121121 typedef struct MLPDecodeContext {
122122 AVCodecContext *avctx;
123+ AVFrame frame;
123124
124125 //! Current access unit being read has a major sync.
125126 int is_major_sync_unit;
@@ -242,6 +243,9 @@ static av_cold int mlp_decode_init(AVCodecContext *avctx) · 116 unmodified lines
242243 m->substream[substr].lossless_check_data = 0xffffffff;
243244 dsputil_init(&m->dsp, avctx);
244245
246+ avcodec_get_frame_defaults(&m->frame);
247+ avctx->coded_frame = &m->frame;
248+
245249 return 0;
246250 }
247251
@@ -946,13 +950,14 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) · 698 unmodified lines
946950 /** Write the audio data into the output buffer. */
947951
948952 static int output_data(MLPDecodeContext *m, unsigned int substr,
949− uint8_t *data, unsigned int *data_size)
953+ void *data, int *got_frame_ptr)
950954 {
955+ AVCodecContext *avctx = m->avctx;
951956 SubStream *s = &m->substream[substr];
952957 unsigned int i, out_ch = 0;
953− int out_size;
954− int32_t *data_32 = (int32_t*) data;
955− int16_t *data_16 = (int16_t*) data;
958+ int32_t *data_32;
959+ int16_t *data_16;
960+ int ret;
956961 int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
957962
958963 if (m->avctx->channels != s->max_matrix_channel + 1) {
@@ -960,11 +965,14 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 1 unmodified line
960965 return AVERROR_INVALIDDATA;
961966 }
962967
963− out_size = s->blockpos * m->avctx->channels *
964− av_get_bytes_per_sample(m->avctx->sample_fmt);
965−
966− if (*data_size < out_size)
967− return AVERROR(EINVAL);
968+ /* get output buffer */
969+ m->frame.nb_samples = s->blockpos;
970+ if ((ret = avctx->get_buffer(avctx, &m->frame)) < 0) {
971+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
972+ return ret;
973+ }
974+ data_32 = (int32_t *)m->frame.data[0];
975+ data_16 = (int16_t *)m->frame.data[0];
968976
969977 for (i = 0; i < s->blockpos; i++) {
970978 for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {
@@ -977,7 +985,8 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 6 unmodified lines
977985 }
978986 }
979987
980− *data_size = out_size;
988+ *got_frame_ptr = 1;
989+ *(AVFrame *)data = m->frame;
981990
982991 return 0;
983992 }
@@ -986,8 +995,8 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 2 unmodified lines
986995 * @return negative on error, 0 if not enough data is present in the input stream,
987996 * otherwise the number of bytes consumed. */
988997
989−static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size,
990− AVPacket *avpkt)
998+static int read_access_unit(AVCodecContext *avctx, void* data,
999+ int *got_frame_ptr, AVPacket *avpkt)
9911000 {
9921001 const uint8_t *buf = avpkt->data;
9931002 int buf_size = avpkt->size;
@@ -1023,7 +1032,7 @@ static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size, · 29 unmodified lines
10231032 if (!m->params_valid) {
10241033 av_log(m->avctx, AV_LOG_WARNING,
10251034 "Stream parameters not seen; skipping frame.\n");
1026− *data_size = 0;
1035+ *got_frame_ptr = 0;
10271036 return length;
10281037 }
10291038
@@ -1168,7 +1177,7 @@ next_substr: · 138 unmodified lines
11681177
11691178 rematrix_channels(m, m->max_decoded_substream);
11701179
1171− if ((ret = output_data(m, m->max_decoded_substream, data, data_size)) < 0)
1180+ if ((ret = output_data(m, m->max_decoded_substream, data, got_frame_ptr)) < 0)
11721181 return ret;
11731182
11741183 return length;
@@ -1189,6 +1198,7 @@ AVCodec ff_mlp_decoder = { · 14 unmodified lines
11891198 .priv_data_size = sizeof(MLPDecodeContext),
11901199 .init = mlp_decode_init,
11911200 .decode = read_access_unit,
1201+ .capabilities = CODEC_CAP_DR1,
11921202 .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),
11931203 };
11941204
@@ -1200,6 +1210,7 @@ AVCodec ff_truehd_decoder = { · 5 unmodified lines
12001210 .priv_data_size = sizeof(MLPDecodeContext),
12011211 .init = mlp_decode_init,
12021212 .decode = read_access_unit,
1213+ .capabilities = CODEC_CAP_DR1,
12031214 .long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
12041215 };
12051216 #endif /* CONFIG_TRUEHD_DECODER */
libavcodec/mpc.h+1−0
@@ -50,6 +50,7 @@ typedef struct { · 49 unmodified lines
5050 }Band;
5151
5252 typedef struct {
53+ AVFrame frame;
5354 DSPContext dsp;
5455 MPADSPContext mpadsp;
5556 GetBitContext gb;
libavcodec/mpc7.c+18−11
@@ -136,6 +136,10 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) · 135 unmodified lines
136136 }
137137 }
138138 vlc_initialized = 1;
139+
140+ avcodec_get_frame_defaults(&c->frame);
141+ avctx->coded_frame = &c->frame;
142+
139143 return 0;
140144 }
141145
@@ -192,9 +196,8 @@ static int get_scale_idx(GetBitContext *gb, int ref) · 50 unmodified lines
192196 return ref + t;
193197 }
194198
195−static int mpc7_decode_frame(AVCodecContext * avctx,
196− void *data, int *data_size,
197− AVPacket *avpkt)
199+static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
200+ int *got_frame_ptr, AVPacket *avpkt)
198201 {
199202 const uint8_t *buf = avpkt->data;
200203 int buf_size = avpkt->size;
@@ -204,7 +207,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 3 unmodified lines
204207 int i, ch;
205208 int mb = -1;
206209 Band *bands = c->bands;
207− int off, out_size;
210+ int off, ret;
208211 int bits_used, bits_avail;
209212
210213 memset(bands, 0, sizeof(*bands) * (c->maxbands + 1));
@@ -213,10 +216,11 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 2 unmodified lines
213216 return AVERROR(EINVAL);
214217 }
215218
216− out_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
217− if (*data_size < out_size) {
218− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
219− return AVERROR(EINVAL);
219+ /* get output buffer */
220+ c->frame.nb_samples = buf[1] ? c->lastframelen : MPC_FRAME_SIZE;
221+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
222+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
223+ return ret;
220224 }
221225
222226 bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);
@@ -276,7 +280,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 53 unmodified lines
276280 for(ch = 0; ch < 2; ch++)
277281 idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);
278282
279− ff_mpc_dequantize_and_synth(c, mb, data, 2);
283+ ff_mpc_dequantize_and_synth(c, mb, c->frame.data[0], 2);
280284
281285 av_free(bits);
282286
@@ -288,10 +292,12 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 5 unmodified lines
288292 }
289293 if(c->frames_to_skip){
290294 c->frames_to_skip--;
291− *data_size = 0;
295+ *got_frame_ptr = 0;
292296 return buf_size;
293297 }
294− *data_size = out_size;
298+
299+ *got_frame_ptr = 1;
300+ *(AVFrame *)data = c->frame;
295301
296302 return buf_size;
297303 }
@@ -312,5 +318,6 @@ AVCodec ff_mpc7_decoder = { · 14 unmodified lines
312318 .init = mpc7_decode_init,
313319 .decode = mpc7_decode_frame,
314320 .flush = mpc7_decode_flush,
321+ .capabilities = CODEC_CAP_DR1,
315322 .long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"),
316323 };
libavcodec/mpc8.c+17−10
@@ -230,12 +230,15 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) · 229 unmodified lines
230230 &mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
231231 }
232232 vlc_initialized = 1;
233+
234+ avcodec_get_frame_defaults(&c->frame);
235+ avctx->coded_frame = &c->frame;
236+
233237 return 0;
234238 }
235239
236−static int mpc8_decode_frame(AVCodecContext * avctx,
237− void *data, int *data_size,
238− AVPacket *avpkt)
240+static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
241+ int *got_frame_ptr, AVPacket *avpkt)
239242 {
240243 const uint8_t *buf = avpkt->data;
241244 int buf_size = avpkt->size;
@@ -243,14 +246,15 @@ static int mpc8_decode_frame(AVCodecContext * avctx, · 1 unmodified line
243246 GetBitContext gb2, *gb = &gb2;
244247 int i, j, k, ch, cnt, res, t;
245248 Band *bands = c->bands;
246− int off, out_size;
249+ int off;
247250 int maxband, keyframe;
248251 int last[2];
249252
250− out_size = MPC_FRAME_SIZE * 2 * avctx->channels;
251− if (*data_size < out_size) {
252− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
253− return AVERROR(EINVAL);
253+ /* get output buffer */
254+ c->frame.nb_samples = MPC_FRAME_SIZE;
255+ if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {
256+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
257+ return res;
254258 }
255259
256260 keyframe = c->cur_frame == 0;
@@ -403,14 +407,16 @@ static int mpc8_decode_frame(AVCodecContext * avctx, · 146 unmodified lines
403407 }
404408 }
405409
406− ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels);
410+ ff_mpc_dequantize_and_synth(c, maxband, c->frame.data[0], avctx->channels);
407411
408412 c->cur_frame++;
409413
410414 c->last_bits_used = get_bits_count(gb);
411415 if(c->cur_frame >= c->frames)
412416 c->cur_frame = 0;
413− *data_size = out_size;
417+
418+ *got_frame_ptr = 1;
419+ *(AVFrame *)data = c->frame;
414420
415421 return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
416422 }
@@ -422,5 +428,6 @@ AVCodec ff_mpc8_decoder = { · 5 unmodified lines
422428 .priv_data_size = sizeof(MPCContext),
423429 .init = mpc8_decode_init,
424430 .decode = mpc8_decode_frame,
431+ .capabilities = CODEC_CAP_DR1,
425432 .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"),
426433 };
libavcodec/mpeg4audio.c+4−3
@@ -76,12 +76,13 @@ static inline int get_sample_rate(GetBitContext *gb, int *index) · 75 unmodified lines
7676 avpriv_mpeg4audio_sample_rates[*index];
7777 }
7878
79−int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size)
79+int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
80+ int bit_size, int sync_extension)
8081 {
8182 GetBitContext gb;
8283 int specific_config_bitindex;
8384
84− init_get_bits(&gb, buf, buf_size*8);
85+ init_get_bits(&gb, buf, bit_size);
8586 c->object_type = get_object_type(&gb);
8687 c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
8788 c->chan_config = get_bits(&gb, 4);
@@ -117,7 +118,7 @@ int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bu · 29 unmodified lines
117118 return -1;
118119 }
119120
120− if (c->ext_object_type != AOT_SBR) {
121+ if (c->ext_object_type != AOT_SBR && sync_extension) {
121122 while (get_bits_left(&gb) > 15) {
122123 if (show_bits(&gb, 11) == 0x2b7) { // sync extension
123124 get_bits(&gb, 11);
libavcodec/mpeg4audio.h+5−2
@@ -42,14 +42,17 @@ typedef struct { · 41 unmodified lines
4242
4343 extern const int avpriv_mpeg4audio_sample_rates[16];
4444 extern const uint8_t ff_mpeg4audio_channels[8];
45+
4546 /**
4647 * Parse MPEG-4 systems extradata to retrieve audio configuration.
4748 * @param[in] c MPEG4AudioConfig structure to fill.
4849 * @param[in] buf Extradata from container.
49− * @param[in] buf_size Extradata size.
50+ * @param[in] bit_size Extradata size in bits.
51+ * @param[in] sync_extension look for a sync extension after config if true.
5052 * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata.
5153 */
52−int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size);
54+int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
55+ int bit_size, int sync_extension);
5356
5457 enum AudioObjectType {
5558 AOT_NULL,
libavcodec/mpegaudiodec.c+57−32
@@ -79,6 +79,7 @@ typedef struct MPADecodeContext { · 78 unmodified lines
7979 int err_recognition;
8080 AVCodecContext* avctx;
8181 MPADSPContext mpadsp;
82+ AVFrame frame;
8283 } MPADecodeContext;
8384
8485 #if CONFIG_FLOAT
@@ -479,6 +480,10 @@ static av_cold int decode_init(AVCodecContext * avctx) · 394 unmodified lines
479480
480481 if (avctx->codec_id == CODEC_ID_MP3ADU)
481482 s->adu_mode = 1;
483+
484+ avcodec_get_frame_defaults(&s->frame);
485+ avctx->coded_frame = &s->frame;
486+
482487 return 0;
483488 }
484489
@@ -1581,7 +1586,7 @@ static int mp_decode_layer3(MPADecodeContext *s) · 1096 unmodified lines
15811586 static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples,
15821587 const uint8_t *buf, int buf_size)
15831588 {
1584− int i, nb_frames, ch;
1589+ int i, nb_frames, ch, ret;
15851590 OUT_INT *samples_ptr;
15861591
15871592 init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE) * 8);
@@ -1629,8 +1634,16 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples, · 41 unmodified lines
16291634 assert(i <= buf_size - HEADER_SIZE && i >= 0);
16301635 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i);
16311636 s->last_buf_size += i;
1637+ }
16321638
1633− break;
1639+ /* get output buffer */
1640+ if (!samples) {
1641+ s->frame.nb_samples = s->avctx->frame_size;
1642+ if ((ret = s->avctx->get_buffer(s->avctx, &s->frame)) < 0) {
1643+ av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1644+ return ret;
1645+ }
1646+ samples = (OUT_INT *)s->frame.data[0];
16341647 }
16351648
16361649 /* apply the synthesis filter */
@@ -1650,7 +1663,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples, · 13 unmodified lines
16501663 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
16511664 }
16521665
1653−static int decode_frame(AVCodecContext * avctx, void *data, int *data_size,
1666+static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
16541667 AVPacket *avpkt)
16551668 {
16561669 const uint8_t *buf = avpkt->data;
@@ -1658,7 +1671,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 1 unmodified line
16581671 MPADecodeContext *s = avctx->priv_data;
16591672 uint32_t header;
16601673 int out_size;
1661− OUT_INT *out_samples = data;
16621674
16631675 if (buf_size < HEADER_SIZE)
16641676 return AVERROR_INVALIDDATA;
@@ -1681,10 +1693,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 16 unmodified lines
16811693 avctx->bit_rate = s->bit_rate;
16821694 avctx->sub_id = s->layer;
16831695
1684− if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT))
1685− return AVERROR(EINVAL);
1686− *data_size = 0;
1687−
16881696 if (s->frame_size <= 0 || s->frame_size > buf_size) {
16891697 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
16901698 return AVERROR_INVALIDDATA;
@@ -1693,9 +1701,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 2 unmodified lines
16931701 buf_size= s->frame_size;
16941702 }
16951703
1696− out_size = mp_decode_frame(s, out_samples, buf, buf_size);
1704+ out_size = mp_decode_frame(s, NULL, buf, buf_size);
16971705 if (out_size >= 0) {
1698− *data_size = out_size;
1706+ *got_frame_ptr = 1;
1707+ *(AVFrame *)data = s->frame;
16991708 avctx->sample_rate = s->sample_rate;
17001709 //FIXME maybe move the other codec info stuff from above here too
17011710 } else {
@@ -1704,6 +1713,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 2 unmodified lines
17041713 If there is more data in the packet, just consume the bad frame
17051714 instead of returning an error, which would discard the whole
17061715 packet. */
1716+ *got_frame_ptr = 0;
17071717 if (buf_size == avpkt->size)
17081718 return out_size;
17091719 }
@@ -1719,15 +1729,14 @@ static void flush(AVCodecContext *avctx) · 9 unmodified lines
17191729 }
17201730
17211731 #if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER
1722−static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size,
1723− AVPacket *avpkt)
1732+static int decode_frame_adu(AVCodecContext *avctx, void *data,
1733+ int *got_frame_ptr, AVPacket *avpkt)
17241734 {
17251735 const uint8_t *buf = avpkt->data;
17261736 int buf_size = avpkt->size;
17271737 MPADecodeContext *s = avctx->priv_data;
17281738 uint32_t header;
17291739 int len, out_size;
1730− OUT_INT *out_samples = data;
17311740
17321741 len = buf_size;
17331742
@@ -1757,9 +1766,6 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, · 23 unmodified lines
17571766 avctx->bit_rate = s->bit_rate;
17581767 avctx->sub_id = s->layer;
17591768
1760− if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT))
1761− return AVERROR(EINVAL);
1762−
17631769 s->frame_size = len;
17641770
17651771 #if FF_API_PARSE_FRAME
@@ -1767,9 +1773,11 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, · 1 unmodified line
17671773 out_size = buf_size;
17681774 else
17691775 #endif
1770− out_size = mp_decode_frame(s, out_samples, buf, buf_size);
1776+ out_size = mp_decode_frame(s, NULL, buf, buf_size);
1777+
1778+ *got_frame_ptr = 1;
1779+ *(AVFrame *)data = s->frame;
17711780
1772− *data_size = out_size;
17731781 return buf_size;
17741782 }
17751783 #endif /* CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER */
@@ -1780,6 +1788,7 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, · 4 unmodified lines
17801788 * Context for MP3On4 decoder
17811789 */
17821790 typedef struct MP3On4DecodeContext {
1791+ AVFrame *frame;
17831792 int frames; ///< number of mp3 frames per block (number of mp3 decoder instances)
17841793 int syncword; ///< syncword patch
17851794 const uint8_t *coff; ///< channel offsets in output buffer
@@ -1843,7 +1852,8 @@ static int decode_init_mp3on4(AVCodecContext * avctx) · 57 unmodified lines
18431852 return AVERROR_INVALIDDATA;
18441853 }
18451854
1846− avpriv_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size);
1855+ avpriv_mpeg4audio_get_config(&cfg, avctx->extradata,
1856+ avctx->extradata_size * 8, 1);
18471857 if (!cfg.chan_config || cfg.chan_config > 7) {
18481858 av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");
18491859 return AVERROR_INVALIDDATA;
@@ -1870,6 +1880,7 @@ static int decode_init_mp3on4(AVCodecContext * avctx) · 20 unmodified lines
18701880 // Put decoder context in place to make init_decode() happy
18711881 avctx->priv_data = s->mp3decctx[0];
18721882 decode_init(avctx);
1883+ s->frame = avctx->coded_frame;
18731884 // Restore mp3on4 context pointer
18741885 avctx->priv_data = s;
18751886 s->mp3decctx[0]->adu_mode = 1; // Set adu mode
@@ -1914,9 +1925,8 @@ static void flush_mp3on4(AVCodecContext *avctx) · 38 unmodified lines
19141925 }
19151926
19161927
1917−static int decode_frame_mp3on4(AVCodecContext * avctx,
1918− void *data, int *data_size,
1919− AVPacket *avpkt)
1928+static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
1929+ int *got_frame_ptr, AVPacket *avpkt)
19201930 {
19211931 const uint8_t *buf = avpkt->data;
19221932 int buf_size = avpkt->size;
@@ -1924,14 +1934,17 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, · 1 unmodified line
19241934 MPADecodeContext *m;
19251935 int fsize, len = buf_size, out_size = 0;
19261936 uint32_t header;
1927− OUT_INT *out_samples = data;
1937+ OUT_INT *out_samples;
19281938 OUT_INT *outptr, *bp;
1929− int fr, j, n, ch;
1939+ int fr, j, n, ch, ret;
19301940
1931− if (*data_size < MPA_FRAME_SIZE * avctx->channels * sizeof(OUT_INT)) {
1932− av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
1933− return AVERROR(EINVAL);
1941+ /* get output buffer */
1942+ s->frame->nb_samples = MPA_FRAME_SIZE;
1943+ if ((ret = avctx->get_buffer(avctx, s->frame)) < 0) {
1944+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1945+ return ret;
19341946 }
1947+ out_samples = (OUT_INT *)s->frame->data[0];
19351948
19361949 // Discard too short frames
19371950 if (buf_size < HEADER_SIZE)
@@ -1990,7 +2003,10 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, · 52 unmodified lines
19902003 /* update codec info */
19912004 avctx->sample_rate = s->mp3decctx[0]->sample_rate;
19922005
1993− *data_size = out_size;
2006+ s->frame->nb_samples = out_size / (avctx->channels * sizeof(OUT_INT));
2007+ *got_frame_ptr = 1;
2008+ *(AVFrame *)data = *s->frame;
2009+
19942010 return buf_size;
19952011 }
19962012 #endif /* CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER */
@@ -2005,7 +2021,9 @@ AVCodec ff_mp1_decoder = { · 8 unmodified lines
20052021 .init = decode_init,
20062022 .decode = decode_frame,
20072023 #if FF_API_PARSE_FRAME
2008− .capabilities = CODEC_CAP_PARSE_ONLY,
2024+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1,
2025+#else
2026+ .capabilities = CODEC_CAP_DR1,
20092027 #endif
20102028 .flush = flush,
20112029 .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
@@ -2020,7 +2038,9 @@ AVCodec ff_mp2_decoder = { · 8 unmodified lines
20202038 .init = decode_init,
20212039 .decode = decode_frame,
20222040 #if FF_API_PARSE_FRAME
2023− .capabilities = CODEC_CAP_PARSE_ONLY,
2041+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1,
2042+#else
2043+ .capabilities = CODEC_CAP_DR1,
20242044 #endif
20252045 .flush = flush,
20262046 .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
@@ -2035,7 +2055,9 @@ AVCodec ff_mp3_decoder = { · 8 unmodified lines
20352055 .init = decode_init,
20362056 .decode = decode_frame,
20372057 #if FF_API_PARSE_FRAME
2038− .capabilities = CODEC_CAP_PARSE_ONLY,
2058+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1,
2059+#else
2060+ .capabilities = CODEC_CAP_DR1,
20392061 #endif
20402062 .flush = flush,
20412063 .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
@@ -2050,7 +2072,9 @@ AVCodec ff_mp3adu_decoder = { · 8 unmodified lines
20502072 .init = decode_init,
20512073 .decode = decode_frame_adu,
20522074 #if FF_API_PARSE_FRAME
2053− .capabilities = CODEC_CAP_PARSE_ONLY,
2075+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1,
2076+#else
2077+ .capabilities = CODEC_CAP_DR1,
20542078 #endif
20552079 .flush = flush,
20562080 .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
@@ -2065,6 +2089,7 @@ AVCodec ff_mp3on4_decoder = { · 8 unmodified lines
20652089 .init = decode_init_mp3on4,
20662090 .close = decode_close_mp3on4,
20672091 .decode = decode_frame_mp3on4,
2092+ .capabilities = CODEC_CAP_DR1,
20682093 .flush = flush_mp3on4,
20692094 .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
20702095 };
libavcodec/mpegaudiodec_float.c+13−4
@@ -31,7 +31,9 @@ AVCodec ff_mp1float_decoder = { · 30 unmodified lines
3131 .init = decode_init,
3232 .decode = decode_frame,
3333 #if FF_API_PARSE_FRAME
34− .capabilities = CODEC_CAP_PARSE_ONLY,
34+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1,
35+#else
36+ .capabilities = CODEC_CAP_DR1,
3537 #endif
3638 .flush = flush,
3739 .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
@@ -46,7 +48,9 @@ AVCodec ff_mp2float_decoder = { · 8 unmodified lines
4648 .init = decode_init,
4749 .decode = decode_frame,
4850 #if FF_API_PARSE_FRAME
49− .capabilities = CODEC_CAP_PARSE_ONLY,
51+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1,
52+#else
53+ .capabilities = CODEC_CAP_DR1,
5054 #endif
5155 .flush = flush,
5256 .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
@@ -61,7 +65,9 @@ AVCodec ff_mp3float_decoder = { · 8 unmodified lines
6165 .init = decode_init,
6266 .decode = decode_frame,
6367 #if FF_API_PARSE_FRAME
64− .capabilities = CODEC_CAP_PARSE_ONLY,
68+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1,
69+#else
70+ .capabilities = CODEC_CAP_DR1,
6571 #endif
6672 .flush = flush,
6773 .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
@@ -76,7 +82,9 @@ AVCodec ff_mp3adufloat_decoder = { · 8 unmodified lines
7682 .init = decode_init,
7783 .decode = decode_frame_adu,
7884 #if FF_API_PARSE_FRAME
79− .capabilities = CODEC_CAP_PARSE_ONLY,
85+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1,
86+#else
87+ .capabilities = CODEC_CAP_DR1,
8088 #endif
8189 .flush = flush,
8290 .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
@@ -91,6 +99,7 @@ AVCodec ff_mp3on4float_decoder = { · 8 unmodified lines
9199 .init = decode_init_mp3on4,
92100 .close = decode_close_mp3on4,
93101 .decode = decode_frame_mp3on4,
102+ .capabilities = CODEC_CAP_DR1,
94103 .flush = flush_mp3on4,
95104 .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
96105 };
libavcodec/mpegvideo.c+6−6
@@ -2351,7 +2351,8 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ · 2350 unmodified lines
23512351
23522352 if (s->avctx->draw_horiz_band) {
23532353 AVFrame *src;
2354− int offset[4];
2354+ int offset[AV_NUM_DATA_POINTERS];
2355+ int i;
23552356
23562357 if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
23572358 src= (AVFrame*)s->current_picture_ptr;
@@ -2361,15 +2362,14 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ · 3 unmodified lines
23612362 return;
23622363
23632364 if(s->pict_type==AV_PICTURE_TYPE_B && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
2364− offset[0]=
2365− offset[1]=
2366− offset[2]=
2367− offset[3]= 0;
2365+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
2366+ offset[i] = 0;
23682367 }else{
23692368 offset[0]= y * s->linesize;
23702369 offset[1]=
23712370 offset[2]= (y >> s->chroma_y_shift) * s->uvlinesize;
2372− offset[3]= 0;
2371+ for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
2372+ offset[i] = 0;
23732373 }
23742374
23752375 emms_c();
libavcodec/nellymoserdec.c+26−14
@@ -47,6 +47,7 @@ · 46 unmodified lines
4747
4848 typedef struct NellyMoserDecodeContext {
4949 AVCodecContext* avctx;
50+ AVFrame frame;
5051 float *float_buf;
5152 DECLARE_ALIGNED(16, float, state)[NELLY_BUF_LEN];
5253 AVLFG random_state;
@@ -142,33 +143,31 @@ static av_cold int decode_init(AVCodecContext * avctx) { · 89 unmodified lines
142143 ff_init_ff_sine_windows(7);
143144
144145 avctx->channel_layout = AV_CH_LAYOUT_MONO;
146+
147+ avcodec_get_frame_defaults(&s->frame);
148+ avctx->coded_frame = &s->frame;
149+
145150 return 0;
146151 }
147152
148−static int decode_tag(AVCodecContext * avctx,
149− void *data, int *data_size,
150− AVPacket *avpkt) {
153+static int decode_tag(AVCodecContext *avctx, void *data,
154+ int *got_frame_ptr, AVPacket *avpkt)
155+{
151156 const uint8_t *buf = avpkt->data;
152157 const uint8_t *side=av_packet_get_side_data(avpkt, 'F', NULL);
153158 int buf_size = avpkt->size;
154159 NellyMoserDecodeContext *s = avctx->priv_data;
155− int data_max = *data_size;
156− int blocks, i, block_size;
157− int16_t *samples_s16 = data;
158− float *samples_flt = data;
159− *data_size = 0;
160+ int blocks, i, ret;
161+ int16_t *samples_s16;
162+ float *samples_flt;
160163
161− block_size = NELLY_SAMPLES * av_get_bytes_per_sample(avctx->sample_fmt);
162164 blocks = buf_size / NELLY_BLOCK_LEN;
163165
164166 if (blocks <= 0) {
165167 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
166168 return AVERROR_INVALIDDATA;
167169 }
168− if (data_max < blocks * block_size) {
169− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
170− return AVERROR(EINVAL);
171− }
170+
172171 if (buf_size % NELLY_BLOCK_LEN) {
173172 av_log(avctx, AV_LOG_WARNING, "Leftover bytes: %d.\n",
174173 buf_size % NELLY_BLOCK_LEN);
@@ -183,6 +182,15 @@ static int decode_tag(AVCodecContext * avctx, · 8 unmodified lines
183182 if(side && blocks>1 && avctx->sample_rate%11025==0 && (1<<((side[0]>>2)&3)) == blocks)
184183 avctx->sample_rate= 11025*(blocks/2);
185184
185+ /* get output buffer */
186+ s->frame.nb_samples = NELLY_SAMPLES * blocks;
187+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
188+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
189+ return ret;
190+ }
191+ samples_s16 = (int16_t *)s->frame.data[0];
192+ samples_flt = (float *)s->frame.data[0];
193+
186194 for (i=0 ; i<blocks ; i++) {
187195 if (avctx->sample_fmt == SAMPLE_FMT_FLT) {
188196 nelly_decode_block(s, buf, samples_flt);
@@ -194,7 +202,9 @@ static int decode_tag(AVCodecContext * avctx, · 5 unmodified lines
194202 }
195203 buf += NELLY_BLOCK_LEN;
196204 }
197− *data_size = blocks * block_size;
205+
206+ *got_frame_ptr = 1;
207+ *(AVFrame *)data = s->frame;
198208
199209 return buf_size;
200210 }
@@ -204,6 +214,7 @@ static av_cold int decode_end(AVCodecContext * avctx) { · 3 unmodified lines
204214
205215 av_freep(&s->float_buf);
206216 ff_mdct_end(&s->imdct_ctx);
217+
207218 return 0;
208219 }
209220
@@ -215,6 +226,7 @@ AVCodec ff_nellymoser_decoder = { · 5 unmodified lines
215226 .init = decode_init,
216227 .close = decode_end,
217228 .decode = decode_tag,
229+ .capabilities = CODEC_CAP_DR1,
218230 .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
219231 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
220232 AV_SAMPLE_FMT_S16,
libavcodec/pcm.c+25−17
@@ -192,6 +192,7 @@ static int pcm_encode_frame(AVCodecContext *avctx, · 191 unmodified lines
192192 }
193193
194194 typedef struct PCMDecode {
195+ AVFrame frame;
195196 short table[256];
196197 } PCMDecode;
197198
@@ -223,6 +224,9 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx) · 25 unmodified lines
223224 if (avctx->sample_fmt == AV_SAMPLE_FMT_S32)
224225 avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec->id);
225226
227+ avcodec_get_frame_defaults(&s->frame);
228+ avctx->coded_frame = &s->frame;
229+
226230 return 0;
227231 }
228232
@@ -243,22 +247,20 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx) · 14 unmodified lines
243247 dst += size / 8; \
244248 }
245249
246−static int pcm_decode_frame(AVCodecContext *avctx,
247− void *data, int *data_size,
248− AVPacket *avpkt)
250+static int pcm_decode_frame(AVCodecContext *avctx, void *data,
251+ int *got_frame_ptr, AVPacket *avpkt)
249252 {
250253 const uint8_t *src = avpkt->data;
251254 int buf_size = avpkt->size;
252255 PCMDecode *s = avctx->priv_data;
253− int sample_size, c, n, out_size;
256+ int sample_size, c, n, ret, samples_per_block;
254257 uint8_t *samples;
255258 int32_t *dst_int32_t;
256259
257− samples = data;
258−
259260 sample_size = av_get_bits_per_sample(avctx->codec_id)/8;
260261
261262 /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */
263+ samples_per_block = 1;
262264 if (CODEC_ID_PCM_DVD == avctx->codec_id) {
263265 if (avctx->bits_per_coded_sample != 20 &&
264266 avctx->bits_per_coded_sample != 24) {
@@ -268,10 +270,13 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 3 unmodified lines
268270 return AVERROR(EINVAL);
269271 }
270272 /* 2 samples are interleaved per block in PCM_DVD */
273+ samples_per_block = 2;
271274 sample_size = avctx->bits_per_coded_sample * 2 / 8;
272− } else if (avctx->codec_id == CODEC_ID_PCM_LXF)
275+ } else if (avctx->codec_id == CODEC_ID_PCM_LXF) {
273276 /* we process 40-bit blocks per channel for LXF */
277+ samples_per_block = 2;
274278 sample_size = 5;
279+ }
275280
276281 if (sample_size == 0) {
277282 av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n");
@@ -290,14 +295,13 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 12 unmodified lines
290295
291296 n = buf_size/sample_size;
292297
293− out_size = n * av_get_bytes_per_sample(avctx->sample_fmt);
294− if (avctx->codec_id == CODEC_ID_PCM_DVD ||
295− avctx->codec_id == CODEC_ID_PCM_LXF)
296− out_size *= 2;
297− if (*data_size < out_size) {
298− av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
299− return AVERROR(EINVAL);
298+ /* get output buffer */
299+ s->frame.nb_samples = n * samples_per_block / avctx->channels;
300+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
301+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
302+ return ret;
300303 }
304+ samples = s->frame.data[0];
301305
302306 switch(avctx->codec->id) {
303307 case CODEC_ID_PCM_U32LE:
@@ -403,7 +407,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 99 unmodified lines
403407 case CODEC_ID_PCM_DVD:
404408 {
405409 const uint8_t *src8;
406− dst_int32_t = data;
410+ dst_int32_t = (int32_t *)s->frame.data[0];
407411 n /= avctx->channels;
408412 switch (avctx->bits_per_coded_sample) {
409413 case 20:
@@ -435,7 +439,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 25 unmodified lines
435439 {
436440 int i;
437441 const uint8_t *src8;
438− dst_int32_t = data;
442+ dst_int32_t = (int32_t *)s->frame.data[0];
439443 n /= avctx->channels;
440444 //unpack and de-planerize
441445 for (i = 0; i < n; i++) {
@@ -456,7 +460,10 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 14 unmodified lines
456460 default:
457461 return -1;
458462 }
459− *data_size = out_size;
463+
464+ *got_frame_ptr = 1;
465+ *(AVFrame *)data = s->frame;
466+
460467 return buf_size;
461468 }
462469
@@ -485,6 +492,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 22 unmodified lines
485492 .priv_data_size = sizeof(PCMDecode), \
486493 .init = pcm_decode_init, \
487494 .decode = pcm_decode_frame, \
495+ .capabilities = CODEC_CAP_DR1, \
488496 .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
489497 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
490498 }
libavcodec/qcelpdec.c+17−9
@@ -56,6 +56,7 @@ typedef enum · 55 unmodified lines
5656
5757 typedef struct
5858 {
59+ AVFrame avframe;
5960 GetBitContext gb;
6061 qcelp_packet_rate bitrate;
6162 QCELPFrame frame; /**< unpacked data frame */
@@ -97,6 +98,9 @@ static av_cold int qcelp_decode_init(AVCodecContext *avctx) · 35 unmodified lines
9798 for(i=0; i<10; i++)
9899 q->prev_lspf[i] = (i+1)/11.;
99100
101+ avcodec_get_frame_defaults(&q->avframe);
102+ avctx->coded_frame = &q->avframe;
103+
100104 return 0;
101105 }
102106
@@ -682,23 +686,25 @@ static void postfilter(QCELPContext *q, float *samples, float *lpc) · 579 unmodified lines
682686 160, 0.9375, &q->postfilter_agc_mem);
683687 }
684688
685−static int qcelp_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
686− AVPacket *avpkt)
689+static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
690+ int *got_frame_ptr, AVPacket *avpkt)
687691 {
688692 const uint8_t *buf = avpkt->data;
689693 int buf_size = avpkt->size;
690694 QCELPContext *q = avctx->priv_data;
691− float *outbuffer = data;
692− int i, out_size;
695+ float *outbuffer;
696+ int i, ret;
693697 float quantized_lspf[10], lpc[10];
694698 float gain[16];
695699 float *formant_mem;
696700
697− out_size = 160 * av_get_bytes_per_sample(avctx->sample_fmt);
698− if (*data_size < out_size) {
699− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
700− return AVERROR(EINVAL);
701+ /* get output buffer */
702+ q->avframe.nb_samples = 160;
703+ if ((ret = avctx->get_buffer(avctx, &q->avframe)) < 0) {
704+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
705+ return ret;
701706 }
707+ outbuffer = (float *)q->avframe.data[0];
702708
703709 if ((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) {
704710 warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");
@@ -783,7 +789,8 @@ erasure: · 78 unmodified lines
783789 memcpy(q->prev_lspf, quantized_lspf, sizeof(q->prev_lspf));
784790 q->prev_bitrate = q->bitrate;
785791
786− *data_size = out_size;
792+ *got_frame_ptr = 1;
793+ *(AVFrame *)data = q->avframe;
787794
788795 return buf_size;
789796 }
@@ -795,6 +802,7 @@ AVCodec ff_qcelp_decoder = · 5 unmodified lines
795802 .id = CODEC_ID_QCELP,
796803 .init = qcelp_decode_init,
797804 .decode = qcelp_decode_frame,
805+ .capabilities = CODEC_CAP_DR1,
798806 .priv_data_size = sizeof(QCELPContext),
799807 .long_name = NULL_IF_CONFIG_SMALL("QCELP / PureVoice"),
800808 };
libavcodec/qdm2.c+18−14
@@ -130,6 +130,8 @@ typedef struct { · 129 unmodified lines
130130 * QDM2 decoder context
131131 */
132132 typedef struct {
133+ AVFrame frame;
134+
133135 /// Parameters from codec header, do not change during playback
134136 int nb_channels; ///< number of channels
135137 int channels; ///< number of channels
@@ -1876,6 +1878,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) · 1740 unmodified lines
18761878
18771879 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
18781880
1881+ avcodec_get_frame_defaults(&s->frame);
1882+ avctx->coded_frame = &s->frame;
1883+
18791884 // dump_context(s);
18801885 return 0;
18811886 }
@@ -1956,30 +1961,27 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) · 74 unmodified lines
19561961 }
19571962
19581963
1959−static int qdm2_decode_frame(AVCodecContext *avctx,
1960− void *data, int *data_size,
1961− AVPacket *avpkt)
1964+static int qdm2_decode_frame(AVCodecContext *avctx, void *data,
1965+ int *got_frame_ptr, AVPacket *avpkt)
19621966 {
19631967 const uint8_t *buf = avpkt->data;
19641968 int buf_size = avpkt->size;
19651969 QDM2Context *s = avctx->priv_data;
1966− int16_t *out = data;
1967− int i, out_size;
1970+ int16_t *out;
1971+ int i, ret;
19681972
19691973 if(!buf)
19701974 return 0;
19711975 if(buf_size < s->checksum_size)
19721976 return -1;
19731977
1974− out_size = 16 * s->channels * s->frame_size *
1975− av_get_bytes_per_sample(avctx->sample_fmt);
1976− if (*data_size < out_size) {
1977− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
1978− return AVERROR(EINVAL);
1978+ /* get output buffer */
1979+ s->frame.nb_samples = 16 * s->frame_size;
1980+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
1981+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1982+ return ret;
19791983 }
1980−
1981− av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n",
1982− buf_size, buf, s->checksum_size, data, *data_size);
1984+ out = (int16_t *)s->frame.data[0];
19831985
19841986 for (i = 0; i < 16; i++) {
19851987 if (qdm2_decode(s, buf, out) < 0)
@@ -1987,7 +1989,8 @@ static int qdm2_decode_frame(AVCodecContext *avctx, · 1 unmodified line
19871989 out += s->channels * s->frame_size;
19881990 }
19891991
1990− *data_size = out_size;
1992+ *got_frame_ptr = 1;
1993+ *(AVFrame *)data = s->frame;
19911994
19921995 return s->checksum_size;
19931996 }
@@ -2001,5 +2004,6 @@ AVCodec ff_qdm2_decoder = · 7 unmodified lines
20012004 .init = qdm2_decode_init,
20022005 .close = qdm2_decode_close,
20032006 .decode = qdm2_decode_frame,
2007+ .capabilities = CODEC_CAP_DR1,
20042008 .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),
20052009 };
libavcodec/ra144.h+1−0
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434
3535 typedef struct {
3636 AVCodecContext *avctx;
37+ AVFrame frame;
3738 LPCContext lpc_ctx;
3839
3940 unsigned int old_energy; ///< previous frame energy
libavcodec/ra144dec.c+20−11
@@ -38,6 +38,10 @@ static av_cold int ra144_decode_init(AVCodecContext * avctx) · 37 unmodified lines
3838 ractx->lpc_coef[1] = ractx->lpc_tables[1];
3939
4040 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
41+
42+ avcodec_get_frame_defaults(&ractx->frame);
43+ avctx->coded_frame = &ractx->frame;
44+
4145 return 0;
4246 }
4347
@@ -54,8 +58,8 @@ static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs, · 10 unmodified lines
5458 }
5559
5660 /** Uncompress one block (20 bytes -> 160*2 bytes). */
57−static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
58− int *data_size, AVPacket *avpkt)
61+static int ra144_decode_frame(AVCodecContext * avctx, void *data,
62+ int *got_frame_ptr, AVPacket *avpkt)
5963 {
6064 const uint8_t *buf = avpkt->data;
6165 int buf_size = avpkt->size;
@@ -64,23 +68,25 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, · 2 unmodified lines
6468 uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block
6569 unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame
6670 int i, j;
67− int out_size;
68− int16_t *data = vdata;
71+ int ret;
72+ int16_t *samples;
6973 unsigned int energy;
7074
7175 RA144Context *ractx = avctx->priv_data;
7276 GetBitContext gb;
7377
74− out_size = NBLOCKS * BLOCKSIZE * av_get_bytes_per_sample(avctx->sample_fmt);
75− if (*data_size < out_size) {
76− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
77− return AVERROR(EINVAL);
78+ /* get output buffer */
79+ ractx->frame.nb_samples = NBLOCKS * BLOCKSIZE;
80+ if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) {
81+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
82+ return ret;
7883 }
84+ samples = (int16_t *)ractx->frame.data[0];
7985
8086 if(buf_size < FRAMESIZE) {
8187 av_log(avctx, AV_LOG_ERROR,
8288 "Frame too small (%d bytes). Truncated file?\n", buf_size);
83− *data_size = 0;
89+ *got_frame_ptr = 0;
8490 return buf_size;
8591 }
8692 init_get_bits(&gb, buf, FRAMESIZE * 8);
@@ -106,7 +112,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, · 19 unmodified lines
106112 do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb);
107113
108114 for (j=0; j < BLOCKSIZE; j++)
109− *data++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2);
115+ *samples++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2);
110116 }
111117
112118 ractx->old_energy = energy;
@@ -114,7 +120,9 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, · 1 unmodified line
114120
115121 FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]);
116122
117− *data_size = out_size;
123+ *got_frame_ptr = 1;
124+ *(AVFrame *)data = ractx->frame;
125+
118126 return FRAMESIZE;
119127 }
120128
@@ -125,5 +133,6 @@ AVCodec ff_ra_144_decoder = { · 4 unmodified lines
125133 .priv_data_size = sizeof(RA144Context),
126134 .init = ra144_decode_init,
127135 .decode = ra144_decode_frame,
136+ .capabilities = CODEC_CAP_DR1,
128137 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
129138 };
libavcodec/ra288.c+18−9
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #define RA288_BLOCKS_PER_FRAME 32
3737
3838 typedef struct {
39+ AVFrame frame;
3940 DSPContext dsp;
4041 DECLARE_ALIGNED(16, float, sp_lpc)[FFALIGN(36, 8)]; ///< LPC coefficients for speech data (spec: A)
4142 DECLARE_ALIGNED(16, float, gain_lpc)[FFALIGN(10, 8)]; ///< LPC coefficients for gain (spec: GB)
@@ -62,6 +63,10 @@ static av_cold int ra288_decode_init(AVCodecContext *avctx) · 20 unmodified lines
6263 RA288Context *ractx = avctx->priv_data;
6364 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
6465 dsputil_init(&ractx->dsp, avctx);
66+
67+ avcodec_get_frame_defaults(&ractx->frame);
68+ avctx->coded_frame = &ractx->frame;
69+
6570 return 0;
6671 }
6772
@@ -165,12 +170,12 @@ static void backward_filter(RA288Context *ractx, · 97 unmodified lines
165170 }
166171
167172 static int ra288_decode_frame(AVCodecContext * avctx, void *data,
168− int *data_size, AVPacket *avpkt)
173+ int *got_frame_ptr, AVPacket *avpkt)
169174 {
170175 const uint8_t *buf = avpkt->data;
171176 int buf_size = avpkt->size;
172− float *out = data;
173− int i, out_size;
177+ float *out;
178+ int i, ret;
174179 RA288Context *ractx = avctx->priv_data;
175180 GetBitContext gb;
176181
@@ -181,12 +186,13 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, · 4 unmodified lines
181186 return AVERROR_INVALIDDATA;
182187 }
183188
184− out_size = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME *
185− av_get_bytes_per_sample(avctx->sample_fmt);
186− if (*data_size < out_size) {
187− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
188− return AVERROR(EINVAL);
189+ /* get output buffer */
190+ ractx->frame.nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME;
191+ if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) {
192+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
193+ return ret;
189194 }
195+ out = (float *)ractx->frame.data[0];
190196
191197 init_get_bits(&gb, buf, avctx->block_align * 8);
192198
@@ -208,7 +214,9 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, · 15 unmodified lines
208214 }
209215 }
210216
211− *data_size = out_size;
217+ *got_frame_ptr = 1;
218+ *(AVFrame *)data = ractx->frame;
219+
212220 return avctx->block_align;
213221 }
214222
@@ -219,5 +227,6 @@ AVCodec ff_ra_288_decoder = { · 4 unmodified lines
219227 .priv_data_size = sizeof(RA288Context),
220228 .init = ra288_decode_init,
221229 .decode = ra288_decode_frame,
230+ .capabilities = CODEC_CAP_DR1,
222231 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"),
223232 };
libavcodec/s302m.c+36−10
@@ -25,6 +25,10 @@ · 24 unmodified lines
2525
2626 #define AES3_HEADER_LEN 4
2727
28+typedef struct S302MDecodeContext {
29+ AVFrame frame;
30+} S302MDecodeContext;
31+
2832 static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
2933 int buf_size)
3034 {
@@ -83,10 +87,12 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf, · 52 unmodified lines
8387 }
8488
8589 static int s302m_decode_frame(AVCodecContext *avctx, void *data,
86− int *data_size, AVPacket *avpkt)
90+ int *got_frame_ptr, AVPacket *avpkt)
8791 {
92+ S302MDecodeContext *s = avctx->priv_data;
8893 const uint8_t *buf = avpkt->data;
8994 int buf_size = avpkt->size;
95+ int block_size, ret;
9096
9197 int frame_size = s302m_parse_frame_header(avctx, buf, buf_size);
9298 if (frame_size < 0)
@@ -95,11 +101,18 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 2 unmodified lines
95101 buf_size -= AES3_HEADER_LEN;
96102 buf += AES3_HEADER_LEN;
97103
98− if (*data_size < 4 * buf_size * 8 / (avctx->bits_per_coded_sample + 4))
99− return -1;
104+ /* get output buffer */
105+ block_size = (avctx->bits_per_coded_sample + 4) / 4;
106+ s->frame.nb_samples = 2 * (buf_size / block_size) / avctx->channels;
107+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
108+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
109+ return ret;
110+ }
111+
112+ buf_size = (s->frame.nb_samples * avctx->channels / 2) * block_size;
100113
101114 if (avctx->bits_per_coded_sample == 24) {
102− uint32_t *o = data;
115+ uint32_t *o = (uint32_t *)s->frame.data[0];
103116 for (; buf_size > 6; buf_size -= 7) {
104117 *o++ = (av_reverse[buf[2]] << 24) |
105118 (av_reverse[buf[1]] << 16) |
@@ -110,9 +123,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines
110123 (av_reverse[buf[3] & 0x0f] << 4);
111124 buf += 7;
112125 }
113− *data_size = (uint8_t*) o - (uint8_t*) data;
114126 } else if (avctx->bits_per_coded_sample == 20) {
115− uint32_t *o = data;
127+ uint32_t *o = (uint32_t *)s->frame.data[0];
116128 for (; buf_size > 5; buf_size -= 6) {
117129 *o++ = (av_reverse[buf[2] & 0xf0] << 28) |
118130 (av_reverse[buf[1]] << 20) |
@@ -122,9 +134,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 3 unmodified lines
122134 (av_reverse[buf[3]] << 12);
123135 buf += 6;
124136 }
125− *data_size = (uint8_t*) o - (uint8_t*) data;
126137 } else {
127− uint16_t *o = data;
138+ uint16_t *o = (uint16_t *)s->frame.data[0];
128139 for (; buf_size > 4; buf_size -= 5) {
129140 *o++ = (av_reverse[buf[1]] << 8) |
130141 av_reverse[buf[0]];
@@ -133,10 +144,22 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 2 unmodified lines
133144 (av_reverse[buf[2]] >> 4);
134145 buf += 5;
135146 }
136− *data_size = (uint8_t*) o - (uint8_t*) data;
137147 }
138148
139− return buf - avpkt->data;
149+ *got_frame_ptr = 1;
150+ *(AVFrame *)data = s->frame;
151+
152+ return avpkt->size;
153+}
154+
155+static int s302m_decode_init(AVCodecContext *avctx)
156+{
157+ S302MDecodeContext *s = avctx->priv_data;
158+
159+ avcodec_get_frame_defaults(&s->frame);
160+ avctx->coded_frame = &s->frame;
161+
162+ return 0;
140163 }
141164
142165
@@ -144,6 +167,9 @@ AVCodec ff_s302m_decoder = { · 1 unmodified line
144167 .name = "s302m",
145168 .type = AVMEDIA_TYPE_AUDIO,
146169 .id = CODEC_ID_S302M,
170+ .priv_data_size = sizeof(S302MDecodeContext),
171+ .init = s302m_decode_init,
147172 .decode = s302m_decode_frame,
173+ .capabilities = CODEC_CAP_DR1,
148174 .long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"),
149175 };
libavcodec/shorten.c+26−19
@@ -79,6 +79,7 @@ static const uint8_t is_audio_command[10] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0 }; · 78 unmodified lines
7979
8080 typedef struct ShortenContext {
8181 AVCodecContext *avctx;
82+ AVFrame frame;
8283 GetBitContext gb;
8384
8485 int min_framesize, max_framesize;
@@ -112,6 +113,9 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx) · 27 unmodified lines
112113 s->avctx = avctx;
113114 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
114115
116+ avcodec_get_frame_defaults(&s->frame);
117+ avctx->coded_frame = &s->frame;
118+
115119 return 0;
116120 }
117121
@@ -394,15 +398,13 @@ static int read_header(ShortenContext *s) · 276 unmodified lines
394398 return 0;
395399 }
396400
397−static int shorten_decode_frame(AVCodecContext *avctx,
398− void *data, int *data_size,
399− AVPacket *avpkt)
401+static int shorten_decode_frame(AVCodecContext *avctx, void *data,
402+ int *got_frame_ptr, AVPacket *avpkt)
400403 {
401404 const uint8_t *buf = avpkt->data;
402405 int buf_size = avpkt->size;
403406 ShortenContext *s = avctx->priv_data;
404407 int i, input_buf_size = 0;
405− int16_t *samples = data;
406408 int ret;
407409
408410 /* allocate internal bitstream buffer */
@@ -436,7 +438,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 27 unmodified lines
436438 /* do not decode until buffer has at least max_framesize bytes or
437439 the end of the file has been reached */
438440 if (buf_size < s->max_framesize && avpkt->data) {
439− *data_size = 0;
441+ *got_frame_ptr = 0;
440442 return input_buf_size;
441443 }
442444 }
@@ -448,13 +450,13 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 5 unmodified lines
448450 if (!s->got_header) {
449451 if ((ret = read_header(s)) < 0)
450452 return ret;
451− *data_size = 0;
453+ *got_frame_ptr = 0;
452454 goto finish_frame;
453455 }
454456
455457 /* if quit command was read previously, don't decode anything */
456458 if (s->got_quit_command) {
457− *data_size = 0;
459+ *got_frame_ptr = 0;
458460 return avpkt->size;
459461 }
460462
@@ -464,7 +466,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 3 unmodified lines
464466 int len;
465467
466468 if (get_bits_left(&s->gb) < 3+FNSIZE) {
467− *data_size = 0;
469+ *got_frame_ptr = 0;
468470 break;
469471 }
470472
@@ -472,7 +474,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 1 unmodified line
472474
473475 if (cmd > FN_VERBATIM) {
474476 av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);
475− *data_size = 0;
477+ *got_frame_ptr = 0;
476478 break;
477479 }
478480
@@ -507,7 +509,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 28 unmodified lines
507509 break;
508510 }
509511 if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {
510− *data_size = 0;
512+ *got_frame_ptr = 0;
511513 break;
512514 }
513515 } else {
@@ -571,19 +573,23 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 57 unmodified lines
571573 /* if this is the last channel in the block, output the samples */
572574 s->cur_chan++;
573575 if (s->cur_chan == s->channels) {
574− int out_size = s->blocksize * s->channels *
575− av_get_bytes_per_sample(avctx->sample_fmt);
576− if (*data_size < out_size) {
577− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
578− return AVERROR(EINVAL);
576+ /* get output buffer */
577+ s->frame.nb_samples = s->blocksize;
578+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
579+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
580+ return ret;
579581 }
580− interleave_buffer(samples, s->channels, s->blocksize, s->decoded);
581− *data_size = out_size;
582+ /* interleave output */
583+ interleave_buffer((int16_t *)s->frame.data[0], s->channels,
584+ s->blocksize, s->decoded);
585+
586+ *got_frame_ptr = 1;
587+ *(AVFrame *)data = s->frame;
582588 }
583589 }
584590 }
585591 if (s->cur_chan < s->channels)
586− *data_size = 0;
592+ *got_frame_ptr = 0;
587593
588594 finish_frame:
589595 s->bitindex = get_bits_count(&s->gb) - 8*((get_bits_count(&s->gb))/8);
@@ -614,6 +620,7 @@ static av_cold int shorten_decode_close(AVCodecContext *avctx) · 24 unmodified lines
614620 }
615621 av_freep(&s->bitstream);
616622 av_freep(&s->coeffs);
623+
617624 return 0;
618625 }
619626
@@ -625,6 +632,6 @@ AVCodec ff_shorten_decoder = { · 5 unmodified lines
625632 .init = shorten_decode_init,
626633 .close = shorten_decode_close,
627634 .decode = shorten_decode_frame,
628− .capabilities = CODEC_CAP_DELAY,
635+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
629636 .long_name= NULL_IF_CONFIG_SMALL("Shorten"),
630637 };
libavcodec/sipr.c+19−15
@@ -507,20 +507,23 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx) · 506 unmodified lines
507507
508508 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
509509
510+ avcodec_get_frame_defaults(&ctx->frame);
511+ avctx->coded_frame = &ctx->frame;
512+
510513 return 0;
511514 }
512515
513−static int sipr_decode_frame(AVCodecContext *avctx, void *datap,
514− int *data_size, AVPacket *avpkt)
516+static int sipr_decode_frame(AVCodecContext *avctx, void *data,
517+ int *got_frame_ptr, AVPacket *avpkt)
515518 {
516519 SiprContext *ctx = avctx->priv_data;
517520 const uint8_t *buf=avpkt->data;
518521 SiprParameters parm;
519522 const SiprModeParam *mode_par = &modes[ctx->mode];
520523 GetBitContext gb;
521− float *data = datap;
524+ float *samples;
522525 int subframe_size = ctx->mode == MODE_16k ? L_SUBFR_16k : SUBFR_SIZE;
523− int i, out_size;
526+ int i, ret;
524527
525528 ctx->avctx = avctx;
526529 if (avpkt->size < (mode_par->bits_per_frame >> 3)) {
@@ -530,27 +533,27 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap, · 3 unmodified lines
530533 return -1;
531534 }
532535
533− out_size = mode_par->frames_per_packet * subframe_size *
534− mode_par->subframe_count *
535− av_get_bytes_per_sample(avctx->sample_fmt);
536− if (*data_size < out_size) {
537− av_log(avctx, AV_LOG_ERROR,
538− "Error processing packet: output buffer (%d) too small\n",
539− *data_size);
540− return -1;
536+ /* get output buffer */
537+ ctx->frame.nb_samples = mode_par->frames_per_packet * subframe_size *
538+ mode_par->subframe_count;
539+ if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
540+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
541+ return ret;
541542 }
543+ samples = (float *)ctx->frame.data[0];
542544
543545 init_get_bits(&gb, buf, mode_par->bits_per_frame);
544546
545547 for (i = 0; i < mode_par->frames_per_packet; i++) {
546548 decode_parameters(&parm, &gb, mode_par);
547549
548− ctx->decode_frame(ctx, &parm, data);
550+ ctx->decode_frame(ctx, &parm, samples);
549551
550− data += subframe_size * mode_par->subframe_count;
552+ samples += subframe_size * mode_par->subframe_count;
551553 }
552554
553− *data_size = out_size;
555+ *got_frame_ptr = 1;
556+ *(AVFrame *)data = ctx->frame;
554557
555558 return mode_par->bits_per_frame >> 3;
556559 }
@@ -562,5 +565,6 @@ AVCodec ff_sipr_decoder = { · 5 unmodified lines
562565 .priv_data_size = sizeof(SiprContext),
563566 .init = sipr_decoder_init,
564567 .decode = sipr_decode_frame,
568+ .capabilities = CODEC_CAP_DR1,
565569 .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
566570 };
libavcodec/smacker.c+31−10
@@ -559,31 +559,43 @@ static av_cold int decode_end(AVCodecContext *avctx) · 558 unmodified lines
559559 }
560560
561561
562+typedef struct SmackerAudioContext {
563+ AVFrame frame;
564+} SmackerAudioContext;
565+
562566 static av_cold int smka_decode_init(AVCodecContext *avctx)
563567 {
568+ SmackerAudioContext *s = avctx->priv_data;
569+
564570 if (avctx->channels < 1 || avctx->channels > 2) {
565571 av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n");
566572 return AVERROR(EINVAL);
567573 }
568574 avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
569575 avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16;
576+
577+ avcodec_get_frame_defaults(&s->frame);
578+ avctx->coded_frame = &s->frame;
579+
570580 return 0;
571581 }
572582
573583 /**
574584 * Decode Smacker audio data
575585 */
576−static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
586+static int smka_decode_frame(AVCodecContext *avctx, void *data,
587+ int *got_frame_ptr, AVPacket *avpkt)
577588 {
589+ SmackerAudioContext *s = avctx->priv_data;
578590 const uint8_t *buf = avpkt->data;
579591 int buf_size = avpkt->size;
580592 GetBitContext gb;
581593 HuffContext h[4];
582594 VLC vlc[4];
583− int16_t *samples = data;
584− uint8_t *samples8 = data;
595+ int16_t *samples;
596+ uint8_t *samples8;
585597 int val;
586− int i, res;
598+ int i, res, ret;
587599 int unp_size;
588600 int bits, stereo;
589601 int pred[2] = {0, 0};
@@ -599,15 +611,11 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 9 unmodified lines
599611
600612 if(!get_bits1(&gb)){
601613 av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
602− *data_size = 0;
614+ *got_frame_ptr = 0;
603615 return 1;
604616 }
605617 stereo = get_bits1(&gb);
606618 bits = get_bits1(&gb);
607− if (unp_size & 0xC0000000 || unp_size > *data_size) {
608− av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
609− return -1;
610− }
611619 if (stereo ^ (avctx->channels != 1)) {
612620 av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
613621 return AVERROR(EINVAL);
@@ -617,6 +625,15 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 3 unmodified lines
617625 return AVERROR(EINVAL);
618626 }
619627
628+ /* get output buffer */
629+ s->frame.nb_samples = unp_size / (avctx->channels * (bits + 1));
630+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
631+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
632+ return ret;
633+ }
634+ samples = (int16_t *)s->frame.data[0];
635+ samples8 = s->frame.data[0];
636+
620637 memset(vlc, 0, sizeof(VLC) * 4);
621638 memset(h, 0, sizeof(HuffContext) * 4);
622639 // Initialize
@@ -706,7 +723,9 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 83 unmodified lines
706723 av_free(h[i].values);
707724 }
708725
709− *data_size = unp_size;
726+ *got_frame_ptr = 1;
727+ *(AVFrame *)data = s->frame;
728+
710729 return buf_size;
711730 }
712731
@@ -726,8 +745,10 @@ AVCodec ff_smackaud_decoder = { · 13 unmodified lines
726745 .name = "smackaud",
727746 .type = AVMEDIA_TYPE_AUDIO,
728747 .id = CODEC_ID_SMACKAUDIO,
748+ .priv_data_size = sizeof(SmackerAudioContext),
729749 .init = smka_decode_init,
730750 .decode = smka_decode_frame,
751+ .capabilities = CODEC_CAP_DR1,
731752 .long_name = NULL_IF_CONFIG_SMALL("Smacker audio"),
732753 };
733754
libavcodec/svq1dec.c+2−1
@@ -195,7 +195,8 @@ static const uint8_t string_table[256] = { · 194 unmodified lines
195195
196196 #define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)\
197197 codebook = (const uint32_t *) cbook[level];\
198− bit_cache = get_bits (bitbuf, 4*stages);\
198+ if (stages > 0)\
199+ bit_cache = get_bits (bitbuf, 4*stages);\
199200 /* calculate codebook entries for this vector */\
200201 for (j=0; j < stages; j++) {\
201202 entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1);\
libavcodec/truespeech.c+18−11
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 * TrueSpeech decoder context
3535 */
3636 typedef struct {
37+ AVFrame frame;
3738 DSPContext dsp;
3839 /* input data */
3940 uint8_t buffer[32];
@@ -69,6 +70,9 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx) · 29 unmodified lines
6970
7071 dsputil_init(&c->dsp, avctx);
7172
73+ avcodec_get_frame_defaults(&c->frame);
74+ avctx->coded_frame = &c->frame;
75+
7276 return 0;
7377 }
7478
@@ -299,17 +303,16 @@ static void truespeech_save_prevvec(TSContext *c) · 224 unmodified lines
299303 c->prevfilt[i] = c->cvector[i];
300304 }
301305
302−static int truespeech_decode_frame(AVCodecContext *avctx,
303− void *data, int *data_size,
304− AVPacket *avpkt)
306+static int truespeech_decode_frame(AVCodecContext *avctx, void *data,
307+ int *got_frame_ptr, AVPacket *avpkt)
305308 {
306309 const uint8_t *buf = avpkt->data;
307310 int buf_size = avpkt->size;
308311 TSContext *c = avctx->priv_data;
309312
310313 int i, j;
311− short *samples = data;
312− int iterations, out_size;
314+ int16_t *samples;
315+ int iterations, ret;
313316
314317 iterations = buf_size / 32;
315318
@@ -319,13 +322,15 @@ static int truespeech_decode_frame(AVCodecContext *avctx, · 3 unmodified lines
319322 return -1;
320323 }
321324
322− out_size = iterations * 240 * av_get_bytes_per_sample(avctx->sample_fmt);
323− if (*data_size < out_size) {
324− av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
325− return AVERROR(EINVAL);
325+ /* get output buffer */
326+ c->frame.nb_samples = iterations * 240;
327+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
328+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
329+ return ret;
326330 }
331+ samples = (int16_t *)c->frame.data[0];
327332
328− memset(samples, 0, out_size);
333+ memset(samples, 0, iterations * 240 * sizeof(*samples));
329334
330335 for(j = 0; j < iterations; j++) {
331336 truespeech_read_frame(c, buf);
@@ -345,7 +350,8 @@ static int truespeech_decode_frame(AVCodecContext *avctx, · 13 unmodified lines
345350 truespeech_save_prevvec(c);
346351 }
347352
348− *data_size = out_size;
353+ *got_frame_ptr = 1;
354+ *(AVFrame *)data = c->frame;
349355
350356 return buf_size;
351357 }
@@ -357,5 +363,6 @@ AVCodec ff_truespeech_decoder = { · 5 unmodified lines
357363 .priv_data_size = sizeof(TSContext),
358364 .init = truespeech_decode_init,
359365 .decode = truespeech_decode_frame,
366+ .capabilities = CODEC_CAP_DR1,
360367 .long_name = NULL_IF_CONFIG_SMALL("DSP Group TrueSpeech"),
361368 };
libavcodec/tta.c+18−12
@@ -56,6 +56,7 @@ typedef struct TTAChannel { · 55 unmodified lines
5656
5757 typedef struct TTAContext {
5858 AVCodecContext *avctx;
59+ AVFrame frame;
5960 GetBitContext gb;
6061
6162 int format, channels, bps, data_length;
@@ -288,17 +289,19 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) · 226 unmodified lines
288289 return -1;
289290 }
290291
292+ avcodec_get_frame_defaults(&s->frame);
293+ avctx->coded_frame = &s->frame;
294+
291295 return 0;
292296 }
293297
294−static int tta_decode_frame(AVCodecContext *avctx,
295− void *data, int *data_size,
296− AVPacket *avpkt)
298+static int tta_decode_frame(AVCodecContext *avctx, void *data,
299+ int *got_frame_ptr, AVPacket *avpkt)
297300 {
298301 const uint8_t *buf = avpkt->data;
299302 int buf_size = avpkt->size;
300303 TTAContext *s = avctx->priv_data;
301− int i, out_size;
304+ int i, ret;
302305 int cur_chan = 0, framelen = s->frame_length;
303306 int32_t *p;
304307
@@ -309,10 +312,11 @@ static int tta_decode_frame(AVCodecContext *avctx, · 4 unmodified lines
309312 if (!s->total_frames && s->last_frame_length)
310313 framelen = s->last_frame_length;
311314
312− out_size = framelen * s->channels * av_get_bytes_per_sample(avctx->sample_fmt);
313− if (*data_size < out_size) {
314− av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n");
315− return -1;
315+ /* get output buffer */
316+ s->frame.nb_samples = framelen;
317+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
318+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
319+ return ret;
316320 }
317321
318322 // decode directly to output buffer for 24-bit sample format
@@ -409,20 +413,20 @@ static int tta_decode_frame(AVCodecContext *avctx, · 90 unmodified lines
409413 // convert to output buffer
410414 switch(s->bps) {
411415 case 1: {
412− uint8_t *samples = data;
416+ uint8_t *samples = (int16_t *)s->frame.data[0];
413417 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
414418 *samples++ = *p + 0x80;
415419 break;
416420 }
417421 case 2: {
418− uint16_t *samples = data;
422+ uint16_t *samples = (int16_t *)s->frame.data[0];
419423 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
420424 *samples++ = *p;
421425 break;
422426 }
423427 case 3: {
424428 // shift samples for 24-bit sample format
425− int32_t *samples = data;
429+ int32_t *samples = (int16_t *)s->frame.data[0];
426430 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
427431 *samples++ <<= 8;
428432 // reset decode buffer
@@ -433,7 +437,8 @@ static int tta_decode_frame(AVCodecContext *avctx, · 4 unmodified lines
433437 av_log(s->avctx, AV_LOG_ERROR, "Error, only 16bit samples supported!\n");
434438 }
435439
436− *data_size = out_size;
440+ *got_frame_ptr = 1;
441+ *(AVFrame *)data = s->frame;
437442
438443 return buf_size;
439444 }
@@ -455,5 +460,6 @@ AVCodec ff_tta_decoder = { · 15 unmodified lines
455460 .init = tta_decode_init,
456461 .close = tta_decode_close,
457462 .decode = tta_decode_frame,
463+ .capabilities = CODEC_CAP_DR1,
458464 .long_name = NULL_IF_CONFIG_SMALL("True Audio (TTA)"),
459465 };
libavcodec/twinvq.c+25−11
@@ -174,6 +174,7 @@ static const ModeTab mode_44_48 = { · 173 unmodified lines
174174
175175 typedef struct TwinContext {
176176 AVCodecContext *avctx;
177+ AVFrame frame;
177178 DSPContext dsp;
178179 FFTContext mdct_ctx[3];
179180
@@ -195,6 +196,7 @@ typedef struct TwinContext { · 15 unmodified lines
195196 float *curr_frame; ///< non-interleaved output
196197 float *prev_frame; ///< non-interleaved previous frame
197198 int last_block_pos[2];
199+ int discarded_packets;
198200
199201 float *cos_tabs[3];
200202
@@ -676,6 +678,9 @@ static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, · 475 unmodified lines
676678 i);
677679 }
678680
681+ if (!out)
682+ return;
683+
679684 size2 = tctx->last_block_pos[0];
680685 size1 = mtab->size - size2;
681686 if (tctx->avctx->channels == 2) {
@@ -811,16 +816,16 @@ static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb, · 129 unmodified lines
811816 }
812817
813818 static int twin_decode_frame(AVCodecContext * avctx, void *data,
814− int *data_size, AVPacket *avpkt)
819+ int *got_frame_ptr, AVPacket *avpkt)
815820 {
816821 const uint8_t *buf = avpkt->data;
817822 int buf_size = avpkt->size;
818823 TwinContext *tctx = avctx->priv_data;
819824 GetBitContext gb;
820825 const ModeTab *mtab = tctx->mtab;
821− float *out = data;
826+ float *out = NULL;
822827 enum FrameType ftype;
823− int window_type, out_size;
828+ int window_type, ret;
824829 static const enum FrameType wtype_to_ftype_table[] = {
825830 FT_LONG, FT_LONG, FT_SHORT, FT_LONG,
826831 FT_MEDIUM, FT_LONG, FT_LONG, FT_MEDIUM, FT_MEDIUM
@@ -832,11 +837,14 @@ static int twin_decode_frame(AVCodecContext * avctx, void *data, · 5 unmodified lines
832837 return AVERROR(EINVAL);
833838 }
834839
835− out_size = mtab->size * avctx->channels *
836− av_get_bytes_per_sample(avctx->sample_fmt);
837− if (*data_size < out_size) {
838− av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
839− return AVERROR(EINVAL);
840+ /* get output buffer */
841+ if (tctx->discarded_packets >= 2) {
842+ tctx->frame.nb_samples = mtab->size;
843+ if ((ret = avctx->get_buffer(avctx, &tctx->frame)) < 0) {
844+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
845+ return ret;
846+ }
847+ out = (float *)tctx->frame.data[0];
840848 }
841849
842850 init_get_bits(&gb, buf, buf_size * 8);
@@ -856,12 +864,14 @@ static int twin_decode_frame(AVCodecContext * avctx, void *data, · 13 unmodified lines
856864
857865 FFSWAP(float*, tctx->curr_frame, tctx->prev_frame);
858866
859− if (tctx->avctx->frame_number < 2) {
860− *data_size=0;
867+ if (tctx->discarded_packets < 2) {
868+ tctx->discarded_packets++;
869+ *got_frame_ptr = 0;
861870 return buf_size;
862871 }
863872
864− *data_size = out_size;
873+ *got_frame_ptr = 1;
874+ *(AVFrame *)data = tctx->frame;;
865875
866876 return buf_size;
867877 }
@@ -1153,6 +1163,9 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) · 285 unmodified lines
11531163
11541164 memset_float(tctx->bark_hist[0][0], 0.1, FF_ARRAY_ELEMS(tctx->bark_hist));
11551165
1166+ avcodec_get_frame_defaults(&tctx->frame);
1167+ avctx->coded_frame = &tctx->frame;
1168+
11561169 return 0;
11571170 }
11581171
@@ -1164,5 +1177,6 @@ AVCodec ff_twinvq_decoder = { · 5 unmodified lines
11641177 .init = twin_decode_init,
11651178 .close = twin_decode_close,
11661179 .decode = twin_decode_frame,
1180+ .capabilities = CODEC_CAP_DR1,
11671181 .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"),
11681182 };
libavcodec/utils.c+224−33
@@ -127,7 +127,10 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height){ · 126 unmodified lines
127127
128128 #define INTERNAL_BUFFER_SIZE (32+1)
129129
130−void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){
130+void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
131+ int linesize_align[AV_NUM_DATA_POINTERS])
132+{
133+ int i;
131134 int w_align= 1;
132135 int h_align= 1;
133136
@@ -213,10 +216,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l · 79 unmodified lines
213216 *height+=2; // some of the optimized chroma MC reads one line too much
214217 // which is also done in mpeg decoders with lowres > 0
215218
216− linesize_align[0] =
217− linesize_align[1] =
218− linesize_align[2] =
219− linesize_align[3] = STRIDE_ALIGN;
219+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
220+ linesize_align[i] = STRIDE_ALIGN;
220221 //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes
221222 //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the
222223 //picture size unneccessarily in some cases. The solution here is not
@@ -225,16 +226,15 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l · 2 unmodified lines
225226 if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||
226227 s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||
227228 s->codec_id == CODEC_ID_VP6A || s->codec_id == CODEC_ID_DIRAC) {
228− linesize_align[0] =
229− linesize_align[1] =
230− linesize_align[2] = 16;
229+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
230+ linesize_align[i] = 16;
231231 }
232232 #endif
233233 }
234234
235235 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
236236 int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w;
237− int linesize_align[4];
237+ int linesize_align[AV_NUM_DATA_POINTERS];
238238 int align;
239239 avcodec_align_dimensions2(s, width, height, linesize_align);
240240 align = FFMAX(linesize_align[0], linesize_align[3]);
@@ -260,7 +260,108 @@ void ff_init_buffer_info(AVCodecContext *s, AVFrame *pic) · 19 unmodified lines
260260 pic->format = s->pix_fmt;
261261 }
262262
263−int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
263+static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
264+{
265+ AVCodecInternal *avci = avctx->internal;
266+ InternalBuffer *buf;
267+ int buf_size, ret, i, needs_extended_data;
268+
269+ buf_size = av_samples_get_buffer_size(NULL, avctx->channels,
270+ frame->nb_samples, avctx->sample_fmt,
271+ 32);
272+ if (buf_size < 0)
273+ return AVERROR(EINVAL);
274+
275+ needs_extended_data = av_sample_fmt_is_planar(avctx->sample_fmt) &&
276+ avctx->channels > AV_NUM_DATA_POINTERS;
277+
278+ /* allocate InternalBuffer if needed */
279+ if (!avci->buffer) {
280+ avci->buffer = av_mallocz(sizeof(InternalBuffer));
281+ if (!avci->buffer)
282+ return AVERROR(ENOMEM);
283+ }
284+ buf = avci->buffer;
285+
286+ /* if there is a previously-used internal buffer, check its size and
287+ channel count to see if we can reuse it */
288+ if (buf->extended_data) {
289+ /* if current buffer is too small, free it */
290+ if (buf->extended_data[0] && buf_size > buf->audio_data_size) {
291+ av_free(buf->extended_data[0]);
292+ if (buf->extended_data != buf->data)
293+ av_free(&buf->extended_data);
294+ buf->extended_data = NULL;
295+ buf->data[0] = NULL;
296+ }
297+ /* if number of channels has changed, reset and/or free extended data
298+ pointers but leave data buffer in buf->data[0] for reuse */
299+ if (buf->nb_channels != avctx->channels) {
300+ if (buf->extended_data != buf->data)
301+ av_free(buf->extended_data);
302+ buf->extended_data = NULL;
303+ }
304+ }
305+
306+ /* if there is no previous buffer or the previous buffer cannot be used
307+ as-is, allocate a new buffer and/or rearrange the channel pointers */
308+ if (!buf->extended_data) {
309+ /* if the channel pointers will fit, just set extended_data to data,
310+ otherwise allocate the extended_data channel pointers */
311+ if (needs_extended_data) {
312+ buf->extended_data = av_mallocz(avctx->channels *
313+ sizeof(*buf->extended_data));
314+ if (!buf->extended_data)
315+ return AVERROR(ENOMEM);
316+ } else {
317+ buf->extended_data = buf->data;
318+ }
319+
320+ /* if there is a previous buffer and it is large enough, reuse it and
321+ just fill-in new channel pointers and linesize, otherwise allocate
322+ a new buffer */
323+ if (buf->extended_data[0]) {
324+ ret = av_samples_fill_arrays(buf->extended_data, &buf->linesize[0],
325+ buf->extended_data[0], avctx->channels,
326+ frame->nb_samples, avctx->sample_fmt,
327+ 32);
328+ } else {
329+ ret = av_samples_alloc(buf->extended_data, &buf->linesize[0],
330+ avctx->channels, frame->nb_samples,
331+ avctx->sample_fmt, 32);
332+ }
333+ if (ret)
334+ return ret;
335+
336+ /* if data was not used for extended_data, we need to copy as many of
337+ the extended_data channel pointers as will fit */
338+ if (needs_extended_data) {
339+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
340+ buf->data[i] = buf->extended_data[i];
341+ }
342+ buf->audio_data_size = buf_size;
343+ buf->nb_channels = avctx->channels;
344+ }
345+
346+ /* copy InternalBuffer info to the AVFrame */
347+ frame->type = FF_BUFFER_TYPE_INTERNAL;
348+ frame->extended_data = buf->extended_data;
349+ frame->linesize[0] = buf->linesize[0];
350+ memcpy(frame->data, buf->data, sizeof(frame->data));
351+
352+ if (avctx->pkt) frame->pkt_pts = avctx->pkt->pts;
353+ else frame->pkt_pts = AV_NOPTS_VALUE;
354+ frame->reordered_opaque = avctx->reordered_opaque;
355+
356+ if (avctx->debug & FF_DEBUG_BUFFERS)
357+ av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p, "
358+ "internal audio buffer used\n", frame);
359+
360+ return 0;
361+}
362+
363+static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
364+{
264365 int i;
265366 int w= s->width;
266367 int h= s->height;
@@ -295,7 +396,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 28 unmodified lines
295396 return -1;
296397 }
297398
298− for(i=0; i<4; i++){
399+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
299400 av_freep(&buf->base[i]);
300401 buf->data[i]= NULL;
301402 }
@@ -310,7 +411,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 8 unmodified lines
310411 int tmpsize;
311412 int unaligned;
312413 AVPicture picture;
313− int stride_align[4];
414+ int stride_align[AV_NUM_DATA_POINTERS];
314415 const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
315416
316417 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
@@ -363,6 +464,10 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 46 unmodified lines
363464 else
364465 buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (pixel_size*EDGE_WIDTH>>h_shift), stride_align[i]);
365466 }
467+ for (; i < AV_NUM_DATA_POINTERS; i++) {
468+ buf->base[i] = buf->data[i] = NULL;
469+ buf->linesize[i] = 0;
470+ }
366471 if(size[1] && !size[2])
367472 ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt);
368473 buf->width = s->width;
@@ -372,11 +477,12 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 3 unmodified lines
372477 }
373478 pic->type= FF_BUFFER_TYPE_INTERNAL;
374479
375− for(i=0; i<4; i++){
480+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
376481 pic->base[i]= buf->base[i];
377482 pic->data[i]= buf->data[i];
378483 pic->linesize[i]= buf->linesize[i];
379484 }
485+ pic->extended_data = pic->data;
380486 avci->buffer_count++;
381487
382488 if (s->pkt) {
@@ -399,11 +505,25 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 16 unmodified lines
399505 return 0;
400506 }
401507
508+int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
509+{
510+ switch (avctx->codec_type) {
511+ case AVMEDIA_TYPE_VIDEO:
512+ return video_get_buffer(avctx, frame);
513+ case AVMEDIA_TYPE_AUDIO:
514+ return audio_get_buffer(avctx, frame);
515+ default:
516+ return -1;
517+ }
518+}
519+
402520 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
403521 int i;
404522 InternalBuffer *buf, *last;
405523 AVCodecInternal *avci = s->internal;
406524
525+ assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
526+
407527 assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
408528 assert(avci->buffer_count);
409529
@@ -421,7 +541,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ · 11 unmodified lines
421541 FFSWAP(InternalBuffer, *buf, *last);
422542 }
423543
424− for(i=0; i<4; i++){
544+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
425545 pic->data[i]=NULL;
426546 // pic->base[i]=NULL;
427547 }
@@ -436,6 +556,8 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ · 8 unmodified lines
436556 AVFrame temp_pic;
437557 int i;
438558
559+ assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
560+
439561 /* If no picture return a new buffer */
440562 if(pic->data[0] == NULL) {
441563 /* We will copy from buffer, so must be readable */
@@ -455,7 +577,7 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ · 13 unmodified lines
455577 * Not internal type and reget_buffer not overridden, emulate cr buffer
456578 */
457579 temp_pic = *pic;
458− for(i = 0; i < 4; i++)
580+ for(i = 0; i < AV_NUM_DATA_POINTERS; i++)
459581 pic->data[i] = pic->base[i] = NULL;
460582 pic->opaque = NULL;
461583 /* Allocate new frame */
@@ -862,36 +984,73 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi · 400 unmodified lines
862984 return ret;
863985 }
864986
987+#if FF_API_OLD_DECODE_AUDIO
865988 int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
866989 int *frame_size_ptr,
867990 AVPacket *avpkt)
868991 {
869− int ret;
992+ AVFrame frame;
993+ int ret, got_frame = 0;
994+
995+ if (avctx->get_buffer != avcodec_default_get_buffer) {
996+ av_log(avctx, AV_LOG_ERROR, "A custom get_buffer() cannot be used with "
997+ "avcodec_decode_audio3()\n");
998+ return AVERROR(EINVAL);
999+ }
1000+
1001+ ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt);
1002+
1003+ if (ret >= 0 && got_frame) {
1004+ int ch, plane_size;
1005+ int planar = av_sample_fmt_is_planar(avctx->sample_fmt);
1006+ int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels,
1007+ frame.nb_samples,
1008+ avctx->sample_fmt, 1);
1009+ if (*frame_size_ptr < data_size) {
1010+ av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for "
1011+ "the current frame (%d < %d)\n", *frame_size_ptr, data_size);
1012+ return AVERROR(EINVAL);
1013+ }
1014+
1015+ memcpy(samples, frame.extended_data[0], plane_size);
1016+
1017+ if (planar && avctx->channels > 1) {
1018+ uint8_t *out = ((uint8_t *)samples) + plane_size;
1019+ for (ch = 1; ch < avctx->channels; ch++) {
1020+ memcpy(out, frame.extended_data[ch], plane_size);
1021+ out += plane_size;
1022+ }
1023+ }
1024+ *frame_size_ptr = data_size;
1025+ } else {
1026+ *frame_size_ptr = 0;
1027+ }
1028+ return ret;
1029+}
1030+#endif
1031+
1032+int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
1033+ AVFrame *frame,
1034+ int *got_frame_ptr,
1035+ AVPacket *avpkt)
1036+{
1037+ int ret = 0;
1038+
1039+ *got_frame_ptr = 0;
8701040
8711041 if (!avpkt->data && avpkt->size) {
8721042 av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
8731043 return AVERROR(EINVAL);
8741044 }
8751045
876− if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
1046+ if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
8771047 av_packet_split_side_data(avpkt);
8781048 avctx->pkt = avpkt;
879− //FIXME remove the check below _after_ ensuring that all audio check that the available space is enough
880− if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
881− av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
882− return -1;
883− }
884− if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
885− *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t)){
886− av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
887− return -1;
1049+ ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
1050+ if (ret >= 0 && *got_frame_ptr) {
1051+ avctx->frame_number++;
1052+ frame->pkt_dts = avpkt->dts;
8881053 }
889−
890− ret = avctx->codec->decode(avctx, samples, frame_size_ptr, avpkt);
891− avctx->frame_number++;
892− }else{
893− ret= 0;
894− *frame_size_ptr=0;
8951054 }
8961055 return ret;
8971056 }
@@ -1230,7 +1389,8 @@ void avcodec_flush_buffers(AVCodecContext *avctx) · 332 unmodified lines
12301389 avctx->codec->flush(avctx);
12311390 }
12321391
1233−void avcodec_default_free_buffers(AVCodecContext *s){
1392+static void video_free_buffers(AVCodecContext *s)
1393+{
12341394 AVCodecInternal *avci = s->internal;
12351395 int i, j;
12361396
@@ -1252,6 +1412,37 @@ void avcodec_default_free_buffers(AVCodecContext *s){ · 15 unmodified lines
12521412 avci->buffer_count=0;
12531413 }
12541414
1415+static void audio_free_buffers(AVCodecContext *avctx)
1416+{
1417+ AVCodecInternal *avci = avctx->internal;
1418+ InternalBuffer *buf;
1419+
1420+ if (!avci->buffer)
1421+ return;
1422+ buf = avci->buffer;
1423+
1424+ if (buf->extended_data) {
1425+ av_free(buf->extended_data[0]);
1426+ if (buf->extended_data != buf->data)
1427+ av_free(buf->extended_data);
1428+ }
1429+ av_freep(&avci->buffer);
1430+}
1431+
1432+void avcodec_default_free_buffers(AVCodecContext *avctx)
1433+{
1434+ switch (avctx->codec_type) {
1435+ case AVMEDIA_TYPE_VIDEO:
1436+ video_free_buffers(avctx);
1437+ break;
1438+ case AVMEDIA_TYPE_AUDIO:
1439+ audio_free_buffers(avctx);
1440+ break;
1441+ default:
1442+ break;
1443+ }
1444+}
1445+
12551446 #if FF_API_OLD_FF_PICT_TYPES
12561447 char av_get_pict_type_char(int pict_type){
12571448 return av_get_picture_type_char(pict_type);
libavcodec/version.h+8−3
@@ -21,8 +21,8 @@ · 20 unmodified lines
2121 #define AVCODEC_VERSION_H
2222
2323 #define LIBAVCODEC_VERSION_MAJOR 53
24−#define LIBAVCODEC_VERSION_MINOR 39
25−#define LIBAVCODEC_VERSION_MICRO 1
24+#define LIBAVCODEC_VERSION_MINOR 40
25+#define LIBAVCODEC_VERSION_MICRO 0
2626
2727 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
2828 LIBAVCODEC_VERSION_MINOR, \
@@ -110,6 +110,11 @@ · 81 unmodified lines
110110 #ifndef FF_API_TIFFENC_COMPLEVEL
111111 #define FF_API_TIFFENC_COMPLEVEL (LIBAVCODEC_VERSION_MAJOR < 54)
112112 #endif
113−
113+#ifndef FF_API_DATA_POINTERS
114+#define FF_API_DATA_POINTERS (LIBAVCODEC_VERSION_MAJOR < 54)
115+#endif
116+#ifndef FF_API_OLD_DECODE_AUDIO
117+#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 54)
118+#endif
114119
115120 #endif /* AVCODEC_VERSION_H */
libavcodec/vmdav.c+23−12
@@ -466,6 +466,7 @@ static av_cold int vmdvideo_decode_end(AVCodecContext *avctx) · 465 unmodified lines
466466 #define BLOCK_TYPE_SILENCE 3
467467
468468 typedef struct VmdAudioContext {
469+ AVFrame frame;
469470 int out_bps;
470471 int chunk_size;
471472 } VmdAudioContext;
@@ -507,6 +508,9 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx) · 35 unmodified lines
507508
508509 s->chunk_size = avctx->block_align + avctx->channels * (s->out_bps == 2);
509510
511+ avcodec_get_frame_defaults(&s->frame);
512+ avctx->coded_frame = &s->frame;
513+
510514 av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, "
511515 "block align = %d, sample rate = %d\n",
512516 avctx->channels, avctx->bits_per_coded_sample, avctx->block_align,
@@ -544,22 +548,21 @@ static void decode_audio_s16(int16_t *out, const uint8_t *buf, int buf_size, · 31 unmodified lines
544548 }
545549 }
546550
547−static int vmdaudio_decode_frame(AVCodecContext *avctx,
548− void *data, int *data_size,
549− AVPacket *avpkt)
551+static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
552+ int *got_frame_ptr, AVPacket *avpkt)
550553 {
551554 const uint8_t *buf = avpkt->data;
552555 const uint8_t *buf_end;
553556 int buf_size = avpkt->size;
554557 VmdAudioContext *s = avctx->priv_data;
555558 int block_type, silent_chunks, audio_chunks;
556− int nb_samples, out_size;
557− uint8_t *output_samples_u8 = data;
558− int16_t *output_samples_s16 = data;
559+ int ret;
560+ uint8_t *output_samples_u8;
561+ int16_t *output_samples_s16;
559562
560563 if (buf_size < 16) {
561564 av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
562− *data_size = 0;
565+ *got_frame_ptr = 0;
563566 return buf_size;
564567 }
565568
@@ -590,10 +593,15 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, · 24 unmodified lines
590593
591594 /* ensure output buffer is large enough */
592595 audio_chunks = buf_size / s->chunk_size;
593− nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels;
594− out_size = nb_samples * avctx->channels * s->out_bps;
595− if (*data_size < out_size)
596− return -1;
596+
597+ /* get output buffer */
598+ s->frame.nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels;
599+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
600+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
601+ return ret;
602+ }
603+ output_samples_u8 = s->frame.data[0];
604+ output_samples_s16 = (int16_t *)s->frame.data[0];
597605
598606 /* decode silent chunks */
599607 if (silent_chunks > 0) {
@@ -623,7 +631,9 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, · 23 unmodified lines
623631 }
624632 }
625633
626− *data_size = out_size;
634+ *got_frame_ptr = 1;
635+ *(AVFrame *)data = s->frame;
636+
627637 return avpkt->size;
628638 }
629639
@@ -651,5 +661,6 @@ AVCodec ff_vmdaudio_decoder = { · 21 unmodified lines
651661 .priv_data_size = sizeof(VmdAudioContext),
652662 .init = vmdaudio_decode_init,
653663 .decode = vmdaudio_decode_frame,
664+ .capabilities = CODEC_CAP_DR1,
654665 .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"),
655666 };
libavcodec/vorbisdec.c+20−13
@@ -125,6 +125,7 @@ typedef struct { · 124 unmodified lines
125125
126126 typedef struct vorbis_context_s {
127127 AVCodecContext *avccontext;
128+ AVFrame frame;
128129 GetBitContext gb;
129130 DSPContext dsp;
130131 FmtConvertContext fmt_conv;
@@ -1037,6 +1038,9 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext) · 906 unmodified lines
10371038 avccontext->sample_rate = vc->audio_samplerate;
10381039 avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2;
10391040
1041+ avcodec_get_frame_defaults(&vc->frame);
1042+ avccontext->coded_frame = &vc->frame;
1043+
10401044 return 0;
10411045 }
10421046
@@ -1609,16 +1613,15 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) · 566 unmodified lines
16091613
16101614 // Return the decoded audio packet through the standard api
16111615
1612−static int vorbis_decode_frame(AVCodecContext *avccontext,
1613− void *data, int *data_size,
1614− AVPacket *avpkt)
1616+static int vorbis_decode_frame(AVCodecContext *avccontext, void *data,
1617+ int *got_frame_ptr, AVPacket *avpkt)
16151618 {
16161619 const uint8_t *buf = avpkt->data;
16171620 int buf_size = avpkt->size;
16181621 vorbis_context *vc = avccontext->priv_data;
16191622 GetBitContext *gb = &(vc->gb);
16201623 const float *channel_ptrs[255];
1621− int i, len, out_size;
1624+ int i, len, ret;
16221625
16231626 av_dlog(NULL, "packet length %d \n", buf_size);
16241627
@@ -1629,18 +1632,18 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, · 4 unmodified lines
16291632
16301633 if (!vc->first_frame) {
16311634 vc->first_frame = 1;
1632− *data_size = 0;
1635+ *got_frame_ptr = 0;
16331636 return buf_size;
16341637 }
16351638
16361639 av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n",
16371640 get_bits_count(gb) / 8, get_bits_count(gb) % 8, len);
16381641
1639− out_size = len * vc->audio_channels *
1640− av_get_bytes_per_sample(avccontext->sample_fmt);
1641− if (*data_size < out_size) {
1642− av_log(avccontext, AV_LOG_ERROR, "output buffer is too small\n");
1643− return AVERROR(EINVAL);
1642+ /* get output buffer */
1643+ vc->frame.nb_samples = len;
1644+ if ((ret = avccontext->get_buffer(avccontext, &vc->frame)) < 0) {
1645+ av_log(avccontext, AV_LOG_ERROR, "get_buffer() failed\n");
1646+ return ret;
16441647 }
16451648
16461649 if (vc->audio_channels > 8) {
@@ -1653,12 +1656,15 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, · 6 unmodified lines
16531656 }
16541657
16551658 if (avccontext->sample_fmt == AV_SAMPLE_FMT_FLT)
1656− vc->fmt_conv.float_interleave(data, channel_ptrs, len, vc->audio_channels);
1659+ vc->fmt_conv.float_interleave((float *)vc->frame.data[0], channel_ptrs,
1660+ len, vc->audio_channels);
16571661 else
1658− vc->fmt_conv.float_to_int16_interleave(data, channel_ptrs, len,
1662+ vc->fmt_conv.float_to_int16_interleave((int16_t *)vc->frame.data[0],
1663+ channel_ptrs, len,
16591664 vc->audio_channels);
16601665
1661− *data_size = out_size;
1666+ *got_frame_ptr = 1;
1667+ *(AVFrame *)data = vc->frame;
16621668
16631669 return buf_size;
16641670 }
@@ -1682,6 +1688,7 @@ AVCodec ff_vorbis_decoder = { · 17 unmodified lines
16821688 .init = vorbis_decode_init,
16831689 .close = vorbis_decode_close,
16841690 .decode = vorbis_decode_frame,
1691+ .capabilities = CODEC_CAP_DR1,
16851692 .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
16861693 .channel_layouts = ff_vorbis_channel_layouts,
16871694 .sample_fmts = (const enum AVSampleFormat[]) {
libavcodec/vp3.c+4−3
@@ -1335,8 +1335,8 @@ end: · 1334 unmodified lines
13351335 */
13361336 static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
13371337 {
1338− int h, cy;
1339− int offset[4];
1338+ int h, cy, i;
1339+ int offset[AV_NUM_DATA_POINTERS];
13401340
13411341 if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
13421342 int y_flipped = s->flipped_image ? s->avctx->height-y : y;
@@ -1362,7 +1362,8 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y) · 19 unmodified lines
13621362 offset[0] = s->current_frame.linesize[0]*y;
13631363 offset[1] = s->current_frame.linesize[1]*cy;
13641364 offset[2] = s->current_frame.linesize[2]*cy;
1365− offset[3] = 0;
1365+ for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
1366+ offset[i] = 0;
13661367
13671368 emms_c();
13681369 s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h);
libavcodec/vp8.c+5−3
@@ -51,8 +51,7 @@ static int vp8_alloc_frame(VP8Context *s, AVFrame *f) · 50 unmodified lines
5151 int ret;
5252 if ((ret = ff_thread_get_buffer(s->avctx, f)) < 0)
5353 return ret;
54− if (s->num_maps_to_be_freed) {
55− assert(!s->maps_are_invalid);
54+ if (s->num_maps_to_be_freed && !s->maps_are_invalid) {
5655 f->ref_index[0] = s->segmentation_maps[--s->num_maps_to_be_freed];
5756 } else if (!(f->ref_index[0] = av_mallocz(s->mb_width * s->mb_height))) {
5857 ff_thread_release_buffer(s->avctx, f);
@@ -1568,13 +1567,15 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 1509 unmodified lines
15681567 VP8Context *s = avctx->priv_data;
15691568 int ret, mb_x, mb_y, i, y, referenced;
15701569 enum AVDiscard skip_thresh;
1571− AVFrame *av_uninit(curframe), *prev_frame = s->framep[VP56_FRAME_CURRENT];
1570+ AVFrame *av_uninit(curframe), *prev_frame;
15721571
15731572 release_queued_segmaps(s, 0);
15741573
15751574 if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0)
15761575 return ret;
15771576
1577+ prev_frame = s->framep[VP56_FRAME_CURRENT];
1578+
15781579 referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT
15791580 || s->update_altref == VP56_FRAME_CURRENT;
15801581
@@ -1815,6 +1816,7 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo · 234 unmodified lines
18151816 if (s->macroblocks_base &&
18161817 (s_src->mb_width != s->mb_width || s_src->mb_height != s->mb_height)) {
18171818 free_buffers(s);
1819+ s->maps_are_invalid = 1;
18181820 }
18191821
18201822 s->prob[0] = s_src->prob[!s_src->update_probabilities];
libavcodec/wavpack.c+44−72
@@ -115,8 +115,6 @@ typedef struct WavpackFrameContext { · 114 unmodified lines
115115 int float_shift;
116116 int float_max_exp;
117117 WvChannel ch[2];
118− int samples_left;
119− int max_samples;
120118 int pos;
121119 SavedContext sc, extra_sc;
122120 } WavpackFrameContext;
@@ -125,6 +123,7 @@ typedef struct WavpackFrameContext { · 2 unmodified lines
125123
126124 typedef struct WavpackContext {
127125 AVCodecContext *avctx;
126+ AVFrame frame;
128127
129128 WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS];
130129 int fdec_num;
@@ -133,7 +132,6 @@ typedef struct WavpackContext { · 2 unmodified lines
133132 int mkv_mode;
134133 int block;
135134 int samples;
136− int samples_left;
137135 int ch_offset;
138136 } WavpackContext;
139137
@@ -485,7 +483,6 @@ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) · 345 unmodified lines
485483 static void wv_reset_saved_context(WavpackFrameContext *s)
486484 {
487485 s->pos = 0;
488− s->samples_left = 0;
489486 s->sc.crc = s->extra_sc.crc = 0xFFFFFFFF;
490487 }
491488
@@ -502,8 +499,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo · 10 unmodified lines
502499 float *dstfl = dst;
503500 const int channel_pad = s->avctx->channels - 2;
504501
505− if(s->samples_left == s->samples)
506− s->one = s->zero = s->zeroes = 0;
502+ s->one = s->zero = s->zeroes = 0;
507503 do{
508504 L = wv_get_value(s, gb, 0, &last);
509505 if(last) break;
@@ -594,13 +590,8 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo · 84 unmodified lines
594590 dst16 += channel_pad;
595591 }
596592 count++;
597− }while(!last && count < s->max_samples);
593+ } while (!last && count < s->samples);
598594
599− if (last)
600− s->samples_left = 0;
601− else
602− s->samples_left -= count;
603− if(!s->samples_left){
604595 wv_reset_saved_context(s);
605596 if(crc != s->CRC){
606597 av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
@@ -610,15 +601,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo · 3 unmodified lines
610601 av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
611602 return -1;
612603 }
613− }else{
614− s->pos = pos;
615− s->sc.crc = crc;
616− s->sc.bits_used = get_bits_count(&s->gb);
617− if(s->got_extra_bits){
618− s->extra_sc.crc = crc_extra_bits;
619− s->extra_sc.bits_used = get_bits_count(&s->gb_extra_bits);
620− }
621− }
604+
622605 return count * 2;
623606 }
624607
@@ -635,8 +618,7 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void · 10 unmodified lines
635618 float *dstfl = dst;
636619 const int channel_stride = s->avctx->channels;
637620
638− if(s->samples_left == s->samples)
639− s->one = s->zero = s->zeroes = 0;
621+ s->one = s->zero = s->zeroes = 0;
640622 do{
641623 T = wv_get_value(s, gb, 0, &last);
642624 S = 0;
@@ -675,13 +657,8 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void · 32 unmodified lines
675657 dst16 += channel_stride;
676658 }
677659 count++;
678− }while(!last && count < s->max_samples);
660+ } while (!last && count < s->samples);
679661
680− if (last)
681− s->samples_left = 0;
682− else
683− s->samples_left -= count;
684− if(!s->samples_left){
685662 wv_reset_saved_context(s);
686663 if(crc != s->CRC){
687664 av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
@@ -691,15 +668,7 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void · 3 unmodified lines
691668 av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
692669 return -1;
693670 }
694− }else{
695− s->pos = pos;
696− s->sc.crc = crc;
697− s->sc.bits_used = get_bits_count(&s->gb);
698− if(s->got_extra_bits){
699− s->extra_sc.crc = crc_extra_bits;
700− s->extra_sc.bits_used = get_bits_count(&s->gb_extra_bits);
701− }
702− }
671+
703672 return count;
704673 }
705674
@@ -743,6 +712,9 @@ static av_cold int wavpack_decode_init(AVCodecContext *avctx) · 37 unmodified lines
743712
744713 s->fdec_num = 0;
745714
715+ avcodec_get_frame_defaults(&s->frame);
716+ avctx->coded_frame = &s->frame;
717+
746718 return 0;
747719 }
748720
@@ -759,7 +731,7 @@ static av_cold int wavpack_decode_end(AVCodecContext *avctx) · 10 unmodified lines
759731 }
760732
761733 static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
762− void *data, int *data_size,
734+ void *data, int *got_frame_ptr,
763735 const uint8_t *buf, int buf_size)
764736 {
765737 WavpackContext *wc = avctx->priv_data;
@@ -774,7 +746,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 8 unmodified lines
774746 int bpp, chan, chmask;
775747
776748 if (buf_size == 0){
777− *data_size = 0;
749+ *got_frame_ptr = 0;
778750 return 0;
779751 }
780752
@@ -789,18 +761,16 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 8 unmodified lines
789761 return -1;
790762 }
791763
792− if(!s->samples_left){
793764 memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
794765 memset(s->ch, 0, sizeof(s->ch));
795766 s->extra_bits = 0;
796767 s->and = s->or = s->shift = 0;
797768 s->got_extra_bits = 0;
798− }
799769
800770 if(!wc->mkv_mode){
801771 s->samples = AV_RL32(buf); buf += 4;
802772 if(!s->samples){
803− *data_size = 0;
773+ *got_frame_ptr = 0;
804774 return 0;
805775 }
806776 }else{
@@ -829,13 +799,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 22 unmodified lines
829799
830800 wc->ch_offset += 1 + s->stereo;
831801
832− s->max_samples = *data_size / (bpp * avctx->channels);
833− s->max_samples = FFMIN(s->max_samples, s->samples);
834− if(s->samples_left > 0){
835− s->max_samples = FFMIN(s->max_samples, s->samples_left);
836− buf = buf_end;
837− }
838−
839802 // parse metadata blocks
840803 while(buf < buf_end){
841804 id = *buf++;
@@ -1064,7 +1027,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 222 unmodified lines
10641027 }
10651028 if(id & WP_IDF_ODD) buf++;
10661029 }
1067− if(!s->samples_left){
1030+
10681031 if(!got_terms){
10691032 av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n");
10701033 return -1;
@@ -1101,16 +1064,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 30 unmodified lines
11011064 s->got_extra_bits = 0;
11021065 }
11031066 }
1104− s->samples_left = s->samples;
1105− }else{
1106− init_get_bits(&s->gb, orig_buf + s->sc.offset, s->sc.size);
1107− skip_bits_long(&s->gb, s->sc.bits_used);
1108− if(s->got_extra_bits){
1109− init_get_bits(&s->gb_extra_bits, orig_buf + s->extra_sc.offset,
1110− s->extra_sc.size);
1111− skip_bits_long(&s->gb_extra_bits, s->extra_sc.bits_used);
1112− }
1113− }
11141067
11151068 if(s->stereo_in){
11161069 if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
@@ -1167,7 +1120,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 50 unmodified lines
11671120 }
11681121 }
11691122
1170− wc->samples_left = s->samples_left;
1123+ *got_frame_ptr = 1;
11711124
11721125 return samplecount * bpp;
11731126 }
@@ -1181,23 +1134,40 @@ static void wavpack_decode_flush(AVCodecContext *avctx) · 7 unmodified lines
11811134 wv_reset_saved_context(s->fdec[i]);
11821135 }
11831136
1184−static int wavpack_decode_frame(AVCodecContext *avctx,
1185− void *data, int *data_size,
1186− AVPacket *avpkt)
1137+static int wavpack_decode_frame(AVCodecContext *avctx, void *data,
1138+ int *got_frame_ptr, AVPacket *avpkt)
11871139 {
11881140 WavpackContext *s = avctx->priv_data;
11891141 const uint8_t *buf = avpkt->data;
11901142 int buf_size = avpkt->size;
1191− int frame_size;
1143+ int frame_size, ret;
11921144 int samplecount = 0;
11931145
11941146 s->block = 0;
1195− s->samples_left = 0;
11961147 s->ch_offset = 0;
11971148
1149+ /* determine number of samples */
11981150 if(s->mkv_mode){
11991151 s->samples = AV_RL32(buf); buf += 4;
1152+ } else {
1153+ if (s->multichannel)
1154+ s->samples = AV_RL32(buf + 4);
1155+ else
1156+ s->samples = AV_RL32(buf);
1157+ }
1158+ if (s->samples <= 0) {
1159+ av_log(avctx, AV_LOG_ERROR, "Invalid number of samples: %d\n",
1160+ s->samples);
1161+ return AVERROR(EINVAL);
1162+ }
1163+
1164+ /* get output buffer */
1165+ s->frame.nb_samples = s->samples;
1166+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
1167+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1168+ return ret;
12001169 }
1170+
12011171 while(buf_size > 0){
12021172 if(!s->multichannel){
12031173 frame_size = buf_size;
@@ -1216,17 +1186,19 @@ static int wavpack_decode_frame(AVCodecContext *avctx, · 12 unmodified lines
12161186 wavpack_decode_flush(avctx);
12171187 return -1;
12181188 }
1219− if((samplecount = wavpack_decode_block(avctx, s->block, data,
1220− data_size, buf, frame_size)) < 0) {
1189+ if((samplecount = wavpack_decode_block(avctx, s->block, s->frame.data[0],
1190+ got_frame_ptr, buf, frame_size)) < 0) {
12211191 wavpack_decode_flush(avctx);
12221192 return -1;
12231193 }
12241194 s->block++;
12251195 buf += frame_size; buf_size -= frame_size;
12261196 }
1227− *data_size = samplecount * avctx->channels;
12281197
1229− return s->samples_left > 0 ? 0 : avpkt->size;
1198+ if (*got_frame_ptr)
1199+ *(AVFrame *)data = s->frame;
1200+
1201+ return avpkt->size;
12301202 }
12311203
12321204 AVCodec ff_wavpack_decoder = {
@@ -1238,6 +1210,6 @@ AVCodec ff_wavpack_decoder = { · 5 unmodified lines
12381210 .close = wavpack_decode_end,
12391211 .decode = wavpack_decode_frame,
12401212 .flush = wavpack_decode_flush,
1241− .capabilities = CODEC_CAP_SUBFRAMES,
1213+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
12421214 .long_name = NULL_IF_CONFIG_SMALL("WavPack"),
12431215 };
libavcodec/wma.h+1−0
@@ -65,6 +65,7 @@ typedef struct CoefVLCTable { · 64 unmodified lines
6565
6666 typedef struct WMACodecContext {
6767 AVCodecContext* avctx;
68+ AVFrame frame;
6869 GetBitContext gb;
6970 PutBitContext pb;
7071 int sample_rate;
libavcodec/wmadec.c+19−12
@@ -136,6 +136,10 @@ static int wma_decode_init(AVCodecContext * avctx) · 135 unmodified lines
136136 }
137137
138138 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
139+
140+ avcodec_get_frame_defaults(&s->frame);
141+ avctx->coded_frame = &s->frame;
142+
139143 return 0;
140144 }
141145
@@ -814,14 +818,13 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples) · 672 unmodified lines
814818 return 0;
815819 }
816820
817−static int wma_decode_superframe(AVCodecContext *avctx,
818− void *data, int *data_size,
819− AVPacket *avpkt)
821+static int wma_decode_superframe(AVCodecContext *avctx, void *data,
822+ int *got_frame_ptr, AVPacket *avpkt)
820823 {
821824 const uint8_t *buf = avpkt->data;
822825 int buf_size = avpkt->size;
823826 WMACodecContext *s = avctx->priv_data;
824− int nb_frames, bit_offset, i, pos, len, out_size;
827+ int nb_frames, bit_offset, i, pos, len, ret;
825828 uint8_t *q;
826829 int16_t *samples;
827830
@@ -836,8 +839,6 @@ static int wma_decode_superframe(AVCodecContext *avctx, · 8 unmodified lines
836839 if(s->block_align)
837840 buf_size = s->block_align;
838841
839− samples = data;
840−
841842 init_get_bits(&s->gb, buf, buf_size*8);
842843
843844 if (s->use_bit_reservoir) {
@@ -848,12 +849,13 @@ static int wma_decode_superframe(AVCodecContext *avctx, · 4 unmodified lines
848849 nb_frames = 1;
849850 }
850851
851− out_size = nb_frames * s->frame_len * s->nb_channels *
852− av_get_bytes_per_sample(avctx->sample_fmt);
853− if (*data_size < out_size) {
854− av_log(s->avctx, AV_LOG_ERROR, "Insufficient output space\n");
855− goto fail;
852+ /* get output buffer */
853+ s->frame.nb_samples = nb_frames * s->frame_len;
854+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
855+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
856+ return ret;
856857 }
858+ samples = (int16_t *)s->frame.data[0];
857859
858860 if (s->use_bit_reservoir) {
859861 bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3);
@@ -920,7 +922,10 @@ static int wma_decode_superframe(AVCodecContext *avctx, · 60 unmodified lines
920922 }
921923
922924 //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d outbytes:%d eaten:%d\n", s->frame_len_bits, s->block_len_bits, s->frame_len, s->block_len, (int8_t *)samples - (int8_t *)data, s->block_align);
923− *data_size = out_size;
925+
926+ *got_frame_ptr = 1;
927+ *(AVFrame *)data = s->frame;
928+
924929 return buf_size;
925930 fail:
926931 /* when error, we reset the bit reservoir */
@@ -945,6 +950,7 @@ AVCodec ff_wmav1_decoder = { · 18 unmodified lines
945950 .close = ff_wma_end,
946951 .decode = wma_decode_superframe,
947952 .flush = flush,
953+ .capabilities = CODEC_CAP_DR1,
948954 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
949955 };
950956
@@ -957,5 +963,6 @@ AVCodec ff_wmav2_decoder = { · 6 unmodified lines
957963 .close = ff_wma_end,
958964 .decode = wma_decode_superframe,
959965 .flush = flush,
966+ .capabilities = CODEC_CAP_DR1,
960967 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
961968 };
libavcodec/wmaprodec.c+36−27
@@ -167,6 +167,7 @@ typedef struct { · 166 unmodified lines
167167 typedef struct WMAProDecodeCtx {
168168 /* generic decoder variables */
169169 AVCodecContext* avctx; ///< codec context for av_log
170+ AVFrame frame; ///< AVFrame for decoded output
170171 DSPContext dsp; ///< accelerated DSP functions
171172 FmtConvertContext fmt_conv;
172173 uint8_t frame_data[MAX_FRAMESIZE +
@@ -209,8 +210,6 @@ typedef struct WMAProDecodeCtx { · 36 unmodified lines
209210 uint32_t frame_num; ///< current frame number (not used for decoding)
210211 GetBitContext gb; ///< bitstream reader context
211212 int buf_bit_size; ///< buffer size in bits
212− float* samples; ///< current samplebuffer pointer
213− float* samples_end; ///< maximum samplebuffer pointer
214213 uint8_t drc_gain; ///< gain for the DRC tool
215214 int8_t skip_frame; ///< skip output step
216215 int8_t parsed_all_subframes; ///< all subframes decoded?
@@ -453,6 +452,10 @@ static av_cold int decode_init(AVCodecContext *avctx) · 236 unmodified lines
453452 dump_context(s);
454453
455454 avctx->channel_layout = channel_mask;
455+
456+ avcodec_get_frame_defaults(&s->frame);
457+ avctx->coded_frame = &s->frame;
458+
456459 return 0;
457460 }
458461
@@ -1279,22 +1282,15 @@ static int decode_subframe(WMAProDecodeCtx *s) · 820 unmodified lines
12791282 *@return 0 if the trailer bit indicates that this is the last frame,
12801283 * 1 if there are additional frames
12811284 */
1282−static int decode_frame(WMAProDecodeCtx *s)
1285+static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
12831286 {
1287+ AVCodecContext *avctx = s->avctx;
12841288 GetBitContext* gb = &s->gb;
12851289 int more_frames = 0;
12861290 int len = 0;
1287− int i;
1291+ int i, ret;
12881292 const float *out_ptr[WMAPRO_MAX_CHANNELS];
1289−
1290− /** check for potential output buffer overflow */
1291− if (s->num_channels * s->samples_per_frame > s->samples_end - s->samples) {
1292− /** return an error if no frame could be decoded at all */
1293− av_log(s->avctx, AV_LOG_ERROR,
1294− "not enough space for the output samples\n");
1295− s->packet_loss = 1;
1296− return 0;
1297− }
1293+ float *samples;
12981294
12991295 /** get frame length */
13001296 if (s->len_prefix)
@@ -1360,10 +1356,19 @@ static int decode_frame(WMAProDecodeCtx *s) · 59 unmodified lines
13601356 }
13611357 }
13621358
1359+ /* get output buffer */
1360+ s->frame.nb_samples = s->samples_per_frame;
1361+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
1362+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1363+ s->packet_loss = 1;
1364+ return 0;
1365+ }
1366+ samples = (float *)s->frame.data[0];
1367+
13631368 /** interleave samples and write them to the output buffer */
13641369 for (i = 0; i < s->num_channels; i++)
13651370 out_ptr[i] = s->channel[i].out;
1366− s->fmt_conv.float_interleave(s->samples, out_ptr, s->samples_per_frame,
1371+ s->fmt_conv.float_interleave(samples, out_ptr, s->samples_per_frame,
13671372 s->num_channels);
13681373
13691374 for (i = 0; i < s->num_channels; i++) {
@@ -1375,8 +1380,10 @@ static int decode_frame(WMAProDecodeCtx *s) · 5 unmodified lines
13751380
13761381 if (s->skip_frame) {
13771382 s->skip_frame = 0;
1378− } else
1379− s->samples += s->num_channels * s->samples_per_frame;
1383+ *got_frame_ptr = 0;
1384+ } else {
1385+ *got_frame_ptr = 1;
1386+ }
13801387
13811388 if (s->len_prefix) {
13821389 if (len != (get_bits_count(gb) - s->frame_offset) + 2) {
@@ -1473,8 +1480,8 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, · 90 unmodified lines
14731480 *@param avpkt input packet
14741481 *@return number of bytes that were read from the input buffer
14751482 */
1476−static int decode_packet(AVCodecContext *avctx,
1477− void *data, int *data_size, AVPacket* avpkt)
1483+static int decode_packet(AVCodecContext *avctx, void *data,
1484+ int *got_frame_ptr, AVPacket* avpkt)
14781485 {
14791486 WMAProDecodeCtx *s = avctx->priv_data;
14801487 GetBitContext* gb = &s->pgb;
@@ -1483,9 +1490,7 @@ static int decode_packet(AVCodecContext *avctx, · 2 unmodified lines
14831490 int num_bits_prev_frame;
14841491 int packet_sequence_number;
14851492
1486− s->samples = data;
1487− s->samples_end = (float*)((int8_t*)data + *data_size);
1488− *data_size = 0;
1493+ *got_frame_ptr = 0;
14891494
14901495 if (s->packet_done || s->packet_loss) {
14911496 s->packet_done = 0;
@@ -1532,7 +1537,7 @@ static int decode_packet(AVCodecContext *avctx, · 40 unmodified lines
15321537
15331538 /** decode the cross packet frame if it is valid */
15341539 if (!s->packet_loss)
1535− decode_frame(s);
1540+ decode_frame(s, got_frame_ptr);
15361541 } else if (s->num_saved_bits - s->frame_offset) {
15371542 av_dlog(avctx, "ignoring %x previously saved bits\n",
15381543 s->num_saved_bits - s->frame_offset);
@@ -1555,7 +1560,7 @@ static int decode_packet(AVCodecContext *avctx, · 16 unmodified lines
15551560 (frame_size = show_bits(gb, s->log2_frame_size)) &&
15561561 frame_size <= remaining_bits(s, gb)) {
15571562 save_bits(s, gb, frame_size, 0);
1558− s->packet_done = !decode_frame(s);
1563+ s->packet_done = !decode_frame(s, got_frame_ptr);
15591564 } else if (!s->len_prefix
15601565 && s->num_saved_bits > get_bits_count(&s->gb)) {
15611566 /** when the frames do not have a length prefix, we don't know
@@ -1565,7 +1570,7 @@ static int decode_packet(AVCodecContext *avctx, · 3 unmodified lines
15651570 therefore we save the incoming packet first, then we append
15661571 the "previous frame" data from the next packet so that
15671572 we get a buffer that only contains full frames */
1568− s->packet_done = !decode_frame(s);
1573+ s->packet_done = !decode_frame(s, got_frame_ptr);
15691574 } else
15701575 s->packet_done = 1;
15711576 }
@@ -1577,10 +1582,14 @@ static int decode_packet(AVCodecContext *avctx, · 5 unmodified lines
15771582 save_bits(s, gb, remaining_bits(s, gb), 0);
15781583 }
15791584
1580− *data_size = (int8_t *)s->samples - (int8_t *)data;
15811585 s->packet_offset = get_bits_count(gb) & 7;
1586+ if (s->packet_loss)
1587+ return AVERROR_INVALIDDATA;
1588+
1589+ if (*got_frame_ptr)
1590+ *(AVFrame *)data = s->frame;
15821591
1583− return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
1592+ return get_bits_count(gb) >> 3;
15841593 }
15851594
15861595 /**
@@ -1611,7 +1620,7 @@ AVCodec ff_wmapro_decoder = { · 24 unmodified lines
16111620 .init = decode_init,
16121621 .close = decode_end,
16131622 .decode = decode_packet,
1614− .capabilities = CODEC_CAP_SUBFRAMES,
1623+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
16151624 .flush= flush,
16161625 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"),
16171626 };
libavcodec/wmavoice.c+26−20
@@ -131,6 +131,7 @@ typedef struct { · 130 unmodified lines
131131 * @name Global values specified in the stream header / extradata or used all over.
132132 * @{
133133 */
134+ AVFrame frame;
134135 GetBitContext gb; ///< packet bitreader. During decoder init,
135136 ///< it contains the extradata from the
136137 ///< demuxer. During decoding, it contains
@@ -438,6 +439,9 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) · 301 unmodified lines
438439
439440 ctx->sample_fmt = AV_SAMPLE_FMT_FLT;
440441
442+ avcodec_get_frame_defaults(&s->frame);
443+ ctx->coded_frame = &s->frame;
444+
441445 return 0;
442446 }
443447
@@ -1725,17 +1729,17 @@ static int check_bits_for_superframe(GetBitContext *orig_gb, · 1281 unmodified lines
17251729 * @return 0 on success, <0 on error or 1 if there was not enough data to
17261730 * fully parse the superframe
17271731 */
1728−static int synth_superframe(AVCodecContext *ctx,
1729− float *samples, int *data_size)
1732+static int synth_superframe(AVCodecContext *ctx, int *got_frame_ptr)
17301733 {
17311734 WMAVoiceContext *s = ctx->priv_data;
17321735 GetBitContext *gb = &s->gb, s_gb;
1733− int n, res, out_size, n_samples = 480;
1736+ int n, res, n_samples = 480;
17341737 double lsps[MAX_FRAMES][MAX_LSPS];
17351738 const double *mean_lsf = s->lsps == 16 ?
17361739 wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode];
17371740 float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12];
17381741 float synth[MAX_LSPS + MAX_SFRAMESIZE];
1742+ float *samples;
17391743
17401744 memcpy(synth, s->synth_history,
17411745 s->lsps * sizeof(*synth));
@@ -1749,7 +1753,7 @@ static int synth_superframe(AVCodecContext *ctx, · 7 unmodified lines
17491753 }
17501754
17511755 if ((res = check_bits_for_superframe(gb, s)) == 1) {
1752− *data_size = 0;
1756+ *got_frame_ptr = 0;
17531757 return 1;
17541758 }
17551759
@@ -1792,13 +1796,14 @@ static int synth_superframe(AVCodecContext *ctx, · 36 unmodified lines
17921796 stabilize_lsps(lsps[n], s->lsps);
17931797 }
17941798
1795− out_size = n_samples * av_get_bytes_per_sample(ctx->sample_fmt);
1796− if (*data_size < out_size) {
1797− av_log(ctx, AV_LOG_ERROR,
1798− "Output buffer too small (%d given - %d needed)\n",
1799− *data_size, out_size);
1800− return -1;
1799+ /* get output buffer */
1800+ s->frame.nb_samples = 480;
1801+ if ((res = ctx->get_buffer(ctx, &s->frame)) < 0) {
1802+ av_log(ctx, AV_LOG_ERROR, "get_buffer() failed\n");
1803+ return res;
18011804 }
1805+ s->frame.nb_samples = n_samples;
1806+ samples = (float *)s->frame.data[0];
18021807
18031808 /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */
18041809 for (n = 0; n < 3; n++) {
@@ -1820,7 +1825,7 @@ static int synth_superframe(AVCodecContext *ctx, · 15 unmodified lines
18201825 lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1],
18211826 &excitation[s->history_nsamples + n * MAX_FRAMESIZE],
18221827 &synth[s->lsps + n * MAX_FRAMESIZE]))) {
1823− *data_size = 0;
1828+ *got_frame_ptr = 0;
18241829 return res;
18251830 }
18261831 }
@@ -1833,8 +1838,7 @@ static int synth_superframe(AVCodecContext *ctx, · 6 unmodified lines
18331838 skip_bits(gb, 10 * (res + 1));
18341839 }
18351840
1836− /* Specify nr. of output samples */
1837− *data_size = out_size;
1841+ *got_frame_ptr = 1;
18381842
18391843 /* Update history */
18401844 memcpy(s->prev_lsps, lsps[2],
@@ -1922,7 +1926,7 @@ static void copy_bits(PutBitContext *pb, · 81 unmodified lines
19221926 * For more information about frames, see #synth_superframe().
19231927 */
19241928 static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
1925− int *data_size, AVPacket *avpkt)
1929+ int *got_frame_ptr, AVPacket *avpkt)
19261930 {
19271931 WMAVoiceContext *s = ctx->priv_data;
19281932 GetBitContext *gb = &s->gb;
@@ -1935,7 +1939,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, · 6 unmodified lines
19351939 * capping the packet size at ctx->block_align. */
19361940 for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align);
19371941 if (!size) {
1938− *data_size = 0;
1942+ *got_frame_ptr = 0;
19391943 return 0;
19401944 }
19411945 init_get_bits(&s->gb, avpkt->data, size << 3);
@@ -1956,10 +1960,11 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, · 14 unmodified lines
19561960 copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits);
19571961 flush_put_bits(&s->pb);
19581962 s->sframe_cache_size += s->spillover_nbits;
1959− if ((res = synth_superframe(ctx, data, data_size)) == 0 &&
1960− *data_size > 0) {
1963+ if ((res = synth_superframe(ctx, got_frame_ptr)) == 0 &&
1964+ *got_frame_ptr) {
19611965 cnt += s->spillover_nbits;
19621966 s->skip_bits_next = cnt & 7;
1967+ *(AVFrame *)data = s->frame;
19631968 return cnt >> 3;
19641969 } else
19651970 skip_bits_long (gb, s->spillover_nbits - cnt +
@@ -1974,11 +1979,12 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, · 8 unmodified lines
19741979 s->sframe_cache_size = 0;
19751980 s->skip_bits_next = 0;
19761981 pos = get_bits_left(gb);
1977− if ((res = synth_superframe(ctx, data, data_size)) < 0) {
1982+ if ((res = synth_superframe(ctx, got_frame_ptr)) < 0) {
19781983 return res;
1979− } else if (*data_size > 0) {
1984+ } else if (*got_frame_ptr) {
19801985 int cnt = get_bits_count(gb);
19811986 s->skip_bits_next = cnt & 7;
1987+ *(AVFrame *)data = s->frame;
19821988 return cnt >> 3;
19831989 } else if ((s->sframe_cache_size = pos) > 0) {
19841990 /* rewind bit reader to start of last (incomplete) superframe... */
@@ -2046,7 +2052,7 @@ AVCodec ff_wmavoice_decoder = { · 61 unmodified lines
20462052 .init = wmavoice_decode_init,
20472053 .close = wmavoice_decode_end,
20482054 .decode = wmavoice_decode_packet,
2049− .capabilities = CODEC_CAP_SUBFRAMES,
2055+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
20502056 .flush = wmavoice_flush,
20512057 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),
20522058 };
libavcodec/ws-snd1.c+29−9
@@ -37,26 +37,37 @@ static const int8_t ws_adpcm_4bit[] = { · 36 unmodified lines
3737 0, 1, 2, 3, 4, 5, 6, 8
3838 };
3939
40+typedef struct WSSndContext {
41+ AVFrame frame;
42+} WSSndContext;
43+
4044 static av_cold int ws_snd_decode_init(AVCodecContext *avctx)
4145 {
46+ WSSndContext *s = avctx->priv_data;
47+
4248 if (avctx->channels != 1) {
4349 av_log_ask_for_sample(avctx, "unsupported number of channels\n");
4450 return AVERROR(EINVAL);
4551 }
4652
4753 avctx->sample_fmt = AV_SAMPLE_FMT_U8;
54+
55+ avcodec_get_frame_defaults(&s->frame);
56+ avctx->coded_frame = &s->frame;
57+
4858 return 0;
4959 }
5060
5161 static int ws_snd_decode_frame(AVCodecContext *avctx, void *data,
52− int *data_size, AVPacket *avpkt)
62+ int *got_frame_ptr, AVPacket *avpkt)
5363 {
64+ WSSndContext *s = avctx->priv_data;
5465 const uint8_t *buf = avpkt->data;
5566 int buf_size = avpkt->size;
5667
57− int in_size, out_size;
68+ int in_size, out_size, ret;
5869 int sample = 128;
59− uint8_t *samples = data;
70+ uint8_t *samples;
6071 uint8_t *samples_end;
6172
6273 if (!buf_size)
@@ -71,19 +82,24 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, void *data, · 8 unmodified lines
7182 in_size = AV_RL16(&buf[2]);
7283 buf += 4;
7384
74− if (out_size > *data_size) {
75− av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
76− return -1;
77− }
7885 if (in_size > buf_size) {
7986 av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n");
8087 return -1;
8188 }
89+
90+ /* get output buffer */
91+ s->frame.nb_samples = out_size;
92+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
93+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
94+ return ret;
95+ }
96+ samples = s->frame.data[0];
8297 samples_end = samples + out_size;
8398
8499 if (in_size == out_size) {
85100 memcpy(samples, buf, out_size);
86− *data_size = out_size;
101+ *got_frame_ptr = 1;
102+ *(AVFrame *)data = s->frame;
87103 return buf_size;
88104 }
89105
@@ -159,7 +175,9 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, void *data, · 69 unmodified lines
159175 }
160176 }
161177
162− *data_size = samples - (uint8_t *)data;
178+ s->frame.nb_samples = samples - s->frame.data[0];
179+ *got_frame_ptr = 1;
180+ *(AVFrame *)data = s->frame;
163181
164182 return buf_size;
165183 }
@@ -168,7 +186,9 @@ AVCodec ff_ws_snd1_decoder = { · 2 unmodified lines
168186 .name = "ws_snd1",
169187 .type = AVMEDIA_TYPE_AUDIO,
170188 .id = CODEC_ID_WESTWOOD_SND1,
189+ .priv_data_size = sizeof(WSSndContext),
171190 .init = ws_snd_decode_init,
172191 .decode = ws_snd_decode_frame,
192+ .capabilities = CODEC_CAP_DR1,
173193 .long_name = NULL_IF_CONFIG_SMALL("Westwood Audio (SND1)"),
174194 };
libavformat/adtsenc.c+1−1
@@ -37,7 +37,7 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf · 36 unmodified lines
3737 int off;
3838
3939 init_get_bits(&gb, buf, size * 8);
40− off = avpriv_mpeg4audio_get_config(&m4ac, buf, size);
40+ off = avpriv_mpeg4audio_get_config(&m4ac, buf, size * 8, 1);
4141 if (off < 0)
4242 return off;
4343 skip_bits_long(&gb, off);
libavformat/asfdec.c+1−1
@@ -1182,7 +1182,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, · 1181 unmodified lines
11821182 return AV_NOPTS_VALUE;
11831183 }
11841184
1185− pts= pkt->dts;
1185+ pts = pkt->dts;
11861186
11871187 av_free_packet(pkt);
11881188 if(pkt->flags&AV_PKT_FLAG_KEY){
libavformat/flvdec.c+1−1
@@ -550,7 +550,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) · 549 unmodified lines
550550 if (st->codec->codec_id == CODEC_ID_AAC) {
551551 MPEG4AudioConfig cfg;
552552 avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
553− st->codec->extradata_size);
553+ st->codec->extradata_size * 8, 1);
554554 st->codec->channels = cfg.channels;
555555 if (cfg.ext_sample_rate)
556556 st->codec->sample_rate = cfg.ext_sample_rate;
libavformat/isom.c+1−1
@@ -438,7 +438,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext · 437 unmodified lines
438438 if (st->codec->codec_id == CODEC_ID_AAC) {
439439 MPEG4AudioConfig cfg;
440440 avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
441− st->codec->extradata_size);
441+ st->codec->extradata_size * 8, 1);
442442 st->codec->channels = cfg.channels;
443443 if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
444444 st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
libavformat/latmenc.c+1−1
@@ -55,7 +55,7 @@ static int latm_decode_extradata(LATMContext *ctx, uint8_t *buf, int size) · 54 unmodified lines
5555 MPEG4AudioConfig m4ac;
5656
5757 init_get_bits(&gb, buf, size * 8);
58− ctx->off = avpriv_mpeg4audio_get_config(&m4ac, buf, size);
58+ ctx->off = avpriv_mpeg4audio_get_config(&m4ac, buf, size * 8, 1);
5959 if (ctx->off < 0)
6060 return ctx->off;
6161 skip_bits_long(&gb, ctx->off);
libavformat/matroskaenc.c+2−1
@@ -448,7 +448,8 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int · 447 unmodified lines
448448 {
449449 MPEG4AudioConfig mp4ac;
450450
451− if (avpriv_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) {
451+ if (avpriv_mpeg4audio_get_config(&mp4ac, codec->extradata,
452+ codec->extradata_size * 8, 1) < 0) {
452453 av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n");
453454 return;
454455 }
libavformat/nullenc.c+1−1
@@ -32,5 +32,5 @@ AVOutputFormat ff_null_muxer = { · 31 unmodified lines
3232 .audio_codec = AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),
3333 .video_codec = CODEC_ID_RAWVIDEO,
3434 .write_packet = null_write_packet,
35− .flags = AVFMT_NOFILE | AVFMT_NOTIMESTAMPS,
35+ .flags = AVFMT_NOFILE | AVFMT_NOTIMESTAMPS | AVFMT_RAWPICTURE,
3636 };
libavformat/rtsp.c+3−0
@@ -1934,6 +1934,7 @@ static int rtp_read_header(AVFormatContext *s, · 1933 unmodified lines
19341934 struct sockaddr_storage addr;
19351935 AVIOContext pb;
19361936 socklen_t addrlen = sizeof(addr);
1937+ RTSPState *rt = s->priv_data;
19371938
19381939 if (!ff_network_init())
19391940 return AVERROR(EIO);
@@ -1997,6 +1998,8 @@ static int rtp_read_header(AVFormatContext *s, · 57 unmodified lines
19971998 /* sdp_read_header initializes this again */
19981999 ff_network_close();
19992000
2001+ rt->media_type_mask = (1 << (AVMEDIA_TYPE_DATA+1)) - 1;
2002+
20002003 ret = sdp_read_header(s, ap);
20012004 s->pb = NULL;
20022005 return ret;

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