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
1267 av_init_packet(&pkt);1267 av_init_packet(&pkt);
1268 pkt.stream_index= ost->index;1268 pkt.stream_index= ost->index;
1269 1269
1270 if (s->oformat->flags & AVFMT_RAWPICTURE) {1270 if (s->oformat->flags & AVFMT_RAWPICTURE &&
1271 enc->codec->id == CODEC_ID_RAWVIDEO) {
1271 /* raw pictures are written as AVPicture structure to1272 /* raw pictures are written as AVPicture structure to
1272 avoid any copies. We support temporarily the older1273 avoid any copies. We support temporarily the older
1273 method. */1274 method. */
@@ -1528,7 +1529,7 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams) · 254 unmodified lines
1528 1529
1529 if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)1530 if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)
1530 continue;1531 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)
1532 continue;1533 continue;
1533 1534
1534 for(;;) {1535 for(;;) {
doc/APIchanges+13−0
@@ -22,6 +22,19 @@ API changes, most recent first: · 21 unmodified lines
222011-10-20 - b35e9e1 - lavu 51.22.0222011-10-20 - b35e9e1 - lavu 51.22.0
23 Add av_strtok() to avstring.h.23 Add av_strtok() to avstring.h.
24 24
252011-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
322011-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
252011-11-23 - bbb46f3 - lavu 51.18.0382011-11-23 - bbb46f3 - lavu 51.18.0
26 Add av_samples_get_buffer_size(), av_samples_fill_arrays(), and39 Add av_samples_get_buffer_size(), av_samples_fill_arrays(), and
27 av_samples_alloc(), to samplefmt.h.40 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
53@anchor{Coding Rules}53@anchor{Coding Rules}
54@section Coding Rules54@section Coding Rules
55 55
56FFmpeg is programmed in the ISO C90 language with a few additional56@subsection Code formatting conventions
57features from ISO C99, namely:
58@itemize @bullet
59@item
60the @samp{inline} keyword;
61@item
62@samp{//} comments;
63@item
64designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
65@item
66compound literals (@samp{x = (struct s) @{ 17, 23 @};})
67@end itemize
68
69These features are supported by all compilers we care about, so we will not
70accept patches to remove their use unless they absolutely do not impair
71clarity and performance.
72 57
73All code must compile with recent versions of GCC and a number of other58There are the following guidelines regarding the indentation in files:
74currently supported compilers. To ensure compatibility, please do not use
75additional C99 features or GCC extensions. Especially watch out for:
76@itemize @bullet59@itemize @bullet
77@item60@item
78mixing 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
84GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
85@end itemize
86
87Indent size is 4.61Indent size is 4.
88The presentation is one inspired by 'indent -i4 -kr -nut'.62@item
89The TAB character is forbidden outside of Makefiles as is any63The TAB character is forbidden outside of Makefiles as is any
90form of trailing whitespace. Commits containing either will be64form of trailing whitespace. Commits containing either will be
91rejected by the git repository.65rejected by the git repository.
66@item
67You should try to limit your code lines to 80 characters; however, do so if and only if this improves readability.
68@end itemize
69The presentation is one inspired by 'indent -i4 -kr -nut'.
92 70
93The main priority in FFmpeg is simplicity and small code size in order to71The main priority in FFmpeg is simplicity and small code size in order to
94minimize the bug count.72minimize the bug count.
95 73
96Comments: Use the JavaDoc/Doxygen74@subsection Comments
97format (see examples below) so that code documentation75Use the JavaDoc/Doxygen format (see examples below) so that code documentation
98can be generated automatically. All nontrivial functions should have a comment76can be generated automatically. All nontrivial functions should have a comment
99above them explaining what the function does, even if it is just one sentence.77above them explaining what the function does, even if it is just one sentence.
100All structures and their member variables should be documented, too.78All structures and their member variables should be documented, too.
@@ -128,11 +106,69 @@ int myfunc(int my_parameter) · 27 unmodified lines
128...106...
129@end example107@end example
130 108
109@subsection C language features
110
111FFmpeg is programmed in the ISO C90 language with a few additional
112features from ISO C99, namely:
113@itemize @bullet
114@item
115the @samp{inline} keyword;
116@item
117@samp{//} comments;
118@item
119designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
120@item
121compound literals (@samp{x = (struct s) @{ 17, 23 @};})
122@end itemize
123
124These features are supported by all compilers we care about, so we will not
125accept patches to remove their use unless they absolutely do not impair
126clarity and performance.
127
128All code must compile with recent versions of GCC and a number of other
129currently supported compilers. To ensure compatibility, please do not use
130additional C99 features or GCC extensions. Especially watch out for:
131@itemize @bullet
132@item
133mixing 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
139GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
140@end itemize
141
142@subsection Naming conventions
143All names are using underscores (_), not CamelCase. For example, @samp{avfilter_get_video_buffer} is
144a valid function name and @samp{AVFilterGetVideo} is not. The only exception from this are structure names;
145they should always be in the CamelCase
146
147There are following conventions for naming variables and functions:
148@itemize @bullet
149@item
150For local variables no prefix is required.
151@item
152For variables and functions declared as @code{static} no prefixes are required.
153@item
154For variables and functions used internally by the library, @code{ff_} prefix should be used.
155For example, @samp{ff_w64_demuxer}.
156@item
157For variables and functions used internally across multiple libraries, use @code{avpriv_}. For example,
158@samp{avpriv_aac_parse_header}.
159@item
160For 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
131fprintf and printf are forbidden in libavformat and libavcodec,166fprintf and printf are forbidden in libavformat and libavcodec,
132please use av_log() instead.167please use av_log() instead.
133 168@item
134Casts should be used only when necessary. Unneeded parentheses169Casts should be used only when necessary. Unneeded parentheses
135should also be avoided if they don't make the code easier to understand.170should also be avoided if they don't make the code easier to understand.
171@end itemize
136 172
137@section Development Policy173@section Development Policy
138 174
doc/general.texi+11−2
@@ -840,13 +840,22 @@ bash directly to work around this: · 839 unmodified lines
840bash ./configure840bash ./configure
841@end example841@end example
842 842
843@subsection Darwin (MacOS X, iPhone)843@anchor{Darwin}
844@subsection Darwin (OSX, iPhone)
844 845
845MacOS X on PowerPC or ARM (iPhone) requires a preprocessor from846The toolchain provided with Xcode is sufficient to build the basic
847unacelerated code.
848
849OSX on PowerPC or ARM (iPhone) requires a preprocessor from
846@url{http://github.com/yuvi/gas-preprocessor} to build the optimized850@url{http://github.com/yuvi/gas-preprocessor} to build the optimized
847assembler functions. Just download the Perl script and put it somewhere851assembler functions. Just download the Perl script and put it somewhere
848in your PATH, FFmpeg's configure will pick it up automatically.852in your PATH, FFmpeg's configure will pick it up automatically.
849 853
854OSX on amd64 and x86 requires @command{yasm} to build most of the
855optimized 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}
857or @url{http://www.macports.org, MacPorts} can easily provide it.
858
850@section Windows859@section Windows
851 860
852To get help and instructions for building FFmpeg under Windows, check out861To 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
1295 av_init_packet(&pkt);1295 av_init_packet(&pkt);
1296 pkt.stream_index= ost->index;1296 pkt.stream_index= ost->index;
1297 1297
1298 if (s->oformat->flags & AVFMT_RAWPICTURE) {1298 if (s->oformat->flags & AVFMT_RAWPICTURE &&
1299 enc->codec->id == CODEC_ID_RAWVIDEO) {
1299 /* raw pictures are written as AVPicture structure to1300 /* raw pictures are written as AVPicture structure to
1300 avoid any copies. We support temporarily the older1301 avoid any copies. We support temporarily the older
1301 method. */1302 method. */
@@ -1560,7 +1561,7 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams) · 258 unmodified lines
1560 1561
1561 if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)1562 if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)
1562 continue;1563 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)
1564 continue;1565 continue;
1565 1566
1566 for(;;) {1567 for(;;) {
libavcodec/8svx.c+23−11
@@ -41,6 +41,7 @@ · 40 unmodified lines
41 41
42/** decoder context */42/** decoder context */
43typedef struct EightSvxContext {43typedef struct EightSvxContext {
44 AVFrame frame;
44 const int8_t *table;45 const int8_t *table;
45 46
46 /* buffer used to store the whole audio decoded/interleaved chunk,47 /* 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
99 return dst-dst0;100 return dst-dst0;
100}101}
101 102
102static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,103/** decode a frame */
103 AVPacket *avpkt)104static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
105 int *got_frame_ptr, AVPacket *avpkt)
104{106{
105 EightSvxContext *esc = avctx->priv_data;107 EightSvxContext *esc = avctx->priv_data;
106 int out_data_size, n;108 int n, out_data_size, ret;
109 uint8_t *out_date;
107 uint8_t *src, *dst;110 uint8_t *src, *dst;
108 111
109 /* decode and interleave the first packet */112 /* 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
145 memcpy(esc->samples, deinterleaved_samples, esc->samples_size);148 memcpy(esc->samples, deinterleaved_samples, esc->samples_size);
146 }149 }
147 150
148 /* return single packed with fixed size */151 /* get output buffer */
149 out_data_size = FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx);152 esc->frame.nb_samples = (FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx) +avctx->channels-1) / avctx->channels;
150 if (*data_size < out_data_size) {153 if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) {
151 av_log(avctx, AV_LOG_ERROR, "Provided buffer with size %d is too small.\n", *data_size);154 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
152 return AVERROR(EINVAL);155 return ret;
153 }156 }
154 157
155 *data_size = out_data_size;158 *got_frame_ptr = 1;
156 dst = data;159 *(AVFrame *)data = esc->frame;
160
161 dst = esc->frame.data[0];
157 src = esc->samples + esc->samples_idx;162 src = esc->samples + esc->samples_idx;
163 out_data_size = esc->frame.nb_samples * avctx->channels;
158 for (n = out_data_size; n > 0; n--)164 for (n = out_data_size; n > 0; n--)
159 *dst++ = *src++ + 128;165 *dst++ = *src++ + 128;
160 esc->samples_idx += *data_size;166 esc->samples_idx += out_data_size;
161 167
162 return avctx->codec->id == CODEC_ID_8SVX_FIB || avctx->codec->id == CODEC_ID_8SVX_EXP ?168 return avctx->codec->id == CODEC_ID_8SVX_FIB || avctx->codec->id == CODEC_ID_8SVX_EXP ?
163 (avctx->frame_number == 0)*2 + out_data_size / 2 :169 (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
184 }190 }
185 avctx->sample_fmt = AV_SAMPLE_FMT_U8;191 avctx->sample_fmt = AV_SAMPLE_FMT_U8;
186 192
193 avcodec_get_frame_defaults(&esc->frame);
194 avctx->coded_frame = &esc->frame;
195
187 return 0;196 return 0;
188}197}
189 198
@@ -206,6 +215,7 @@ AVCodec ff_eightsvx_fib_decoder = { · 16 unmodified lines
206 .init = eightsvx_decode_init,215 .init = eightsvx_decode_init,
207 .decode = eightsvx_decode_frame,216 .decode = eightsvx_decode_frame,
208 .close = eightsvx_decode_close,217 .close = eightsvx_decode_close,
218 .capabilities = CODEC_CAP_DR1,
209 .long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),219 .long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
210};220};
211 221
@@ -217,6 +227,7 @@ AVCodec ff_eightsvx_exp_decoder = { · 5 unmodified lines
217 .init = eightsvx_decode_init,227 .init = eightsvx_decode_init,
218 .decode = eightsvx_decode_frame,228 .decode = eightsvx_decode_frame,
219 .close = eightsvx_decode_close,229 .close = eightsvx_decode_close,
230 .capabilities = CODEC_CAP_DR1,
220 .long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),231 .long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),
221};232};
222 233
@@ -228,5 +239,6 @@ AVCodec ff_pcm_s8_planar_decoder = { · 5 unmodified lines
228 .init = eightsvx_decode_init,239 .init = eightsvx_decode_init,
229 .close = eightsvx_decode_close,240 .close = eightsvx_decode_close,
230 .decode = eightsvx_decode_frame,241 .decode = eightsvx_decode_frame,
242 .capabilities = CODEC_CAP_DR1,
231 .long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),243 .long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
232};244};
libavcodec/aac.h+1−0
@@ -251,6 +251,7 @@ typedef struct { · 250 unmodified lines
251 */251 */
252typedef struct {252typedef struct {
253 AVCodecContext *avctx;253 AVCodecContext *avctx;
254 AVFrame frame;
254 255
255 MPEG4AudioConfig m4ac;256 MPEG4AudioConfig m4ac;
256 257
libavcodec/aacdec.c+61−45
@@ -471,15 +471,17 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, · 470 unmodified lines
471 * @param ac pointer to AACContext, may be null471 * @param ac pointer to AACContext, may be null
472 * @param avctx pointer to AVCCodecContext, used for logging472 * @param avctx pointer to AVCCodecContext, used for logging
473 * @param m4ac pointer to MPEG4AudioConfig, used for parsing473 * @param m4ac pointer to MPEG4AudioConfig, used for parsing
474 * @param data pointer to AVCodecContext extradata474 * @param data pointer to buffer holding an audio specific config
475 * @param data_size size of AVCCodecContext extradata475 * @param bit_size size of audio specific config or data in bits
476 * @param sync_extension look for an appended sync extension
476 *477 *
477 * @return Returns error status or number of consumed bits. <0 - error478 * @return Returns error status or number of consumed bits. <0 - error
478 */479 */
479static int decode_audio_specific_config(AACContext *ac,480static int decode_audio_specific_config(AACContext *ac,
480 AVCodecContext *avctx,481 AVCodecContext *avctx,
481 MPEG4AudioConfig *m4ac,482 MPEG4AudioConfig *m4ac,
482 const uint8_t *data, int data_size, int asclen)483 const uint8_t *data, int bit_size,
484 int sync_extension)
483{485{
484 GetBitContext gb;486 GetBitContext gb;
485 int i;487 int i;
@@ -489,9 +491,9 @@ static int decode_audio_specific_config(AACContext *ac, · 3 unmodified lines
489 av_dlog(avctx, "%02x ", avctx->extradata[i]);491 av_dlog(avctx, "%02x ", avctx->extradata[i]);
490 av_dlog(avctx, "\n");492 av_dlog(avctx, "\n");
491 493
492 init_get_bits(&gb, data, data_size * 8);494 init_get_bits(&gb, data, bit_size);
493 495
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)
495 return -1;497 return -1;
496 if (m4ac->sampling_index > 12) {498 if (m4ac->sampling_index > 12) {
497 av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);499 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
591 if (avctx->extradata_size > 0) {593 if (avctx->extradata_size > 0) {
592 if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,594 if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
593 avctx->extradata,595 avctx->extradata,
594 avctx->extradata_size, 8*avctx->extradata_size) < 0)596 avctx->extradata_size*8, 1) < 0)
595 return -1;597 return -1;
596 } else {598 } else {
597 int sr, i;599 int sr, i;
@@ -665,6 +667,9 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) · 67 unmodified lines
665 667
666 cbrt_tableinit();668 cbrt_tableinit();
667 669
670 avcodec_get_frame_defaults(&ac->frame);
671 avctx->coded_frame = &ac->frame;
672
668 return 0;673 return 0;
669}674}
670 675
@@ -2132,12 +2137,12 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) · 1461 unmodified lines
2132}2137}
2133 2138
2134static int aac_decode_frame_int(AVCodecContext *avctx, void *data,2139static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
2135 int *data_size, GetBitContext *gb)2140 int *got_frame_ptr, GetBitContext *gb)
2136{2141{
2137 AACContext *ac = avctx->priv_data;2142 AACContext *ac = avctx->priv_data;
2138 ChannelElement *che = NULL, *che_prev = NULL;2143 ChannelElement *che = NULL, *che_prev = NULL;
2139 enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;2144 enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;
2140 int err, elem_id, data_size_tmp;2145 int err, elem_id;
2141 int samples = 0, multiplier, audio_found = 0;2146 int samples = 0, multiplier, audio_found = 0;
2142 2147
2143 if (show_bits(gb, 12) == 0xfff) {2148 if (show_bits(gb, 12) == 0xfff) {
@@ -2250,24 +2255,26 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, · 106 unmodified lines
2250 avctx->frame_size = samples;2255 avctx->frame_size = samples;
2251 }2256 }
2252 2257
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
2263 if (samples) {2258 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
2264 if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT)2266 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,
2266 samples, avctx->channels);2269 samples, avctx->channels);
2267 else2270 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,
2269 samples, avctx->channels);2273 samples, avctx->channels);
2274
2275 *(AVFrame *)data = ac->frame;
2270 }2276 }
2277 *got_frame_ptr = !!samples;
2271 2278
2272 if (ac->output_configured && audio_found)2279 if (ac->output_configured && audio_found)
2273 ac->output_configured = OC_LOCKED;2280 ac->output_configured = OC_LOCKED;
@@ -2276,7 +2283,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, · 2 unmodified lines
2276}2283}
2277 2284
2278static int aac_decode_frame(AVCodecContext *avctx, void *data,2285static int aac_decode_frame(AVCodecContext *avctx, void *data,
2279 int *data_size, AVPacket *avpkt)2286 int *got_frame_ptr, AVPacket *avpkt)
2280{2287{
2281 const uint8_t *buf = avpkt->data;2288 const uint8_t *buf = avpkt->data;
2282 int buf_size = avpkt->size;2289 int buf_size = avpkt->size;
@@ -2287,7 +2294,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines
2287 2294
2288 init_get_bits(&gb, buf, buf_size * 8);2295 init_get_bits(&gb, buf, buf_size * 8);
2289 2296
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)
2291 return err;2298 return err;
2292 2299
2293 buf_consumed = (get_bits_count(&gb) + 7) >> 3;2300 buf_consumed = (get_bits_count(&gb) + 7) >> 3;
@@ -2340,30 +2347,40 @@ static inline uint32_t latm_get_value(GetBitContext *b) · 46 unmodified lines
2340static int latm_decode_audio_specific_config(struct LATMContext *latmctx,2347static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
2341 GetBitContext *gb, int asclen)2348 GetBitContext *gb, int asclen)
2342{2349{
2343 AVCodecContext *avctx = latmctx->aac_ctx.avctx;2350 AACContext *ac = &latmctx->aac_ctx;
2344 AACContext *ac= &latmctx->aac_ctx;2351 AVCodecContext *avctx = ac->avctx;
2345 MPEG4AudioConfig m4ac=ac->m4ac;2352 MPEG4AudioConfig m4ac = {0};
2346 int config_start_bit = get_bits_count(gb);2353 int config_start_bit = get_bits_count(gb);
2347 int bits_consumed, esize;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);
2348 2362
2349 if (config_start_bit % 8) {2363 if (config_start_bit % 8) {
2350 av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific "2364 av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific "
2351 "config not byte aligned.\n", 1);2365 "config not byte aligned.\n", 1);
2352 return AVERROR_INVALIDDATA;2366 return AVERROR_INVALIDDATA;
2353 } else {2367 }
2354 bits_consumed =2368 bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
2355 decode_audio_specific_config(ac, avctx, &m4ac,
2356 gb->buffer + (config_start_bit / 8),2369 gb->buffer + (config_start_bit / 8),
2357 get_bits_left(gb) / 8, asclen);2370 asclen, sync_extension);
2358 2371
2359 if (bits_consumed < 0)2372 if (bits_consumed < 0)
2360 return AVERROR_INVALIDDATA;2373 return AVERROR_INVALIDDATA;
2361 if(ac->m4ac.sample_rate != m4ac.sample_rate || m4ac.chan_config != ac->m4ac.chan_config)2374
2362 ac->m4ac= m4ac;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;
2363 2380
2364 esize = (bits_consumed+7) / 8;2381 esize = (bits_consumed+7) / 8;
2365 2382
2366 if (avctx->extradata_size <= esize) {2383 if (avctx->extradata_size < esize) {
2367 av_free(avctx->extradata);2384 av_free(avctx->extradata);
2368 avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);2385 avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);
2369 if (!avctx->extradata)2386 if (!avctx->extradata)
@@ -2373,9 +2390,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 3 unmodified lines
2373 avctx->extradata_size = esize;2390 avctx->extradata_size = esize;
2374 memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);2391 memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
2375 memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);2392 memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
2376
2377 skip_bits_long(gb, bits_consumed);
2378 }2393 }
2394 skip_bits_long(gb, bits_consumed);
2379 2395
2380 return bits_consumed;2396 return bits_consumed;
2381}2397}
@@ -2512,8 +2528,8 @@ static int read_audio_mux_element(struct LATMContext *latmctx, · 130 unmodified lines
2512}2528}
2513 2529
2514 2530
2515static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size,2531static int latm_decode_frame(AVCodecContext *avctx, void *out,
2516 AVPacket *avpkt)2532 int *got_frame_ptr, AVPacket *avpkt)
2517{2533{
2518 struct LATMContext *latmctx = avctx->priv_data;2534 struct LATMContext *latmctx = avctx->priv_data;
2519 int muxlength, err;2535 int muxlength, err;
@@ -2535,12 +2551,12 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, · 15 unmodified lines
2535 2551
2536 if (!latmctx->initialized) {2552 if (!latmctx->initialized) {
2537 if (!avctx->extradata) {2553 if (!avctx->extradata) {
2538 *out_size = 0;2554 *got_frame_ptr = 0;
2539 return avpkt->size;2555 return avpkt->size;
2540 } else {2556 } else {
2541 if ((err = decode_audio_specific_config(2557 if ((err = decode_audio_specific_config(
2542 &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.m4ac,2558 &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)
2544 return err;2560 return err;
2545 latmctx->initialized = 1;2561 latmctx->initialized = 1;
2546 }2562 }
@@ -2553,7 +2569,7 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, · 6 unmodified lines
2553 return AVERROR_INVALIDDATA;2569 return AVERROR_INVALIDDATA;
2554 }2570 }
2555 2571
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)
2557 return err;2573 return err;
2558 2574
2559 return muxlength;2575 return muxlength;
@@ -2583,7 +2599,7 @@ AVCodec ff_aac_decoder = { · 23 unmodified lines
2583 .sample_fmts = (const enum AVSampleFormat[]) {2599 .sample_fmts = (const enum AVSampleFormat[]) {
2584 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE2600 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
2585 },2601 },
2586 .capabilities = CODEC_CAP_CHANNEL_CONF,2602 .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
2587 .channel_layouts = aac_channel_layout,2603 .channel_layouts = aac_channel_layout,
2588};2604};
2589 2605
@@ -2604,7 +2620,7 @@ AVCodec ff_aac_latm_decoder = { · 14 unmodified lines
2604 .sample_fmts = (const enum AVSampleFormat[]) {2620 .sample_fmts = (const enum AVSampleFormat[]) {
2605 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE2621 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
2606 },2622 },
2607 .capabilities = CODEC_CAP_CHANNEL_CONF,2623 .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
2608 .channel_layouts = aac_channel_layout,2624 .channel_layouts = aac_channel_layout,
2609 .flush = flush,2625 .flush = flush,
2610};2626};
libavcodec/ac3dec.c+24−16
@@ -208,6 +208,9 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) · 207 unmodified lines
208 }208 }
209 s->downmixed = 1;209 s->downmixed = 1;
210 210
211 avcodec_get_frame_defaults(&s->frame);
212 avctx->coded_frame = &s->frame;
213
211 return 0;214 return 0;
212}215}
213 216
@@ -1296,16 +1299,15 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) · 1082 unmodified lines
1296/**1299/**
1297 * Decode a single AC-3 frame.1300 * Decode a single AC-3 frame.
1298 */1301 */
1299static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,1302static int ac3_decode_frame(AVCodecContext * avctx, void *data,
1300 AVPacket *avpkt)1303 int *got_frame_ptr, AVPacket *avpkt)
1301{1304{
1302 const uint8_t *buf = avpkt->data;1305 const uint8_t *buf = avpkt->data;
1303 int buf_size = avpkt->size;1306 int buf_size = avpkt->size;
1304 AC3DecodeContext *s = avctx->priv_data;1307 AC3DecodeContext *s = avctx->priv_data;
1305 float *out_samples_flt = data;1308 float *out_samples_flt;
1306 int16_t *out_samples_s16 = data;1309 int16_t *out_samples_s16;
1307 int blk, ch, err;1310 int blk, ch, err, ret;
1308 int data_size_orig, data_size_tmp;
1309 const uint8_t *channel_map;1311 const uint8_t *channel_map;
1310 const float *output[AC3_MAX_CHANNELS];1312 const float *output[AC3_MAX_CHANNELS];
1311 1313
@@ -1322,8 +1324,6 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 10 unmodified lines
1322 init_get_bits(&s->gbc, buf, buf_size * 8);1324 init_get_bits(&s->gbc, buf, buf_size * 8);
1323 1325
1324 /* parse the syncinfo */1326 /* parse the syncinfo */
1325 data_size_orig = *data_size;
1326 *data_size = 0;
1327 err = parse_frame_header(s);1327 err = parse_frame_header(s);
1328 1328
1329 if (err) {1329 if (err) {
@@ -1345,6 +1345,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 15 unmodified lines
1345 /* TODO: add support for substreams and dependent frames */1345 /* TODO: add support for substreams and dependent frames */
1346 if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {1346 if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
1347 av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n");1347 av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n");
1348 *got_frame_ptr = 0;
1348 return s->frame_size;1349 return s->frame_size;
1349 } else {1350 } else {
1350 av_log(avctx, AV_LOG_ERROR, "invalid frame type\n");1351 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
1406 if (s->bitstream_mode == 0x7 && s->channels > 1)1407 if (s->bitstream_mode == 0x7 && s->channels > 1)
1407 avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;1408 avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
1408 1409
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
1409 /* decode the audio blocks */1419 /* decode the audio blocks */
1410 channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];1420 channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
1411 for (ch = 0; ch < s->out_channels; ch++)1421 for (ch = 0; ch < s->out_channels; ch++)
1412 output[ch] = s->output[channel_map[ch]];1422 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;
1418 for (blk = 0; blk < s->num_blocks; blk++) {1423 for (blk = 0; blk < s->num_blocks; blk++) {
1419 if (!err && decode_audio_block(s, blk)) {1424 if (!err && decode_audio_block(s, blk)) {
1420 av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");1425 av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
1421 err = 1;1426 err = 1;
1422 }1427 }
1423
1424 if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {1428 if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
1425 s->fmt_conv.float_interleave(out_samples_flt, output, 256,1429 s->fmt_conv.float_interleave(out_samples_flt, output, 256,
1426 s->out_channels);1430 s->out_channels);
@@ -1431,8 +1435,10 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 4 unmodified lines
1431 out_samples_s16 += 256 * s->out_channels;1435 out_samples_s16 += 256 * s->out_channels;
1432 }1436 }
1433 }1437 }
1434 *data_size = s->num_blocks * 256 * avctx->channels *1438
1435 av_get_bytes_per_sample(avctx->sample_fmt);1439 *got_frame_ptr = 1;
1440 *(AVFrame *)data = s->frame;
1441
1436 return FFMIN(buf_size, s->frame_size);1442 return FFMIN(buf_size, s->frame_size);
1437}1443}
1438 1444
@@ -1477,6 +1483,7 @@ AVCodec ff_ac3_decoder = { · 38 unmodified lines
1477 .init = ac3_decode_init,1483 .init = ac3_decode_init,
1478 .close = ac3_decode_end,1484 .close = ac3_decode_end,
1479 .decode = ac3_decode_frame,1485 .decode = ac3_decode_frame,
1486 .capabilities = CODEC_CAP_DR1,
1480 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),1487 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
1481 .sample_fmts = (const enum AVSampleFormat[]) {1488 .sample_fmts = (const enum AVSampleFormat[]) {
1482 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE1489 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
@@ -1499,6 +1506,7 @@ AVCodec ff_eac3_decoder = { · 16 unmodified lines
1499 .init = ac3_decode_init,1506 .init = ac3_decode_init,
1500 .close = ac3_decode_end,1507 .close = ac3_decode_end,
1501 .decode = ac3_decode_frame,1508 .decode = ac3_decode_frame,
1509 .capabilities = CODEC_CAP_DR1,
1502 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),1510 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
1503 .sample_fmts = (const enum AVSampleFormat[]) {1511 .sample_fmts = (const enum AVSampleFormat[]) {
1504 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE1512 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
libavcodec/ac3dec.h+1−0
@@ -68,6 +68,7 @@ · 67 unmodified lines
68typedef struct {68typedef struct {
69 AVClass *class; ///< class for AVOptions69 AVClass *class; ///< class for AVOptions
70 AVCodecContext *avctx; ///< parent context70 AVCodecContext *avctx; ///< parent context
71 AVFrame frame; ///< AVFrame for decoded output
71 GetBitContext gbc; ///< bitstream reader72 GetBitContext gbc; ///< bitstream reader
72 73
73///@name Bit stream information74///@name Bit stream information
libavcodec/adpcm.c+25−17
@@ -84,6 +84,7 @@ static const int swf_index_tables[4][16] = { · 83 unmodified lines
84/* end of tables */84/* end of tables */
85 85
86typedef struct ADPCMDecodeContext {86typedef struct ADPCMDecodeContext {
87 AVFrame frame;
87 ADPCMChannelStatus status[6];88 ADPCMChannelStatus status[6];
88} ADPCMDecodeContext;89} ADPCMDecodeContext;
89 90
@@ -124,6 +125,10 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 34 unmodified lines
124 break;125 break;
125 }126 }
126 avctx->sample_fmt = AV_SAMPLE_FMT_S16;127 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
128
129 avcodec_get_frame_defaults(&c->frame);
130 avctx->coded_frame = &c->frame;
131
127 return 0;132 return 0;
128}133}
129 134
@@ -501,9 +506,8 @@ static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf, · 371 unmodified lines
501 decode_top_nibble_next = 1; \506 decode_top_nibble_next = 1; \
502 }507 }
503 508
504static int adpcm_decode_frame(AVCodecContext *avctx,509static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
505 void *data, int *data_size,510 int *got_frame_ptr, AVPacket *avpkt)
506 AVPacket *avpkt)
507{511{
508 const uint8_t *buf = avpkt->data;512 const uint8_t *buf = avpkt->data;
509 int buf_size = avpkt->size;513 int buf_size = avpkt->size;
@@ -514,7 +518,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 4 unmodified lines
514 const uint8_t *src;518 const uint8_t *src;
515 int st; /* stereo */519 int st; /* stereo */
516 int count1, count2;520 int count1, count2;
517 int nb_samples, coded_samples, out_bps, out_size;521 int nb_samples, coded_samples, ret;
518 522
519 nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples);523 nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples);
520 if (nb_samples <= 0) {524 if (nb_samples <= 0) {
@@ -522,22 +526,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 1 unmodified line
522 return AVERROR_INVALIDDATA;526 return AVERROR_INVALIDDATA;
523 }527 }
524 528
525 out_bps = av_get_bytes_per_sample(avctx->sample_fmt);529 /* get output buffer */
526 out_size = nb_samples * avctx->channels * out_bps;530 c->frame.nb_samples = nb_samples;
527 if (*data_size < out_size) {531 if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
528 av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");532 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
529 return AVERROR(EINVAL);533 return ret;
530 }534 }
535 samples = (short *)c->frame.data[0];
536
531 /* use coded_samples when applicable */537 /* use coded_samples when applicable */
532 /* it is always <= nb_samples, so the output buffer will be large enough */538 /* it is always <= nb_samples, so the output buffer will be large enough */
533 if (coded_samples) {539 if (coded_samples) {
534 if (coded_samples != nb_samples)540 if (coded_samples != nb_samples)
535 av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");541 av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
536 nb_samples = coded_samples;542 c->frame.nb_samples = nb_samples = coded_samples;
537 out_size = nb_samples * avctx->channels * out_bps;
538 }543 }
539 544
540 samples = data;
541 src = buf;545 src = buf;
542 546
543 st = avctx->channels == 2 ? 1 : 0;547 st = avctx->channels == 2 ? 1 : 0;
@@ -576,7 +580,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 32 unmodified lines
576 cs->step_index = 88;580 cs->step_index = 88;
577 }581 }
578 582
579 samples = (short*)data + channel;583 samples = (short *)c->frame.data[0] + channel;
580 584
581 for (m = 0; m < 32; m++) {585 for (m = 0; m < 32; m++) {
582 *samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3);586 *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
628 }632 }
629 633
630 for (i = 0; i < avctx->channels; i++) {634 for (i = 0; i < avctx->channels; i++) {
631 samples = (short*)data + i;635 samples = (short *)c->frame.data[0] + i;
632 cs = &c->status[i];636 cs = &c->status[i];
633 for (n = nb_samples >> 1; n > 0; n--, src++) {637 for (n = nb_samples >> 1; n > 0; n--, src++) {
634 uint8_t v = *src;638 uint8_t v = *src;
@@ -965,7 +969,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 330 unmodified lines
965 }969 }
966 }970 }
967 971
968 out_size = count * 28 * avctx->channels * out_bps;972 c->frame.nb_samples = count * 28;
969 src = src_end;973 src = src_end;
970 break;974 break;
971 }975 }
@@ -1144,7 +1148,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 172 unmodified lines
1144 prev[0][i] = (int16_t)bytestream_get_be16(&src);1148 prev[0][i] = (int16_t)bytestream_get_be16(&src);
1145 1149
1146 for (ch = 0; ch <= st; ch++) {1150 for (ch = 0; ch <= st; ch++) {
1147 samples = (unsigned short *) data + ch;1151 samples = (short *)c->frame.data[0] + ch;
1148 1152
1149 /* Read in every sample for this channel. */1153 /* Read in every sample for this channel. */
1150 for (i = 0; i < nb_samples / 14; i++) {1154 for (i = 0; i < nb_samples / 14; i++) {
@@ -1177,7 +1181,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 26 unmodified lines
1177 default:1181 default:
1178 return -1;1182 return -1;
1179 }1183 }
1180 *data_size = out_size;1184
1185 *got_frame_ptr = 1;
1186 *(AVFrame *)data = c->frame;
1187
1181 return src - buf;1188 return src - buf;
1182}1189}
1183 1190
@@ -1190,6 +1197,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 6 unmodified lines
1190 .priv_data_size = sizeof(ADPCMDecodeContext), \1197 .priv_data_size = sizeof(ADPCMDecodeContext), \
1191 .init = adpcm_decode_init, \1198 .init = adpcm_decode_init, \
1192 .decode = adpcm_decode_frame, \1199 .decode = adpcm_decode_frame, \
1200 .capabilities = CODEC_CAP_DR1, \
1193 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \1201 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
1194}1202}
1195 1203
libavcodec/adx.h+1−0
@@ -40,6 +40,7 @@ typedef struct { · 39 unmodified lines
40} ADXChannelState;40} ADXChannelState;
41 41
42typedef struct {42typedef struct {
43 AVFrame frame;
43 int channels;44 int channels;
44 ADXChannelState prev[2];45 ADXChannelState prev[2];
45 int header_parsed;46 int header_parsed;
libavcodec/adxdec.c+27−14
@@ -50,6 +50,10 @@ static av_cold int adx_decode_init(AVCodecContext *avctx) · 49 unmodified lines
50 c->channels = avctx->channels;50 c->channels = avctx->channels;
51 51
52 avctx->sample_fmt = AV_SAMPLE_FMT_S16;52 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
53
54 avcodec_get_frame_defaults(&c->frame);
55 avctx->coded_frame = &c->frame;
56
53 return 0;57 return 0;
54}58}
55 59
@@ -89,36 +93,42 @@ static int adx_decode(ADXContext *c, int16_t *out, const uint8_t *in, int ch) · 33 unmodified lines
89 return 0;93 return 0;
90}94}
91 95
92static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,96static int adx_decode_frame(AVCodecContext *avctx, void *data,
93 AVPacket *avpkt)97 int *got_frame_ptr, AVPacket *avpkt)
94{98{
95 int buf_size = avpkt->size;99 int buf_size = avpkt->size;
96 ADXContext *c = avctx->priv_data;100 ADXContext *c = avctx->priv_data;
97 int16_t *samples = data;101 int16_t *samples;
98 const uint8_t *buf = avpkt->data;102 const uint8_t *buf = avpkt->data;
99 int num_blocks, ch;103 int num_blocks, ch, ret;
100 104
101 if (c->eof) {105 if (c->eof) {
102 *data_size = 0;106 *got_frame_ptr = 0;
103 return buf_size;107 return buf_size;
104 }108 }
105 109
106 /* 18 bytes of data are expanded into 32*2 bytes of audio,110 /* calculate number of blocks in the packet */
107 so guard against buffer overflows */
108 num_blocks = buf_size / (BLOCK_SIZE * c->channels);111 num_blocks = buf_size / (BLOCK_SIZE * c->channels);
109 if (num_blocks > *data_size / (BLOCK_SAMPLES * c->channels)) {112
110 buf_size = (*data_size / (BLOCK_SAMPLES * c->channels)) * BLOCK_SIZE;113 /* if the packet is not an even multiple of BLOCK_SIZE, check for an EOF
111 num_blocks = buf_size / (BLOCK_SIZE * c->channels);114 packet */
112 }115 if (!num_blocks || buf_size % (BLOCK_SIZE * avctx->channels)) {
113 if (!buf_size || buf_size % (BLOCK_SIZE * avctx->channels)) {
114 if (buf_size >= 4 && (AV_RB16(buf) & 0x8000)) {116 if (buf_size >= 4 && (AV_RB16(buf) & 0x8000)) {
115 c->eof = 1;117 c->eof = 1;
116 *data_size = 0;118 *got_frame_ptr = 0;
117 return avpkt->size;119 return avpkt->size;
118 }120 }
119 return AVERROR_INVALIDDATA;121 return AVERROR_INVALIDDATA;
120 }122 }
121 123
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
122 while (num_blocks--) {132 while (num_blocks--) {
123 for (ch = 0; ch < c->channels; ch++) {133 for (ch = 0; ch < c->channels; ch++) {
124 if (adx_decode(c, samples + ch, buf, ch)) {134 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
132 samples += BLOCK_SAMPLES * c->channels;142 samples += BLOCK_SAMPLES * c->channels;
133 }143 }
134 144
135 *data_size = (uint8_t*)samples - (uint8_t*)data;145 *got_frame_ptr = 1;
146 *(AVFrame *)data = c->frame;
147
136 return buf - avpkt->data;148 return buf - avpkt->data;
137}149}
138 150
@@ -143,5 +155,6 @@ AVCodec ff_adpcm_adx_decoder = { · 4 unmodified lines
143 .priv_data_size = sizeof(ADXContext),155 .priv_data_size = sizeof(ADXContext),
144 .init = adx_decode_init,156 .init = adx_decode_init,
145 .decode = adx_decode_frame,157 .decode = adx_decode_frame,
158 .capabilities = CODEC_CAP_DR1,
146 .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),159 .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
147};160};
libavcodec/alac.c+28−17
@@ -62,10 +62,10 @@ · 61 unmodified lines
62typedef struct {62typedef struct {
63 63
64 AVCodecContext *avctx;64 AVCodecContext *avctx;
65 AVFrame frame;
65 GetBitContext gb;66 GetBitContext gb;
66 67
67 int numchannels;68 int numchannels;
68 int bytespersample;
69 69
70 /* buffers */70 /* buffers */
71 int32_t *predicterror_buffer[MAX_CHANNELS];71 int32_t *predicterror_buffer[MAX_CHANNELS];
@@ -351,9 +351,8 @@ static void interleave_stereo_24(int32_t *buffer[MAX_CHANNELS], · 279 unmodified lines
351 }351 }
352}352}
353 353
354static int alac_decode_frame(AVCodecContext *avctx,354static int alac_decode_frame(AVCodecContext *avctx, void *data,
355 void *outbuffer, int *outputsize,355 int *got_frame_ptr, AVPacket *avpkt)
356 AVPacket *avpkt)
357{356{
358 const uint8_t *inbuffer = avpkt->data;357 const uint8_t *inbuffer = avpkt->data;
359 int input_buffer_size = avpkt->size;358 int input_buffer_size = avpkt->size;
@@ -366,7 +365,7 @@ static int alac_decode_frame(AVCodecContext *avctx, · 6 unmodified lines
366 int isnotcompressed;365 int isnotcompressed;
367 uint8_t interlacing_shift;366 uint8_t interlacing_shift;
368 uint8_t interlacing_leftweight;367 uint8_t interlacing_leftweight;
369 int i, ch;368 int i, ch, ret;
370 369
371 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);370 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
372 371
@@ -401,14 +400,17 @@ static int alac_decode_frame(AVCodecContext *avctx, · 28 unmodified lines
401 } else400 } else
402 outputsamples = alac->setinfo_max_samples_per_frame;401 outputsamples = alac->setinfo_max_samples_per_frame;
403 402
404 alac->bytespersample = channels * av_get_bytes_per_sample(avctx->sample_fmt);403 /* get output buffer */
405 404 if (outputsamples > INT32_MAX) {
406 if(outputsamples > *outputsize / alac->bytespersample){405 av_log(avctx, AV_LOG_ERROR, "unsupported block size: %u\n", outputsamples);
407 av_log(avctx, AV_LOG_ERROR, "sample buffer too small\n");406 return AVERROR_INVALIDDATA;
408 return -1;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;
409 }412 }
410 413
411 *outputsize = outputsamples * alac->bytespersample;
412 readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1;414 readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1;
413 if (readsamplesize > MIN_CACHE_BITS) {415 if (readsamplesize > MIN_CACHE_BITS) {
414 av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize);416 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
501 switch(alac->setinfo_sample_size) {503 switch(alac->setinfo_sample_size) {
502 case 16:504 case 16:
503 if (channels == 2) {505 if (channels == 2) {
504 interleave_stereo_16(alac->outputsamples_buffer, outbuffer,506 interleave_stereo_16(alac->outputsamples_buffer,
505 outputsamples);507 (int16_t *)alac->frame.data[0], outputsamples);
506 } else {508 } else {
509 int16_t *outbuffer = (int16_t *)alac->frame.data[0];
507 for (i = 0; i < outputsamples; i++) {510 for (i = 0; i < outputsamples; i++) {
508 ((int16_t*)outbuffer)[i] = alac->outputsamples_buffer[0][i];511 outbuffer[i] = alac->outputsamples_buffer[0][i];
509 }512 }
510 }513 }
511 break;514 break;
512 case 24:515 case 24:
513 if (channels == 2) {516 if (channels == 2) {
514 interleave_stereo_24(alac->outputsamples_buffer, outbuffer,517 interleave_stereo_24(alac->outputsamples_buffer,
515 outputsamples);518 (int32_t *)alac->frame.data[0], outputsamples);
516 } else {519 } else {
520 int32_t *outbuffer = (int32_t *)alac->frame.data[0];
517 for (i = 0; i < outputsamples; i++)521 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;
519 }523 }
520 break;524 break;
521 }525 }
@@ -523,6 +527,9 @@ static int alac_decode_frame(AVCodecContext *avctx, · 1 unmodified line
523 if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)527 if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)
524 av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));528 av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));
525 529
530 *got_frame_ptr = 1;
531 *(AVFrame *)data = alac->frame;
532
526 return input_buffer_size;533 return input_buffer_size;
527}534}
528 535
@@ -637,6 +644,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx) · 108 unmodified lines
637 return ret;644 return ret;
638 }645 }
639 646
647 avcodec_get_frame_defaults(&alac->frame);
648 avctx->coded_frame = &alac->frame;
649
640 return 0;650 return 0;
641}651}
642 652
@@ -648,5 +658,6 @@ AVCodec ff_alac_decoder = { · 5 unmodified lines
648 .init = alac_decode_init,658 .init = alac_decode_init,
649 .close = alac_decode_close,659 .close = alac_decode_close,
650 .decode = alac_decode_frame,660 .decode = alac_decode_frame,
661 .capabilities = CODEC_CAP_DR1,
651 .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),662 .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
652};663};
libavcodec/alacenc.c+54−47
@@ -75,20 +75,22 @@ typedef struct AlacEncodeContext { · 74 unmodified lines
75} AlacEncodeContext;75} AlacEncodeContext;
76 76
77 77
78static void init_sample_buffers(AlacEncodeContext *s, const int16_t *input_samples)78static void init_sample_buffers(AlacEncodeContext *s,
79 const int16_t *input_samples)
79{80{
80 int ch, i;81 int ch, i;
81 82
82 for(ch=0;ch<s->avctx->channels;ch++) {83 for (ch = 0; ch < s->avctx->channels; ch++) {
83 const int16_t *sptr = input_samples + ch;84 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++) {
85 s->sample_buf[ch][i] = *sptr;86 s->sample_buf[ch][i] = *sptr;
86 sptr += s->avctx->channels;87 sptr += s->avctx->channels;
87 }88 }
88 }89 }
89}90}
90 91
91static void encode_scalar(AlacEncodeContext *s, int x, int k, int write_sample_size)92static void encode_scalar(AlacEncodeContext *s, int x,
93 int k, int write_sample_size)
92{94{
93 int divisor, q, r;95 int divisor, q, r;
94 96
@@ -97,17 +99,17 @@ static void encode_scalar(AlacEncodeContext *s, int x, int k, int write_sample_s · 2 unmodified lines
97 q = x / divisor;99 q = x / divisor;
98 r = x % divisor;100 r = x % divisor;
99 101
100 if(q > 8) {102 if (q > 8) {
101 // write escape code and sample value directly103 // write escape code and sample value directly
102 put_bits(&s->pbctx, 9, ALAC_ESCAPE_CODE);104 put_bits(&s->pbctx, 9, ALAC_ESCAPE_CODE);
103 put_bits(&s->pbctx, write_sample_size, x);105 put_bits(&s->pbctx, write_sample_size, x);
104 } else {106 } else {
105 if(q)107 if (q)
106 put_bits(&s->pbctx, q, (1<<q) - 1);108 put_bits(&s->pbctx, q, (1<<q) - 1);
107 put_bits(&s->pbctx, 1, 0);109 put_bits(&s->pbctx, 1, 0);
108 110
109 if(k != 1) {111 if (k != 1) {
110 if(r > 0)112 if (r > 0)
111 put_bits(&s->pbctx, k, r+1);113 put_bits(&s->pbctx, k, r+1);
112 else114 else
113 put_bits(&s->pbctx, k-1, 0);115 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
164 166
165 /* calculate sum of 2nd order residual for each channel */167 /* calculate sum of 2nd order residual for each channel */
166 sum[0] = sum[1] = sum[2] = sum[3] = 0;168 sum[0] = sum[1] = sum[2] = sum[3] = 0;
167 for(i=2; i<n; i++) {169 for (i = 2; i < n; i++) {
168 lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2];170 lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2];
169 rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2];171 rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2];
170 sum[2] += FFABS((lt + rt) >> 1);172 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
181 183
182 /* return mode with lowest score */184 /* return mode with lowest score */
183 best = 0;185 best = 0;
184 for(i=1; i<4; i++) {186 for (i = 1; i < 4; i++) {
185 if(score[i] < score[best]) {187 if (score[i] < score[best]) {
186 best = i;188 best = i;
187 }189 }
188 }190 }
@@ -205,7 +207,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 16 unmodified lines
205 break;207 break;
206 208
207 case ALAC_CHMODE_LEFT_SIDE:209 case ALAC_CHMODE_LEFT_SIDE:
208 for(i=0; i<n; i++) {210 for (i = 0; i < n; i++) {
209 right[i] = left[i] - right[i];211 right[i] = left[i] - right[i];
210 }212 }
211 s->interlacing_leftweight = 1;213 s->interlacing_leftweight = 1;
@@ -213,7 +215,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 1 unmodified line
213 break;215 break;
214 216
215 case ALAC_CHMODE_RIGHT_SIDE:217 case ALAC_CHMODE_RIGHT_SIDE:
216 for(i=0; i<n; i++) {218 for (i = 0; i < n; i++) {
217 tmp = right[i];219 tmp = right[i];
218 right[i] = left[i] - right[i];220 right[i] = left[i] - right[i];
219 left[i] = tmp + (right[i] >> 31);221 left[i] = tmp + (right[i] >> 31);
@@ -223,7 +225,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 3 unmodified lines
223 break;225 break;
224 226
225 default:227 default:
226 for(i=0; i<n; i++) {228 for (i = 0; i < n; i++) {
227 tmp = left[i];229 tmp = left[i];
228 left[i] = (tmp + right[i]) >> 1;230 left[i] = (tmp + right[i]) >> 1;
229 right[i] = tmp - right[i];231 right[i] = tmp - right[i];
@@ -239,10 +241,10 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) · 9 unmodified lines
239 int i;241 int i;
240 AlacLPCContext lpc = s->lpc[ch];242 AlacLPCContext lpc = s->lpc[ch];
241 243
242 if(lpc.lpc_order == 31) {244 if (lpc.lpc_order == 31) {
243 s->predictor_buf[0] = s->sample_buf[ch][0];245 s->predictor_buf[0] = s->sample_buf[ch][0];
244 246
245 for(i=1; i<s->avctx->frame_size; i++)247 for (i = 1; i < s->avctx->frame_size; i++)
246 s->predictor_buf[i] = s->sample_buf[ch][i] - s->sample_buf[ch][i-1];248 s->predictor_buf[i] = s->sample_buf[ch][i] - s->sample_buf[ch][i-1];
247 249
248 return;250 return;
@@ -250,17 +252,17 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) · 1 unmodified line
250 252
251 // generalised linear predictor253 // generalised linear predictor
252 254
253 if(lpc.lpc_order > 0) {255 if (lpc.lpc_order > 0) {
254 int32_t *samples = s->sample_buf[ch];256 int32_t *samples = s->sample_buf[ch];
255 int32_t *residual = s->predictor_buf;257 int32_t *residual = s->predictor_buf;
256 258
257 // generate warm-up samples259 // generate warm-up samples
258 residual[0] = samples[0];260 residual[0] = samples[0];
259 for(i=1;i<=lpc.lpc_order;i++)261 for (i = 1; i <= lpc.lpc_order; i++)
260 residual[i] = samples[i] - samples[i-1];262 residual[i] = samples[i] - samples[i-1];
261 263
262 // perform lpc on remaining samples264 // 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++) {
264 int sum = 1 << (lpc.lpc_quant - 1), res_val, j;266 int sum = 1 << (lpc.lpc_quant - 1), res_val, j;
265 267
266 for (j = 0; j < lpc.lpc_order; j++) {268 for (j = 0; j < lpc.lpc_order; j++) {
@@ -303,7 +305,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 36 unmodified lines
303 int sign_modifier = 0, i, k;305 int sign_modifier = 0, i, k;
304 int32_t *samples = s->predictor_buf;306 int32_t *samples = s->predictor_buf;
305 307
306 for(i=0;i < s->avctx->frame_size;) {308 for (i = 0; i < s->avctx->frame_size;) {
307 int x;309 int x;
308 310
309 k = av_log2((history >> 9) + 3);311 k = av_log2((history >> 9) + 3);
@@ -320,15 +322,15 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 10 unmodified lines
320 - ((history * s->rc.history_mult) >> 9);322 - ((history * s->rc.history_mult) >> 9);
321 323
322 sign_modifier = 0;324 sign_modifier = 0;
323 if(x > 0xFFFF)325 if (x > 0xFFFF)
324 history = 0xFFFF;326 history = 0xFFFF;
325 327
326 if((history < 128) && (i < s->avctx->frame_size)) {328 if (history < 128 && i < s->avctx->frame_size) {
327 unsigned int block_size = 0;329 unsigned int block_size = 0;
328 330
329 k = 7 - av_log2(history) + ((history + 16) >> 6);331 k = 7 - av_log2(history) + ((history + 16) >> 6);
330 332
331 while((*samples == 0) && (i < s->avctx->frame_size)) {333 while (*samples == 0 && i < s->avctx->frame_size) {
332 samples++;334 samples++;
333 i++;335 i++;
334 block_size++;336 block_size++;
@@ -347,12 +349,12 @@ static void write_compressed_frame(AlacEncodeContext *s) · 12 unmodified lines
347{349{
348 int i, j;350 int i, j;
349 351
350 if(s->avctx->channels == 2)352 if (s->avctx->channels == 2)
351 alac_stereo_decorrelation(s);353 alac_stereo_decorrelation(s);
352 put_bits(&s->pbctx, 8, s->interlacing_shift);354 put_bits(&s->pbctx, 8, s->interlacing_shift);
353 put_bits(&s->pbctx, 8, s->interlacing_leftweight);355 put_bits(&s->pbctx, 8, s->interlacing_leftweight);
354 356
355 for(i=0;i<s->avctx->channels;i++) {357 for (i = 0; i < s->avctx->channels; i++) {
356 358
357 calc_predictor_params(s, i);359 calc_predictor_params(s, i);
358 360
@@ -362,14 +364,14 @@ static void write_compressed_frame(AlacEncodeContext *s) · 3 unmodified lines
362 put_bits(&s->pbctx, 3, s->rc.rice_modifier);364 put_bits(&s->pbctx, 3, s->rc.rice_modifier);
363 put_bits(&s->pbctx, 5, s->lpc[i].lpc_order);365 put_bits(&s->pbctx, 5, s->lpc[i].lpc_order);
364 // predictor coeff. table366 // 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++) {
366 put_sbits(&s->pbctx, 16, s->lpc[i].lpc_coeff[j]);368 put_sbits(&s->pbctx, 16, s->lpc[i].lpc_coeff[j]);
367 }369 }
368 }370 }
369 371
370 // apply lpc and entropy coding to audio samples372 // apply lpc and entropy coding to audio samples
371 373
372 for(i=0;i<s->avctx->channels;i++) {374 for (i = 0; i < s->avctx->channels; i++) {
373 alac_linear_predictor(s, i);375 alac_linear_predictor(s, i);
374 alac_entropy_coder(s);376 alac_entropy_coder(s);
375 }377 }
@@ -384,7 +386,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 8 unmodified lines
384 avctx->frame_size = DEFAULT_FRAME_SIZE;386 avctx->frame_size = DEFAULT_FRAME_SIZE;
385 avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;387 avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;
386 388
387 if(avctx->sample_fmt != AV_SAMPLE_FMT_S16) {389 if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) {
388 av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n");390 av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n");
389 return -1;391 return -1;
390 }392 }
@@ -395,7 +397,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 4 unmodified lines
395 }397 }
396 398
397 // Set default compression level399 // Set default compression level
398 if(avctx->compression_level == FF_COMPRESSION_DEFAULT)400 if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
399 s->compression_level = 2;401 s->compression_level = 2;
400 else402 else
401 s->compression_level = av_clip(avctx->compression_level, 0, 2);403 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
416 AV_WB8 (alac_extradata+17, avctx->bits_per_coded_sample);418 AV_WB8 (alac_extradata+17, avctx->bits_per_coded_sample);
417 AV_WB8 (alac_extradata+21, avctx->channels);419 AV_WB8 (alac_extradata+21, avctx->channels);
418 AV_WB32(alac_extradata+24, s->max_coded_frame_size);420 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 bitrate421 AV_WB32(alac_extradata+28,
422 avctx->sample_rate * avctx->channels * avctx->bits_per_coded_sample); // average bitrate
420 AV_WB32(alac_extradata+32, avctx->sample_rate);423 AV_WB32(alac_extradata+32, avctx->sample_rate);
421 424
422 // Set relevant extradata fields425 // Set relevant extradata fields
423 if(s->compression_level > 0) {426 if (s->compression_level > 0) {
424 AV_WB8(alac_extradata+18, s->rc.history_mult);427 AV_WB8(alac_extradata+18, s->rc.history_mult);
425 AV_WB8(alac_extradata+19, s->rc.initial_history);428 AV_WB8(alac_extradata+19, s->rc.initial_history);
426 AV_WB8(alac_extradata+20, s->rc.k_modifier);429 AV_WB8(alac_extradata+20, s->rc.k_modifier);
427 }430 }
428 431
429 s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;432 s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;
430 if(avctx->min_prediction_order >= 0) {433 if (avctx->min_prediction_order >= 0) {
431 if(avctx->min_prediction_order < MIN_LPC_ORDER ||434 if (avctx->min_prediction_order < MIN_LPC_ORDER ||
432 avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {435 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);
434 return -1;438 return -1;
435 }439 }
436 440
@@ -438,18 +442,20 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 1 unmodified line
438 }442 }
439 443
440 s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;444 s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;
441 if(avctx->max_prediction_order >= 0) {445 if (avctx->max_prediction_order >= 0) {
442 if(avctx->max_prediction_order < MIN_LPC_ORDER ||446 if (avctx->max_prediction_order < MIN_LPC_ORDER ||
443 avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {447 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);448 av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
449 avctx->max_prediction_order);
445 return -1;450 return -1;
446 }451 }
447 452
448 s->max_prediction_order = avctx->max_prediction_order;453 s->max_prediction_order = avctx->max_prediction_order;
449 }454 }
450 455
451 if(s->max_prediction_order < s->min_prediction_order) {456 if (s->max_prediction_order < s->min_prediction_order) {
452 av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n",457 av_log(avctx, AV_LOG_ERROR,
458 "invalid prediction orders: min=%d max=%d\n",
453 s->min_prediction_order, s->max_prediction_order);459 s->min_prediction_order, s->max_prediction_order);
454 return -1;460 return -1;
455 }461 }
@@ -474,12 +480,12 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 18 unmodified lines
474 PutBitContext *pb = &s->pbctx;480 PutBitContext *pb = &s->pbctx;
475 int i, out_bytes, verbatim_flag = 0;481 int i, out_bytes, verbatim_flag = 0;
476 482
477 if(avctx->frame_size > DEFAULT_FRAME_SIZE) {483 if (avctx->frame_size > DEFAULT_FRAME_SIZE) {
478 av_log(avctx, AV_LOG_ERROR, "input frame size exceeded\n");484 av_log(avctx, AV_LOG_ERROR, "input frame size exceeded\n");
479 return -1;485 return -1;
480 }486 }
481 487
482 if(buf_size < 2*s->max_coded_frame_size) {488 if (buf_size < 2 * s->max_coded_frame_size) {
483 av_log(avctx, AV_LOG_ERROR, "buffer size is too small\n");489 av_log(avctx, AV_LOG_ERROR, "buffer size is too small\n");
484 return -1;490 return -1;
485 }491 }
@@ -487,11 +493,11 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 1 unmodified line
487verbatim:493verbatim:
488 init_put_bits(pb, frame, buf_size);494 init_put_bits(pb, frame, buf_size);
489 495
490 if((s->compression_level == 0) || verbatim_flag) {496 if (s->compression_level == 0 || verbatim_flag) {
491 // Verbatim mode497 // Verbatim mode
492 const int16_t *samples = data;498 const int16_t *samples = data;
493 write_frame_header(s, 1);499 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++) {
495 put_sbits(pb, 16, *samples++);501 put_sbits(pb, 16, *samples++);
496 }502 }
497 } else {503 } else {
@@ -504,9 +510,9 @@ verbatim: · 6 unmodified lines
504 flush_put_bits(pb);510 flush_put_bits(pb);
505 out_bytes = put_bits_count(pb) >> 3;511 out_bytes = put_bits_count(pb) >> 3;
506 512
507 if(out_bytes > s->max_coded_frame_size) {513 if (out_bytes > s->max_coded_frame_size) {
508 /* frame too large. use verbatim mode */514 /* frame too large. use verbatim mode */
509 if(verbatim_flag || (s->compression_level == 0)) {515 if (verbatim_flag || s->compression_level == 0) {
510 /* still too large. must be an error. */516 /* still too large. must be an error. */
511 av_log(avctx, AV_LOG_ERROR, "error encoding frame\n");517 av_log(avctx, AV_LOG_ERROR, "error encoding frame\n");
512 return -1;518 return -1;
@@ -537,6 +543,7 @@ AVCodec ff_alac_encoder = { · 24 unmodified lines
537 .encode = alac_encode_frame,543 .encode = alac_encode_frame,
538 .close = alac_encode_close,544 .close = alac_encode_close,
539 .capabilities = CODEC_CAP_SMALL_LAST_FRAME,545 .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 },
541 .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),548 .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
542};549};
libavcodec/alsdec.c+25−20
@@ -191,6 +191,7 @@ typedef struct { · 190 unmodified lines
191 191
192typedef struct {192typedef struct {
193 AVCodecContext *avctx;193 AVCodecContext *avctx;
194 AVFrame frame;
194 ALSSpecificConfig sconf;195 ALSSpecificConfig sconf;
195 GetBitContext gb;196 GetBitContext gb;
196 DSPContext dsp;197 DSPContext dsp;
@@ -290,7 +291,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 93 unmodified lines
290 init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8);291 init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8);
291 292
292 config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata,293 config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata,
293 avctx->extradata_size);294 avctx->extradata_size * 8, 1);
294 295
295 if (config_offset < 0)296 if (config_offset < 0)
296 return -1;297 return -1;
@@ -1415,15 +1416,14 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 1118 unmodified lines
1415 1416
1416/** Decode an ALS frame.1417/** Decode an ALS frame.
1417 */1418 */
1418static int decode_frame(AVCodecContext *avctx,1419static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
1419 void *data, int *data_size,
1420 AVPacket *avpkt)1420 AVPacket *avpkt)
1421{1421{
1422 ALSDecContext *ctx = avctx->priv_data;1422 ALSDecContext *ctx = avctx->priv_data;
1423 ALSSpecificConfig *sconf = &ctx->sconf;1423 ALSSpecificConfig *sconf = &ctx->sconf;
1424 const uint8_t *buffer = avpkt->data;1424 const uint8_t *buffer = avpkt->data;
1425 int buffer_size = avpkt->size;1425 int buffer_size = avpkt->size;
1426 int invalid_frame, size;1426 int invalid_frame, ret;
1427 unsigned int c, sample, ra_frame, bytes_read, shift;1427 unsigned int c, sample, ra_frame, bytes_read, shift;
1428 1428
1429 init_get_bits(&ctx->gb, buffer, buffer_size * 8);1429 init_get_bits(&ctx->gb, buffer, buffer_size * 8);
@@ -1448,21 +1448,17 @@ static int decode_frame(AVCodecContext *avctx, · 18 unmodified lines
1448 1448
1449 ctx->frame_id++;1449 ctx->frame_id++;
1450 1450
1451 // check for size of decoded data1451 /* get output buffer */
1452 size = ctx->cur_frame_length * avctx->channels *1452 ctx->frame.nb_samples = ctx->cur_frame_length;
1453 av_get_bytes_per_sample(avctx->sample_fmt);1453 if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
1454 1454 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1455 if (size > *data_size) {1455 return ret;
1456 av_log(avctx, AV_LOG_ERROR, "Decoded data exceeds buffer size.\n");
1457 return -1;
1458 }1456 }
1459 1457
1460 *data_size = size;
1461
1462 // transform decoded frame into output format1458 // transform decoded frame into output format
1463 #define INTERLEAVE_OUTPUT(bps) \1459 #define INTERLEAVE_OUTPUT(bps) \
1464 { \1460 { \
1465 int##bps##_t *dest = (int##bps##_t*) data; \1461 int##bps##_t *dest = (int##bps##_t*)ctx->frame.data[0]; \
1466 shift = bps - ctx->avctx->bits_per_raw_sample; \1462 shift = bps - ctx->avctx->bits_per_raw_sample; \
1467 for (sample = 0; sample < ctx->cur_frame_length; sample++) \1463 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1468 for (c = 0; c < avctx->channels; c++) \1464 for (c = 0; c < avctx->channels; c++) \
@@ -1480,7 +1476,7 @@ static int decode_frame(AVCodecContext *avctx, · 11 unmodified lines
1480 int swap = HAVE_BIGENDIAN != sconf->msb_first;1476 int swap = HAVE_BIGENDIAN != sconf->msb_first;
1481 1477
1482 if (ctx->avctx->bits_per_raw_sample == 24) {1478 if (ctx->avctx->bits_per_raw_sample == 24) {
1483 int32_t *src = data;1479 int32_t *src = (int32_t *)ctx->frame.data[0];
1484 1480
1485 for (sample = 0;1481 for (sample = 0;
1486 sample < ctx->cur_frame_length * avctx->channels;1482 sample < ctx->cur_frame_length * avctx->channels;
@@ -1501,22 +1497,25 @@ static int decode_frame(AVCodecContext *avctx, · 14 unmodified lines
1501 1497
1502 if (swap) {1498 if (swap) {
1503 if (ctx->avctx->bits_per_raw_sample <= 16) {1499 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];
1505 int16_t *dest = (int16_t*) ctx->crc_buffer;1501 int16_t *dest = (int16_t*) ctx->crc_buffer;
1506 for (sample = 0;1502 for (sample = 0;
1507 sample < ctx->cur_frame_length * avctx->channels;1503 sample < ctx->cur_frame_length * avctx->channels;
1508 sample++)1504 sample++)
1509 *dest++ = av_bswap16(src[sample]);1505 *dest++ = av_bswap16(src[sample]);
1510 } else {1506 } 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],
1512 ctx->cur_frame_length * avctx->channels);1509 ctx->cur_frame_length * avctx->channels);
1513 }1510 }
1514 crc_source = ctx->crc_buffer;1511 crc_source = ctx->crc_buffer;
1515 } else {1512 } else {
1516 crc_source = data;1513 crc_source = ctx->frame.data[0];
1517 }1514 }
1518 1515
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));
1520 }1519 }
1521 1520
1522 1521
@@ -1527,6 +1526,9 @@ static int decode_frame(AVCodecContext *avctx, · 4 unmodified lines
1527 }1526 }
1528 }1527 }
1529 1528
1529 *got_frame_ptr = 1;
1530 *(AVFrame *)data = ctx->frame;
1531
1530 1532
1531 bytes_read = invalid_frame ? buffer_size :1533 bytes_read = invalid_frame ? buffer_size :
1532 (get_bits_count(&ctx->gb) + 7) >> 3;1534 (get_bits_count(&ctx->gb) + 7) >> 3;
@@ -1724,6 +1726,9 @@ static av_cold int decode_init(AVCodecContext *avctx) · 191 unmodified lines
1724 1726
1725 dsputil_init(&ctx->dsp, avctx);1727 dsputil_init(&ctx->dsp, avctx);
1726 1728
1729 avcodec_get_frame_defaults(&ctx->frame);
1730 avctx->coded_frame = &ctx->frame;
1731
1727 return 0;1732 return 0;
1728}1733}
1729 1734
@@ -1747,7 +1752,7 @@ AVCodec ff_als_decoder = { · 17 unmodified lines
1747 .close = decode_end,1752 .close = decode_end,
1748 .decode = decode_frame,1753 .decode = decode_frame,
1749 .flush = flush,1754 .flush = flush,
1750 .capabilities = CODEC_CAP_SUBFRAMES,1755 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
1751 .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"),1756 .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"),
1752};1757};
1753 1758
libavcodec/amrnbdec.c+19−6
@@ -95,6 +95,7 @@ · 94 unmodified lines
95#define AMR_AGC_ALPHA 0.995#define AMR_AGC_ALPHA 0.9
96 96
97typedef struct AMRContext {97typedef struct AMRContext {
98 AVFrame avframe; ///< AVFrame for decoded samples
98 AMRNBFrame frame; ///< decoded AMR parameters (lsf coefficients, codebook indexes, etc)99 AMRNBFrame frame; ///< decoded AMR parameters (lsf coefficients, codebook indexes, etc)
99 uint8_t bad_frame_indicator; ///< bad frame ? 1 : 0100 uint8_t bad_frame_indicator; ///< bad frame ? 1 : 0
100 enum Mode cur_frame_mode;101 enum Mode cur_frame_mode;
@@ -167,6 +168,9 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx) · 66 unmodified lines
167 for (i = 0; i < 4; i++)168 for (i = 0; i < 4; i++)
168 p->prediction_error[i] = MIN_ENERGY;169 p->prediction_error[i] = MIN_ENERGY;
169 170
171 avcodec_get_frame_defaults(&p->avframe);
172 avctx->coded_frame = &p->avframe;
173
170 return 0;174 return 0;
171}175}
172 176
@@ -919,21 +923,29 @@ static void postfilter(AMRContext *p, float *lpc, float *buf_out) · 746 unmodified lines
919 923
920/// @}924/// @}
921 925
922static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,926static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
923 AVPacket *avpkt)927 int *got_frame_ptr, AVPacket *avpkt)
924{928{
925 929
926 AMRContext *p = avctx->priv_data; // pointer to private data930 AMRContext *p = avctx->priv_data; // pointer to private data
927 const uint8_t *buf = avpkt->data;931 const uint8_t *buf = avpkt->data;
928 int buf_size = avpkt->size;932 int buf_size = avpkt->size;
929 float *buf_out = data; // pointer to the output data buffer933 float *buf_out; // pointer to the output data buffer
930 int i, subframe;934 int i, subframe, ret;
931 float fixed_gain_factor;935 float fixed_gain_factor;
932 AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing936 AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing
933 float spare_vector[AMR_SUBFRAME_SIZE]; // extra stack space to hold result from anti-sparseness processing937 float spare_vector[AMR_SUBFRAME_SIZE]; // extra stack space to hold result from anti-sparseness processing
934 float synth_fixed_gain; // the fixed gain that synthesis should use938 float synth_fixed_gain; // the fixed gain that synthesis should use
935 const float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use939 const float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use
936 940
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
937 p->cur_frame_mode = unpack_bitstream(p, buf, buf_size);949 p->cur_frame_mode = unpack_bitstream(p, buf, buf_size);
938 if (p->cur_frame_mode == MODE_DTX) {950 if (p->cur_frame_mode == MODE_DTX) {
939 av_log_missing_feature(avctx, "dtx mode", 0);951 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
1029 ff_weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3],1041 ff_weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3],
1030 0.84, 0.16, LP_FILTER_ORDER);1042 0.84, 0.16, LP_FILTER_ORDER);
1031 1043
1032 /* report how many samples we got */1044 *got_frame_ptr = 1;
1033 *data_size = AMR_BLOCK_SIZE * sizeof(float);1045 *(AVFrame *)data = p->avframe;
1034 1046
1035 /* return the amount of bytes consumed if everything was OK */1047 /* return the amount of bytes consumed if everything was OK */
1036 return frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC1048 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
1044 .priv_data_size = sizeof(AMRContext),1056 .priv_data_size = sizeof(AMRContext),
1045 .init = amrnb_decode_init,1057 .init = amrnb_decode_init,
1046 .decode = amrnb_decode_frame,1058 .decode = amrnb_decode_frame,
1059 .capabilities = CODEC_CAP_DR1,
1047 .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate NarrowBand"),1060 .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate NarrowBand"),
1048 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},1061 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
1049};1062};
libavcodec/amrwbdec.c+20−7
@@ -41,6 +41,7 @@ · 40 unmodified lines
41#include "amrwbdata.h"41#include "amrwbdata.h"
42 42
43typedef struct {43typedef struct {
44 AVFrame avframe; ///< AVFrame for decoded samples
44 AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream45 AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream
45 enum Mode fr_cur_mode; ///< mode index of current frame46 enum Mode fr_cur_mode; ///< mode index of current frame
46 uint8_t fr_quality; ///< frame quality index (FQI)47 uint8_t fr_quality; ///< frame quality index (FQI)
@@ -102,6 +103,9 @@ static av_cold int amrwb_decode_init(AVCodecContext *avctx) · 55 unmodified lines
102 for (i = 0; i < 4; i++)103 for (i = 0; i < 4; i++)
103 ctx->prediction_error[i] = MIN_ENERGY;104 ctx->prediction_error[i] = MIN_ENERGY;
104 105
106 avcodec_get_frame_defaults(&ctx->avframe);
107 avctx->coded_frame = &ctx->avframe;
108
105 return 0;109 return 0;
106}110}
107 111
@@ -1062,15 +1066,15 @@ static void update_sub_state(AMRWBContext *ctx) · 954 unmodified lines
1062 LP_ORDER_16k * sizeof(float));1066 LP_ORDER_16k * sizeof(float));
1063}1067}
1064 1068
1065static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,1069static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
1066 AVPacket *avpkt)1070 int *got_frame_ptr, AVPacket *avpkt)
1067{1071{
1068 AMRWBContext *ctx = avctx->priv_data;1072 AMRWBContext *ctx = avctx->priv_data;
1069 AMRWBFrame *cf = &ctx->frame;1073 AMRWBFrame *cf = &ctx->frame;
1070 const uint8_t *buf = avpkt->data;1074 const uint8_t *buf = avpkt->data;
1071 int buf_size = avpkt->size;1075 int buf_size = avpkt->size;
1072 int expected_fr_size, header_size;1076 int expected_fr_size, header_size;
1073 float *buf_out = data;1077 float *buf_out;
1074 float spare_vector[AMRWB_SFR_SIZE]; // extra stack space to hold result from anti-sparseness processing1078 float spare_vector[AMRWB_SFR_SIZE]; // extra stack space to hold result from anti-sparseness processing
1075 float fixed_gain_factor; // fixed gain correction factor (gamma)1079 float fixed_gain_factor; // fixed gain correction factor (gamma)
1076 float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use1080 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
1080 float hb_exc[AMRWB_SFR_SIZE_16k]; // excitation for the high frequency band1084 float hb_exc[AMRWB_SFR_SIZE_16k]; // excitation for the high frequency band
1081 float hb_samples[AMRWB_SFR_SIZE_16k]; // filtered high-band samples from synthesis1085 float hb_samples[AMRWB_SFR_SIZE_16k]; // filtered high-band samples from synthesis
1082 float hb_gain;1086 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];
1084 1096
1085 header_size = decode_mime_header(ctx, buf);1097 header_size = decode_mime_header(ctx, buf);
1086 expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1;1098 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
1088 if (buf_size < expected_fr_size) {1100 if (buf_size < expected_fr_size) {
1089 av_log(avctx, AV_LOG_ERROR,1101 av_log(avctx, AV_LOG_ERROR,
1090 "Frame too small (%d bytes). Truncated file?\n", buf_size);1102 "Frame too small (%d bytes). Truncated file?\n", buf_size);
1091 *data_size = 0;1103 *got_frame_ptr = 0;
1092 return buf_size;1104 return buf_size;
1093 }1105 }
1094 1106
@@ -1219,8 +1231,8 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 124 unmodified lines
1219 memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));1231 memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));
1220 memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float));1232 memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float));
1221 1233
1222 /* report how many samples we got */1234 *got_frame_ptr = 1;
1223 *data_size = 4 * AMRWB_SFR_SIZE_16k * sizeof(float);1235 *(AVFrame *)data = ctx->avframe;
1224 1236
1225 return expected_fr_size;1237 return expected_fr_size;
1226}1238}
@@ -1232,6 +1244,7 @@ AVCodec ff_amrwb_decoder = { · 5 unmodified lines
1232 .priv_data_size = sizeof(AMRWBContext),1244 .priv_data_size = sizeof(AMRWBContext),
1233 .init = amrwb_decode_init,1245 .init = amrwb_decode_init,
1234 .decode = amrwb_decode_frame,1246 .decode = amrwb_decode_frame,
1247 .capabilities = CODEC_CAP_DR1,
1235 .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"),1248 .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"),
1236 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},1249 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
1237};1250};
libavcodec/apedec.c+22−15
@@ -129,6 +129,7 @@ typedef struct APEPredictor { · 128 unmodified lines
129/** Decoder context */129/** Decoder context */
130typedef struct APEContext {130typedef struct APEContext {
131 AVCodecContext *avctx;131 AVCodecContext *avctx;
132 AVFrame frame;
132 DSPContext dsp;133 DSPContext dsp;
133 int channels;134 int channels;
134 int samples; ///< samples left to decode in current frame135 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
215 dsputil_init(&s->dsp, avctx);216 dsputil_init(&s->dsp, avctx);
216 avctx->sample_fmt = AV_SAMPLE_FMT_S16;217 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
217 avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;218 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
218 return 0;223 return 0;
219filter_alloc_fail:224filter_alloc_fail:
220 ape_decode_close(avctx);225 ape_decode_close(avctx);
@@ -805,16 +810,15 @@ static void ape_unpack_stereo(APEContext *ctx, int count) · 584 unmodified lines
805 }810 }
806}811}
807 812
808static int ape_decode_frame(AVCodecContext *avctx,813static int ape_decode_frame(AVCodecContext *avctx, void *data,
809 void *data, int *data_size,814 int *got_frame_ptr, AVPacket *avpkt)
810 AVPacket *avpkt)
811{815{
812 const uint8_t *buf = avpkt->data;816 const uint8_t *buf = avpkt->data;
813 int buf_size = avpkt->size;817 int buf_size = avpkt->size;
814 APEContext *s = avctx->priv_data;818 APEContext *s = avctx->priv_data;
815 int16_t *samples = data;819 int16_t *samples;
816 int i;820 int i, ret;
817 int blockstodecode, out_size;821 int blockstodecode;
818 int bytes_used = 0;822 int bytes_used = 0;
819 823
820 /* this should never be negative, but bad things will happen if it is, so824 /* 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
826 void *tmp_data;830 void *tmp_data;
827 831
828 if (!buf_size) {832 if (!buf_size) {
829 *data_size = 0;833 *got_frame_ptr = 0;
830 return 0;834 return 0;
831 }835 }
832 if (buf_size < 8) {836 if (buf_size < 8) {
@@ -874,18 +878,19 @@ static int ape_decode_frame(AVCodecContext *avctx, · 41 unmodified lines
874 }878 }
875 879
876 if (!s->data) {880 if (!s->data) {
877 *data_size = 0;881 *got_frame_ptr = 0;
878 return buf_size;882 return buf_size;
879 }883 }
880 884
881 blockstodecode = FFMIN(BLOCKS_PER_LOOP, s->samples);885 blockstodecode = FFMIN(BLOCKS_PER_LOOP, s->samples);
882 886
883 out_size = blockstodecode * avctx->channels *887 /* get output buffer */
884 av_get_bytes_per_sample(avctx->sample_fmt);888 s->frame.nb_samples = blockstodecode;
885 if (*data_size < out_size) {889 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
886 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small.\n");890 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
887 return AVERROR(EINVAL);891 return ret;
888 }892 }
893 samples = (int16_t *)s->frame.data[0];
889 894
890 s->error=0;895 s->error=0;
891 896
@@ -909,7 +914,9 @@ static int ape_decode_frame(AVCodecContext *avctx, · 17 unmodified lines
909 914
910 s->samples -= blockstodecode;915 s->samples -= blockstodecode;
911 916
912 *data_size = out_size;917 *got_frame_ptr = 1;
918 *(AVFrame *)data = s->frame;
919
913 return bytes_used;920 return bytes_used;
914}921}
915 922
@@ -927,7 +934,7 @@ AVCodec ff_ape_decoder = { · 11 unmodified lines
927 .init = ape_decode_init,934 .init = ape_decode_init,
928 .close = ape_decode_close,935 .close = ape_decode_close,
929 .decode = ape_decode_frame,936 .decode = ape_decode_frame,
930 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY,937 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1,
931 .flush = ape_flush,938 .flush = ape_flush,
932 .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),939 .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
933};940};
libavcodec/arm/h264dsp_neon.S+314−353
@@ -19,55 +19,16 @@ · 18 unmodified lines
19 */19 */
20 20
21#include "asm.S"21#include "asm.S"
22 22#include "neon.S"
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
62 23
63/* chroma_mc8(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */24/* chroma_mc8(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */
64 .macro h264_chroma_mc8 type25.macro h264_chroma_mc8 type
65function ff_\type\()_h264_chroma_mc8_neon, export=126function ff_\type\()_h264_chroma_mc8_neon, export=1
66 push {r4-r7, lr}27 push {r4-r7, lr}
67 ldrd r4, [sp, #20]28 ldrd r4, [sp, #20]
68.ifc \type,avg29 .ifc \type,avg
69 mov lr, r030 mov lr, r0
70.endif31 .endif
71 pld [r1]32 pld [r1]
72 pld [r1, r2]33 pld [r1, r2]
73 34
@@ -75,7 +36,7 @@ A muls r7, r4, r5 · 1 unmodified line
75T mul r7, r4, r536T mul r7, r4, r5
76T cmp r7, #037T cmp r7, #0
77 rsb r6, r7, r5, lsl #338 rsb r6, r7, r5, lsl #3
78 rsb ip, r7, r4, lsl #339 rsb r12, r7, r4, lsl #3
79 sub r4, r7, r4, lsl #340 sub r4, r7, r4, lsl #3
80 sub r4, r4, r5, lsl #341 sub r4, r4, r5, lsl #3
81 add r4, r4, #6442 add r4, r4, #64
@@ -86,10 +47,10 @@ T cmp r7, #0 · 4 unmodified lines
86 47
87 vdup.8 d0, r448 vdup.8 d0, r4
88 lsl r4, r2, #149 lsl r4, r2, #1
89 vdup.8 d1, ip50 vdup.8 d1, r12
90 vld1.64 {d4, d5}, [r1], r451 vld1.8 {d4, d5}, [r1], r4
91 vdup.8 d2, r652 vdup.8 d2, r6
92 vld1.64 {d6, d7}, [r5], r453 vld1.8 {d6, d7}, [r5], r4
93 vdup.8 d3, r754 vdup.8 d3, r7
94 55
95 vext.8 d5, d4, d5, #156 vext.8 d5, d4, d5, #1
@@ -98,7 +59,7 @@ T cmp r7, #0 · 2 unmodified lines
981: pld [r5]591: pld [r5]
99 vmull.u8 q8, d4, d060 vmull.u8 q8, d4, d0
100 vmlal.u8 q8, d5, d161 vmlal.u8 q8, d5, d1
101 vld1.64 {d4, d5}, [r1], r462 vld1.8 {d4, d5}, [r1], r4
102 vmlal.u8 q8, d6, d263 vmlal.u8 q8, d6, d2
103 vext.8 d5, d4, d5, #164 vext.8 d5, d4, d5, #1
104 vmlal.u8 q8, d7, d365 vmlal.u8 q8, d7, d3
@@ -108,57 +69,57 @@ T cmp r7, #0 · 3 unmodified lines
108 vmlal.u8 q9, d4, d269 vmlal.u8 q9, d4, d2
109 vmlal.u8 q9, d5, d370 vmlal.u8 q9, d5, d3
110 vrshrn.u16 d16, q8, #671 vrshrn.u16 d16, q8, #6
111 vld1.64 {d6, d7}, [r5], r472 vld1.8 {d6, d7}, [r5], r4
112 pld [r1]73 pld [r1]
113 vrshrn.u16 d17, q9, #674 vrshrn.u16 d17, q9, #6
114.ifc \type,avg75 .ifc \type,avg
115 vld1.64 {d20}, [lr,:64], r276 vld1.8 {d20}, [lr,:64], r2
116 vld1.64 {d21}, [lr,:64], r277 vld1.8 {d21}, [lr,:64], r2
117 vrhadd.u8 q8, q8, q1078 vrhadd.u8 q8, q8, q10
118.endif79 .endif
119 vext.8 d7, d6, d7, #180 vext.8 d7, d6, d7, #1
120 vst1.64 {d16}, [r0,:64], r281 vst1.8 {d16}, [r0,:64], r2
121 vst1.64 {d17}, [r0,:64], r282 vst1.8 {d17}, [r0,:64], r2
122 bgt 1b83 bgt 1b
123 84
124 pop {r4-r7, pc}85 pop {r4-r7, pc}
125 86
1262: tst r6, r6872: tst r6, r6
127 add ip, ip, r688 add r12, r12, r6
128 vdup.8 d0, r489 vdup.8 d0, r4
129 vdup.8 d1, ip90 vdup.8 d1, r12
130 91
131 beq 4f92 beq 4f
132 93
133 add r5, r1, r294 add r5, r1, r2
134 lsl r4, r2, #195 lsl r4, r2, #1
135 vld1.64 {d4}, [r1], r496 vld1.8 {d4}, [r1], r4
136 vld1.64 {d6}, [r5], r497 vld1.8 {d6}, [r5], r4
137 98
1383: pld [r5]993: pld [r5]
139 vmull.u8 q8, d4, d0100 vmull.u8 q8, d4, d0
140 vmlal.u8 q8, d6, d1101 vmlal.u8 q8, d6, d1
141 vld1.64 {d4}, [r1], r4102 vld1.8 {d4}, [r1], r4
142 vmull.u8 q9, d6, d0103 vmull.u8 q9, d6, d0
143 vmlal.u8 q9, d4, d1104 vmlal.u8 q9, d4, d1
144 vld1.64 {d6}, [r5], r4105 vld1.8 {d6}, [r5], r4
145 vrshrn.u16 d16, q8, #6106 vrshrn.u16 d16, q8, #6
146 vrshrn.u16 d17, q9, #6107 vrshrn.u16 d17, q9, #6
147.ifc \type,avg108 .ifc \type,avg
148 vld1.64 {d20}, [lr,:64], r2109 vld1.8 {d20}, [lr,:64], r2
149 vld1.64 {d21}, [lr,:64], r2110 vld1.8 {d21}, [lr,:64], r2
150 vrhadd.u8 q8, q8, q10111 vrhadd.u8 q8, q8, q10
151.endif112 .endif
152 subs r3, r3, #2113 subs r3, r3, #2
153 pld [r1]114 pld [r1]
154 vst1.64 {d16}, [r0,:64], r2115 vst1.8 {d16}, [r0,:64], r2
155 vst1.64 {d17}, [r0,:64], r2116 vst1.8 {d17}, [r0,:64], r2
156 bgt 3b117 bgt 3b
157 118
158 pop {r4-r7, pc}119 pop {r4-r7, pc}
159 120
1604: vld1.64 {d4, d5}, [r1], r21214: vld1.8 {d4, d5}, [r1], r2
161 vld1.64 {d6, d7}, [r1], r2122 vld1.8 {d6, d7}, [r1], r2
162 vext.8 d5, d4, d5, #1123 vext.8 d5, d4, d5, #1
163 vext.8 d7, d6, d7, #1124 vext.8 d7, d6, d7, #1
164 125
@@ -166,36 +127,36 @@ T cmp r7, #0 · 1 unmodified line
166 subs r3, r3, #2127 subs r3, r3, #2
167 vmull.u8 q8, d4, d0128 vmull.u8 q8, d4, d0
168 vmlal.u8 q8, d5, d1129 vmlal.u8 q8, d5, d1
169 vld1.64 {d4, d5}, [r1], r2130 vld1.8 {d4, d5}, [r1], r2
170 vmull.u8 q9, d6, d0131 vmull.u8 q9, d6, d0
171 vmlal.u8 q9, d7, d1132 vmlal.u8 q9, d7, d1
172 pld [r1]133 pld [r1]
173 vext.8 d5, d4, d5, #1134 vext.8 d5, d4, d5, #1
174 vrshrn.u16 d16, q8, #6135 vrshrn.u16 d16, q8, #6
175 vrshrn.u16 d17, q9, #6136 vrshrn.u16 d17, q9, #6
176.ifc \type,avg137 .ifc \type,avg
177 vld1.64 {d20}, [lr,:64], r2138 vld1.8 {d20}, [lr,:64], r2
178 vld1.64 {d21}, [lr,:64], r2139 vld1.8 {d21}, [lr,:64], r2
179 vrhadd.u8 q8, q8, q10140 vrhadd.u8 q8, q8, q10
180.endif141 .endif
181 vld1.64 {d6, d7}, [r1], r2142 vld1.8 {d6, d7}, [r1], r2
182 vext.8 d7, d6, d7, #1143 vext.8 d7, d6, d7, #1
183 vst1.64 {d16}, [r0,:64], r2144 vst1.8 {d16}, [r0,:64], r2
184 vst1.64 {d17}, [r0,:64], r2145 vst1.8 {d17}, [r0,:64], r2
185 bgt 5b146 bgt 5b
186 147
187 pop {r4-r7, pc}148 pop {r4-r7, pc}
188endfunc149endfunc
189 .endm150.endm
190 151
191/* chroma_mc4(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */152/* chroma_mc4(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */
192 .macro h264_chroma_mc4 type153.macro h264_chroma_mc4 type
193function ff_\type\()_h264_chroma_mc4_neon, export=1154function ff_\type\()_h264_chroma_mc4_neon, export=1
194 push {r4-r7, lr}155 push {r4-r7, lr}
195 ldrd r4, [sp, #20]156 ldrd r4, [sp, #20]
196.ifc \type,avg157 .ifc \type,avg
197 mov lr, r0158 mov lr, r0
198.endif159 .endif
199 pld [r1]160 pld [r1]
200 pld [r1, r2]161 pld [r1, r2]
201 162
@@ -203,7 +164,7 @@ A muls r7, r4, r5 · 1 unmodified line
203T mul r7, r4, r5164T mul r7, r4, r5
204T cmp r7, #0165T cmp r7, #0
205 rsb r6, r7, r5, lsl #3166 rsb r6, r7, r5, lsl #3
206 rsb ip, r7, r4, lsl #3167 rsb r12, r7, r4, lsl #3
207 sub r4, r7, r4, lsl #3168 sub r4, r7, r4, lsl #3
208 sub r4, r4, r5, lsl #3169 sub r4, r4, r5, lsl #3
209 add r4, r4, #64170 add r4, r4, #64
@@ -214,10 +175,10 @@ T cmp r7, #0 · 4 unmodified lines
214 175
215 vdup.8 d0, r4176 vdup.8 d0, r4
216 lsl r4, r2, #1177 lsl r4, r2, #1
217 vdup.8 d1, ip178 vdup.8 d1, r12
218 vld1.64 {d4}, [r1], r4179 vld1.8 {d4}, [r1], r4
219 vdup.8 d2, r6180 vdup.8 d2, r6
220 vld1.64 {d6}, [r5], r4181 vld1.8 {d6}, [r5], r4
221 vdup.8 d3, r7182 vdup.8 d3, r7
222 183
223 vext.8 d5, d4, d5, #1184 vext.8 d5, d4, d5, #1
@@ -231,22 +192,22 @@ T cmp r7, #0 · 7 unmodified lines
2311: pld [r5]1921: pld [r5]
232 vmull.u8 q8, d4, d0193 vmull.u8 q8, d4, d0
233 vmlal.u8 q8, d6, d2194 vmlal.u8 q8, d6, d2
234 vld1.64 {d4}, [r1], r4195 vld1.8 {d4}, [r1], r4
235 vext.8 d5, d4, d5, #1196 vext.8 d5, d4, d5, #1
236 vtrn.32 d4, d5197 vtrn.32 d4, d5
237 vmull.u8 q9, d6, d0198 vmull.u8 q9, d6, d0
238 vmlal.u8 q9, d4, d2199 vmlal.u8 q9, d4, d2
239 vld1.64 {d6}, [r5], r4200 vld1.8 {d6}, [r5], r4
240 vadd.i16 d16, d16, d17201 vadd.i16 d16, d16, d17
241 vadd.i16 d17, d18, d19202 vadd.i16 d17, d18, d19
242 vrshrn.u16 d16, q8, #6203 vrshrn.u16 d16, q8, #6
243 subs r3, r3, #2204 subs r3, r3, #2
244 pld [r1]205 pld [r1]
245.ifc \type,avg206 .ifc \type,avg
246 vld1.32 {d20[0]}, [lr,:32], r2207 vld1.32 {d20[0]}, [lr,:32], r2
247 vld1.32 {d20[1]}, [lr,:32], r2208 vld1.32 {d20[1]}, [lr,:32], r2
248 vrhadd.u8 d16, d16, d20209 vrhadd.u8 d16, d16, d20
249.endif210 .endif
250 vext.8 d7, d6, d7, #1211 vext.8 d7, d6, d7, #1
251 vtrn.32 d6, d7212 vtrn.32 d6, d7
252 vst1.32 {d16[0]}, [r0,:32], r2213 vst1.32 {d16[0]}, [r0,:32], r2
@@ -256,9 +217,9 @@ T cmp r7, #0 · 3 unmodified lines
256 pop {r4-r7, pc}217 pop {r4-r7, pc}
257 218
2582: tst r6, r62192: tst r6, r6
259 add ip, ip, r6220 add r12, r12, r6
260 vdup.8 d0, r4221 vdup.8 d0, r4
261 vdup.8 d1, ip222 vdup.8 d1, r12
262 vtrn.32 d0, d1223 vtrn.32 d0, d1
263 224
264 beq 4f225 beq 4f
@@ -277,11 +238,11 @@ T cmp r7, #0 · 12 unmodified lines
277 vadd.i16 d16, d16, d17238 vadd.i16 d16, d16, d17
278 vadd.i16 d17, d18, d19239 vadd.i16 d17, d18, d19
279 vrshrn.u16 d16, q8, #6240 vrshrn.u16 d16, q8, #6
280.ifc \type,avg241 .ifc \type,avg
281 vld1.32 {d20[0]}, [lr,:32], r2242 vld1.32 {d20[0]}, [lr,:32], r2
282 vld1.32 {d20[1]}, [lr,:32], r2243 vld1.32 {d20[1]}, [lr,:32], r2
283 vrhadd.u8 d16, d16, d20244 vrhadd.u8 d16, d16, d20
284.endif245 .endif
285 subs r3, r3, #2246 subs r3, r3, #2
286 pld [r1]247 pld [r1]
287 vst1.32 {d16[0]}, [r0,:32], r2248 vst1.32 {d16[0]}, [r0,:32], r2
@@ -290,8 +251,8 @@ T cmp r7, #0 · 2 unmodified lines
290 251
291 pop {r4-r7, pc}252 pop {r4-r7, pc}
292 253
2934: vld1.64 {d4}, [r1], r22544: vld1.8 {d4}, [r1], r2
294 vld1.64 {d6}, [r1], r2255 vld1.8 {d6}, [r1], r2
295 vext.8 d5, d4, d5, #1256 vext.8 d5, d4, d5, #1
296 vext.8 d7, d6, d7, #1257 vext.8 d7, d6, d7, #1
297 vtrn.32 d4, d5258 vtrn.32 d4, d5
@@ -300,19 +261,19 @@ T cmp r7, #0 · 2 unmodified lines
3005: vmull.u8 q8, d4, d02615: vmull.u8 q8, d4, d0
301 vmull.u8 q9, d6, d0262 vmull.u8 q9, d6, d0
302 subs r3, r3, #2263 subs r3, r3, #2
303 vld1.64 {d4}, [r1], r2264 vld1.8 {d4}, [r1], r2
304 vext.8 d5, d4, d5, #1265 vext.8 d5, d4, d5, #1
305 vtrn.32 d4, d5266 vtrn.32 d4, d5
306 vadd.i16 d16, d16, d17267 vadd.i16 d16, d16, d17
307 vadd.i16 d17, d18, d19268 vadd.i16 d17, d18, d19
308 pld [r1]269 pld [r1]
309 vrshrn.u16 d16, q8, #6270 vrshrn.u16 d16, q8, #6
310.ifc \type,avg271 .ifc \type,avg
311 vld1.32 {d20[0]}, [lr,:32], r2272 vld1.32 {d20[0]}, [lr,:32], r2
312 vld1.32 {d20[1]}, [lr,:32], r2273 vld1.32 {d20[1]}, [lr,:32], r2
313 vrhadd.u8 d16, d16, d20274 vrhadd.u8 d16, d16, d20
314.endif275 .endif
315 vld1.64 {d6}, [r1], r2276 vld1.8 {d6}, [r1], r2
316 vext.8 d7, d6, d7, #1277 vext.8 d7, d6, d7, #1
317 vtrn.32 d6, d7278 vtrn.32 d6, d7
318 pld [r1]279 pld [r1]
@@ -322,9 +283,9 @@ T cmp r7, #0 · 3 unmodified lines
322 283
323 pop {r4-r7, pc}284 pop {r4-r7, pc}
324endfunc285endfunc
325 .endm286.endm
326 287
327 .macro h264_chroma_mc2 type288.macro h264_chroma_mc2 type
328function ff_\type\()_h264_chroma_mc2_neon, export=1289function ff_\type\()_h264_chroma_mc2_neon, export=1
329 push {r4-r6, lr}290 push {r4-r6, lr}
330 ldr r4, [sp, #16]291 ldr r4, [sp, #16]
@@ -354,29 +315,29 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 · 23 unmodified lines
354 vtrn.16 q2, q3315 vtrn.16 q2, q3
355 vmull.u8 q8, d4, d0316 vmull.u8 q8, d4, d0
356 vmlal.u8 q8, d5, d1317 vmlal.u8 q8, d5, d1
357.ifc \type,avg318 .ifc \type,avg
358 vld1.16 {d18[0]}, [r0,:16], r2319 vld1.16 {d18[0]}, [r0,:16], r2
359 vld1.16 {d18[1]}, [r0,:16]320 vld1.16 {d18[1]}, [r0,:16]
360 sub r0, r0, r2321 sub r0, r0, r2
361.endif322 .endif
362 vtrn.32 d16, d17323 vtrn.32 d16, d17
363 vadd.i16 d16, d16, d17324 vadd.i16 d16, d16, d17
364 vrshrn.u16 d16, q8, #6325 vrshrn.u16 d16, q8, #6
365.ifc \type,avg326 .ifc \type,avg
366 vrhadd.u8 d16, d16, d18327 vrhadd.u8 d16, d16, d18
367.endif328 .endif
368 vst1.16 {d16[0]}, [r0,:16], r2329 vst1.16 {d16[0]}, [r0,:16], r2
369 vst1.16 {d16[1]}, [r0,:16], r2330 vst1.16 {d16[1]}, [r0,:16], r2
370 subs r3, r3, #2331 subs r3, r3, #2
371 bgt 1b332 bgt 1b
372 pop {r4-r6, pc}333 pop {r4-r6, pc}
3732:3342:
374.ifc \type,put335 .ifc \type,put
375 ldrh_post r5, r1, r2336 ldrh_post r5, r1, r2
376 strh_post r5, r0, r2337 strh_post r5, r0, r2
377 ldrh_post r6, r1, r2338 ldrh_post r6, r1, r2
378 strh_post r6, r0, r2339 strh_post r6, r0, r2
379.else340 .else
380 vld1.16 {d16[0]}, [r1], r2341 vld1.16 {d16[0]}, [r1], r2
381 vld1.16 {d16[1]}, [r1], r2342 vld1.16 {d16[1]}, [r1], r2
382 vld1.16 {d18[0]}, [r0,:16], r2343 vld1.16 {d18[0]}, [r0,:16], r2
@@ -385,7 +346,7 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 · 2 unmodified lines
385 vrhadd.u8 d16, d16, d18346 vrhadd.u8 d16, d16, d18
386 vst1.16 {d16[0]}, [r0,:16], r2347 vst1.16 {d16[0]}, [r0,:16], r2
387 vst1.16 {d16[1]}, [r0,:16], r2348 vst1.16 {d16[1]}, [r0,:16], r2
388.endif349 .endif
389 subs r3, r3, #2350 subs r3, r3, #2
390 bgt 2b351 bgt 2b
391 pop {r4-r6, pc}352 pop {r4-r6, pc}
@@ -401,22 +362,22 @@ endfunc · 9 unmodified lines
401 362
402 /* H.264 loop filter */363 /* H.264 loop filter */
403 364
404 .macro h264_loop_filter_start365.macro h264_loop_filter_start
405 ldr ip, [sp]366 ldr r12, [sp]
406 tst r2, r2367 tst r2, r2
407 ldr ip, [ip]368 ldr r12, [r12]
408 it ne369 it ne
409 tstne r3, r3370 tstne r3, r3
410 vmov.32 d24[0], ip371 vmov.32 d24[0], r12
411 and ip, ip, ip, lsl #16372 and r12, r12, r12, lsl #16
412 it eq373 it eq
413 bxeq lr374 bxeq lr
414 ands ip, ip, ip, lsl #8375 ands r12, r12, r12, lsl #8
415 it lt376 it lt
416 bxlt lr377 bxlt lr
417 .endm378.endm
418 379
419 .macro h264_loop_filter_luma380.macro h264_loop_filter_luma
420 vdup.8 q11, r2 @ alpha381 vdup.8 q11, r2 @ alpha
421 vmovl.u8 q12, d24382 vmovl.u8 q12, d24
422 vabd.u8 q6, q8, q0 @ abs(p0 - q0)383 vabd.u8 q6, q8, q0 @ abs(p0 - q0)
@@ -482,29 +443,29 @@ endfunc · 59 unmodified lines
482 vqmovun.s16 d17, q6443 vqmovun.s16 d17, q6
483 vqmovun.s16 d0, q11444 vqmovun.s16 d0, q11
484 vqmovun.s16 d1, q12445 vqmovun.s16 d1, q12
485 .endm446.endm
486 447
487function ff_h264_v_loop_filter_luma_neon, export=1448function ff_h264_v_loop_filter_luma_neon, export=1
488 h264_loop_filter_start449 h264_loop_filter_start
489 450
490 vld1.64 {d0, d1}, [r0,:128], r1451 vld1.8 {d0, d1}, [r0,:128], r1
491 vld1.64 {d2, d3}, [r0,:128], r1452 vld1.8 {d2, d3}, [r0,:128], r1
492 vld1.64 {d4, d5}, [r0,:128], r1453 vld1.8 {d4, d5}, [r0,:128], r1
493 sub r0, r0, r1, lsl #2454 sub r0, r0, r1, lsl #2
494 sub r0, r0, r1, lsl #1455 sub r0, r0, r1, lsl #1
495 vld1.64 {d20,d21}, [r0,:128], r1456 vld1.8 {d20,d21}, [r0,:128], r1
496 vld1.64 {d18,d19}, [r0,:128], r1457 vld1.8 {d18,d19}, [r0,:128], r1
497 vld1.64 {d16,d17}, [r0,:128], r1458 vld1.8 {d16,d17}, [r0,:128], r1
498 459
499 vpush {d8-d15}460 vpush {d8-d15}
500 461
501 h264_loop_filter_luma462 h264_loop_filter_luma
502 463
503 sub r0, r0, r1, lsl #1464 sub r0, r0, r1, lsl #1
504 vst1.64 {d8, d9}, [r0,:128], r1465 vst1.8 {d8, d9}, [r0,:128], r1
505 vst1.64 {d16,d17}, [r0,:128], r1466 vst1.8 {d16,d17}, [r0,:128], r1
506 vst1.64 {d0, d1}, [r0,:128], r1467 vst1.8 {d0, d1}, [r0,:128], r1
507 vst1.64 {d10,d11}, [r0,:128]468 vst1.8 {d10,d11}, [r0,:128]
508 469
509 vpop {d8-d15}470 vpop {d8-d15}
510 bx lr471 bx lr
@@ -514,22 +475,22 @@ function ff_h264_h_loop_filter_luma_neon, export=1 · 3 unmodified lines
514 h264_loop_filter_start475 h264_loop_filter_start
515 476
516 sub r0, r0, #4477 sub r0, r0, #4
517 vld1.64 {d6}, [r0], r1478 vld1.8 {d6}, [r0], r1
518 vld1.64 {d20}, [r0], r1479 vld1.8 {d20}, [r0], r1
519 vld1.64 {d18}, [r0], r1480 vld1.8 {d18}, [r0], r1
520 vld1.64 {d16}, [r0], r1481 vld1.8 {d16}, [r0], r1
521 vld1.64 {d0}, [r0], r1482 vld1.8 {d0}, [r0], r1
522 vld1.64 {d2}, [r0], r1483 vld1.8 {d2}, [r0], r1
523 vld1.64 {d4}, [r0], r1484 vld1.8 {d4}, [r0], r1
524 vld1.64 {d26}, [r0], r1485 vld1.8 {d26}, [r0], r1
525 vld1.64 {d7}, [r0], r1486 vld1.8 {d7}, [r0], r1
526 vld1.64 {d21}, [r0], r1487 vld1.8 {d21}, [r0], r1
527 vld1.64 {d19}, [r0], r1488 vld1.8 {d19}, [r0], r1
528 vld1.64 {d17}, [r0], r1489 vld1.8 {d17}, [r0], r1
529 vld1.64 {d1}, [r0], r1490 vld1.8 {d1}, [r0], r1
530 vld1.64 {d3}, [r0], r1491 vld1.8 {d3}, [r0], r1
531 vld1.64 {d5}, [r0], r1492 vld1.8 {d5}, [r0], r1
532 vld1.64 {d27}, [r0], r1493 vld1.8 {d27}, [r0], r1
533 494
534 transpose_8x8 q3, q10, q9, q8, q0, q1, q2, q13495 transpose_8x8 q3, q10, q9, q8, q0, q1, q2, q13
535 496
@@ -562,7 +523,7 @@ function ff_h264_h_loop_filter_luma_neon, export=1 · 26 unmodified lines
562 bx lr523 bx lr
563endfunc524endfunc
564 525
565 .macro h264_loop_filter_chroma526.macro h264_loop_filter_chroma
566 vdup.8 d22, r2 @ alpha527 vdup.8 d22, r2 @ alpha
567 vmovl.u8 q12, d24528 vmovl.u8 q12, d24
568 vabd.u8 d26, d16, d0 @ abs(p0 - q0)529 vabd.u8 d26, d16, d0 @ abs(p0 - q0)
@@ -591,22 +552,22 @@ endfunc · 22 unmodified lines
591 vsubw.s8 q11, q11, d4552 vsubw.s8 q11, q11, d4
592 vqmovun.s16 d16, q14553 vqmovun.s16 d16, q14
593 vqmovun.s16 d0, q11554 vqmovun.s16 d0, q11
594 .endm555.endm
595 556
596function ff_h264_v_loop_filter_chroma_neon, export=1557function ff_h264_v_loop_filter_chroma_neon, export=1
597 h264_loop_filter_start558 h264_loop_filter_start
598 559
599 sub r0, r0, r1, lsl #1560 sub r0, r0, r1, lsl #1
600 vld1.64 {d18}, [r0,:64], r1561 vld1.8 {d18}, [r0,:64], r1
601 vld1.64 {d16}, [r0,:64], r1562 vld1.8 {d16}, [r0,:64], r1
602 vld1.64 {d0}, [r0,:64], r1563 vld1.8 {d0}, [r0,:64], r1
603 vld1.64 {d2}, [r0,:64]564 vld1.8 {d2}, [r0,:64]
604 565
605 h264_loop_filter_chroma566 h264_loop_filter_chroma
606 567
607 sub r0, r0, r1, lsl #1568 sub r0, r0, r1, lsl #1
608 vst1.64 {d16}, [r0,:64], r1569 vst1.8 {d16}, [r0,:64], r1
609 vst1.64 {d0}, [r0,:64], r1570 vst1.8 {d0}, [r0,:64], r1
610 571
611 bx lr572 bx lr
612endfunc573endfunc
@@ -651,20 +612,20 @@ endfunc · 38 unmodified lines
651 612
652 /* H.264 qpel MC */613 /* H.264 qpel MC */
653 614
654 .macro lowpass_const r615.macro lowpass_const r
655 movw \r, #5616 movw \r, #5
656 movt \r, #20617 movt \r, #20
657 vmov.32 d6[0], \r618 vmov.32 d6[0], \r
658 .endm619.endm
659 620
660 .macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1621.macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1
661.if \narrow622 .if \narrow
662 t0 .req q0623 t0 .req q0
663 t1 .req q8624 t1 .req q8
664.else625 .else
665 t0 .req \d0626 t0 .req \d0
666 t1 .req \d1627 t1 .req \d1
667.endif628 .endif
668 vext.8 d2, \r0, \r1, #2629 vext.8 d2, \r0, \r1, #2
669 vext.8 d3, \r0, \r1, #3630 vext.8 d3, \r0, \r1, #3
670 vaddl.u8 q1, d2, d3631 vaddl.u8 q1, d2, d3
@@ -685,20 +646,20 @@ endfunc · 14 unmodified lines
685 vaddl.u8 t1, \r2, d31646 vaddl.u8 t1, \r2, d31
686 vmla.i16 t1, q9, d6[1]647 vmla.i16 t1, q9, d6[1]
687 vmls.i16 t1, q10, d6[0]648 vmls.i16 t1, q10, d6[0]
688.if \narrow649 .if \narrow
689 vqrshrun.s16 \d0, t0, #5650 vqrshrun.s16 \d0, t0, #5
690 vqrshrun.s16 \d1, t1, #5651 vqrshrun.s16 \d1, t1, #5
691.endif652 .endif
692 .unreq t0653 .unreq t0
693 .unreq t1654 .unreq t1
694 .endm655.endm
695 656
696 .macro lowpass_8_1 r0, r1, d0, narrow=1657.macro lowpass_8_1 r0, r1, d0, narrow=1
697.if \narrow658 .if \narrow
698 t0 .req q0659 t0 .req q0
699.else660 .else
700 t0 .req \d0661 t0 .req \d0
701.endif662 .endif
702 vext.8 d2, \r0, \r1, #2663 vext.8 d2, \r0, \r1, #2
703 vext.8 d3, \r0, \r1, #3664 vext.8 d3, \r0, \r1, #3
704 vaddl.u8 q1, d2, d3665 vaddl.u8 q1, d2, d3
@@ -709,13 +670,13 @@ endfunc · 4 unmodified lines
709 vaddl.u8 t0, \r0, d30670 vaddl.u8 t0, \r0, d30
710 vmla.i16 t0, q1, d6[1]671 vmla.i16 t0, q1, d6[1]
711 vmls.i16 t0, q2, d6[0]672 vmls.i16 t0, q2, d6[0]
712.if \narrow673 .if \narrow
713 vqrshrun.s16 \d0, t0, #5674 vqrshrun.s16 \d0, t0, #5
714.endif675 .endif
715 .unreq t0676 .unreq t0
716 .endm677.endm
717 678
718 .macro lowpass_8.16 r0, r1, l0, h0, l1, h1, d679.macro lowpass_8.16 r0, r1, l0, h0, l1, h1, d
719 vext.16 q1, \r0, \r1, #2680 vext.16 q1, \r0, \r1, #2
720 vext.16 q0, \r0, \r1, #3681 vext.16 q0, \r0, \r1, #3
721 vaddl.s16 q9, d2, d0682 vaddl.s16 q9, d2, d0
@@ -750,59 +711,59 @@ endfunc · 28 unmodified lines
750 vrshrn.s32 d19, q1, #10711 vrshrn.s32 d19, q1, #10
751 712
752 vqmovun.s16 \d, q9713 vqmovun.s16 \d, q9
753 .endm714.endm
754 715
755function put_h264_qpel16_h_lowpass_neon_packed716function put_h264_qpel16_h_lowpass_neon_packed
756 mov r4, lr717 mov r4, lr
757 mov ip, #16718 mov r12, #16
758 mov r3, #8719 mov r3, #8
759 bl put_h264_qpel8_h_lowpass_neon720 bl put_h264_qpel8_h_lowpass_neon
760 sub r1, r1, r2, lsl #4721 sub r1, r1, r2, lsl #4
761 add r1, r1, #8722 add r1, r1, #8
762 mov ip, #16723 mov r12, #16
763 mov lr, r4724 mov lr, r4
764 b put_h264_qpel8_h_lowpass_neon725 b put_h264_qpel8_h_lowpass_neon
765endfunc726endfunc
766 727
767 .macro h264_qpel_h_lowpass type728.macro h264_qpel_h_lowpass type
768function \type\()_h264_qpel16_h_lowpass_neon729function \type\()_h264_qpel16_h_lowpass_neon
769 push {lr}730 push {lr}
770 mov ip, #16731 mov r12, #16
771 bl \type\()_h264_qpel8_h_lowpass_neon732 bl \type\()_h264_qpel8_h_lowpass_neon
772 sub r0, r0, r3, lsl #4733 sub r0, r0, r3, lsl #4
773 sub r1, r1, r2, lsl #4734 sub r1, r1, r2, lsl #4
774 add r0, r0, #8735 add r0, r0, #8
775 add r1, r1, #8736 add r1, r1, #8
776 mov ip, #16737 mov r12, #16
777 pop {lr}738 pop {lr}
778endfunc739endfunc
779 740
780function \type\()_h264_qpel8_h_lowpass_neon741function \type\()_h264_qpel8_h_lowpass_neon
7811: vld1.64 {d0, d1}, [r1], r27421: vld1.8 {d0, d1}, [r1], r2
782 vld1.64 {d16,d17}, [r1], r2743 vld1.8 {d16,d17}, [r1], r2
783 subs ip, ip, #2744 subs r12, r12, #2
784 lowpass_8 d0, d1, d16, d17, d0, d16745 lowpass_8 d0, d1, d16, d17, d0, d16
785.ifc \type,avg746 .ifc \type,avg
786 vld1.8 {d2}, [r0,:64], r3747 vld1.8 {d2}, [r0,:64], r3
787 vrhadd.u8 d0, d0, d2748 vrhadd.u8 d0, d0, d2
788 vld1.8 {d3}, [r0,:64]749 vld1.8 {d3}, [r0,:64]
789 vrhadd.u8 d16, d16, d3750 vrhadd.u8 d16, d16, d3
790 sub r0, r0, r3751 sub r0, r0, r3
791.endif752 .endif
792 vst1.64 {d0}, [r0,:64], r3753 vst1.8 {d0}, [r0,:64], r3
793 vst1.64 {d16}, [r0,:64], r3754 vst1.8 {d16}, [r0,:64], r3
794 bne 1b755 bne 1b
795 bx lr756 bx lr
796endfunc757endfunc
797 .endm758.endm
798 759
799 h264_qpel_h_lowpass put760 h264_qpel_h_lowpass put
800 h264_qpel_h_lowpass avg761 h264_qpel_h_lowpass avg
801 762
802 .macro h264_qpel_h_lowpass_l2 type763.macro h264_qpel_h_lowpass_l2 type
803function \type\()_h264_qpel16_h_lowpass_l2_neon764function \type\()_h264_qpel16_h_lowpass_l2_neon
804 push {lr}765 push {lr}
805 mov ip, #16766 mov r12, #16
806 bl \type\()_h264_qpel8_h_lowpass_l2_neon767 bl \type\()_h264_qpel8_h_lowpass_l2_neon
807 sub r0, r0, r2, lsl #4768 sub r0, r0, r2, lsl #4
808 sub r1, r1, r2, lsl #4769 sub r1, r1, r2, lsl #4
@@ -810,31 +771,31 @@ function \type\()_h264_qpel16_h_lowpass_l2_neon · 1 unmodified line
810 add r0, r0, #8771 add r0, r0, #8
811 add r1, r1, #8772 add r1, r1, #8
812 add r3, r3, #8773 add r3, r3, #8
813 mov ip, #16774 mov r12, #16
814 pop {lr}775 pop {lr}
815endfunc776endfunc
816 777
817function \type\()_h264_qpel8_h_lowpass_l2_neon778function \type\()_h264_qpel8_h_lowpass_l2_neon
8181: vld1.64 {d0, d1}, [r1], r27791: vld1.8 {d0, d1}, [r1], r2
819 vld1.64 {d16,d17}, [r1], r2780 vld1.8 {d16,d17}, [r1], r2
820 vld1.64 {d28}, [r3], r2781 vld1.8 {d28}, [r3], r2
821 vld1.64 {d29}, [r3], r2782 vld1.8 {d29}, [r3], r2
822 subs ip, ip, #2783 subs r12, r12, #2
823 lowpass_8 d0, d1, d16, d17, d0, d1784 lowpass_8 d0, d1, d16, d17, d0, d1
824 vrhadd.u8 q0, q0, q14785 vrhadd.u8 q0, q0, q14
825.ifc \type,avg786 .ifc \type,avg
826 vld1.8 {d2}, [r0,:64], r2787 vld1.8 {d2}, [r0,:64], r2
827 vrhadd.u8 d0, d0, d2788 vrhadd.u8 d0, d0, d2
828 vld1.8 {d3}, [r0,:64]789 vld1.8 {d3}, [r0,:64]
829 vrhadd.u8 d1, d1, d3790 vrhadd.u8 d1, d1, d3
830 sub r0, r0, r2791 sub r0, r0, r2
831.endif792 .endif
832 vst1.64 {d0}, [r0,:64], r2793 vst1.8 {d0}, [r0,:64], r2
833 vst1.64 {d1}, [r0,:64], r2794 vst1.8 {d1}, [r0,:64], r2
834 bne 1b795 bne 1b
835 bx lr796 bx lr
836endfunc797endfunc
837 .endm798.endm
838 799
839 h264_qpel_h_lowpass_l2 put800 h264_qpel_h_lowpass_l2 put
840 h264_qpel_h_lowpass_l2 avg801 h264_qpel_h_lowpass_l2 avg
@@ -854,7 +815,7 @@ function put_h264_qpel16_v_lowpass_neon_packed · 13 unmodified lines
854 b put_h264_qpel8_v_lowpass_neon815 b put_h264_qpel8_v_lowpass_neon
855endfunc816endfunc
856 817
857 .macro h264_qpel_v_lowpass type818.macro h264_qpel_v_lowpass type
858function \type\()_h264_qpel16_v_lowpass_neon819function \type\()_h264_qpel16_v_lowpass_neon
859 mov r4, lr820 mov r4, lr
860 bl \type\()_h264_qpel8_v_lowpass_neon821 bl \type\()_h264_qpel8_v_lowpass_neon
@@ -871,19 +832,19 @@ function \type\()_h264_qpel16_v_lowpass_neon · 10 unmodified lines
871endfunc832endfunc
872 833
873function \type\()_h264_qpel8_v_lowpass_neon834function \type\()_h264_qpel8_v_lowpass_neon
874 vld1.64 {d8}, [r1], r3835 vld1.8 {d8}, [r1], r3
875 vld1.64 {d10}, [r1], r3836 vld1.8 {d10}, [r1], r3
876 vld1.64 {d12}, [r1], r3837 vld1.8 {d12}, [r1], r3
877 vld1.64 {d14}, [r1], r3838 vld1.8 {d14}, [r1], r3
878 vld1.64 {d22}, [r1], r3839 vld1.8 {d22}, [r1], r3
879 vld1.64 {d24}, [r1], r3840 vld1.8 {d24}, [r1], r3
880 vld1.64 {d26}, [r1], r3841 vld1.8 {d26}, [r1], r3
881 vld1.64 {d28}, [r1], r3842 vld1.8 {d28}, [r1], r3
882 vld1.64 {d9}, [r1], r3843 vld1.8 {d9}, [r1], r3
883 vld1.64 {d11}, [r1], r3844 vld1.8 {d11}, [r1], r3
884 vld1.64 {d13}, [r1], r3845 vld1.8 {d13}, [r1], r3
885 vld1.64 {d15}, [r1], r3846 vld1.8 {d15}, [r1], r3
886 vld1.64 {d23}, [r1]847 vld1.8 {d23}, [r1]
887 848
888 transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14849 transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14
889 lowpass_8 d8, d9, d10, d11, d8, d10850 lowpass_8 d8, d9, d10, d11, d8, d10
@@ -892,7 +853,7 @@ function \type\()_h264_qpel8_v_lowpass_neon · 2 unmodified lines
892 lowpass_8 d26, d27, d28, d29, d26, d28853 lowpass_8 d26, d27, d28, d29, d26, d28
893 transpose_8x8 d8, d10, d12, d14, d22, d24, d26, d28854 transpose_8x8 d8, d10, d12, d14, d22, d24, d26, d28
894 855
895.ifc \type,avg856 .ifc \type,avg
896 vld1.8 {d9}, [r0,:64], r2857 vld1.8 {d9}, [r0,:64], r2
897 vrhadd.u8 d8, d8, d9858 vrhadd.u8 d8, d8, d9
898 vld1.8 {d11}, [r0,:64], r2859 vld1.8 {d11}, [r0,:64], r2
@@ -910,34 +871,34 @@ function \type\()_h264_qpel8_v_lowpass_neon · 11 unmodified lines
910 vld1.8 {d29}, [r0,:64], r2871 vld1.8 {d29}, [r0,:64], r2
911 vrhadd.u8 d28, d28, d29872 vrhadd.u8 d28, d28, d29
912 sub r0, r0, r2, lsl #3873 sub r0, r0, r2, lsl #3
913.endif874 .endif
914 875
915 vst1.64 {d8}, [r0,:64], r2876 vst1.8 {d8}, [r0,:64], r2
916 vst1.64 {d10}, [r0,:64], r2877 vst1.8 {d10}, [r0,:64], r2
917 vst1.64 {d12}, [r0,:64], r2878 vst1.8 {d12}, [r0,:64], r2
918 vst1.64 {d14}, [r0,:64], r2879 vst1.8 {d14}, [r0,:64], r2
919 vst1.64 {d22}, [r0,:64], r2880 vst1.8 {d22}, [r0,:64], r2
920 vst1.64 {d24}, [r0,:64], r2881 vst1.8 {d24}, [r0,:64], r2
921 vst1.64 {d26}, [r0,:64], r2882 vst1.8 {d26}, [r0,:64], r2
922 vst1.64 {d28}, [r0,:64], r2883 vst1.8 {d28}, [r0,:64], r2
923 884
924 bx lr885 bx lr
925endfunc886endfunc
926 .endm887.endm
927 888
928 h264_qpel_v_lowpass put889 h264_qpel_v_lowpass put
929 h264_qpel_v_lowpass avg890 h264_qpel_v_lowpass avg
930 891
931 .macro h264_qpel_v_lowpass_l2 type892.macro h264_qpel_v_lowpass_l2 type
932function \type\()_h264_qpel16_v_lowpass_l2_neon893function \type\()_h264_qpel16_v_lowpass_l2_neon
933 mov r4, lr894 mov r4, lr
934 bl \type\()_h264_qpel8_v_lowpass_l2_neon895 bl \type\()_h264_qpel8_v_lowpass_l2_neon
935 sub r1, r1, r3, lsl #2896 sub r1, r1, r3, lsl #2
936 bl \type\()_h264_qpel8_v_lowpass_l2_neon897 bl \type\()_h264_qpel8_v_lowpass_l2_neon
937 sub r0, r0, r3, lsl #4898 sub r0, r0, r3, lsl #4
938 sub ip, ip, r2, lsl #4899 sub r12, r12, r2, lsl #4
939 add r0, r0, #8900 add r0, r0, #8
940 add ip, ip, #8901 add r12, r12, #8
941 sub r1, r1, r3, lsl #4902 sub r1, r1, r3, lsl #4
942 sub r1, r1, r3, lsl #2903 sub r1, r1, r3, lsl #2
943 add r1, r1, #8904 add r1, r1, #8
@@ -947,19 +908,19 @@ function \type\()_h264_qpel16_v_lowpass_l2_neon · 3 unmodified lines
947endfunc908endfunc
948 909
949function \type\()_h264_qpel8_v_lowpass_l2_neon910function \type\()_h264_qpel8_v_lowpass_l2_neon
950 vld1.64 {d8}, [r1], r3911 vld1.8 {d8}, [r1], r3
951 vld1.64 {d10}, [r1], r3912 vld1.8 {d10}, [r1], r3
952 vld1.64 {d12}, [r1], r3913 vld1.8 {d12}, [r1], r3
953 vld1.64 {d14}, [r1], r3914 vld1.8 {d14}, [r1], r3
954 vld1.64 {d22}, [r1], r3915 vld1.8 {d22}, [r1], r3
955 vld1.64 {d24}, [r1], r3916 vld1.8 {d24}, [r1], r3
956 vld1.64 {d26}, [r1], r3917 vld1.8 {d26}, [r1], r3
957 vld1.64 {d28}, [r1], r3918 vld1.8 {d28}, [r1], r3
958 vld1.64 {d9}, [r1], r3919 vld1.8 {d9}, [r1], r3
959 vld1.64 {d11}, [r1], r3920 vld1.8 {d11}, [r1], r3
960 vld1.64 {d13}, [r1], r3921 vld1.8 {d13}, [r1], r3
961 vld1.64 {d15}, [r1], r3922 vld1.8 {d15}, [r1], r3
962 vld1.64 {d23}, [r1]923 vld1.8 {d23}, [r1]
963 924
964 transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14925 transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14
965 lowpass_8 d8, d9, d10, d11, d8, d9926 lowpass_8 d8, d9, d10, d11, d8, d9
@@ -968,20 +929,20 @@ function \type\()_h264_qpel8_v_lowpass_l2_neon · 2 unmodified lines
968 lowpass_8 d26, d27, d28, d29, d26, d27929 lowpass_8 d26, d27, d28, d29, d26, d27
969 transpose_8x8 d8, d9, d12, d13, d22, d23, d26, d27930 transpose_8x8 d8, d9, d12, d13, d22, d23, d26, d27
970 931
971 vld1.64 {d0}, [ip], r2932 vld1.8 {d0}, [r12], r2
972 vld1.64 {d1}, [ip], r2933 vld1.8 {d1}, [r12], r2
973 vld1.64 {d2}, [ip], r2934 vld1.8 {d2}, [r12], r2
974 vld1.64 {d3}, [ip], r2935 vld1.8 {d3}, [r12], r2
975 vld1.64 {d4}, [ip], r2936 vld1.8 {d4}, [r12], r2
976 vrhadd.u8 q0, q0, q4937 vrhadd.u8 q0, q0, q4
977 vld1.64 {d5}, [ip], r2938 vld1.8 {d5}, [r12], r2
978 vrhadd.u8 q1, q1, q6939 vrhadd.u8 q1, q1, q6
979 vld1.64 {d10}, [ip], r2940 vld1.8 {d10}, [r12], r2
980 vrhadd.u8 q2, q2, q11941 vrhadd.u8 q2, q2, q11
981 vld1.64 {d11}, [ip], r2942 vld1.8 {d11}, [r12], r2
982 vrhadd.u8 q5, q5, q13943 vrhadd.u8 q5, q5, q13
983 944
984.ifc \type,avg945 .ifc \type,avg
985 vld1.8 {d16}, [r0,:64], r3946 vld1.8 {d16}, [r0,:64], r3
986 vrhadd.u8 d0, d0, d16947 vrhadd.u8 d0, d0, d16
987 vld1.8 {d17}, [r0,:64], r3948 vld1.8 {d17}, [r0,:64], r3
@@ -999,51 +960,51 @@ function \type\()_h264_qpel8_v_lowpass_l2_neon · 11 unmodified lines
999 vld1.8 {d17}, [r0,:64], r3960 vld1.8 {d17}, [r0,:64], r3
1000 vrhadd.u8 d11, d11, d17961 vrhadd.u8 d11, d11, d17
1001 sub r0, r0, r3, lsl #3962 sub r0, r0, r3, lsl #3
1002.endif963 .endif
1003 964
1004 vst1.64 {d0}, [r0,:64], r3965 vst1.8 {d0}, [r0,:64], r3
1005 vst1.64 {d1}, [r0,:64], r3966 vst1.8 {d1}, [r0,:64], r3
1006 vst1.64 {d2}, [r0,:64], r3967 vst1.8 {d2}, [r0,:64], r3
1007 vst1.64 {d3}, [r0,:64], r3968 vst1.8 {d3}, [r0,:64], r3
1008 vst1.64 {d4}, [r0,:64], r3969 vst1.8 {d4}, [r0,:64], r3
1009 vst1.64 {d5}, [r0,:64], r3970 vst1.8 {d5}, [r0,:64], r3
1010 vst1.64 {d10}, [r0,:64], r3971 vst1.8 {d10}, [r0,:64], r3
1011 vst1.64 {d11}, [r0,:64], r3972 vst1.8 {d11}, [r0,:64], r3
1012 973
1013 bx lr974 bx lr
1014endfunc975endfunc
1015 .endm976.endm
1016 977
1017 h264_qpel_v_lowpass_l2 put978 h264_qpel_v_lowpass_l2 put
1018 h264_qpel_v_lowpass_l2 avg979 h264_qpel_v_lowpass_l2 avg
1019 980
1020function put_h264_qpel8_hv_lowpass_neon_top981function put_h264_qpel8_hv_lowpass_neon_top
1021 lowpass_const ip982 lowpass_const r12
1022 mov ip, #12983 mov r12, #12
10231: vld1.64 {d0, d1}, [r1], r39841: vld1.8 {d0, d1}, [r1], r3
1024 vld1.64 {d16,d17}, [r1], r3985 vld1.8 {d16,d17}, [r1], r3
1025 subs ip, ip, #2986 subs r12, r12, #2
1026 lowpass_8 d0, d1, d16, d17, q11, q12, narrow=0987 lowpass_8 d0, d1, d16, d17, q11, q12, narrow=0
1027 vst1.64 {d22-d25}, [r4,:128]!988 vst1.8 {d22-d25}, [r4,:128]!
1028 bne 1b989 bne 1b
1029 990
1030 vld1.64 {d0, d1}, [r1]991 vld1.8 {d0, d1}, [r1]
1031 lowpass_8_1 d0, d1, q12, narrow=0992 lowpass_8_1 d0, d1, q12, narrow=0
1032 993
1033 mov ip, #-16994 mov r12, #-16
1034 add r4, r4, ip995 add r4, r4, r12
1035 vld1.64 {d30,d31}, [r4,:128], ip996 vld1.8 {d30,d31}, [r4,:128], r12
1036 vld1.64 {d20,d21}, [r4,:128], ip997 vld1.8 {d20,d21}, [r4,:128], r12
1037 vld1.64 {d18,d19}, [r4,:128], ip998 vld1.8 {d18,d19}, [r4,:128], r12
1038 vld1.64 {d16,d17}, [r4,:128], ip999 vld1.8 {d16,d17}, [r4,:128], r12
1039 vld1.64 {d14,d15}, [r4,:128], ip1000 vld1.8 {d14,d15}, [r4,:128], r12
1040 vld1.64 {d12,d13}, [r4,:128], ip1001 vld1.8 {d12,d13}, [r4,:128], r12
1041 vld1.64 {d10,d11}, [r4,:128], ip1002 vld1.8 {d10,d11}, [r4,:128], r12
1042 vld1.64 {d8, d9}, [r4,:128], ip1003 vld1.8 {d8, d9}, [r4,:128], r12
1043 vld1.64 {d6, d7}, [r4,:128], ip1004 vld1.8 {d6, d7}, [r4,:128], r12
1044 vld1.64 {d4, d5}, [r4,:128], ip1005 vld1.8 {d4, d5}, [r4,:128], r12
1045 vld1.64 {d2, d3}, [r4,:128], ip1006 vld1.8 {d2, d3}, [r4,:128], r12
1046 vld1.64 {d0, d1}, [r4,:128]1007 vld1.8 {d0, d1}, [r4,:128]
1047 1008
1048 swap4 d1, d3, d5, d7, d8, d10, d12, d141009 swap4 d1, d3, d5, d7, d8, d10, d12, d14
1049 transpose16_4x4 q0, q1, q2, q3, q4, q5, q6, q71010 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
1051 swap4 d17, d19, d21, d31, d24, d26, d28, d221012 swap4 d17, d19, d21, d31, d24, d26, d28, d22
1052 transpose16_4x4 q8, q9, q10, q15, q12, q13, q14, q111013 transpose16_4x4 q8, q9, q10, q15, q12, q13, q14, q11
1053 1014
1054 vst1.64 {d30,d31}, [r4,:128]!1015 vst1.8 {d30,d31}, [r4,:128]!
1055 vst1.64 {d6, d7}, [r4,:128]!1016 vst1.8 {d6, d7}, [r4,:128]!
1056 vst1.64 {d20,d21}, [r4,:128]!1017 vst1.8 {d20,d21}, [r4,:128]!
1057 vst1.64 {d4, d5}, [r4,:128]!1018 vst1.8 {d4, d5}, [r4,:128]!
1058 vst1.64 {d18,d19}, [r4,:128]!1019 vst1.8 {d18,d19}, [r4,:128]!
1059 vst1.64 {d2, d3}, [r4,:128]!1020 vst1.8 {d2, d3}, [r4,:128]!
1060 vst1.64 {d16,d17}, [r4,:128]!1021 vst1.8 {d16,d17}, [r4,:128]!
1061 vst1.64 {d0, d1}, [r4,:128]1022 vst1.8 {d0, d1}, [r4,:128]
1062 1023
1063 lowpass_8.16 q4, q12, d8, d9, d24, d25, d81024 lowpass_8.16 q4, q12, d8, d9, d24, d25, d8
1064 lowpass_8.16 q5, q13, d10, d11, d26, d27, d91025 lowpass_8.16 q5, q13, d10, d11, d26, d27, d9
1065 lowpass_8.16 q6, q14, d12, d13, d28, d29, d101026 lowpass_8.16 q6, q14, d12, d13, d28, d29, d10
1066 lowpass_8.16 q7, q11, d14, d15, d22, d23, d111027 lowpass_8.16 q7, q11, d14, d15, d22, d23, d11
1067 1028
1068 vld1.64 {d16,d17}, [r4,:128], ip1029 vld1.8 {d16,d17}, [r4,:128], r12
1069 vld1.64 {d30,d31}, [r4,:128], ip1030 vld1.8 {d30,d31}, [r4,:128], r12
1070 lowpass_8.16 q8, q15, d16, d17, d30, d31, d121031 lowpass_8.16 q8, q15, d16, d17, d30, d31, d12
1071 vld1.64 {d16,d17}, [r4,:128], ip1032 vld1.8 {d16,d17}, [r4,:128], r12
1072 vld1.64 {d30,d31}, [r4,:128], ip1033 vld1.8 {d30,d31}, [r4,:128], r12
1073 lowpass_8.16 q8, q15, d16, d17, d30, d31, d131034 lowpass_8.16 q8, q15, d16, d17, d30, d31, d13
1074 vld1.64 {d16,d17}, [r4,:128], ip1035 vld1.8 {d16,d17}, [r4,:128], r12
1075 vld1.64 {d30,d31}, [r4,:128], ip1036 vld1.8 {d30,d31}, [r4,:128], r12
1076 lowpass_8.16 q8, q15, d16, d17, d30, d31, d141037 lowpass_8.16 q8, q15, d16, d17, d30, d31, d14
1077 vld1.64 {d16,d17}, [r4,:128], ip1038 vld1.8 {d16,d17}, [r4,:128], r12
1078 vld1.64 {d30,d31}, [r4,:128]1039 vld1.8 {d30,d31}, [r4,:128]
1079 lowpass_8.16 q8, q15, d16, d17, d30, d31, d151040 lowpass_8.16 q8, q15, d16, d17, d30, d31, d15
1080 1041
1081 transpose_8x8 d12, d13, d14, d15, d8, d9, d10, d111042 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
1083 bx lr1044 bx lr
1084endfunc1045endfunc
1085 1046
1086 .macro h264_qpel8_hv_lowpass type1047.macro h264_qpel8_hv_lowpass type
1087function \type\()_h264_qpel8_hv_lowpass_neon1048function \type\()_h264_qpel8_hv_lowpass_neon
1088 mov r10, lr1049 mov r10, lr
1089 bl put_h264_qpel8_hv_lowpass_neon_top1050 bl put_h264_qpel8_hv_lowpass_neon_top
1090.ifc \type,avg1051 .ifc \type,avg
1091 vld1.8 {d0}, [r0,:64], r21052 vld1.8 {d0}, [r0,:64], r2
1092 vrhadd.u8 d12, d12, d01053 vrhadd.u8 d12, d12, d0
1093 vld1.8 {d1}, [r0,:64], r21054 vld1.8 {d1}, [r0,:64], r2
@@ -1105,39 +1066,39 @@ function \type\()_h264_qpel8_hv_lowpass_neon · 11 unmodified lines
1105 vld1.8 {d7}, [r0,:64], r21066 vld1.8 {d7}, [r0,:64], r2
1106 vrhadd.u8 d11, d11, d71067 vrhadd.u8 d11, d11, d7
1107 sub r0, r0, r2, lsl #31068 sub r0, r0, r2, lsl #3
1108.endif1069 .endif
1109 1070
1110 vst1.64 {d12}, [r0,:64], r21071 vst1.8 {d12}, [r0,:64], r2
1111 vst1.64 {d13}, [r0,:64], r21072 vst1.8 {d13}, [r0,:64], r2
1112 vst1.64 {d14}, [r0,:64], r21073 vst1.8 {d14}, [r0,:64], r2
1113 vst1.64 {d15}, [r0,:64], r21074 vst1.8 {d15}, [r0,:64], r2
1114 vst1.64 {d8}, [r0,:64], r21075 vst1.8 {d8}, [r0,:64], r2
1115 vst1.64 {d9}, [r0,:64], r21076 vst1.8 {d9}, [r0,:64], r2
1116 vst1.64 {d10}, [r0,:64], r21077 vst1.8 {d10}, [r0,:64], r2
1117 vst1.64 {d11}, [r0,:64], r21078 vst1.8 {d11}, [r0,:64], r2
1118 1079
1119 mov lr, r101080 mov lr, r10
1120 bx lr1081 bx lr
1121endfunc1082endfunc
1122 .endm1083.endm
1123 1084
1124 h264_qpel8_hv_lowpass put1085 h264_qpel8_hv_lowpass put
1125 h264_qpel8_hv_lowpass avg1086 h264_qpel8_hv_lowpass avg
1126 1087
1127 .macro h264_qpel8_hv_lowpass_l2 type1088.macro h264_qpel8_hv_lowpass_l2 type
1128function \type\()_h264_qpel8_hv_lowpass_l2_neon1089function \type\()_h264_qpel8_hv_lowpass_l2_neon
1129 mov r10, lr1090 mov r10, lr
1130 bl put_h264_qpel8_hv_lowpass_neon_top1091 bl put_h264_qpel8_hv_lowpass_neon_top
1131 1092
1132 vld1.64 {d0, d1}, [r2,:128]!1093 vld1.8 {d0, d1}, [r2,:128]!
1133 vld1.64 {d2, d3}, [r2,:128]!1094 vld1.8 {d2, d3}, [r2,:128]!
1134 vrhadd.u8 q0, q0, q61095 vrhadd.u8 q0, q0, q6
1135 vld1.64 {d4, d5}, [r2,:128]!1096 vld1.8 {d4, d5}, [r2,:128]!
1136 vrhadd.u8 q1, q1, q71097 vrhadd.u8 q1, q1, q7
1137 vld1.64 {d6, d7}, [r2,:128]!1098 vld1.8 {d6, d7}, [r2,:128]!
1138 vrhadd.u8 q2, q2, q41099 vrhadd.u8 q2, q2, q4
1139 vrhadd.u8 q3, q3, q51100 vrhadd.u8 q3, q3, q5
1140.ifc \type,avg1101 .ifc \type,avg
1141 vld1.8 {d16}, [r0,:64], r31102 vld1.8 {d16}, [r0,:64], r3
1142 vrhadd.u8 d0, d0, d161103 vrhadd.u8 d0, d0, d16
1143 vld1.8 {d17}, [r0,:64], r31104 vld1.8 {d17}, [r0,:64], r3
@@ -1155,25 +1116,25 @@ function \type\()_h264_qpel8_hv_lowpass_l2_neon · 11 unmodified lines
1155 vld1.8 {d23}, [r0,:64], r31116 vld1.8 {d23}, [r0,:64], r3
1156 vrhadd.u8 d7, d7, d231117 vrhadd.u8 d7, d7, d23
1157 sub r0, r0, r3, lsl #31118 sub r0, r0, r3, lsl #3
1158.endif1119 .endif
1159 vst1.64 {d0}, [r0,:64], r31120 vst1.8 {d0}, [r0,:64], r3
1160 vst1.64 {d1}, [r0,:64], r31121 vst1.8 {d1}, [r0,:64], r3
1161 vst1.64 {d2}, [r0,:64], r31122 vst1.8 {d2}, [r0,:64], r3
1162 vst1.64 {d3}, [r0,:64], r31123 vst1.8 {d3}, [r0,:64], r3
1163 vst1.64 {d4}, [r0,:64], r31124 vst1.8 {d4}, [r0,:64], r3
1164 vst1.64 {d5}, [r0,:64], r31125 vst1.8 {d5}, [r0,:64], r3
1165 vst1.64 {d6}, [r0,:64], r31126 vst1.8 {d6}, [r0,:64], r3
1166 vst1.64 {d7}, [r0,:64], r31127 vst1.8 {d7}, [r0,:64], r3
1167 1128
1168 mov lr, r101129 mov lr, r10
1169 bx lr1130 bx lr
1170endfunc1131endfunc
1171 .endm1132.endm
1172 1133
1173 h264_qpel8_hv_lowpass_l2 put1134 h264_qpel8_hv_lowpass_l2 put
1174 h264_qpel8_hv_lowpass_l2 avg1135 h264_qpel8_hv_lowpass_l2 avg
1175 1136
1176 .macro h264_qpel16_hv type1137.macro h264_qpel16_hv type
1177function \type\()_h264_qpel16_hv_lowpass_neon1138function \type\()_h264_qpel16_hv_lowpass_neon
1178 mov r9, lr1139 mov r9, lr
1179 bl \type\()_h264_qpel8_hv_lowpass_neon1140 bl \type\()_h264_qpel8_hv_lowpass_neon
@@ -1206,17 +1167,17 @@ function \type\()_h264_qpel16_hv_lowpass_l2_neon · 26 unmodified lines
1206 mov lr, r91167 mov lr, r9
1207 b \type\()_h264_qpel8_hv_lowpass_l2_neon1168 b \type\()_h264_qpel8_hv_lowpass_l2_neon
1208endfunc1169endfunc
1209 .endm1170.endm
1210 1171
1211 h264_qpel16_hv put1172 h264_qpel16_hv put
1212 h264_qpel16_hv avg1173 h264_qpel16_hv avg
1213 1174
1214 .macro h264_qpel8 type1175.macro h264_qpel8 type
1215function ff_\type\()_h264_qpel8_mc10_neon, export=11176function ff_\type\()_h264_qpel8_mc10_neon, export=1
1216 lowpass_const r31177 lowpass_const r3
1217 mov r3, r11178 mov r3, r1
1218 sub r1, r1, #21179 sub r1, r1, #2
1219 mov ip, #81180 mov r12, #8
1220 b \type\()_h264_qpel8_h_lowpass_l2_neon1181 b \type\()_h264_qpel8_h_lowpass_l2_neon
1221endfunc1182endfunc
1222 1183
@@ -1224,7 +1185,7 @@ function ff_\type\()_h264_qpel8_mc20_neon, export=1 · 1 unmodified line
1224 lowpass_const r31185 lowpass_const r3
1225 sub r1, r1, #21186 sub r1, r1, #2
1226 mov r3, r21187 mov r3, r2
1227 mov ip, #81188 mov r12, #8
1228 b \type\()_h264_qpel8_h_lowpass_neon1189 b \type\()_h264_qpel8_h_lowpass_neon
1229endfunc1190endfunc
1230 1191
@@ -1232,13 +1193,13 @@ function ff_\type\()_h264_qpel8_mc30_neon, export=1 · 1 unmodified line
1232 lowpass_const r31193 lowpass_const r3
1233 add r3, r1, #11194 add r3, r1, #1
1234 sub r1, r1, #21195 sub r1, r1, #2
1235 mov ip, #81196 mov r12, #8
1236 b \type\()_h264_qpel8_h_lowpass_l2_neon1197 b \type\()_h264_qpel8_h_lowpass_l2_neon
1237endfunc1198endfunc
1238 1199
1239function ff_\type\()_h264_qpel8_mc01_neon, export=11200function ff_\type\()_h264_qpel8_mc01_neon, export=1
1240 push {lr}1201 push {lr}
1241 mov ip, r11202 mov r12, r1
1242\type\()_h264_qpel8_mc01:1203\type\()_h264_qpel8_mc01:
1243 lowpass_const r31204 lowpass_const r3
1244 mov r3, r21205 mov r3, r2
@@ -1261,12 +1222,12 @@ T mov sp, r0 · 16 unmodified lines
1261 mov r0, sp1222 mov r0, sp
1262 sub r1, r1, #21223 sub r1, r1, #2
1263 mov r3, #81224 mov r3, #8
1264 mov ip, #81225 mov r12, #8
1265 vpush {d8-d15}1226 vpush {d8-d15}
1266 bl put_h264_qpel8_h_lowpass_neon1227 bl put_h264_qpel8_h_lowpass_neon
1267 ldrd r0, [r11], #81228 ldrd r0, [r11], #8
1268 mov r3, r21229 mov r3, r2
1269 add ip, sp, #641230 add r12, sp, #64
1270 sub r1, r1, r2, lsl #11231 sub r1, r1, r2, lsl #1
1271 mov r2, #81232 mov r2, #8
1272 bl \type\()_h264_qpel8_v_lowpass_l2_neon1233 bl \type\()_h264_qpel8_v_lowpass_l2_neon
@@ -1287,7 +1248,7 @@ T mov sp, r0 · 14 unmodified lines
1287 sub r1, r1, #21248 sub r1, r1, #2
1288 mov r3, #81249 mov r3, #8
1289 mov r0, sp1250 mov r0, sp
1290 mov ip, #81251 mov r12, #8
1291 vpush {d8-d15}1252 vpush {d8-d15}
1292 bl put_h264_qpel8_h_lowpass_neon1253 bl put_h264_qpel8_h_lowpass_neon
1293 mov r4, r01254 mov r4, r0
@@ -1372,7 +1333,7 @@ endfunc · 78 unmodified lines
1372 1333
1373function ff_\type\()_h264_qpel8_mc03_neon, export=11334function ff_\type\()_h264_qpel8_mc03_neon, export=1
1374 push {lr}1335 push {lr}
1375 add ip, r1, r21336 add r12, r1, r2
1376 b \type\()_h264_qpel8_mc011337 b \type\()_h264_qpel8_mc01
1377endfunc1338endfunc
1378 1339
@@ -1395,12 +1356,12 @@ function ff_\type\()_h264_qpel8_mc33_neon, export=1 · 16 unmodified lines
1395 sub r1, r1, #11356 sub r1, r1, #1
1396 b \type\()_h264_qpel8_mc111357 b \type\()_h264_qpel8_mc11
1397endfunc1358endfunc
1398 .endm1359.endm
1399 1360
1400 h264_qpel8 put1361 h264_qpel8 put
1401 h264_qpel8 avg1362 h264_qpel8 avg
1402 1363
1403 .macro h264_qpel16 type1364.macro h264_qpel16 type
1404function ff_\type\()_h264_qpel16_mc10_neon, export=11365function ff_\type\()_h264_qpel16_mc10_neon, export=1
1405 lowpass_const r31366 lowpass_const r3
1406 mov r3, r11367 mov r3, r1
@@ -1424,7 +1385,7 @@ endfunc · 17 unmodified lines
1424 1385
1425function ff_\type\()_h264_qpel16_mc01_neon, export=11386function ff_\type\()_h264_qpel16_mc01_neon, export=1
1426 push {r4, lr}1387 push {r4, lr}
1427 mov ip, r11388 mov r12, r1
1428\type\()_h264_qpel16_mc01:1389\type\()_h264_qpel16_mc01:
1429 lowpass_const r31390 lowpass_const r3
1430 mov r3, r21391 mov r3, r2
@@ -1451,7 +1412,7 @@ T mov sp, r0 · 20 unmodified lines
1451 bl put_h264_qpel16_h_lowpass_neon1412 bl put_h264_qpel16_h_lowpass_neon
1452 ldrd r0, [r11], #81413 ldrd r0, [r11], #8
1453 mov r3, r21414 mov r3, r2
1454 add ip, sp, #641415 add r12, sp, #64
1455 sub r1, r1, r2, lsl #11416 sub r1, r1, r2, lsl #1
1456 mov r2, #161417 mov r2, #16
1457 bl \type\()_h264_qpel16_v_lowpass_l2_neon1418 bl \type\()_h264_qpel16_v_lowpass_l2_neon
@@ -1554,7 +1515,7 @@ endfunc · 96 unmodified lines
1554 1515
1555function ff_\type\()_h264_qpel16_mc03_neon, export=11516function ff_\type\()_h264_qpel16_mc03_neon, export=1
1556 push {r4, lr}1517 push {r4, lr}
1557 add ip, r1, r21518 add r12, r1, r2
1558 b \type\()_h264_qpel16_mc011519 b \type\()_h264_qpel16_mc01
1559endfunc1520endfunc
1560 1521
@@ -1577,14 +1538,14 @@ function ff_\type\()_h264_qpel16_mc33_neon, export=1 · 16 unmodified lines
1577 sub r1, r1, #11538 sub r1, r1, #1
1578 b \type\()_h264_qpel16_mc111539 b \type\()_h264_qpel16_mc11
1579endfunc1540endfunc
1580 .endm1541.endm
1581 1542
1582 h264_qpel16 put1543 h264_qpel16 put
1583 h264_qpel16 avg1544 h264_qpel16 avg
1584 1545
1585@ Biweighted prediction1546@ Biweighted prediction
1586 1547
1587 .macro biweight_16 macs, macd1548.macro biweight_16 macs, macd
1588 vdup.8 d0, r41549 vdup.8 d0, r4
1589 vdup.8 d1, r51550 vdup.8 d1, r5
1590 vmov q2, q81551 vmov q2, q8
@@ -1622,9 +1583,9 @@ endfunc · 31 unmodified lines
1622 vst1.8 {d24-d25},[r6,:128], r21583 vst1.8 {d24-d25},[r6,:128], r2
1623 bne 1b1584 bne 1b
1624 pop {r4-r6, pc}1585 pop {r4-r6, pc}
1625 .endm1586.endm
1626 1587
1627 .macro biweight_8 macs, macd1588.macro biweight_8 macs, macd
1628 vdup.8 d0, r41589 vdup.8 d0, r4
1629 vdup.8 d1, r51590 vdup.8 d1, r5
1630 vmov q1, q81591 vmov q1, q8
@@ -1652,9 +1613,9 @@ endfunc · 21 unmodified lines
1652 vst1.8 {d4},[r6,:64], r21613 vst1.8 {d4},[r6,:64], r2
1653 bne 1b1614 bne 1b
1654 pop {r4-r6, pc}1615 pop {r4-r6, pc}
1655 .endm1616.endm
1656 1617
1657 .macro biweight_4 macs, macd1618.macro biweight_4 macs, macd
1658 vdup.8 d0, r41619 vdup.8 d0, r4
1659 vdup.8 d1, r51620 vdup.8 d1, r5
1660 vmov q1, q81621 vmov q1, q8
@@ -1694,9 +1655,9 @@ endfunc · 33 unmodified lines
1694 vst1.32 {d2[0]},[r6,:32], r21655 vst1.32 {d2[0]},[r6,:32], r2
1695 vst1.32 {d2[1]},[r6,:32], r21656 vst1.32 {d2[1]},[r6,:32], r2
1696 pop {r4-r6, pc}1657 pop {r4-r6, pc}
1697 .endm1658.endm
1698 1659
1699 .macro biweight_func w1660.macro biweight_func w
1700function ff_biweight_h264_pixels_\w\()_neon, export=11661function ff_biweight_h264_pixels_\w\()_neon, export=1
1701 push {r4-r6, lr}1662 push {r4-r6, lr}
1702 ldr r12, [sp, #16]1663 ldr r12, [sp, #16]
@@ -1726,7 +1687,7 @@ function ff_biweight_h264_pixels_\w\()_neon, export=1 · 23 unmodified lines
172640: rsb r5, r5, #0168740: rsb r5, r5, #0
1727 biweight_\w vmlsl.u8, vmlal.u81688 biweight_\w vmlsl.u8, vmlal.u8
1728endfunc1689endfunc
1729 .endm1690.endm
1730 1691
1731 biweight_func 161692 biweight_func 16
1732 biweight_func 81693 biweight_func 8
@@ -1734,7 +1695,7 @@ endfunc · 1 unmodified line
1734 1695
1735@ Weighted prediction1696@ Weighted prediction
1736 1697
1737 .macro weight_16 add1698.macro weight_16 add
1738 vdup.8 d0, r121699 vdup.8 d0, r12
17391: subs r2, r2, #217001: subs r2, r2, #2
1740 vld1.8 {d20-d21},[r0,:128], r11701 vld1.8 {d20-d21},[r0,:128], r1
@@ -1761,9 +1722,9 @@ endfunc · 20 unmodified lines
1761 vst1.8 {d24-d25},[r4,:128], r11722 vst1.8 {d24-d25},[r4,:128], r1
1762 bne 1b1723 bne 1b
1763 pop {r4, pc}1724 pop {r4, pc}
1764 .endm1725.endm
1765 1726
1766 .macro weight_8 add1727.macro weight_8 add
1767 vdup.8 d0, r121728 vdup.8 d0, r12
17681: subs r2, r2, #217291: subs r2, r2, #2
1769 vld1.8 {d4},[r0,:64], r11730 vld1.8 {d4},[r0,:64], r1
@@ -1782,9 +1743,9 @@ endfunc · 12 unmodified lines
1782 vst1.8 {d4},[r4,:64], r11743 vst1.8 {d4},[r4,:64], r1
1783 bne 1b1744 bne 1b
1784 pop {r4, pc}1745 pop {r4, pc}
1785 .endm1746.endm
1786 1747
1787 .macro weight_4 add1748.macro weight_4 add
1788 vdup.8 d0, r121749 vdup.8 d0, r12
1789 vmov q1, q81750 vmov q1, q8
1790 vmov q10, q81751 vmov q10, q8
@@ -1818,9 +1779,9 @@ endfunc · 27 unmodified lines
1818 vst1.32 {d2[0]},[r4,:32], r11779 vst1.32 {d2[0]},[r4,:32], r1
1819 vst1.32 {d2[1]},[r4,:32], r11780 vst1.32 {d2[1]},[r4,:32], r1
1820 pop {r4, pc}1781 pop {r4, pc}
1821 .endm1782.endm
1822 1783
1823 .macro weight_func w1784.macro weight_func w
1824function ff_weight_h264_pixels_\w\()_neon, export=11785function ff_weight_h264_pixels_\w\()_neon, export=1
1825 push {r4, lr}1786 push {r4, lr}
1826 ldr r12, [sp, #8]1787 ldr r12, [sp, #8]
@@ -1845,7 +1806,7 @@ function ff_weight_h264_pixels_\w\()_neon, export=1 · 18 unmodified lines
184510: rsb r12, r12, #0180610: rsb r12, r12, #0
1846 weight_\w vsub.s161807 weight_\w vsub.s16
1847endfunc1808endfunc
1848 .endm1809.endm
1849 1810
1850 weight_func 161811 weight_func 16
1851 weight_func 81812 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
22 */22 */
23 23
24#include "asm.S"24#include "asm.S"
25#include "neon.S"
25 26
26function ff_vp8_luma_dc_wht_neon, export=127function ff_vp8_luma_dc_wht_neon, export=1
27 vld1.16 {q0-q1}, [r1,:128]28 vld1.16 {q0-q1}, [r1,:128]
@@ -442,23 +443,6 @@ endfunc · 414 unmodified lines
442 .endif443 .endif
443.endm444.endm
444 445
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
462.macro vp8_v_loop_filter16 name, inner=0, simple=0446.macro vp8_v_loop_filter16 name, inner=0, simple=0
463function ff_vp8_v_loop_filter16\name\()_neon, export=1447function ff_vp8_v_loop_filter16\name\()_neon, export=1
464 vpush {q4-q7}448 vpush {q4-q7}
@@ -593,7 +577,7 @@ function ff_vp8_h_loop_filter16\name\()_neon, export=1 · 128 unmodified lines
593 vld1.8 {d13}, [r0], r1577 vld1.8 {d13}, [r0], r1
594 vld1.8 {d15}, [r0], r1578 vld1.8 {d15}, [r0], r1
595 579
596 transpose8x16matrix580 transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7
597 581
598 vdup.8 q14, r2 @ flim_E582 vdup.8 q14, r2 @ flim_E
599 .if !\simple583 .if !\simple
@@ -604,7 +588,7 @@ function ff_vp8_h_loop_filter16\name\()_neon, export=1 · 4 unmodified lines
604 588
605 sub r0, r0, r1, lsl #4 @ backup 16 rows589 sub r0, r0, r1, lsl #4 @ backup 16 rows
606 590
607 transpose8x16matrix591 transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7
608 592
609 @ Store pixels:593 @ Store pixels:
610 vst1.8 {d0}, [r0], r1594 vst1.8 {d0}, [r0], r1
@@ -658,7 +642,7 @@ function ff_vp8_h_loop_filter8uv\name\()_neon, export=1 · 47 unmodified lines
658 vld1.8 {d14}, [r0], r2642 vld1.8 {d14}, [r0], r2
659 vld1.8 {d15}, [r1], r2643 vld1.8 {d15}, [r1], r2
660 644
661 transpose8x16matrix645 transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7
662 646
663 vdup.8 q14, r3 @ flim_E647 vdup.8 q14, r3 @ flim_E
664 vdup.8 q15, r12 @ flim_I648 vdup.8 q15, r12 @ flim_I
@@ -669,7 +653,7 @@ function ff_vp8_h_loop_filter8uv\name\()_neon, export=1 · 4 unmodified lines
669 sub r0, r0, r2, lsl #3 @ backup u 8 rows653 sub r0, r0, r2, lsl #3 @ backup u 8 rows
670 sub r1, r1, r2, lsl #3 @ backup v 8 rows654 sub r1, r1, r2, lsl #3 @ backup v 8 rows
671 655
672 transpose8x16matrix656 transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7
673 657
674 @ Store pixels:658 @ Store pixels:
675 vst1.8 {d0}, [r0], r2659 vst1.8 {d0}, [r0], r2
libavcodec/atrac1.c+17−9
@@ -72,6 +72,7 @@ typedef struct { · 71 unmodified lines
72 * The atrac1 context, holds all needed parameters for decoding72 * The atrac1 context, holds all needed parameters for decoding
73 */73 */
74typedef struct {74typedef struct {
75 AVFrame frame;
75 AT1SUCtx SUs[AT1_MAX_CHANNELS]; ///< channel sound unit76 AT1SUCtx SUs[AT1_MAX_CHANNELS]; ///< channel sound unit
76 DECLARE_ALIGNED(32, float, spec)[AT1_SU_SAMPLES]; ///< the mdct spectrum buffer77 DECLARE_ALIGNED(32, float, spec)[AT1_SU_SAMPLES]; ///< the mdct spectrum buffer
77 78
@@ -273,14 +274,14 @@ static void at1_subband_synthesis(AT1Ctx *q, AT1SUCtx* su, float *pOut) · 195 unmodified lines
273 274
274 275
275static int atrac1_decode_frame(AVCodecContext *avctx, void *data,276static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
276 int *data_size, AVPacket *avpkt)277 int *got_frame_ptr, AVPacket *avpkt)
277{278{
278 const uint8_t *buf = avpkt->data;279 const uint8_t *buf = avpkt->data;
279 int buf_size = avpkt->size;280 int buf_size = avpkt->size;
280 AT1Ctx *q = avctx->priv_data;281 AT1Ctx *q = avctx->priv_data;
281 int ch, ret, out_size;282 int ch, ret;
282 GetBitContext gb;283 GetBitContext gb;
283 float* samples = data;284 float *samples;
284 285
285 286
286 if (buf_size < 212 * q->channels) {287 if (buf_size < 212 * q->channels) {
@@ -288,12 +289,13 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data, · 1 unmodified line
288 return AVERROR_INVALIDDATA;289 return AVERROR_INVALIDDATA;
289 }290 }
290 291
291 out_size = q->channels * AT1_SU_SAMPLES *292 /* get output buffer */
292 av_get_bytes_per_sample(avctx->sample_fmt);293 q->frame.nb_samples = AT1_SU_SAMPLES;
293 if (*data_size < out_size) {294 if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
294 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");295 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
295 return AVERROR(EINVAL);296 return ret;
296 }297 }
298 samples = (float *)q->frame.data[0];
297 299
298 for (ch = 0; ch < q->channels; ch++) {300 for (ch = 0; ch < q->channels; ch++) {
299 AT1SUCtx* su = &q->SUs[ch];301 AT1SUCtx* su = &q->SUs[ch];
@@ -321,7 +323,9 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data, · 21 unmodified lines
321 AT1_SU_SAMPLES, 2);323 AT1_SU_SAMPLES, 2);
322 }324 }
323 325
324 *data_size = out_size;326 *got_frame_ptr = 1;
327 *(AVFrame *)data = q->frame;
328
325 return avctx->block_align;329 return avctx->block_align;
326}330}
327 331
@@ -389,6 +393,9 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) · 61 unmodified lines
389 q->SUs[1].spectrum[0] = q->SUs[1].spec1;393 q->SUs[1].spectrum[0] = q->SUs[1].spec1;
390 q->SUs[1].spectrum[1] = q->SUs[1].spec2;394 q->SUs[1].spectrum[1] = q->SUs[1].spec2;
391 395
396 avcodec_get_frame_defaults(&q->frame);
397 avctx->coded_frame = &q->frame;
398
392 return 0;399 return 0;
393}400}
394 401
@@ -401,5 +408,6 @@ AVCodec ff_atrac1_decoder = { · 6 unmodified lines
401 .init = atrac1_decode_init,408 .init = atrac1_decode_init,
402 .close = atrac1_decode_end,409 .close = atrac1_decode_end,
403 .decode = atrac1_decode_frame,410 .decode = atrac1_decode_frame,
411 .capabilities = CODEC_CAP_DR1,
404 .long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Coding)"),412 .long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Coding)"),
405};413};
libavcodec/atrac3.c+21−13
@@ -86,6 +86,7 @@ typedef struct { · 85 unmodified lines
86} channel_unit;86} channel_unit;
87 87
88typedef struct {88typedef struct {
89 AVFrame frame;
89 GetBitContext gb;90 GetBitContext gb;
90 //@{91 //@{
91 /** stream data */92 /** stream data */
@@ -823,16 +824,16 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, · 731 unmodified lines
823 * @param avctx pointer to the AVCodecContext824 * @param avctx pointer to the AVCodecContext
824 */825 */
825 826
826static int atrac3_decode_frame(AVCodecContext *avctx,827static int atrac3_decode_frame(AVCodecContext *avctx, void *data,
827 void *data, int *data_size,828 int *got_frame_ptr, AVPacket *avpkt)
828 AVPacket *avpkt) {829{
829 const uint8_t *buf = avpkt->data;830 const uint8_t *buf = avpkt->data;
830 int buf_size = avpkt->size;831 int buf_size = avpkt->size;
831 ATRAC3Context *q = avctx->priv_data;832 ATRAC3Context *q = avctx->priv_data;
832 int result = 0, out_size;833 int result;
833 const uint8_t* databuf;834 const uint8_t* databuf;
834 float *samples_flt = data;835 float *samples_flt;
835 int16_t *samples_s16 = data;836 int16_t *samples_s16;
836 837
837 if (buf_size < avctx->block_align) {838 if (buf_size < avctx->block_align) {
838 av_log(avctx, AV_LOG_ERROR,839 av_log(avctx, AV_LOG_ERROR,
@@ -840,12 +841,14 @@ static int atrac3_decode_frame(AVCodecContext *avctx, · 1 unmodified line
840 return AVERROR_INVALIDDATA;841 return AVERROR_INVALIDDATA;
841 }842 }
842 843
843 out_size = SAMPLES_PER_FRAME * q->channels *844 /* get output buffer */
844 av_get_bytes_per_sample(avctx->sample_fmt);845 q->frame.nb_samples = SAMPLES_PER_FRAME;
845 if (*data_size < out_size) {846 if ((result = avctx->get_buffer(avctx, &q->frame)) < 0) {
846 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");847 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
847 return AVERROR(EINVAL);848 return result;
848 }849 }
850 samples_flt = (float *)q->frame.data[0];
851 samples_s16 = (int16_t *)q->frame.data[0];
849 852
850 /* Check if we need to descramble and what buffer to pass on. */853 /* Check if we need to descramble and what buffer to pass on. */
851 if (q->scrambled_stream) {854 if (q->scrambled_stream) {
@@ -875,7 +878,9 @@ static int atrac3_decode_frame(AVCodecContext *avctx, · 23 unmodified lines
875 (const float **)q->outSamples,878 (const float **)q->outSamples,
876 SAMPLES_PER_FRAME, q->channels);879 SAMPLES_PER_FRAME, q->channels);
877 }880 }
878 *data_size = out_size;881
882 *got_frame_ptr = 1;
883 *(AVFrame *)data = q->frame;
879 884
880 return avctx->block_align;885 return avctx->block_align;
881}886}
@@ -1047,6 +1052,9 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 165 unmodified lines
1047 }1052 }
1048 }1053 }
1049 1054
1055 avcodec_get_frame_defaults(&q->frame);
1056 avctx->coded_frame = &q->frame;
1057
1050 return 0;1058 return 0;
1051}1059}
1052 1060
@@ -1060,6 +1068,6 @@ AVCodec ff_atrac3_decoder = · 7 unmodified lines
1060 .init = atrac3_decode_init,1068 .init = atrac3_decode_init,
1061 .close = atrac3_decode_close,1069 .close = atrac3_decode_close,
1062 .decode = atrac3_decode_frame,1070 .decode = atrac3_decode_frame,
1063 .capabilities = CODEC_CAP_SUBFRAMES,1071 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
1064 .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),1072 .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),
1065};1073};
libavcodec/avcodec.h+149−19
@@ -491,8 +491,10 @@ enum CodecID { · 490 unmodified lines
491#define CH_LAYOUT_STEREO_DOWNMIX AV_CH_LAYOUT_STEREO_DOWNMIX491#define CH_LAYOUT_STEREO_DOWNMIX AV_CH_LAYOUT_STEREO_DOWNMIX
492#endif492#endif
493 493
494#if FF_API_OLD_DECODE_AUDIO
494/* in bytes */495/* in bytes */
495#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio496#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
497#endif
496 498
497/**499/**
498 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.500 * 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
947 * sizeof(AVFrame) must not be used outside libav*.949 * sizeof(AVFrame) must not be used outside libav*.
948 */950 */
949typedef struct AVFrame {951typedef 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
950 /**957 /**
951 * pointer to the picture planes.958 * pointer to the picture/channel planes.
952 * This might be different from the first allocated byte959 * This might be different from the first allocated byte
953 * - encoding:960 * - encoding: Set by user
954 * - decoding: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()
955 */973 */
956 uint8_t *data[4];974 int linesize[AV_NUM_DATA_POINTERS];
957 int linesize[4];975
958 /**976 /**
959 * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.977 * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
960 * This isn't used by libavcodec unless the default get/release_buffer() is used.978 * This isn't used by libavcodec unless the default get/release_buffer() is used.
961 * - encoding:979 * - encoding:
962 * - decoding:980 * - decoding:
963 */981 */
964 uint8_t *base[4];982 uint8_t *base[AV_NUM_DATA_POINTERS];
965 /**983 /**
966 * 1 -> keyframe, 0-> not984 * 1 -> keyframe, 0-> not
967 * - encoding: Set by libavcodec.985 * - encoding: Set by libavcodec.
@@ -1008,7 +1026,7 @@ typedef struct AVFrame { · 40 unmodified lines
1008 * buffer age (1->was last buffer and dint change, 2->..., ...).1026 * buffer age (1->was last buffer and dint change, 2->..., ...).
1009 * Set to INT_MAX if the buffer has not been used yet.1027 * Set to INT_MAX if the buffer has not been used yet.
1010 * - encoding: unused1028 * - encoding: unused
1011 * - decoding: MUST be set by get_buffer().1029 * - decoding: MUST be set by get_buffer() for video.
1012 */1030 */
1013 int age;1031 int age;
1014 1032
@@ -1085,7 +1103,7 @@ typedef struct AVFrame { · 70 unmodified lines
1085 * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.1103 * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
1086 * - decoding: unused1104 * - decoding: unused
1087 */1105 */
1088 uint64_t error[4];1106 uint64_t error[AV_NUM_DATA_POINTERS];
1089 1107
1090 /**1108 /**
1091 * type of the buffer (to keep track of who has to deallocate data[*])1109 * type of the buffer (to keep track of who has to deallocate data[*])
@@ -1206,6 +1224,33 @@ typedef struct AVFrame { · 114 unmodified lines
1206 */1224 */
1207 void *thread_opaque;1225 void *thread_opaque;
1208 1226
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
1209 /**1254 /**
1210 * frame timestamp estimated using various heuristics, in stream time base1255 * frame timestamp estimated using various heuristics, in stream time base
1211 * - encoding: unused1256 * - encoding: unused
@@ -1379,7 +1424,7 @@ typedef struct AVCodecContext { · 167 unmodified lines
1379 * @param offset offset into the AVFrame.data from which the slice should be read1424 * @param offset offset into the AVFrame.data from which the slice should be read
1380 */1425 */
1381 void (*draw_horiz_band)(struct AVCodecContext *s,1426 void (*draw_horiz_band)(struct AVCodecContext *s,
1382 const AVFrame *src, int offset[4],1427 const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1383 int y, int type, int height);1428 int y, int type, int height);
1384 1429
1385 /* audio only */1430 /* audio only */
@@ -1602,15 +1647,56 @@ typedef struct AVCodecContext { · 216 unmodified lines
1602 1647
1603 /**1648 /**
1604 * Called at the beginning of each frame to get a buffer for it.1649 * 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.1650 *
1606 * avcodec_align_dimensions2() should be used to find the required width and1651 * The function will set AVFrame.data[], AVFrame.linesize[].
1607 * height, as they normally need to be rounded up to the next multiple of 16.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 *
1608 * if CODEC_CAP_DR1 is not set then get_buffer() must call1657 * if CODEC_CAP_DR1 is not set then get_buffer() must call
1609 * avcodec_default_get_buffer() instead of providing buffers allocated by1658 * avcodec_default_get_buffer() instead of providing buffers allocated by
1610 * some other means.1659 * 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 *
1611 * If frame multithreading is used and thread_safe_callbacks is set,1674 * 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.1675 * it may be called from a different thread, but not from more than one at
1613 * Does not need to be reentrant.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 *
1614 * - encoding: unused1700 * - encoding: unused
1615 * - decoding: Set by libavcodec, user can override.1701 * - decoding: Set by libavcodec, user can override.
1616 */1702 */
@@ -1929,7 +2015,7 @@ typedef struct AVCodecContext { · 312 unmodified lines
1929 * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.2015 * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
1930 * - decoding: unused2016 * - decoding: unused
1931 */2017 */
1932 uint64_t error[4];2018 uint64_t error[AV_NUM_DATA_POINTERS];
1933 2019
1934 /**2020 /**
1935 * motion estimation comparison function2021 * motion estimation comparison function
@@ -3253,8 +3339,8 @@ typedef struct AVHWAccel { · 1317 unmodified lines
3253 * the last component is alpha3339 * the last component is alpha
3254 */3340 */
3255typedef struct AVPicture {3341typedef struct AVPicture {
3256 uint8_t *data[4];3342 uint8_t *data[AV_NUM_DATA_POINTERS];
3257 int linesize[4]; ///< number of bytes per line3343 int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
3258} AVPicture;3344} AVPicture;
3259 3345
3260#define AVPALETTE_SIZE 10243346#define AVPALETTE_SIZE 1024
@@ -3922,7 +4008,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); · 661 unmodified lines
3922 * according to avcodec_get_edge_width() before.4008 * according to avcodec_get_edge_width() before.
3923 */4009 */
3924void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,4010void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
3925 int linesize_align[4]);4011 int linesize_align[AV_NUM_DATA_POINTERS]);
3926 4012
3927enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);4013enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
3928 4014
@@ -4005,7 +4091,12 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec); · 76 unmodified lines
4005 */4091 */
4006int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options);4092int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options);
4007 4093
4094#if FF_API_OLD_DECODE_AUDIO
4008/**4095/**
4096 * Wrapper function which calls avcodec_decode_audio4.
4097 *
4098 * @deprecated Use avcodec_decode_audio4 instead.
4099 *
4009 * Decode the audio frame of size avpkt->size from avpkt->data into samples.4100 * Decode the audio frame of size avpkt->size from avpkt->data into samples.
4010 * Some decoders may support multiple frames in a single AVPacket, such4101 * Some decoders may support multiple frames in a single AVPacket, such
4011 * decoders would then just decode the first frame. In this case,4102 * 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
4040 *4131 *
4041 * @param avctx the codec context4132 * @param avctx the codec context
4042 * @param[out] samples the output buffer, sample type in avctx->sample_fmt4133 * @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.
4043 * @param[in,out] frame_size_ptr the output buffer size in bytes4136 * @param[in,out] frame_size_ptr the output buffer size in bytes
4044 * @param[in] avpkt The input AVPacket containing the input buffer.4137 * @param[in] avpkt The input AVPacket containing the input buffer.
4045 * You can create such packet with av_init_packet() and by then setting4138 * 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
4048 * @return On error a negative value is returned, otherwise the number of bytes4141 * @return On error a negative value is returned, otherwise the number of bytes
4049 * used or zero if no frame data was decompressed (used) from the input AVPacket.4142 * used or zero if no frame data was decompressed (used) from the input AVPacket.
4050 */4143 */
4051int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,4144attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
4052 int *frame_size_ptr,4145 int *frame_size_ptr,
4053 AVPacket *avpkt);4146 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 */
4182int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
4183 int *got_frame_ptr, AVPacket *avpkt);
4054 4184
4055/**4185/**
4056 * Decode the video frame of size avpkt->size from avpkt->data into picture.4186 * 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
45#define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)45#define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
46 46
47typedef struct {47typedef struct {
48 AVFrame frame;
48 GetBitContext gb;49 GetBitContext gb;
49 DSPContext dsp;50 DSPContext dsp;
50 FmtConvertContext fmt_conv;51 FmtConvertContext fmt_conv;
@@ -147,6 +148,9 @@ static av_cold int decode_init(AVCodecContext *avctx) · 96 unmodified lines
147 else148 else
148 return -1;149 return -1;
149 150
151 avcodec_get_frame_defaults(&s->frame);
152 avctx->coded_frame = &s->frame;
153
150 return 0;154 return 0;
151}155}
152 156
@@ -293,6 +297,7 @@ static av_cold int decode_end(AVCodecContext *avctx) · 140 unmodified lines
293 ff_rdft_end(&s->trans.rdft);297 ff_rdft_end(&s->trans.rdft);
294 else if (CONFIG_BINKAUDIO_DCT_DECODER)298 else if (CONFIG_BINKAUDIO_DCT_DECODER)
295 ff_dct_end(&s->trans.dct);299 ff_dct_end(&s->trans.dct);
300
296 return 0;301 return 0;
297}302}
298 303
@@ -302,20 +307,19 @@ static void get_bits_align32(GetBitContext *s) · 3 unmodified lines
302 if (n) skip_bits(s, n);307 if (n) skip_bits(s, n);
303}308}
304 309
305static int decode_frame(AVCodecContext *avctx,310static int decode_frame(AVCodecContext *avctx, void *data,
306 void *data, int *data_size,311 int *got_frame_ptr, AVPacket *avpkt)
307 AVPacket *avpkt)
308{312{
309 BinkAudioContext *s = avctx->priv_data;313 BinkAudioContext *s = avctx->priv_data;
310 int16_t *samples = data;314 int16_t *samples;
311 GetBitContext *gb = &s->gb;315 GetBitContext *gb = &s->gb;
312 int out_size, consumed = 0;316 int ret, consumed = 0;
313 317
314 if (!get_bits_left(gb)) {318 if (!get_bits_left(gb)) {
315 uint8_t *buf;319 uint8_t *buf;
316 /* handle end-of-stream */320 /* handle end-of-stream */
317 if (!avpkt->size) {321 if (!avpkt->size) {
318 *data_size = 0;322 *got_frame_ptr = 0;
319 return 0;323 return 0;
320 }324 }
321 if (avpkt->size < 4) {325 if (avpkt->size < 4) {
@@ -334,11 +338,13 @@ static int decode_frame(AVCodecContext *avctx, · 12 unmodified lines
334 skip_bits_long(gb, 32);338 skip_bits_long(gb, 32);
335 }339 }
336 340
337 out_size = s->block_size * av_get_bytes_per_sample(avctx->sample_fmt);341 /* get output buffer */
338 if (*data_size < out_size) {342 s->frame.nb_samples = s->block_size / avctx->channels;
339 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");343 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
340 return AVERROR(EINVAL);344 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
345 return ret;
341 }346 }
347 samples = (int16_t *)s->frame.data[0];
342 348
343 if (decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT)) {349 if (decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT)) {
344 av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n");350 av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n");
@@ -346,7 +352,9 @@ static int decode_frame(AVCodecContext *avctx, · 1 unmodified line
346 }352 }
347 get_bits_align32(gb);353 get_bits_align32(gb);
348 354
349 *data_size = out_size;355 *got_frame_ptr = 1;
356 *(AVFrame *)data = s->frame;
357
350 return consumed;358 return consumed;
351}359}
352 360
@@ -358,7 +366,7 @@ AVCodec ff_binkaudio_rdft_decoder = { · 5 unmodified lines
358 .init = decode_init,366 .init = decode_init,
359 .close = decode_end,367 .close = decode_end,
360 .decode = decode_frame,368 .decode = decode_frame,
361 .capabilities = CODEC_CAP_DELAY,369 .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
362 .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)")370 .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)")
363};371};
364 372
@@ -370,6 +378,6 @@ AVCodec ff_binkaudio_dct_decoder = { · 5 unmodified lines
370 .init = decode_init,378 .init = decode_init,
371 .close = decode_end,379 .close = decode_end,
372 .decode = decode_frame,380 .decode = decode_frame,
373 .capabilities = CODEC_CAP_DELAY,381 .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
374 .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)")382 .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)")
375};383};
libavcodec/cook.c+30−13
@@ -122,6 +122,7 @@ typedef struct cook { · 121 unmodified lines
122 void (* saturate_output) (struct cook *q, int chan, float *out);122 void (* saturate_output) (struct cook *q, int chan, float *out);
123 123
124 AVCodecContext* avctx;124 AVCodecContext* avctx;
125 AVFrame frame;
125 GetBitContext gb;126 GetBitContext gb;
126 /* stream data */127 /* stream data */
127 int nb_channels;128 int nb_channels;
@@ -131,6 +132,7 @@ typedef struct cook { · 3 unmodified lines
131 int samples_per_channel;132 int samples_per_channel;
132 /* states */133 /* states */
133 AVLFG random_state;134 AVLFG random_state;
135 int discarded_packets;
134 136
135 /* transform data */137 /* transform data */
136 FFTContext mdct_ctx;138 FFTContext mdct_ctx;
@@ -896,7 +898,8 @@ mlt_compensate_output(COOKContext *q, float *decode_buffer, · 759 unmodified lines
896 float *out, int chan)898 float *out, int chan)
897{899{
898 imlt_gain(q, decode_buffer, gains_ptr, previous_buffer);900 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);
900}903}
901 904
902 905
@@ -953,24 +956,28 @@ static void decode_subpacket(COOKContext *q, COOKSubpacket *p, · 50 unmodified lines
953 * @param avctx pointer to the AVCodecContext956 * @param avctx pointer to the AVCodecContext
954 */957 */
955 958
956static int cook_decode_frame(AVCodecContext *avctx,959static int cook_decode_frame(AVCodecContext *avctx, void *data,
957 void *data, int *data_size,960 int *got_frame_ptr, AVPacket *avpkt)
958 AVPacket *avpkt) {961{
959 const uint8_t *buf = avpkt->data;962 const uint8_t *buf = avpkt->data;
960 int buf_size = avpkt->size;963 int buf_size = avpkt->size;
961 COOKContext *q = avctx->priv_data;964 COOKContext *q = avctx->priv_data;
962 int i, out_size;965 float *samples = NULL;
966 int i, ret;
963 int offset = 0;967 int offset = 0;
964 int chidx = 0;968 int chidx = 0;
965 969
966 if (buf_size < avctx->block_align)970 if (buf_size < avctx->block_align)
967 return buf_size;971 return buf_size;
968 972
969 out_size = q->nb_channels * q->samples_per_channel *973 /* get output buffer */
970 av_get_bytes_per_sample(avctx->sample_fmt);974 if (q->discarded_packets >= 2) {
971 if (*data_size < out_size) {975 q->frame.nb_samples = q->samples_per_channel;
972 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");976 if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
973 return AVERROR(EINVAL);977 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
978 return ret;
979 }
980 samples = (float *)q->frame.data[0];
974 }981 }
975 982
976 /* estimate subpacket sizes */983 /* estimate subpacket sizes */
@@ -990,15 +997,21 @@ static int cook_decode_frame(AVCodecContext *avctx, · 13 unmodified lines
990 q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv;997 q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv;
991 q->subpacket[i].ch_idx = chidx;998 q->subpacket[i].ch_idx = chidx;
992 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);999 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);
994 offset += q->subpacket[i].size;1001 offset += q->subpacket[i].size;
995 chidx += q->subpacket[i].num_channels;1002 chidx += q->subpacket[i].num_channels;
996 av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb));1003 av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb));
997 }1004 }
998 *data_size = out_size;
999 1005
1000 /* Discard the first two frames: no valid audio. */1006 /* 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;
1002 1015
1003 return avctx->block_align;1016 return avctx->block_align;
1004}1017}
@@ -1246,6 +1259,9 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 241 unmodified lines
1246 else1259 else
1247 avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;1260 avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
1248 1261
1262 avcodec_get_frame_defaults(&q->frame);
1263 avctx->coded_frame = &q->frame;
1264
1249#ifdef DEBUG1265#ifdef DEBUG
1250 dump_cook_context(q);1266 dump_cook_context(q);
1251#endif1267#endif
@@ -1262,5 +1278,6 @@ AVCodec ff_cook_decoder = · 10 unmodified lines
1262 .init = cook_decode_init,1278 .init = cook_decode_init,
1263 .close = cook_decode_close,1279 .close = cook_decode_close,
1264 .decode = cook_decode_frame,1280 .decode = cook_decode_frame,
1281 .capabilities = CODEC_CAP_DR1,
1265 .long_name = NULL_IF_CONFIG_SMALL("COOK"),1282 .long_name = NULL_IF_CONFIG_SMALL("COOK"),
1266};1283};
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
261 261
262typedef struct {262typedef struct {
263 AVCodecContext *avctx;263 AVCodecContext *avctx;
264 AVFrame frame;
264 /* Frame header */265 /* Frame header */
265 int frame_type; ///< type of the current frame266 int frame_type; ///< type of the current frame
266 int samples_deficit; ///< deficit sample count267 int samples_deficit; ///< deficit sample count
@@ -1634,9 +1635,8 @@ static void dca_exss_parse_header(DCAContext *s) · 1367 unmodified lines
1634 * Main frame decoding function1635 * Main frame decoding function
1635 * FIXME add arguments1636 * FIXME add arguments
1636 */1637 */
1637static int dca_decode_frame(AVCodecContext * avctx,1638static int dca_decode_frame(AVCodecContext *avctx, void *data,
1638 void *data, int *data_size,1639 int *got_frame_ptr, AVPacket *avpkt)
1639 AVPacket *avpkt)
1640{1640{
1641 const uint8_t *buf = avpkt->data;1641 const uint8_t *buf = avpkt->data;
1642 int buf_size = avpkt->size;1642 int buf_size = avpkt->size;
@@ -1644,9 +1644,8 @@ static int dca_decode_frame(AVCodecContext * avctx, · 1 unmodified line
1644 int lfe_samples;1644 int lfe_samples;
1645 int num_core_channels = 0;1645 int num_core_channels = 0;
1646 int i, ret;1646 int i, ret;
1647 float *samples_flt = data;1647 float *samples_flt;
1648 int16_t *samples_s16 = data;1648 int16_t *samples_s16;
1649 int out_size;
1650 DCAContext *s = avctx->priv_data;1649 DCAContext *s = avctx->priv_data;
1651 int channels;1650 int channels;
1652 int core_ss_end;1651 int core_ss_end;
@@ -1832,11 +1831,14 @@ static int dca_decode_frame(AVCodecContext * avctx, · 179 unmodified lines
1832 avctx->channels = channels;1831 avctx->channels = channels;
1833 }1832 }
1834 1833
1835 out_size = 256 / 8 * s->sample_blocks * channels *1834 /* get output buffer */
1836 av_get_bytes_per_sample(avctx->sample_fmt);1835 s->frame.nb_samples = 256 * (s->sample_blocks / 8);
1837 if (*data_size < out_size)1836 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
1838 return AVERROR(EINVAL);1837 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1839 *data_size = out_size;1838 return ret;
1839 }
1840 samples_flt = (float *)s->frame.data[0];
1841 samples_s16 = (int16_t *)s->frame.data[0];
1840 1842
1841 /* filter to get final output */1843 /* filter to get final output */
1842 for (i = 0; i < (s->sample_blocks / 8); i++) {1844 for (i = 0; i < (s->sample_blocks / 8); i++) {
@@ -1870,6 +1872,9 @@ static int dca_decode_frame(AVCodecContext * avctx, · 27 unmodified lines
1870 s->lfe_data[i] = s->lfe_data[i + lfe_samples];1872 s->lfe_data[i] = s->lfe_data[i + lfe_samples];
1871 }1873 }
1872 1874
1875 *got_frame_ptr = 1;
1876 *(AVFrame *)data = s->frame;
1877
1873 return buf_size;1878 return buf_size;
1874}1879}
1875 1880
@@ -1912,6 +1917,9 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) · 36 unmodified lines
1912 avctx->channels = avctx->request_channels;1917 avctx->channels = avctx->request_channels;
1913 }1918 }
1914 1919
1920 avcodec_get_frame_defaults(&s->frame);
1921 avctx->coded_frame = &s->frame;
1922
1915 return 0;1923 return 0;
1916}1924}
1917 1925
@@ -1940,7 +1948,7 @@ AVCodec ff_dca_decoder = { · 22 unmodified lines
1940 .decode = dca_decode_frame,1948 .decode = dca_decode_frame,
1941 .close = dca_decode_end,1949 .close = dca_decode_end,
1942 .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),1950 .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,
1944 .sample_fmts = (const enum AVSampleFormat[]) {1952 .sample_fmts = (const enum AVSampleFormat[]) {
1945 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE1953 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
1946 },1954 },
libavcodec/dpcm.c+19−9
@@ -42,6 +42,7 @@ · 41 unmodified lines
42#include "bytestream.h"42#include "bytestream.h"
43 43
44typedef struct DPCMContext {44typedef struct DPCMContext {
45 AVFrame frame;
45 int channels;46 int channels;
46 int16_t roq_square_array[256];47 int16_t roq_square_array[256];
47 int sample[2]; ///< previous sample (for SOL_DPCM)48 int sample[2]; ///< previous sample (for SOL_DPCM)
@@ -162,22 +163,25 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx) · 114 unmodified lines
162 else163 else
163 avctx->sample_fmt = AV_SAMPLE_FMT_S16;164 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
164 165
166 avcodec_get_frame_defaults(&s->frame);
167 avctx->coded_frame = &s->frame;
168
165 return 0;169 return 0;
166}170}
167 171
168 172
169static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size,173static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
170 AVPacket *avpkt)174 int *got_frame_ptr, AVPacket *avpkt)
171{175{
172 const uint8_t *buf = avpkt->data;176 const uint8_t *buf = avpkt->data;
173 int buf_size = avpkt->size;177 int buf_size = avpkt->size;
174 const uint8_t *buf_end = buf + buf_size;178 const uint8_t *buf_end = buf + buf_size;
175 DPCMContext *s = avctx->priv_data;179 DPCMContext *s = avctx->priv_data;
176 int out = 0;180 int out = 0, ret;
177 int predictor[2];181 int predictor[2];
178 int ch = 0;182 int ch = 0;
179 int stereo = s->channels - 1;183 int stereo = s->channels - 1;
180 int16_t *output_samples = data;184 int16_t *output_samples;
181 185
182 /* calculate output size */186 /* calculate output size */
183 switch(avctx->codec->id) {187 switch(avctx->codec->id) {
@@ -197,15 +201,18 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 13 unmodified lines
197 out = buf_size;201 out = buf_size;
198 break;202 break;
199 }203 }
200 out *= av_get_bytes_per_sample(avctx->sample_fmt);
201 if (out <= 0) {204 if (out <= 0) {
202 av_log(avctx, AV_LOG_ERROR, "packet is too small\n");205 av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
203 return AVERROR(EINVAL);206 return AVERROR(EINVAL);
204 }207 }
205 if (*data_size < out) {208
206 av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");209 /* get output buffer */
207 return AVERROR(EINVAL);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;
208 }214 }
215 output_samples = (int16_t *)s->frame.data[0];
209 216
210 switch(avctx->codec->id) {217 switch(avctx->codec->id) {
211 218
@@ -307,7 +314,9 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 95 unmodified lines
307 break;314 break;
308 }315 }
309 316
310 *data_size = out;317 *got_frame_ptr = 1;
318 *(AVFrame *)data = s->frame;
319
311 return buf_size;320 return buf_size;
312}321}
313 322
@@ -319,6 +328,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 5 unmodified lines
319 .priv_data_size = sizeof(DPCMContext), \328 .priv_data_size = sizeof(DPCMContext), \
320 .init = dpcm_decode_init, \329 .init = dpcm_decode_init, \
321 .decode = dpcm_decode_frame, \330 .decode = dpcm_decode_frame, \
331 .capabilities = CODEC_CAP_DR1, \
322 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \332 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
323}333}
324 334
libavcodec/dsicinav.c+18−12
@@ -44,6 +44,7 @@ typedef struct CinVideoContext { · 43 unmodified lines
44} CinVideoContext;44} CinVideoContext;
45 45
46typedef struct CinAudioContext {46typedef struct CinAudioContext {
47 AVFrame frame;
47 int initial_decode_frame;48 int initial_decode_frame;
48 int delta;49 int delta;
49} CinAudioContext;50} CinAudioContext;
@@ -318,25 +319,28 @@ static av_cold int cinaudio_decode_init(AVCodecContext *avctx) · 268 unmodified lines
318 cin->delta = 0;319 cin->delta = 0;
319 avctx->sample_fmt = AV_SAMPLE_FMT_S16;320 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
320 321
322 avcodec_get_frame_defaults(&cin->frame);
323 avctx->coded_frame = &cin->frame;
324
321 return 0;325 return 0;
322}326}
323 327
324static int cinaudio_decode_frame(AVCodecContext *avctx,328static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
325 void *data, int *data_size,329 int *got_frame_ptr, AVPacket *avpkt)
326 AVPacket *avpkt)
327{330{
328 const uint8_t *buf = avpkt->data;331 const uint8_t *buf = avpkt->data;
329 CinAudioContext *cin = avctx->priv_data;332 CinAudioContext *cin = avctx->priv_data;
330 const uint8_t *buf_end = buf + avpkt->size;333 const uint8_t *buf_end = buf + avpkt->size;
331 int16_t *samples = data;334 int16_t *samples;
332 int delta, out_size;335 int delta, ret;
333 336
334 out_size = (avpkt->size - cin->initial_decode_frame) *337 /* get output buffer */
335 av_get_bytes_per_sample(avctx->sample_fmt);338 cin->frame.nb_samples = avpkt->size - cin->initial_decode_frame;
336 if (*data_size < out_size) {339 if ((ret = avctx->get_buffer(avctx, &cin->frame)) < 0) {
337 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");340 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
338 return AVERROR(EINVAL);341 return ret;
339 }342 }
343 samples = (int16_t *)cin->frame.data[0];
340 344
341 delta = cin->delta;345 delta = cin->delta;
342 if (cin->initial_decode_frame) {346 if (cin->initial_decode_frame) {
@@ -352,7 +356,8 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, · 9 unmodified lines
352 }356 }
353 cin->delta = delta;357 cin->delta = delta;
354 358
355 *data_size = out_size;359 *got_frame_ptr = 1;
360 *(AVFrame *)data = cin->frame;
356 361
357 return avpkt->size;362 return avpkt->size;
358}363}
@@ -377,5 +382,6 @@ AVCodec ff_dsicinaudio_decoder = { · 18 unmodified lines
377 .priv_data_size = sizeof(CinAudioContext),382 .priv_data_size = sizeof(CinAudioContext),
378 .init = cinaudio_decode_init,383 .init = cinaudio_decode_init,
379 .decode = cinaudio_decode_frame,384 .decode = cinaudio_decode_frame,
385 .capabilities = CODEC_CAP_DR1,
380 .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"),386 .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"),
381};387};
libavcodec/flacdec.c+21−16
@@ -49,6 +49,7 @@ typedef struct FLACContext { · 48 unmodified lines
49 FLACSTREAMINFO49 FLACSTREAMINFO
50 50
51 AVCodecContext *avctx; ///< parent AVCodecContext51 AVCodecContext *avctx; ///< parent AVCodecContext
52 AVFrame frame;
52 GetBitContext gb; ///< GetBitContext initialized to start at the current frame53 GetBitContext gb; ///< GetBitContext initialized to start at the current frame
53 54
54 int blocksize; ///< number of samples in the current frame55 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
116 allocate_buffers(s);117 allocate_buffers(s);
117 s->got_streaminfo = 1;118 s->got_streaminfo = 1;
118 119
120 avcodec_get_frame_defaults(&s->frame);
121 avctx->coded_frame = &s->frame;
122
119 return 0;123 return 0;
120}124}
121 125
@@ -542,20 +546,18 @@ static int decode_frame(FLACContext *s) · 420 unmodified lines
542 return 0;546 return 0;
543}547}
544 548
545static int flac_decode_frame(AVCodecContext *avctx,549static int flac_decode_frame(AVCodecContext *avctx, void *data,
546 void *data, int *data_size,550 int *got_frame_ptr, AVPacket *avpkt)
547 AVPacket *avpkt)
548{551{
549 const uint8_t *buf = avpkt->data;552 const uint8_t *buf = avpkt->data;
550 int buf_size = avpkt->size;553 int buf_size = avpkt->size;
551 FLACContext *s = avctx->priv_data;554 FLACContext *s = avctx->priv_data;
552 int i, j = 0, bytes_read = 0;555 int i, j = 0, bytes_read = 0;
553 int16_t *samples_16 = data;556 int16_t *samples_16;
554 int32_t *samples_32 = data;557 int32_t *samples_32;
555 int alloc_data_size= *data_size;558 int ret;
556 int output_size;
557 559
558 *data_size=0;560 *got_frame_ptr = 0;
559 561
560 if (s->max_framesize == 0) {562 if (s->max_framesize == 0) {
561 s->max_framesize =563 s->max_framesize =
@@ -586,15 +588,14 @@ static int flac_decode_frame(AVCodecContext *avctx, · 24 unmodified lines
586 }588 }
587 bytes_read = (get_bits_count(&s->gb)+7)/8;589 bytes_read = (get_bits_count(&s->gb)+7)/8;
588 590
589 /* check if allocated data size is large enough for output */591 /* get output buffer */
590 output_size = s->blocksize * s->channels *592 s->frame.nb_samples = s->blocksize;
591 av_get_bytes_per_sample(avctx->sample_fmt);593 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
592 if (output_size > alloc_data_size) {594 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
593 av_log(s->avctx, AV_LOG_ERROR, "output data size is larger than "595 return ret;
594 "allocated data size\n");
595 return -1;
596 }596 }
597 *data_size = output_size;597 samples_16 = (int16_t *)s->frame.data[0];
598 samples_32 = (int32_t *)s->frame.data[0];
598 599
599#define DECORRELATE(left, right)\600#define DECORRELATE(left, right)\
600 assert(s->channels == 2);\601 assert(s->channels == 2);\
@@ -639,6 +640,9 @@ static int flac_decode_frame(AVCodecContext *avctx, · 38 unmodified lines
639 buf_size - bytes_read, buf_size);640 buf_size - bytes_read, buf_size);
640 }641 }
641 642
643 *got_frame_ptr = 1;
644 *(AVFrame *)data = s->frame;
645
642 return bytes_read;646 return bytes_read;
643}647}
644 648
@@ -662,5 +666,6 @@ AVCodec ff_flac_decoder = { · 17 unmodified lines
662 .init = flac_decode_init,666 .init = flac_decode_init,
663 .close = flac_decode_close,667 .close = flac_decode_close,
664 .decode = flac_decode_frame,668 .decode = flac_decode_frame,
669 .capabilities = CODEC_CAP_DR1,
665 .long_name= NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),670 .long_name= NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
666};671};
libavcodec/g722.h+2−0
@@ -26,10 +26,12 @@ · 25 unmodified lines
26#define AVCODEC_G722_H26#define AVCODEC_G722_H
27 27
28#include <stdint.h>28#include <stdint.h>
29#include "avcodec.h"
29 30
30#define PREV_SAMPLES_BUF_SIZE 102431#define PREV_SAMPLES_BUF_SIZE 1024
31 32
32typedef struct {33typedef struct {
34 AVFrame frame;
33 int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples35 int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples
34 int prev_samples_pos; ///< the number of values in prev_samples36 int prev_samples_pos; ///< the number of values in prev_samples
35 37
libavcodec/g722dec.c+17−8
@@ -66,6 +66,9 @@ static av_cold int g722_decode_init(AVCodecContext * avctx) · 65 unmodified lines
66 c->band[1].scale_factor = 2;66 c->band[1].scale_factor = 2;
67 c->prev_samples_pos = 22;67 c->prev_samples_pos = 22;
68 68
69 avcodec_get_frame_defaults(&c->frame);
70 avctx->coded_frame = &c->frame;
71
69 return 0;72 return 0;
70}73}
71 74
@@ -81,20 +84,22 @@ static const int16_t *low_inv_quants[3] = { ff_g722_low_inv_quant6, · 9 unmodified lines
81 ff_g722_low_inv_quant4 };84 ff_g722_low_inv_quant4 };
82 85
83static int g722_decode_frame(AVCodecContext *avctx, void *data,86static int g722_decode_frame(AVCodecContext *avctx, void *data,
84 int *data_size, AVPacket *avpkt)87 int *got_frame_ptr, AVPacket *avpkt)
85{88{
86 G722Context *c = avctx->priv_data;89 G722Context *c = avctx->priv_data;
87 int16_t *out_buf = data;90 int16_t *out_buf;
88 int j, out_len;91 int j, ret;
89 const int skip = 8 - avctx->bits_per_coded_sample;92 const int skip = 8 - avctx->bits_per_coded_sample;
90 const int16_t *quantizer_table = low_inv_quants[skip];93 const int16_t *quantizer_table = low_inv_quants[skip];
91 GetBitContext gb;94 GetBitContext gb;
92 95
93 out_len = avpkt->size * 2 * av_get_bytes_per_sample(avctx->sample_fmt);96 /* get output buffer */
94 if (*data_size < out_len) {97 c->frame.nb_samples = avpkt->size * 2;
95 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");98 if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
96 return AVERROR(EINVAL);99 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
100 return ret;
97 }101 }
102 out_buf = (int16_t *)c->frame.data[0];
98 103
99 init_get_bits(&gb, avpkt->data, avpkt->size * 8);104 init_get_bits(&gb, avpkt->data, avpkt->size * 8);
100 105
@@ -128,7 +133,10 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data, · 27 unmodified lines
128 c->prev_samples_pos = 22;133 c->prev_samples_pos = 22;
129 }134 }
130 }135 }
131 *data_size = out_len;136
137 *got_frame_ptr = 1;
138 *(AVFrame *)data = c->frame;
139
132 return avpkt->size;140 return avpkt->size;
133}141}
134 142
@@ -139,5 +147,6 @@ AVCodec ff_adpcm_g722_decoder = { · 4 unmodified lines
139 .priv_data_size = sizeof(G722Context),147 .priv_data_size = sizeof(G722Context),
140 .init = g722_decode_init,148 .init = g722_decode_init,
141 .decode = g722_decode_frame,149 .decode = g722_decode_frame,
150 .capabilities = CODEC_CAP_DR1,
142 .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),151 .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
143};152};
libavcodec/g726.c+19−10
@@ -75,6 +75,7 @@ typedef struct G726Tables { · 74 unmodified lines
75 75
76typedef struct G726Context {76typedef struct G726Context {
77 AVClass *class;77 AVClass *class;
78 AVFrame frame;
78 G726Tables tbls; /**< static tables needed for computation */79 G726Tables tbls; /**< static tables needed for computation */
79 80
80 Float11 sr[2]; /**< prev. reconstructed samples */81 Float11 sr[2]; /**< prev. reconstructed samples */
@@ -427,26 +428,31 @@ static av_cold int g726_decode_init(AVCodecContext *avctx) · 346 unmodified lines
427 428
428 avctx->sample_fmt = AV_SAMPLE_FMT_S16;429 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
429 430
431 avcodec_get_frame_defaults(&c->frame);
432 avctx->coded_frame = &c->frame;
433
430 return 0;434 return 0;
431}435}
432 436
433static int g726_decode_frame(AVCodecContext *avctx,437static int g726_decode_frame(AVCodecContext *avctx, void *data,
434 void *data, int *data_size,438 int *got_frame_ptr, AVPacket *avpkt)
435 AVPacket *avpkt)
436{439{
437 const uint8_t *buf = avpkt->data;440 const uint8_t *buf = avpkt->data;
438 int buf_size = avpkt->size;441 int buf_size = avpkt->size;
439 G726Context *c = avctx->priv_data;442 G726Context *c = avctx->priv_data;
440 int16_t *samples = data;443 int16_t *samples;
441 GetBitContext gb;444 GetBitContext gb;
442 int out_samples, out_size;445 int out_samples, ret;
443 446
444 out_samples = buf_size * 8 / c->code_size;447 out_samples = buf_size * 8 / c->code_size;
445 out_size = out_samples * av_get_bytes_per_sample(avctx->sample_fmt);448
446 if (*data_size < out_size) {449 /* get output buffer */
447 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");450 c->frame.nb_samples = out_samples;
448 return AVERROR(EINVAL);451 if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
452 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
453 return ret;
449 }454 }
455 samples = (int16_t *)c->frame.data[0];
450 456
451 init_get_bits(&gb, buf, buf_size * 8);457 init_get_bits(&gb, buf, buf_size * 8);
452 458
@@ -456,7 +462,9 @@ static int g726_decode_frame(AVCodecContext *avctx, · 3 unmodified lines
456 if (get_bits_left(&gb) > 0)462 if (get_bits_left(&gb) > 0)
457 av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n");463 av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n");
458 464
459 *data_size = out_size;465 *got_frame_ptr = 1;
466 *(AVFrame *)data = c->frame;
467
460 return buf_size;468 return buf_size;
461}469}
462 470
@@ -474,6 +482,7 @@ AVCodec ff_adpcm_g726_decoder = { · 11 unmodified lines
474 .init = g726_decode_init,482 .init = g726_decode_init,
475 .decode = g726_decode_frame,483 .decode = g726_decode_frame,
476 .flush = g726_decode_flush,484 .flush = g726_decode_flush,
485 .capabilities = CODEC_CAP_DR1,
477 .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"),486 .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"),
478};487};
479#endif488#endif
libavcodec/gsmdec.c+22−10
@@ -32,6 +32,8 @@ · 31 unmodified lines
32 32
33static av_cold int gsm_init(AVCodecContext *avctx)33static av_cold int gsm_init(AVCodecContext *avctx)
34{34{
35 GSMContext *s = avctx->priv_data;
36
35 avctx->channels = 1;37 avctx->channels = 1;
36 if (!avctx->sample_rate)38 if (!avctx->sample_rate)
37 avctx->sample_rate = 8000;39 avctx->sample_rate = 8000;
@@ -47,30 +49,35 @@ static av_cold int gsm_init(AVCodecContext *avctx) · 9 unmodified lines
47 avctx->block_align = GSM_MS_BLOCK_SIZE;49 avctx->block_align = GSM_MS_BLOCK_SIZE;
48 }50 }
49 51
52 avcodec_get_frame_defaults(&s->frame);
53 avctx->coded_frame = &s->frame;
54
50 return 0;55 return 0;
51}56}
52 57
53static int gsm_decode_frame(AVCodecContext *avctx, void *data,58static int gsm_decode_frame(AVCodecContext *avctx, void *data,
54 int *data_size, AVPacket *avpkt)59 int *got_frame_ptr, AVPacket *avpkt)
55{60{
61 GSMContext *s = avctx->priv_data;
56 int res;62 int res;
57 GetBitContext gb;63 GetBitContext gb;
58 const uint8_t *buf = avpkt->data;64 const uint8_t *buf = avpkt->data;
59 int buf_size = avpkt->size;65 int buf_size = avpkt->size;
60 int16_t *samples = data;66 int16_t *samples;
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 }
68 67
69 if (buf_size < avctx->block_align) {68 if (buf_size < avctx->block_align) {
70 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");69 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
71 return AVERROR_INVALIDDATA;70 return AVERROR_INVALIDDATA;
72 }71 }
73 72
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
74 switch (avctx->codec_id) {81 switch (avctx->codec_id) {
75 case CODEC_ID_GSM:82 case CODEC_ID_GSM:
76 init_get_bits(&gb, buf, buf_size * 8);83 init_get_bits(&gb, buf, buf_size * 8);
@@ -85,7 +92,10 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data, · 8 unmodified lines
85 if (res < 0)92 if (res < 0)
86 return res;93 return res;
87 }94 }
88 *data_size = frame_bytes;95
96 *got_frame_ptr = 1;
97 *(AVFrame *)data = s->frame;
98
89 return avctx->block_align;99 return avctx->block_align;
90}100}
91 101
@@ -103,6 +113,7 @@ AVCodec ff_gsm_decoder = { · 11 unmodified lines
103 .init = gsm_init,113 .init = gsm_init,
104 .decode = gsm_decode_frame,114 .decode = gsm_decode_frame,
105 .flush = gsm_flush,115 .flush = gsm_flush,
116 .capabilities = CODEC_CAP_DR1,
106 .long_name = NULL_IF_CONFIG_SMALL("GSM"),117 .long_name = NULL_IF_CONFIG_SMALL("GSM"),
107};118};
108 119
@@ -114,5 +125,6 @@ AVCodec ff_gsm_ms_decoder = { · 5 unmodified lines
114 .init = gsm_init,125 .init = gsm_init,
115 .decode = gsm_decode_frame,126 .decode = gsm_decode_frame,
116 .flush = gsm_flush,127 .flush = gsm_flush,
128 .capabilities = CODEC_CAP_DR1,
117 .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"),129 .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"),
118};130};
libavcodec/gsmdec_data.h+2−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
23#define AVCODEC_GSMDEC_DATA23#define AVCODEC_GSMDEC_DATA
24 24
25#include <stdint.h>25#include <stdint.h>
26#include "avcodec.h"
26 27
27// input and output sizes in byte28// input and output sizes in byte
28#define GSM_BLOCK_SIZE 3329#define GSM_BLOCK_SIZE 33
@@ -30,6 +31,7 @@ · 1 unmodified line
30#define GSM_FRAME_SIZE 16031#define GSM_FRAME_SIZE 160
31 32
32typedef struct {33typedef struct {
34 AVFrame frame;
33 // Contains first 120 elements from the previous frame35 // Contains first 120 elements from the previous frame
34 // (used by long_term_synth according to the "lag"),36 // (used by long_term_synth according to the "lag"),
35 // then in the following 160 elements the current37 // 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
956 956
957#if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER957#if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER
958static void draw_slice(HYuvContext *s, int y){958static void draw_slice(HYuvContext *s, int y){
959 int h, cy;959 int h, cy, i;
960 int offset[4];960 int offset[AV_NUM_DATA_POINTERS];
961 961
962 if(s->avctx->draw_horiz_band==NULL)962 if(s->avctx->draw_horiz_band==NULL)
963 return;963 return;
@@ -974,7 +974,8 @@ static void draw_slice(HYuvContext *s, int y){ · 10 unmodified lines
974 offset[0] = s->picture.linesize[0]*y;974 offset[0] = s->picture.linesize[0]*y;
975 offset[1] = s->picture.linesize[1]*cy;975 offset[1] = s->picture.linesize[1]*cy;
976 offset[2] = s->picture.linesize[2]*cy;976 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;
978 emms_c();979 emms_c();
979 980
980 s->avctx->draw_horiz_band(s->avctx, &s->picture, offset, y, 3, h);981 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
51#define COEFFS 25651#define COEFFS 256
52 52
53typedef struct {53typedef struct {
54 AVFrame frame;
55
54 float old_floor[BANDS];56 float old_floor[BANDS];
55 float flcoeffs1[BANDS];57 float flcoeffs1[BANDS];
56 float flcoeffs2[BANDS];58 float flcoeffs2[BANDS];
@@ -168,6 +170,10 @@ static av_cold int imc_decode_init(AVCodecContext * avctx) · 111 unmodified lines
168 dsputil_init(&q->dsp, avctx);170 dsputil_init(&q->dsp, avctx);
169 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;171 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
170 avctx->channel_layout = AV_CH_LAYOUT_MONO;172 avctx->channel_layout = AV_CH_LAYOUT_MONO;
173
174 avcodec_get_frame_defaults(&q->frame);
175 avctx->coded_frame = &q->frame;
176
171 return 0;177 return 0;
172}178}
173 179
@@ -649,9 +655,8 @@ static int imc_get_coeffs (IMCContext* q) { · 475 unmodified lines
649 return 0;655 return 0;
650}656}
651 657
652static int imc_decode_frame(AVCodecContext * avctx,658static int imc_decode_frame(AVCodecContext * avctx, void *data,
653 void *data, int *data_size,659 int *got_frame_ptr, AVPacket *avpkt)
654 AVPacket *avpkt)
655{660{
656 const uint8_t *buf = avpkt->data;661 const uint8_t *buf = avpkt->data;
657 int buf_size = avpkt->size;662 int buf_size = avpkt->size;
@@ -659,7 +664,7 @@ static int imc_decode_frame(AVCodecContext * avctx, · 1 unmodified line
659 IMCContext *q = avctx->priv_data;664 IMCContext *q = avctx->priv_data;
660 665
661 int stream_format_code;666 int stream_format_code;
662 int imc_hdr, i, j, out_size, ret;667 int imc_hdr, i, j, ret;
663 int flag;668 int flag;
664 int bits, summer;669 int bits, summer;
665 int counter, bitscount;670 int counter, bitscount;
@@ -670,15 +675,16 @@ static int imc_decode_frame(AVCodecContext * avctx, · 4 unmodified lines
670 return AVERROR_INVALIDDATA;675 return AVERROR_INVALIDDATA;
671 }676 }
672 677
673 out_size = COEFFS * av_get_bytes_per_sample(avctx->sample_fmt);678 /* get output buffer */
674 if (*data_size < out_size) {679 q->frame.nb_samples = COEFFS;
675 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");680 if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
676 return AVERROR(EINVAL);681 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
682 return ret;
677 }683 }
684 q->out_samples = (float *)q->frame.data[0];
678 685
679 q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2);686 q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2);
680 687
681 q->out_samples = data;
682 init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);688 init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
683 689
684 /* Check the frame header */690 /* Check the frame header */
@@ -823,7 +829,8 @@ static int imc_decode_frame(AVCodecContext * avctx, · 138 unmodified lines
823 829
824 imc_imdct256(q);830 imc_imdct256(q);
825 831
826 *data_size = out_size;832 *got_frame_ptr = 1;
833 *(AVFrame *)data = q->frame;
827 834
828 return IMC_BLOCK_SIZE;835 return IMC_BLOCK_SIZE;
829}836}
@@ -834,6 +841,7 @@ static av_cold int imc_decode_close(AVCodecContext * avctx) · 4 unmodified lines
834 IMCContext *q = avctx->priv_data;841 IMCContext *q = avctx->priv_data;
835 842
836 ff_fft_end(&q->fft);843 ff_fft_end(&q->fft);
844
837 return 0;845 return 0;
838}846}
839 847
@@ -846,5 +854,6 @@ AVCodec ff_imc_decoder = { · 6 unmodified lines
846 .init = imc_decode_init,854 .init = imc_decode_init,
847 .close = imc_decode_close,855 .close = imc_decode_close,
848 .decode = imc_decode_frame,856 .decode = imc_decode_frame,
857 .capabilities = CODEC_CAP_DR1,
849 .long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"),858 .long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"),
850};859};
libavcodec/internal.h+6−3
@@ -31,12 +31,15 @@ · 30 unmodified lines
31 31
32typedef struct InternalBuffer {32typedef struct InternalBuffer {
33 int last_pic_num;33 int last_pic_num;
34 uint8_t *base[4];34 uint8_t *base[AV_NUM_DATA_POINTERS];
35 uint8_t *data[4];35 uint8_t *data[AV_NUM_DATA_POINTERS];
36 int linesize[4];36 int linesize[AV_NUM_DATA_POINTERS];
37 int width;37 int width;
38 int height;38 int height;
39 enum PixelFormat pix_fmt;39 enum PixelFormat pix_fmt;
40 uint8_t **extended_data;
41 int audio_data_size;
42 int nb_channels;
40} InternalBuffer;43} InternalBuffer;
41 44
42typedef struct AVCodecInternal {45typedef struct AVCodecInternal {
libavcodec/libgsm.c+40−18
@@ -124,7 +124,14 @@ AVCodec ff_libgsm_ms_encoder = { · 123 unmodified lines
124 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),124 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
125};125};
126 126
127typedef struct LibGSMDecodeContext {
128 AVFrame frame;
129 struct gsm_state *state;
130} LibGSMDecodeContext;
131
127static av_cold int libgsm_decode_init(AVCodecContext *avctx) {132static av_cold int libgsm_decode_init(AVCodecContext *avctx) {
133 LibGSMDecodeContext *s = avctx->priv_data;
134
128 if (avctx->channels > 1) {135 if (avctx->channels > 1) {
129 av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n",136 av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n",
130 avctx->channels);137 avctx->channels);
@@ -139,7 +146,7 @@ static av_cold int libgsm_decode_init(AVCodecContext *avctx) { · 8 unmodified lines
139 146
140 avctx->sample_fmt = AV_SAMPLE_FMT_S16;147 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
141 148
142 avctx->priv_data = gsm_create();149 s->state = gsm_create();
143 150
144 switch(avctx->codec_id) {151 switch(avctx->codec_id) {
145 case CODEC_ID_GSM:152 case CODEC_ID_GSM:
@@ -154,59 +161,72 @@ static av_cold int libgsm_decode_init(AVCodecContext *avctx) { · 8 unmodified lines
154 }161 }
155 }162 }
156 163
164 avcodec_get_frame_defaults(&s->frame);
165 avctx->coded_frame = &s->frame;
166
157 return 0;167 return 0;
158}168}
159 169
160static av_cold int libgsm_decode_close(AVCodecContext *avctx) {170static av_cold int libgsm_decode_close(AVCodecContext *avctx) {
161 gsm_destroy(avctx->priv_data);171 LibGSMDecodeContext *s = avctx->priv_data;
162 avctx->priv_data = NULL;172
173 gsm_destroy(s->state);
174 s->state = NULL;
163 return 0;175 return 0;
164}176}
165 177
166static int libgsm_decode_frame(AVCodecContext *avctx,178static int libgsm_decode_frame(AVCodecContext *avctx, void *data,
167 void *data, int *data_size,179 int *got_frame_ptr, AVPacket *avpkt)
168 AVPacket *avpkt) {180{
169 int i, ret;181 int i, ret;
170 struct gsm_state *s = avctx->priv_data;182 LibGSMDecodeContext *s = avctx->priv_data;
171 uint8_t *buf = avpkt->data;183 uint8_t *buf = avpkt->data;
172 int buf_size = avpkt->size;184 int buf_size = avpkt->size;
173 int16_t *samples = data;185 int16_t *samples;
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 }
180 186
181 if (buf_size < avctx->block_align) {187 if (buf_size < avctx->block_align) {
182 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");188 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
183 return AVERROR_INVALIDDATA;189 return AVERROR_INVALIDDATA;
184 }190 }
185 191
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
186 for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) {200 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)
188 return -1;202 return -1;
189 buf += GSM_BLOCK_SIZE;203 buf += GSM_BLOCK_SIZE;
190 samples += GSM_FRAME_SIZE;204 samples += GSM_FRAME_SIZE;
191 }205 }
192 206
193 *data_size = out_size;207 *got_frame_ptr = 1;
208 *(AVFrame *)data = s->frame;
209
194 return avctx->block_align;210 return avctx->block_align;
195}211}
196 212
197static void libgsm_flush(AVCodecContext *avctx) {213static void libgsm_flush(AVCodecContext *avctx) {
198 gsm_destroy(avctx->priv_data);214 LibGSMDecodeContext *s = avctx->priv_data;
199 avctx->priv_data = gsm_create();215
216 gsm_destroy(s->state);
217 s->state = gsm_create();
200}218}
201 219
202AVCodec ff_libgsm_decoder = {220AVCodec ff_libgsm_decoder = {
203 .name = "libgsm",221 .name = "libgsm",
204 .type = AVMEDIA_TYPE_AUDIO,222 .type = AVMEDIA_TYPE_AUDIO,
205 .id = CODEC_ID_GSM,223 .id = CODEC_ID_GSM,
224 .priv_data_size = sizeof(LibGSMDecodeContext),
206 .init = libgsm_decode_init,225 .init = libgsm_decode_init,
207 .close = libgsm_decode_close,226 .close = libgsm_decode_close,
208 .decode = libgsm_decode_frame,227 .decode = libgsm_decode_frame,
209 .flush = libgsm_flush,228 .flush = libgsm_flush,
229 .capabilities = CODEC_CAP_DR1,
210 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),230 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
211};231};
212 232
@@ -214,9 +234,11 @@ AVCodec ff_libgsm_ms_decoder = { · 1 unmodified line
214 .name = "libgsm_ms",234 .name = "libgsm_ms",
215 .type = AVMEDIA_TYPE_AUDIO,235 .type = AVMEDIA_TYPE_AUDIO,
216 .id = CODEC_ID_GSM_MS,236 .id = CODEC_ID_GSM_MS,
237 .priv_data_size = sizeof(LibGSMDecodeContext),
217 .init = libgsm_decode_init,238 .init = libgsm_decode_init,
218 .close = libgsm_decode_close,239 .close = libgsm_decode_close,
219 .decode = libgsm_decode_frame,240 .decode = libgsm_decode_frame,
220 .flush = libgsm_flush,241 .flush = libgsm_flush,
242 .capabilities = CODEC_CAP_DR1,
221 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),243 .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
222};244};
libavcodec/libopencore-amr.c+35−17
@@ -79,6 +79,7 @@ static int get_bitrate_mode(int bitrate, void *log_ctx) · 78 unmodified lines
79 79
80typedef struct AMRContext {80typedef struct AMRContext {
81 AVClass *av_class;81 AVClass *av_class;
82 AVFrame frame;
82 void *dec_state;83 void *dec_state;
83 void *enc_state;84 void *enc_state;
84 int enc_bitrate;85 int enc_bitrate;
@@ -112,6 +113,9 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx) · 27 unmodified lines
112 return AVERROR(ENOSYS);113 return AVERROR(ENOSYS);
113 }114 }
114 115
116 avcodec_get_frame_defaults(&s->frame);
117 avctx->coded_frame = &s->frame;
118
115 return 0;119 return 0;
116}120}
117 121
@@ -120,26 +124,28 @@ static av_cold int amr_nb_decode_close(AVCodecContext *avctx) · 2 unmodified lines
120 AMRContext *s = avctx->priv_data;124 AMRContext *s = avctx->priv_data;
121 125
122 Decoder_Interface_exit(s->dec_state);126 Decoder_Interface_exit(s->dec_state);
127
123 return 0;128 return 0;
124}129}
125 130
126static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,131static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
127 int *data_size, AVPacket *avpkt)132 int *got_frame_ptr, AVPacket *avpkt)
128{133{
129 const uint8_t *buf = avpkt->data;134 const uint8_t *buf = avpkt->data;
130 int buf_size = avpkt->size;135 int buf_size = avpkt->size;
131 AMRContext *s = avctx->priv_data;136 AMRContext *s = avctx->priv_data;
132 static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };137 static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
133 enum Mode dec_mode;138 enum Mode dec_mode;
134 int packet_size, out_size;139 int packet_size, ret;
135 140
136 av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n",141 av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n",
137 buf, buf_size, avctx->frame_number);142 buf, buf_size, avctx->frame_number);
138 143
139 out_size = 160 * av_get_bytes_per_sample(avctx->sample_fmt);144 /* get output buffer */
140 if (*data_size < out_size) {145 s->frame.nb_samples = 160;
141 av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");146 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
142 return AVERROR(EINVAL);147 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
148 return ret;
143 }149 }
144 150
145 dec_mode = (buf[0] >> 3) & 0x000F;151 dec_mode = (buf[0] >> 3) & 0x000F;
@@ -154,8 +160,10 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data, · 8 unmodified lines
154 av_dlog(avctx, "packet_size=%d buf= 0x%X %X %X %X\n",160 av_dlog(avctx, "packet_size=%d buf= 0x%X %X %X %X\n",
155 packet_size, buf[0], buf[1], buf[2], buf[3]);161 packet_size, buf[0], buf[1], buf[2], buf[3]);
156 /* call decoder */162 /* call decoder */
157 Decoder_Interface_Decode(s->dec_state, buf, data, 0);163 Decoder_Interface_Decode(s->dec_state, buf, (short *)s->frame.data[0], 0);
158 *data_size = out_size;164
165 *got_frame_ptr = 1;
166 *(AVFrame *)data = s->frame;
159 167
160 return packet_size;168 return packet_size;
161}169}
@@ -168,6 +176,7 @@ AVCodec ff_libopencore_amrnb_decoder = { · 6 unmodified lines
168 .init = amr_nb_decode_init,176 .init = amr_nb_decode_init,
169 .close = amr_nb_decode_close,177 .close = amr_nb_decode_close,
170 .decode = amr_nb_decode_frame,178 .decode = amr_nb_decode_frame,
179 .capabilities = CODEC_CAP_DR1,
171 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),180 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),
172};181};
173 182
@@ -251,6 +260,7 @@ AVCodec ff_libopencore_amrnb_encoder = { · 77 unmodified lines
251#include <opencore-amrwb/if_rom.h>260#include <opencore-amrwb/if_rom.h>
252 261
253typedef struct AMRWBContext {262typedef struct AMRWBContext {
263 AVFrame frame;
254 void *state;264 void *state;
255} AMRWBContext;265} AMRWBContext;
256 266
@@ -267,23 +277,27 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx) · 10 unmodified lines
267 return AVERROR(ENOSYS);277 return AVERROR(ENOSYS);
268 }278 }
269 279
280 avcodec_get_frame_defaults(&s->frame);
281 avctx->coded_frame = &s->frame;
282
270 return 0;283 return 0;
271}284}
272 285
273static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,286static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
274 int *data_size, AVPacket *avpkt)287 int *got_frame_ptr, AVPacket *avpkt)
275{288{
276 const uint8_t *buf = avpkt->data;289 const uint8_t *buf = avpkt->data;
277 int buf_size = avpkt->size;290 int buf_size = avpkt->size;
278 AMRWBContext *s = avctx->priv_data;291 AMRWBContext *s = avctx->priv_data;
279 int mode;292 int mode, ret;
280 int packet_size, out_size;293 int packet_size;
281 static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};294 static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
282 295
283 out_size = 320 * av_get_bytes_per_sample(avctx->sample_fmt);296 /* get output buffer */
284 if (*data_size < out_size) {297 s->frame.nb_samples = 320;
285 av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");298 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
286 return AVERROR(EINVAL);299 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
300 return ret;
287 }301 }
288 302
289 mode = (buf[0] >> 3) & 0x000F;303 mode = (buf[0] >> 3) & 0x000F;
@@ -295,8 +309,11 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data, · 5 unmodified lines
295 return AVERROR_INVALIDDATA;309 return AVERROR_INVALIDDATA;
296 }310 }
297 311
298 D_IF_decode(s->state, buf, data, _good_frame);312 D_IF_decode(s->state, buf, (short *)s->frame.data[0], _good_frame);
299 *data_size = out_size;313
314 *got_frame_ptr = 1;
315 *(AVFrame *)data = s->frame;
316
300 return packet_size;317 return packet_size;
301}318}
302 319
@@ -316,6 +333,7 @@ AVCodec ff_libopencore_amrwb_decoder = { · 13 unmodified lines
316 .init = amr_wb_decode_init,333 .init = amr_wb_decode_init,
317 .close = amr_wb_decode_close,334 .close = amr_wb_decode_close,
318 .decode = amr_wb_decode_frame,335 .decode = amr_wb_decode_frame,
336 .capabilities = CODEC_CAP_DR1,
319 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"),337 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"),
320};338};
321 339
libavcodec/libspeexdec.c+21−15
@@ -25,6 +25,7 @@ · 24 unmodified lines
25#include "avcodec.h"25#include "avcodec.h"
26 26
27typedef struct {27typedef struct {
28 AVFrame frame;
28 SpeexBits bits;29 SpeexBits bits;
29 SpeexStereoState stereo;30 SpeexStereoState stereo;
30 void *dec_state;31 void *dec_state;
@@ -89,26 +90,29 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx) · 58 unmodified lines
89 s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;90 s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
90 speex_decoder_ctl(s->dec_state, SPEEX_SET_HANDLER, &callback);91 speex_decoder_ctl(s->dec_state, SPEEX_SET_HANDLER, &callback);
91 }92 }
93
94 avcodec_get_frame_defaults(&s->frame);
95 avctx->coded_frame = &s->frame;
96
92 return 0;97 return 0;
93}98}
94 99
95static int libspeex_decode_frame(AVCodecContext *avctx,100static int libspeex_decode_frame(AVCodecContext *avctx, void *data,
96 void *data, int *data_size,101 int *got_frame_ptr, AVPacket *avpkt)
97 AVPacket *avpkt)
98{102{
99 uint8_t *buf = avpkt->data;103 uint8_t *buf = avpkt->data;
100 int buf_size = avpkt->size;104 int buf_size = avpkt->size;
101 LibSpeexContext *s = avctx->priv_data;105 LibSpeexContext *s = avctx->priv_data;
102 int16_t *output = data;106 int16_t *output;
103 int out_size, ret, consumed = 0;107 int ret, consumed = 0;
104 108
105 /* check output buffer size */109 /* get output buffer */
106 out_size = s->frame_size * avctx->channels *110 s->frame.nb_samples = s->frame_size;
107 av_get_bytes_per_sample(avctx->sample_fmt);111 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
108 if (*data_size < out_size) {112 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
109 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");113 return ret;
110 return AVERROR(EINVAL);
111 }114 }
115 output = (int16_t *)s->frame.data[0];
112 116
113 /* if there is not enough data left for the smallest possible frame,117 /* if there is not enough data left for the smallest possible frame,
114 reset the libspeex buffer using the current packet, otherwise ignore118 reset the libspeex buffer using the current packet, otherwise ignore
@@ -116,7 +120,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx, · 1 unmodified line
116 if (speex_bits_remaining(&s->bits) < 43) {120 if (speex_bits_remaining(&s->bits) < 43) {
117 /* check for flush packet */121 /* check for flush packet */
118 if (!buf || !buf_size) {122 if (!buf || !buf_size) {
119 *data_size = 0;123 *got_frame_ptr = 0;
120 return buf_size;124 return buf_size;
121 }125 }
122 /* set new buffer */126 /* set new buffer */
@@ -133,7 +137,9 @@ static int libspeex_decode_frame(AVCodecContext *avctx, · 10 unmodified lines
133 if (avctx->channels == 2)137 if (avctx->channels == 2)
134 speex_decode_stereo_int(output, s->frame_size, &s->stereo);138 speex_decode_stereo_int(output, s->frame_size, &s->stereo);
135 139
136 *data_size = out_size;140 *got_frame_ptr = 1;
141 *(AVFrame *)data = s->frame;
142
137 return consumed;143 return consumed;
138}144}
139 145
@@ -163,6 +169,6 @@ AVCodec ff_libspeex_decoder = { · 23 unmodified lines
163 .close = libspeex_decode_close,169 .close = libspeex_decode_close,
164 .decode = libspeex_decode_frame,170 .decode = libspeex_decode_frame,
165 .flush = libspeex_decode_flush,171 .flush = libspeex_decode_flush,
166 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY,172 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1,
167 .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"),173 .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"),
168};174};
libavcodec/mace.c+21−12
@@ -153,6 +153,7 @@ typedef struct ChannelData { · 152 unmodified lines
153} ChannelData;153} ChannelData;
154 154
155typedef struct MACEContext {155typedef struct MACEContext {
156 AVFrame frame;
156 ChannelData chd[2];157 ChannelData chd[2];
157} MACEContext;158} MACEContext;
158 159
@@ -228,30 +229,35 @@ static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, · 69 unmodified lines
228 229
229static av_cold int mace_decode_init(AVCodecContext * avctx)230static av_cold int mace_decode_init(AVCodecContext * avctx)
230{231{
232 MACEContext *ctx = avctx->priv_data;
233
231 if (avctx->channels > 2)234 if (avctx->channels > 2)
232 return -1;235 return -1;
233 avctx->sample_fmt = AV_SAMPLE_FMT_S16;236 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
237
238 avcodec_get_frame_defaults(&ctx->frame);
239 avctx->coded_frame = &ctx->frame;
240
234 return 0;241 return 0;
235}242}
236 243
237static int mace_decode_frame(AVCodecContext *avctx,244static int mace_decode_frame(AVCodecContext *avctx, void *data,
238 void *data, int *data_size,245 int *got_frame_ptr, AVPacket *avpkt)
239 AVPacket *avpkt)
240{246{
241 const uint8_t *buf = avpkt->data;247 const uint8_t *buf = avpkt->data;
242 int buf_size = avpkt->size;248 int buf_size = avpkt->size;
243 int16_t *samples = data;249 int16_t *samples;
244 MACEContext *ctx = avctx->priv_data;250 MACEContext *ctx = avctx->priv_data;
245 int i, j, k, l;251 int i, j, k, l, ret;
246 int out_size;
247 int is_mace3 = (avctx->codec_id == CODEC_ID_MACE3);252 int is_mace3 = (avctx->codec_id == CODEC_ID_MACE3);
248 253
249 out_size = 3 * (buf_size << (1 - is_mace3)) *254 /* get output buffer */
250 av_get_bytes_per_sample(avctx->sample_fmt);255 ctx->frame.nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
251 if (*data_size < out_size) {256 if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
252 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");257 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
253 return AVERROR(EINVAL);258 return ret;
254 }259 }
260 samples = (int16_t *)ctx->frame.data[0];
255 261
256 for(i = 0; i < avctx->channels; i++) {262 for(i = 0; i < avctx->channels; i++) {
257 int16_t *output = samples + i;263 int16_t *output = samples + i;
@@ -277,7 +283,8 @@ static int mace_decode_frame(AVCodecContext *avctx, · 19 unmodified lines
277 }283 }
278 }284 }
279 285
280 *data_size = out_size;286 *got_frame_ptr = 1;
287 *(AVFrame *)data = ctx->frame;
281 288
282 return buf_size;289 return buf_size;
283}290}
@@ -289,6 +296,7 @@ AVCodec ff_mace3_decoder = { · 5 unmodified lines
289 .priv_data_size = sizeof(MACEContext),296 .priv_data_size = sizeof(MACEContext),
290 .init = mace_decode_init,297 .init = mace_decode_init,
291 .decode = mace_decode_frame,298 .decode = mace_decode_frame,
299 .capabilities = CODEC_CAP_DR1,
292 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),300 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),
293};301};
294 302
@@ -299,6 +307,7 @@ AVCodec ff_mace6_decoder = { · 4 unmodified lines
299 .priv_data_size = sizeof(MACEContext),307 .priv_data_size = sizeof(MACEContext),
300 .init = mace_decode_init,308 .init = mace_decode_init,
301 .decode = mace_decode_frame,309 .decode = mace_decode_frame,
310 .capabilities = CODEC_CAP_DR1,
302 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"),311 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"),
303};312};
304 313
libavcodec/mlpdec.c+25−14
@@ -120,6 +120,7 @@ typedef struct SubStream { · 119 unmodified lines
120 120
121typedef struct MLPDecodeContext {121typedef struct MLPDecodeContext {
122 AVCodecContext *avctx;122 AVCodecContext *avctx;
123 AVFrame frame;
123 124
124 //! Current access unit being read has a major sync.125 //! Current access unit being read has a major sync.
125 int is_major_sync_unit;126 int is_major_sync_unit;
@@ -242,6 +243,9 @@ static av_cold int mlp_decode_init(AVCodecContext *avctx) · 116 unmodified lines
242 m->substream[substr].lossless_check_data = 0xffffffff;243 m->substream[substr].lossless_check_data = 0xffffffff;
243 dsputil_init(&m->dsp, avctx);244 dsputil_init(&m->dsp, avctx);
244 245
246 avcodec_get_frame_defaults(&m->frame);
247 avctx->coded_frame = &m->frame;
248
245 return 0;249 return 0;
246}250}
247 251
@@ -946,13 +950,14 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) · 698 unmodified lines
946/** Write the audio data into the output buffer. */950/** Write the audio data into the output buffer. */
947 951
948static int output_data(MLPDecodeContext *m, unsigned int substr,952static int output_data(MLPDecodeContext *m, unsigned int substr,
949 uint8_t *data, unsigned int *data_size)953 void *data, int *got_frame_ptr)
950{954{
955 AVCodecContext *avctx = m->avctx;
951 SubStream *s = &m->substream[substr];956 SubStream *s = &m->substream[substr];
952 unsigned int i, out_ch = 0;957 unsigned int i, out_ch = 0;
953 int out_size;958 int32_t *data_32;
954 int32_t *data_32 = (int32_t*) data;959 int16_t *data_16;
955 int16_t *data_16 = (int16_t*) data;960 int ret;
956 int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);961 int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
957 962
958 if (m->avctx->channels != s->max_matrix_channel + 1) {963 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
960 return AVERROR_INVALIDDATA;965 return AVERROR_INVALIDDATA;
961 }966 }
962 967
963 out_size = s->blockpos * m->avctx->channels *968 /* get output buffer */
964 av_get_bytes_per_sample(m->avctx->sample_fmt);969 m->frame.nb_samples = s->blockpos;
965 970 if ((ret = avctx->get_buffer(avctx, &m->frame)) < 0) {
966 if (*data_size < out_size)971 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
967 return AVERROR(EINVAL);972 return ret;
973 }
974 data_32 = (int32_t *)m->frame.data[0];
975 data_16 = (int16_t *)m->frame.data[0];
968 976
969 for (i = 0; i < s->blockpos; i++) {977 for (i = 0; i < s->blockpos; i++) {
970 for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {978 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
977 }985 }
978 }986 }
979 987
980 *data_size = out_size;988 *got_frame_ptr = 1;
989 *(AVFrame *)data = m->frame;
981 990
982 return 0;991 return 0;
983}992}
@@ -986,8 +995,8 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 2 unmodified lines
986 * @return negative on error, 0 if not enough data is present in the input stream,995 * @return negative on error, 0 if not enough data is present in the input stream,
987 * otherwise the number of bytes consumed. */996 * otherwise the number of bytes consumed. */
988 997
989static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size,998static int read_access_unit(AVCodecContext *avctx, void* data,
990 AVPacket *avpkt)999 int *got_frame_ptr, AVPacket *avpkt)
991{1000{
992 const uint8_t *buf = avpkt->data;1001 const uint8_t *buf = avpkt->data;
993 int buf_size = avpkt->size;1002 int buf_size = avpkt->size;
@@ -1023,7 +1032,7 @@ static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size, · 29 unmodified lines
1023 if (!m->params_valid) {1032 if (!m->params_valid) {
1024 av_log(m->avctx, AV_LOG_WARNING,1033 av_log(m->avctx, AV_LOG_WARNING,
1025 "Stream parameters not seen; skipping frame.\n");1034 "Stream parameters not seen; skipping frame.\n");
1026 *data_size = 0;1035 *got_frame_ptr = 0;
1027 return length;1036 return length;
1028 }1037 }
1029 1038
@@ -1168,7 +1177,7 @@ next_substr: · 138 unmodified lines
1168 1177
1169 rematrix_channels(m, m->max_decoded_substream);1178 rematrix_channels(m, m->max_decoded_substream);
1170 1179
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)
1172 return ret;1181 return ret;
1173 1182
1174 return length;1183 return length;
@@ -1189,6 +1198,7 @@ AVCodec ff_mlp_decoder = { · 14 unmodified lines
1189 .priv_data_size = sizeof(MLPDecodeContext),1198 .priv_data_size = sizeof(MLPDecodeContext),
1190 .init = mlp_decode_init,1199 .init = mlp_decode_init,
1191 .decode = read_access_unit,1200 .decode = read_access_unit,
1201 .capabilities = CODEC_CAP_DR1,
1192 .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),1202 .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),
1193};1203};
1194 1204
@@ -1200,6 +1210,7 @@ AVCodec ff_truehd_decoder = { · 5 unmodified lines
1200 .priv_data_size = sizeof(MLPDecodeContext),1210 .priv_data_size = sizeof(MLPDecodeContext),
1201 .init = mlp_decode_init,1211 .init = mlp_decode_init,
1202 .decode = read_access_unit,1212 .decode = read_access_unit,
1213 .capabilities = CODEC_CAP_DR1,
1203 .long_name = NULL_IF_CONFIG_SMALL("TrueHD"),1214 .long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
1204};1215};
1205#endif /* CONFIG_TRUEHD_DECODER */1216#endif /* CONFIG_TRUEHD_DECODER */
libavcodec/mpc.h+1−0
@@ -50,6 +50,7 @@ typedef struct { · 49 unmodified lines
50}Band;50}Band;
51 51
52typedef struct {52typedef struct {
53 AVFrame frame;
53 DSPContext dsp;54 DSPContext dsp;
54 MPADSPContext mpadsp;55 MPADSPContext mpadsp;
55 GetBitContext gb;56 GetBitContext gb;
libavcodec/mpc7.c+18−11
@@ -136,6 +136,10 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) · 135 unmodified lines
136 }136 }
137 }137 }
138 vlc_initialized = 1;138 vlc_initialized = 1;
139
140 avcodec_get_frame_defaults(&c->frame);
141 avctx->coded_frame = &c->frame;
142
139 return 0;143 return 0;
140}144}
141 145
@@ -192,9 +196,8 @@ static int get_scale_idx(GetBitContext *gb, int ref) · 50 unmodified lines
192 return ref + t;196 return ref + t;
193}197}
194 198
195static int mpc7_decode_frame(AVCodecContext * avctx,199static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
196 void *data, int *data_size,200 int *got_frame_ptr, AVPacket *avpkt)
197 AVPacket *avpkt)
198{201{
199 const uint8_t *buf = avpkt->data;202 const uint8_t *buf = avpkt->data;
200 int buf_size = avpkt->size;203 int buf_size = avpkt->size;
@@ -204,7 +207,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 3 unmodified lines
204 int i, ch;207 int i, ch;
205 int mb = -1;208 int mb = -1;
206 Band *bands = c->bands;209 Band *bands = c->bands;
207 int off, out_size;210 int off, ret;
208 int bits_used, bits_avail;211 int bits_used, bits_avail;
209 212
210 memset(bands, 0, sizeof(*bands) * (c->maxbands + 1));213 memset(bands, 0, sizeof(*bands) * (c->maxbands + 1));
@@ -213,10 +216,11 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 2 unmodified lines
213 return AVERROR(EINVAL);216 return AVERROR(EINVAL);
214 }217 }
215 218
216 out_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;219 /* get output buffer */
217 if (*data_size < out_size) {220 c->frame.nb_samples = buf[1] ? c->lastframelen : MPC_FRAME_SIZE;
218 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");221 if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
219 return AVERROR(EINVAL);222 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
223 return ret;
220 }224 }
221 225
222 bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);226 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
276 for(ch = 0; ch < 2; ch++)280 for(ch = 0; ch < 2; ch++)
277 idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);281 idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);
278 282
279 ff_mpc_dequantize_and_synth(c, mb, data, 2);283 ff_mpc_dequantize_and_synth(c, mb, c->frame.data[0], 2);
280 284
281 av_free(bits);285 av_free(bits);
282 286
@@ -288,10 +292,12 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 5 unmodified lines
288 }292 }
289 if(c->frames_to_skip){293 if(c->frames_to_skip){
290 c->frames_to_skip--;294 c->frames_to_skip--;
291 *data_size = 0;295 *got_frame_ptr = 0;
292 return buf_size;296 return buf_size;
293 }297 }
294 *data_size = out_size;298
299 *got_frame_ptr = 1;
300 *(AVFrame *)data = c->frame;
295 301
296 return buf_size;302 return buf_size;
297}303}
@@ -312,5 +318,6 @@ AVCodec ff_mpc7_decoder = { · 14 unmodified lines
312 .init = mpc7_decode_init,318 .init = mpc7_decode_init,
313 .decode = mpc7_decode_frame,319 .decode = mpc7_decode_frame,
314 .flush = mpc7_decode_flush,320 .flush = mpc7_decode_flush,
321 .capabilities = CODEC_CAP_DR1,
315 .long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"),322 .long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"),
316};323};
libavcodec/mpc8.c+17−10
@@ -230,12 +230,15 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) · 229 unmodified lines
230 &mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);230 &mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
231 }231 }
232 vlc_initialized = 1;232 vlc_initialized = 1;
233
234 avcodec_get_frame_defaults(&c->frame);
235 avctx->coded_frame = &c->frame;
236
233 return 0;237 return 0;
234}238}
235 239
236static int mpc8_decode_frame(AVCodecContext * avctx,240static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
237 void *data, int *data_size,241 int *got_frame_ptr, AVPacket *avpkt)
238 AVPacket *avpkt)
239{242{
240 const uint8_t *buf = avpkt->data;243 const uint8_t *buf = avpkt->data;
241 int buf_size = avpkt->size;244 int buf_size = avpkt->size;
@@ -243,14 +246,15 @@ static int mpc8_decode_frame(AVCodecContext * avctx, · 1 unmodified line
243 GetBitContext gb2, *gb = &gb2;246 GetBitContext gb2, *gb = &gb2;
244 int i, j, k, ch, cnt, res, t;247 int i, j, k, ch, cnt, res, t;
245 Band *bands = c->bands;248 Band *bands = c->bands;
246 int off, out_size;249 int off;
247 int maxband, keyframe;250 int maxband, keyframe;
248 int last[2];251 int last[2];
249 252
250 out_size = MPC_FRAME_SIZE * 2 * avctx->channels;253 /* get output buffer */
251 if (*data_size < out_size) {254 c->frame.nb_samples = MPC_FRAME_SIZE;
252 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");255 if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {
253 return AVERROR(EINVAL);256 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
257 return res;
254 }258 }
255 259
256 keyframe = c->cur_frame == 0;260 keyframe = c->cur_frame == 0;
@@ -403,14 +407,16 @@ static int mpc8_decode_frame(AVCodecContext * avctx, · 146 unmodified lines
403 }407 }
404 }408 }
405 409
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);
407 411
408 c->cur_frame++;412 c->cur_frame++;
409 413
410 c->last_bits_used = get_bits_count(gb);414 c->last_bits_used = get_bits_count(gb);
411 if(c->cur_frame >= c->frames)415 if(c->cur_frame >= c->frames)
412 c->cur_frame = 0;416 c->cur_frame = 0;
413 *data_size = out_size;417
418 *got_frame_ptr = 1;
419 *(AVFrame *)data = c->frame;
414 420
415 return c->cur_frame ? c->last_bits_used >> 3 : buf_size;421 return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
416}422}
@@ -422,5 +428,6 @@ AVCodec ff_mpc8_decoder = { · 5 unmodified lines
422 .priv_data_size = sizeof(MPCContext),428 .priv_data_size = sizeof(MPCContext),
423 .init = mpc8_decode_init,429 .init = mpc8_decode_init,
424 .decode = mpc8_decode_frame,430 .decode = mpc8_decode_frame,
431 .capabilities = CODEC_CAP_DR1,
425 .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"),432 .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"),
426};433};
libavcodec/mpeg4audio.c+4−3
@@ -76,12 +76,13 @@ static inline int get_sample_rate(GetBitContext *gb, int *index) · 75 unmodified lines
76 avpriv_mpeg4audio_sample_rates[*index];76 avpriv_mpeg4audio_sample_rates[*index];
77}77}
78 78
79int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size)79int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
80 int bit_size, int sync_extension)
80{81{
81 GetBitContext gb;82 GetBitContext gb;
82 int specific_config_bitindex;83 int specific_config_bitindex;
83 84
84 init_get_bits(&gb, buf, buf_size*8);85 init_get_bits(&gb, buf, bit_size);
85 c->object_type = get_object_type(&gb);86 c->object_type = get_object_type(&gb);
86 c->sample_rate = get_sample_rate(&gb, &c->sampling_index);87 c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
87 c->chan_config = get_bits(&gb, 4);88 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
117 return -1;118 return -1;
118 }119 }
119 120
120 if (c->ext_object_type != AOT_SBR) {121 if (c->ext_object_type != AOT_SBR && sync_extension) {
121 while (get_bits_left(&gb) > 15) {122 while (get_bits_left(&gb) > 15) {
122 if (show_bits(&gb, 11) == 0x2b7) { // sync extension123 if (show_bits(&gb, 11) == 0x2b7) { // sync extension
123 get_bits(&gb, 11);124 get_bits(&gb, 11);
libavcodec/mpeg4audio.h+5−2
@@ -42,14 +42,17 @@ typedef struct { · 41 unmodified lines
42 42
43extern const int avpriv_mpeg4audio_sample_rates[16];43extern const int avpriv_mpeg4audio_sample_rates[16];
44extern const uint8_t ff_mpeg4audio_channels[8];44extern const uint8_t ff_mpeg4audio_channels[8];
45
45/**46/**
46 * Parse MPEG-4 systems extradata to retrieve audio configuration.47 * Parse MPEG-4 systems extradata to retrieve audio configuration.
47 * @param[in] c MPEG4AudioConfig structure to fill.48 * @param[in] c MPEG4AudioConfig structure to fill.
48 * @param[in] buf Extradata from container.49 * @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.
50 * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata.52 * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata.
51 */53 */
52int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size);54int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
55 int bit_size, int sync_extension);
53 56
54enum AudioObjectType {57enum AudioObjectType {
55 AOT_NULL,58 AOT_NULL,
libavcodec/mpegaudiodec.c+57−32
@@ -79,6 +79,7 @@ typedef struct MPADecodeContext { · 78 unmodified lines
79 int err_recognition;79 int err_recognition;
80 AVCodecContext* avctx;80 AVCodecContext* avctx;
81 MPADSPContext mpadsp;81 MPADSPContext mpadsp;
82 AVFrame frame;
82} MPADecodeContext;83} MPADecodeContext;
83 84
84#if CONFIG_FLOAT85#if CONFIG_FLOAT
@@ -479,6 +480,10 @@ static av_cold int decode_init(AVCodecContext * avctx) · 394 unmodified lines
479 480
480 if (avctx->codec_id == CODEC_ID_MP3ADU)481 if (avctx->codec_id == CODEC_ID_MP3ADU)
481 s->adu_mode = 1;482 s->adu_mode = 1;
483
484 avcodec_get_frame_defaults(&s->frame);
485 avctx->coded_frame = &s->frame;
486
482 return 0;487 return 0;
483}488}
484 489
@@ -1581,7 +1586,7 @@ static int mp_decode_layer3(MPADecodeContext *s) · 1096 unmodified lines
1581static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples,1586static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples,
1582 const uint8_t *buf, int buf_size)1587 const uint8_t *buf, int buf_size)
1583{1588{
1584 int i, nb_frames, ch;1589 int i, nb_frames, ch, ret;
1585 OUT_INT *samples_ptr;1590 OUT_INT *samples_ptr;
1586 1591
1587 init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE) * 8);1592 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
1629 assert(i <= buf_size - HEADER_SIZE && i >= 0);1634 assert(i <= buf_size - HEADER_SIZE && i >= 0);
1630 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i);1635 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i);
1631 s->last_buf_size += i;1636 s->last_buf_size += i;
1637 }
1632 1638
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];
1634 }1647 }
1635 1648
1636 /* apply the synthesis filter */1649 /* apply the synthesis filter */
@@ -1650,7 +1663,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples, · 13 unmodified lines
1650 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;1663 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
1651}1664}
1652 1665
1653static int decode_frame(AVCodecContext * avctx, void *data, int *data_size,1666static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
1654 AVPacket *avpkt)1667 AVPacket *avpkt)
1655{1668{
1656 const uint8_t *buf = avpkt->data;1669 const uint8_t *buf = avpkt->data;
@@ -1658,7 +1671,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 1 unmodified line
1658 MPADecodeContext *s = avctx->priv_data;1671 MPADecodeContext *s = avctx->priv_data;
1659 uint32_t header;1672 uint32_t header;
1660 int out_size;1673 int out_size;
1661 OUT_INT *out_samples = data;
1662 1674
1663 if (buf_size < HEADER_SIZE)1675 if (buf_size < HEADER_SIZE)
1664 return AVERROR_INVALIDDATA;1676 return AVERROR_INVALIDDATA;
@@ -1681,10 +1693,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 16 unmodified lines
1681 avctx->bit_rate = s->bit_rate;1693 avctx->bit_rate = s->bit_rate;
1682 avctx->sub_id = s->layer;1694 avctx->sub_id = s->layer;
1683 1695
1684 if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT))
1685 return AVERROR(EINVAL);
1686 *data_size = 0;
1687
1688 if (s->frame_size <= 0 || s->frame_size > buf_size) {1696 if (s->frame_size <= 0 || s->frame_size > buf_size) {
1689 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");1697 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
1690 return AVERROR_INVALIDDATA;1698 return AVERROR_INVALIDDATA;
@@ -1693,9 +1701,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 2 unmodified lines
1693 buf_size= s->frame_size;1701 buf_size= s->frame_size;
1694 }1702 }
1695 1703
1696 out_size = mp_decode_frame(s, out_samples, buf, buf_size);1704 out_size = mp_decode_frame(s, NULL, buf, buf_size);
1697 if (out_size >= 0) {1705 if (out_size >= 0) {
1698 *data_size = out_size;1706 *got_frame_ptr = 1;
1707 *(AVFrame *)data = s->frame;
1699 avctx->sample_rate = s->sample_rate;1708 avctx->sample_rate = s->sample_rate;
1700 //FIXME maybe move the other codec info stuff from above here too1709 //FIXME maybe move the other codec info stuff from above here too
1701 } else {1710 } else {
@@ -1704,6 +1713,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 2 unmodified lines
1704 If there is more data in the packet, just consume the bad frame1713 If there is more data in the packet, just consume the bad frame
1705 instead of returning an error, which would discard the whole1714 instead of returning an error, which would discard the whole
1706 packet. */1715 packet. */
1716 *got_frame_ptr = 0;
1707 if (buf_size == avpkt->size)1717 if (buf_size == avpkt->size)
1708 return out_size;1718 return out_size;
1709 }1719 }
@@ -1719,15 +1729,14 @@ static void flush(AVCodecContext *avctx) · 9 unmodified lines
1719}1729}
1720 1730
1721#if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER1731#if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER
1722static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size,1732static int decode_frame_adu(AVCodecContext *avctx, void *data,
1723 AVPacket *avpkt)1733 int *got_frame_ptr, AVPacket *avpkt)
1724{1734{
1725 const uint8_t *buf = avpkt->data;1735 const uint8_t *buf = avpkt->data;
1726 int buf_size = avpkt->size;1736 int buf_size = avpkt->size;
1727 MPADecodeContext *s = avctx->priv_data;1737 MPADecodeContext *s = avctx->priv_data;
1728 uint32_t header;1738 uint32_t header;
1729 int len, out_size;1739 int len, out_size;
1730 OUT_INT *out_samples = data;
1731 1740
1732 len = buf_size;1741 len = buf_size;
1733 1742
@@ -1757,9 +1766,6 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, · 23 unmodified lines
1757 avctx->bit_rate = s->bit_rate;1766 avctx->bit_rate = s->bit_rate;
1758 avctx->sub_id = s->layer;1767 avctx->sub_id = s->layer;
1759 1768
1760 if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT))
1761 return AVERROR(EINVAL);
1762
1763 s->frame_size = len;1769 s->frame_size = len;
1764 1770
1765#if FF_API_PARSE_FRAME1771#if FF_API_PARSE_FRAME
@@ -1767,9 +1773,11 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, · 1 unmodified line
1767 out_size = buf_size;1773 out_size = buf_size;
1768 else1774 else
1769#endif1775#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;
1771 1780
1772 *data_size = out_size;
1773 return buf_size;1781 return buf_size;
1774}1782}
1775#endif /* CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER */1783#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
1780 * Context for MP3On4 decoder1788 * Context for MP3On4 decoder
1781 */1789 */
1782typedef struct MP3On4DecodeContext {1790typedef struct MP3On4DecodeContext {
1791 AVFrame *frame;
1783 int frames; ///< number of mp3 frames per block (number of mp3 decoder instances)1792 int frames; ///< number of mp3 frames per block (number of mp3 decoder instances)
1784 int syncword; ///< syncword patch1793 int syncword; ///< syncword patch
1785 const uint8_t *coff; ///< channel offsets in output buffer1794 const uint8_t *coff; ///< channel offsets in output buffer
@@ -1843,7 +1852,8 @@ static int decode_init_mp3on4(AVCodecContext * avctx) · 57 unmodified lines
1843 return AVERROR_INVALIDDATA;1852 return AVERROR_INVALIDDATA;
1844 }1853 }
1845 1854
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);
1847 if (!cfg.chan_config || cfg.chan_config > 7) {1857 if (!cfg.chan_config || cfg.chan_config > 7) {
1848 av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");1858 av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");
1849 return AVERROR_INVALIDDATA;1859 return AVERROR_INVALIDDATA;
@@ -1870,6 +1880,7 @@ static int decode_init_mp3on4(AVCodecContext * avctx) · 20 unmodified lines
1870 // Put decoder context in place to make init_decode() happy1880 // Put decoder context in place to make init_decode() happy
1871 avctx->priv_data = s->mp3decctx[0];1881 avctx->priv_data = s->mp3decctx[0];
1872 decode_init(avctx);1882 decode_init(avctx);
1883 s->frame = avctx->coded_frame;
1873 // Restore mp3on4 context pointer1884 // Restore mp3on4 context pointer
1874 avctx->priv_data = s;1885 avctx->priv_data = s;
1875 s->mp3decctx[0]->adu_mode = 1; // Set adu mode1886 s->mp3decctx[0]->adu_mode = 1; // Set adu mode
@@ -1914,9 +1925,8 @@ static void flush_mp3on4(AVCodecContext *avctx) · 38 unmodified lines
1914}1925}
1915 1926
1916 1927
1917static int decode_frame_mp3on4(AVCodecContext * avctx,1928static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
1918 void *data, int *data_size,1929 int *got_frame_ptr, AVPacket *avpkt)
1919 AVPacket *avpkt)
1920{1930{
1921 const uint8_t *buf = avpkt->data;1931 const uint8_t *buf = avpkt->data;
1922 int buf_size = avpkt->size;1932 int buf_size = avpkt->size;
@@ -1924,14 +1934,17 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, · 1 unmodified line
1924 MPADecodeContext *m;1934 MPADecodeContext *m;
1925 int fsize, len = buf_size, out_size = 0;1935 int fsize, len = buf_size, out_size = 0;
1926 uint32_t header;1936 uint32_t header;
1927 OUT_INT *out_samples = data;1937 OUT_INT *out_samples;
1928 OUT_INT *outptr, *bp;1938 OUT_INT *outptr, *bp;
1929 int fr, j, n, ch;1939 int fr, j, n, ch, ret;
1930 1940
1931 if (*data_size < MPA_FRAME_SIZE * avctx->channels * sizeof(OUT_INT)) {1941 /* get output buffer */
1932 av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");1942 s->frame->nb_samples = MPA_FRAME_SIZE;
1933 return AVERROR(EINVAL);1943 if ((ret = avctx->get_buffer(avctx, s->frame)) < 0) {
1944 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1945 return ret;
1934 }1946 }
1947 out_samples = (OUT_INT *)s->frame->data[0];
1935 1948
1936 // Discard too short frames1949 // Discard too short frames
1937 if (buf_size < HEADER_SIZE)1950 if (buf_size < HEADER_SIZE)
@@ -1990,7 +2003,10 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, · 52 unmodified lines
1990 /* update codec info */2003 /* update codec info */
1991 avctx->sample_rate = s->mp3decctx[0]->sample_rate;2004 avctx->sample_rate = s->mp3decctx[0]->sample_rate;
1992 2005
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
1994 return buf_size;2010 return buf_size;
1995}2011}
1996#endif /* CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER */2012#endif /* CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER */
@@ -2005,7 +2021,9 @@ AVCodec ff_mp1_decoder = { · 8 unmodified lines
2005 .init = decode_init,2021 .init = decode_init,
2006 .decode = decode_frame,2022 .decode = decode_frame,
2007#if FF_API_PARSE_FRAME2023#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,
2009#endif2027#endif
2010 .flush = flush,2028 .flush = flush,
2011 .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),2029 .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
@@ -2020,7 +2038,9 @@ AVCodec ff_mp2_decoder = { · 8 unmodified lines
2020 .init = decode_init,2038 .init = decode_init,
2021 .decode = decode_frame,2039 .decode = decode_frame,
2022#if FF_API_PARSE_FRAME2040#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,
2024#endif2044#endif
2025 .flush = flush,2045 .flush = flush,
2026 .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),2046 .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
@@ -2035,7 +2055,9 @@ AVCodec ff_mp3_decoder = { · 8 unmodified lines
2035 .init = decode_init,2055 .init = decode_init,
2036 .decode = decode_frame,2056 .decode = decode_frame,
2037#if FF_API_PARSE_FRAME2057#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,
2039#endif2061#endif
2040 .flush = flush,2062 .flush = flush,
2041 .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),2063 .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
@@ -2050,7 +2072,9 @@ AVCodec ff_mp3adu_decoder = { · 8 unmodified lines
2050 .init = decode_init,2072 .init = decode_init,
2051 .decode = decode_frame_adu,2073 .decode = decode_frame_adu,
2052#if FF_API_PARSE_FRAME2074#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,
2054#endif2078#endif
2055 .flush = flush,2079 .flush = flush,
2056 .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),2080 .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
2065 .init = decode_init_mp3on4,2089 .init = decode_init_mp3on4,
2066 .close = decode_close_mp3on4,2090 .close = decode_close_mp3on4,
2067 .decode = decode_frame_mp3on4,2091 .decode = decode_frame_mp3on4,
2092 .capabilities = CODEC_CAP_DR1,
2068 .flush = flush_mp3on4,2093 .flush = flush_mp3on4,
2069 .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),2094 .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
2070};2095};
libavcodec/mpegaudiodec_float.c+13−4
@@ -31,7 +31,9 @@ AVCodec ff_mp1float_decoder = { · 30 unmodified lines
31 .init = decode_init,31 .init = decode_init,
32 .decode = decode_frame,32 .decode = decode_frame,
33#if FF_API_PARSE_FRAME33#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,
35#endif37#endif
36 .flush = flush,38 .flush = flush,
37 .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),39 .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
@@ -46,7 +48,9 @@ AVCodec ff_mp2float_decoder = { · 8 unmodified lines
46 .init = decode_init,48 .init = decode_init,
47 .decode = decode_frame,49 .decode = decode_frame,
48#if FF_API_PARSE_FRAME50#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,
50#endif54#endif
51 .flush = flush,55 .flush = flush,
52 .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),56 .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
@@ -61,7 +65,9 @@ AVCodec ff_mp3float_decoder = { · 8 unmodified lines
61 .init = decode_init,65 .init = decode_init,
62 .decode = decode_frame,66 .decode = decode_frame,
63#if FF_API_PARSE_FRAME67#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,
65#endif71#endif
66 .flush = flush,72 .flush = flush,
67 .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),73 .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
@@ -76,7 +82,9 @@ AVCodec ff_mp3adufloat_decoder = { · 8 unmodified lines
76 .init = decode_init,82 .init = decode_init,
77 .decode = decode_frame_adu,83 .decode = decode_frame_adu,
78#if FF_API_PARSE_FRAME84#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,
80#endif88#endif
81 .flush = flush,89 .flush = flush,
82 .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),90 .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
91 .init = decode_init_mp3on4,99 .init = decode_init_mp3on4,
92 .close = decode_close_mp3on4,100 .close = decode_close_mp3on4,
93 .decode = decode_frame_mp3on4,101 .decode = decode_frame_mp3on4,
102 .capabilities = CODEC_CAP_DR1,
94 .flush = flush_mp3on4,103 .flush = flush_mp3on4,
95 .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),104 .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
96};105};
libavcodec/mpegvideo.c+6−6
@@ -2351,7 +2351,8 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ · 2350 unmodified lines
2351 2351
2352 if (s->avctx->draw_horiz_band) {2352 if (s->avctx->draw_horiz_band) {
2353 AVFrame *src;2353 AVFrame *src;
2354 int offset[4];2354 int offset[AV_NUM_DATA_POINTERS];
2355 int i;
2355 2356
2356 if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))2357 if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
2357 src= (AVFrame*)s->current_picture_ptr;2358 src= (AVFrame*)s->current_picture_ptr;
@@ -2361,15 +2362,14 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ · 3 unmodified lines
2361 return;2362 return;
2362 2363
2363 if(s->pict_type==AV_PICTURE_TYPE_B && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){2364 if(s->pict_type==AV_PICTURE_TYPE_B && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
2364 offset[0]=2365 for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
2365 offset[1]=2366 offset[i] = 0;
2366 offset[2]=
2367 offset[3]= 0;
2368 }else{2367 }else{
2369 offset[0]= y * s->linesize;2368 offset[0]= y * s->linesize;
2370 offset[1]=2369 offset[1]=
2371 offset[2]= (y >> s->chroma_y_shift) * s->uvlinesize;2370 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;
2373 }2373 }
2374 2374
2375 emms_c();2375 emms_c();
libavcodec/nellymoserdec.c+26−14
@@ -47,6 +47,7 @@ · 46 unmodified lines
47 47
48typedef struct NellyMoserDecodeContext {48typedef struct NellyMoserDecodeContext {
49 AVCodecContext* avctx;49 AVCodecContext* avctx;
50 AVFrame frame;
50 float *float_buf;51 float *float_buf;
51 DECLARE_ALIGNED(16, float, state)[NELLY_BUF_LEN];52 DECLARE_ALIGNED(16, float, state)[NELLY_BUF_LEN];
52 AVLFG random_state;53 AVLFG random_state;
@@ -142,33 +143,31 @@ static av_cold int decode_init(AVCodecContext * avctx) { · 89 unmodified lines
142 ff_init_ff_sine_windows(7);143 ff_init_ff_sine_windows(7);
143 144
144 avctx->channel_layout = AV_CH_LAYOUT_MONO;145 avctx->channel_layout = AV_CH_LAYOUT_MONO;
146
147 avcodec_get_frame_defaults(&s->frame);
148 avctx->coded_frame = &s->frame;
149
145 return 0;150 return 0;
146}151}
147 152
148static int decode_tag(AVCodecContext * avctx,153static int decode_tag(AVCodecContext *avctx, void *data,
149 void *data, int *data_size,154 int *got_frame_ptr, AVPacket *avpkt)
150 AVPacket *avpkt) {155{
151 const uint8_t *buf = avpkt->data;156 const uint8_t *buf = avpkt->data;
152 const uint8_t *side=av_packet_get_side_data(avpkt, 'F', NULL);157 const uint8_t *side=av_packet_get_side_data(avpkt, 'F', NULL);
153 int buf_size = avpkt->size;158 int buf_size = avpkt->size;
154 NellyMoserDecodeContext *s = avctx->priv_data;159 NellyMoserDecodeContext *s = avctx->priv_data;
155 int data_max = *data_size;160 int blocks, i, ret;
156 int blocks, i, block_size;161 int16_t *samples_s16;
157 int16_t *samples_s16 = data;162 float *samples_flt;
158 float *samples_flt = data;
159 *data_size = 0;
160 163
161 block_size = NELLY_SAMPLES * av_get_bytes_per_sample(avctx->sample_fmt);
162 blocks = buf_size / NELLY_BLOCK_LEN;164 blocks = buf_size / NELLY_BLOCK_LEN;
163 165
164 if (blocks <= 0) {166 if (blocks <= 0) {
165 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");167 av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
166 return AVERROR_INVALIDDATA;168 return AVERROR_INVALIDDATA;
167 }169 }
168 if (data_max < blocks * block_size) {170
169 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
170 return AVERROR(EINVAL);
171 }
172 if (buf_size % NELLY_BLOCK_LEN) {171 if (buf_size % NELLY_BLOCK_LEN) {
173 av_log(avctx, AV_LOG_WARNING, "Leftover bytes: %d.\n",172 av_log(avctx, AV_LOG_WARNING, "Leftover bytes: %d.\n",
174 buf_size % NELLY_BLOCK_LEN);173 buf_size % NELLY_BLOCK_LEN);
@@ -183,6 +182,15 @@ static int decode_tag(AVCodecContext * avctx, · 8 unmodified lines
183 if(side && blocks>1 && avctx->sample_rate%11025==0 && (1<<((side[0]>>2)&3)) == blocks)182 if(side && blocks>1 && avctx->sample_rate%11025==0 && (1<<((side[0]>>2)&3)) == blocks)
184 avctx->sample_rate= 11025*(blocks/2);183 avctx->sample_rate= 11025*(blocks/2);
185 184
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
186 for (i=0 ; i<blocks ; i++) {194 for (i=0 ; i<blocks ; i++) {
187 if (avctx->sample_fmt == SAMPLE_FMT_FLT) {195 if (avctx->sample_fmt == SAMPLE_FMT_FLT) {
188 nelly_decode_block(s, buf, samples_flt);196 nelly_decode_block(s, buf, samples_flt);
@@ -194,7 +202,9 @@ static int decode_tag(AVCodecContext * avctx, · 5 unmodified lines
194 }202 }
195 buf += NELLY_BLOCK_LEN;203 buf += NELLY_BLOCK_LEN;
196 }204 }
197 *data_size = blocks * block_size;205
206 *got_frame_ptr = 1;
207 *(AVFrame *)data = s->frame;
198 208
199 return buf_size;209 return buf_size;
200}210}
@@ -204,6 +214,7 @@ static av_cold int decode_end(AVCodecContext * avctx) { · 3 unmodified lines
204 214
205 av_freep(&s->float_buf);215 av_freep(&s->float_buf);
206 ff_mdct_end(&s->imdct_ctx);216 ff_mdct_end(&s->imdct_ctx);
217
207 return 0;218 return 0;
208}219}
209 220
@@ -215,6 +226,7 @@ AVCodec ff_nellymoser_decoder = { · 5 unmodified lines
215 .init = decode_init,226 .init = decode_init,
216 .close = decode_end,227 .close = decode_end,
217 .decode = decode_tag,228 .decode = decode_tag,
229 .capabilities = CODEC_CAP_DR1,
218 .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),230 .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
219 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,231 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
220 AV_SAMPLE_FMT_S16,232 AV_SAMPLE_FMT_S16,
libavcodec/pcm.c+25−17
@@ -192,6 +192,7 @@ static int pcm_encode_frame(AVCodecContext *avctx, · 191 unmodified lines
192}192}
193 193
194typedef struct PCMDecode {194typedef struct PCMDecode {
195 AVFrame frame;
195 short table[256];196 short table[256];
196} PCMDecode;197} PCMDecode;
197 198
@@ -223,6 +224,9 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx) · 25 unmodified lines
223 if (avctx->sample_fmt == AV_SAMPLE_FMT_S32)224 if (avctx->sample_fmt == AV_SAMPLE_FMT_S32)
224 avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec->id);225 avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec->id);
225 226
227 avcodec_get_frame_defaults(&s->frame);
228 avctx->coded_frame = &s->frame;
229
226 return 0;230 return 0;
227}231}
228 232
@@ -243,22 +247,20 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx) · 14 unmodified lines
243 dst += size / 8; \247 dst += size / 8; \
244 }248 }
245 249
246static int pcm_decode_frame(AVCodecContext *avctx,250static int pcm_decode_frame(AVCodecContext *avctx, void *data,
247 void *data, int *data_size,251 int *got_frame_ptr, AVPacket *avpkt)
248 AVPacket *avpkt)
249{252{
250 const uint8_t *src = avpkt->data;253 const uint8_t *src = avpkt->data;
251 int buf_size = avpkt->size;254 int buf_size = avpkt->size;
252 PCMDecode *s = avctx->priv_data;255 PCMDecode *s = avctx->priv_data;
253 int sample_size, c, n, out_size;256 int sample_size, c, n, ret, samples_per_block;
254 uint8_t *samples;257 uint8_t *samples;
255 int32_t *dst_int32_t;258 int32_t *dst_int32_t;
256 259
257 samples = data;
258
259 sample_size = av_get_bits_per_sample(avctx->codec_id)/8;260 sample_size = av_get_bits_per_sample(avctx->codec_id)/8;
260 261
261 /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */262 /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */
263 samples_per_block = 1;
262 if (CODEC_ID_PCM_DVD == avctx->codec_id) {264 if (CODEC_ID_PCM_DVD == avctx->codec_id) {
263 if (avctx->bits_per_coded_sample != 20 &&265 if (avctx->bits_per_coded_sample != 20 &&
264 avctx->bits_per_coded_sample != 24) {266 avctx->bits_per_coded_sample != 24) {
@@ -268,10 +270,13 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 3 unmodified lines
268 return AVERROR(EINVAL);270 return AVERROR(EINVAL);
269 }271 }
270 /* 2 samples are interleaved per block in PCM_DVD */272 /* 2 samples are interleaved per block in PCM_DVD */
273 samples_per_block = 2;
271 sample_size = avctx->bits_per_coded_sample * 2 / 8;274 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) {
273 /* we process 40-bit blocks per channel for LXF */276 /* we process 40-bit blocks per channel for LXF */
277 samples_per_block = 2;
274 sample_size = 5;278 sample_size = 5;
279 }
275 280
276 if (sample_size == 0) {281 if (sample_size == 0) {
277 av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n");282 av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n");
@@ -290,14 +295,13 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 12 unmodified lines
290 295
291 n = buf_size/sample_size;296 n = buf_size/sample_size;
292 297
293 out_size = n * av_get_bytes_per_sample(avctx->sample_fmt);298 /* get output buffer */
294 if (avctx->codec_id == CODEC_ID_PCM_DVD ||299 s->frame.nb_samples = n * samples_per_block / avctx->channels;
295 avctx->codec_id == CODEC_ID_PCM_LXF)300 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
296 out_size *= 2;301 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
297 if (*data_size < out_size) {302 return ret;
298 av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
299 return AVERROR(EINVAL);
300 }303 }
304 samples = s->frame.data[0];
301 305
302 switch(avctx->codec->id) {306 switch(avctx->codec->id) {
303 case CODEC_ID_PCM_U32LE:307 case CODEC_ID_PCM_U32LE:
@@ -403,7 +407,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 99 unmodified lines
403 case CODEC_ID_PCM_DVD:407 case CODEC_ID_PCM_DVD:
404 {408 {
405 const uint8_t *src8;409 const uint8_t *src8;
406 dst_int32_t = data;410 dst_int32_t = (int32_t *)s->frame.data[0];
407 n /= avctx->channels;411 n /= avctx->channels;
408 switch (avctx->bits_per_coded_sample) {412 switch (avctx->bits_per_coded_sample) {
409 case 20:413 case 20:
@@ -435,7 +439,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 25 unmodified lines
435 {439 {
436 int i;440 int i;
437 const uint8_t *src8;441 const uint8_t *src8;
438 dst_int32_t = data;442 dst_int32_t = (int32_t *)s->frame.data[0];
439 n /= avctx->channels;443 n /= avctx->channels;
440 //unpack and de-planerize444 //unpack and de-planerize
441 for (i = 0; i < n; i++) {445 for (i = 0; i < n; i++) {
@@ -456,7 +460,10 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 14 unmodified lines
456 default:460 default:
457 return -1;461 return -1;
458 }462 }
459 *data_size = out_size;463
464 *got_frame_ptr = 1;
465 *(AVFrame *)data = s->frame;
466
460 return buf_size;467 return buf_size;
461}468}
462 469
@@ -485,6 +492,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 22 unmodified lines
485 .priv_data_size = sizeof(PCMDecode), \492 .priv_data_size = sizeof(PCMDecode), \
486 .init = pcm_decode_init, \493 .init = pcm_decode_init, \
487 .decode = pcm_decode_frame, \494 .decode = pcm_decode_frame, \
495 .capabilities = CODEC_CAP_DR1, \
488 .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \496 .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
489 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \497 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
490}498}
libavcodec/qcelpdec.c+17−9
@@ -56,6 +56,7 @@ typedef enum · 55 unmodified lines
56 56
57typedef struct57typedef struct
58{58{
59 AVFrame avframe;
59 GetBitContext gb;60 GetBitContext gb;
60 qcelp_packet_rate bitrate;61 qcelp_packet_rate bitrate;
61 QCELPFrame frame; /**< unpacked data frame */62 QCELPFrame frame; /**< unpacked data frame */
@@ -97,6 +98,9 @@ static av_cold int qcelp_decode_init(AVCodecContext *avctx) · 35 unmodified lines
97 for(i=0; i<10; i++)98 for(i=0; i<10; i++)
98 q->prev_lspf[i] = (i+1)/11.;99 q->prev_lspf[i] = (i+1)/11.;
99 100
101 avcodec_get_frame_defaults(&q->avframe);
102 avctx->coded_frame = &q->avframe;
103
100 return 0;104 return 0;
101}105}
102 106
@@ -682,23 +686,25 @@ static void postfilter(QCELPContext *q, float *samples, float *lpc) · 579 unmodified lines
682 160, 0.9375, &q->postfilter_agc_mem);686 160, 0.9375, &q->postfilter_agc_mem);
683}687}
684 688
685static int qcelp_decode_frame(AVCodecContext *avctx, void *data, int *data_size,689static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
686 AVPacket *avpkt)690 int *got_frame_ptr, AVPacket *avpkt)
687{691{
688 const uint8_t *buf = avpkt->data;692 const uint8_t *buf = avpkt->data;
689 int buf_size = avpkt->size;693 int buf_size = avpkt->size;
690 QCELPContext *q = avctx->priv_data;694 QCELPContext *q = avctx->priv_data;
691 float *outbuffer = data;695 float *outbuffer;
692 int i, out_size;696 int i, ret;
693 float quantized_lspf[10], lpc[10];697 float quantized_lspf[10], lpc[10];
694 float gain[16];698 float gain[16];
695 float *formant_mem;699 float *formant_mem;
696 700
697 out_size = 160 * av_get_bytes_per_sample(avctx->sample_fmt);701 /* get output buffer */
698 if (*data_size < out_size) {702 q->avframe.nb_samples = 160;
699 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");703 if ((ret = avctx->get_buffer(avctx, &q->avframe)) < 0) {
700 return AVERROR(EINVAL);704 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
705 return ret;
701 }706 }
707 outbuffer = (float *)q->avframe.data[0];
702 708
703 if ((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) {709 if ((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) {
704 warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");710 warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");
@@ -783,7 +789,8 @@ erasure: · 78 unmodified lines
783 memcpy(q->prev_lspf, quantized_lspf, sizeof(q->prev_lspf));789 memcpy(q->prev_lspf, quantized_lspf, sizeof(q->prev_lspf));
784 q->prev_bitrate = q->bitrate;790 q->prev_bitrate = q->bitrate;
785 791
786 *data_size = out_size;792 *got_frame_ptr = 1;
793 *(AVFrame *)data = q->avframe;
787 794
788 return buf_size;795 return buf_size;
789}796}
@@ -795,6 +802,7 @@ AVCodec ff_qcelp_decoder = · 5 unmodified lines
795 .id = CODEC_ID_QCELP,802 .id = CODEC_ID_QCELP,
796 .init = qcelp_decode_init,803 .init = qcelp_decode_init,
797 .decode = qcelp_decode_frame,804 .decode = qcelp_decode_frame,
805 .capabilities = CODEC_CAP_DR1,
798 .priv_data_size = sizeof(QCELPContext),806 .priv_data_size = sizeof(QCELPContext),
799 .long_name = NULL_IF_CONFIG_SMALL("QCELP / PureVoice"),807 .long_name = NULL_IF_CONFIG_SMALL("QCELP / PureVoice"),
800};808};
libavcodec/qdm2.c+18−14
@@ -130,6 +130,8 @@ typedef struct { · 129 unmodified lines
130 * QDM2 decoder context130 * QDM2 decoder context
131 */131 */
132typedef struct {132typedef struct {
133 AVFrame frame;
134
133 /// Parameters from codec header, do not change during playback135 /// Parameters from codec header, do not change during playback
134 int nb_channels; ///< number of channels136 int nb_channels; ///< number of channels
135 int channels; ///< number of channels137 int channels; ///< number of channels
@@ -1876,6 +1878,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) · 1740 unmodified lines
1876 1878
1877 avctx->sample_fmt = AV_SAMPLE_FMT_S16;1879 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
1878 1880
1881 avcodec_get_frame_defaults(&s->frame);
1882 avctx->coded_frame = &s->frame;
1883
1879// dump_context(s);1884// dump_context(s);
1880 return 0;1885 return 0;
1881}1886}
@@ -1956,30 +1961,27 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) · 74 unmodified lines
1956}1961}
1957 1962
1958 1963
1959static int qdm2_decode_frame(AVCodecContext *avctx,1964static int qdm2_decode_frame(AVCodecContext *avctx, void *data,
1960 void *data, int *data_size,1965 int *got_frame_ptr, AVPacket *avpkt)
1961 AVPacket *avpkt)
1962{1966{
1963 const uint8_t *buf = avpkt->data;1967 const uint8_t *buf = avpkt->data;
1964 int buf_size = avpkt->size;1968 int buf_size = avpkt->size;
1965 QDM2Context *s = avctx->priv_data;1969 QDM2Context *s = avctx->priv_data;
1966 int16_t *out = data;1970 int16_t *out;
1967 int i, out_size;1971 int i, ret;
1968 1972
1969 if(!buf)1973 if(!buf)
1970 return 0;1974 return 0;
1971 if(buf_size < s->checksum_size)1975 if(buf_size < s->checksum_size)
1972 return -1;1976 return -1;
1973 1977
1974 out_size = 16 * s->channels * s->frame_size *1978 /* get output buffer */
1975 av_get_bytes_per_sample(avctx->sample_fmt);1979 s->frame.nb_samples = 16 * s->frame_size;
1976 if (*data_size < out_size) {1980 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
1977 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");1981 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1978 return AVERROR(EINVAL);1982 return ret;
1979 }1983 }
1980 1984 out = (int16_t *)s->frame.data[0];
1981 av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n",
1982 buf_size, buf, s->checksum_size, data, *data_size);
1983 1985
1984 for (i = 0; i < 16; i++) {1986 for (i = 0; i < 16; i++) {
1985 if (qdm2_decode(s, buf, out) < 0)1987 if (qdm2_decode(s, buf, out) < 0)
@@ -1987,7 +1989,8 @@ static int qdm2_decode_frame(AVCodecContext *avctx, · 1 unmodified line
1987 out += s->channels * s->frame_size;1989 out += s->channels * s->frame_size;
1988 }1990 }
1989 1991
1990 *data_size = out_size;1992 *got_frame_ptr = 1;
1993 *(AVFrame *)data = s->frame;
1991 1994
1992 return s->checksum_size;1995 return s->checksum_size;
1993}1996}
@@ -2001,5 +2004,6 @@ AVCodec ff_qdm2_decoder = · 7 unmodified lines
2001 .init = qdm2_decode_init,2004 .init = qdm2_decode_init,
2002 .close = qdm2_decode_close,2005 .close = qdm2_decode_close,
2003 .decode = qdm2_decode_frame,2006 .decode = qdm2_decode_frame,
2007 .capabilities = CODEC_CAP_DR1,
2004 .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),2008 .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),
2005};2009};
libavcodec/ra144.h+1−0
@@ -34,6 +34,7 @@ · 33 unmodified lines
34 34
35typedef struct {35typedef struct {
36 AVCodecContext *avctx;36 AVCodecContext *avctx;
37 AVFrame frame;
37 LPCContext lpc_ctx;38 LPCContext lpc_ctx;
38 39
39 unsigned int old_energy; ///< previous frame energy40 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
38 ractx->lpc_coef[1] = ractx->lpc_tables[1];38 ractx->lpc_coef[1] = ractx->lpc_tables[1];
39 39
40 avctx->sample_fmt = AV_SAMPLE_FMT_S16;40 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
41
42 avcodec_get_frame_defaults(&ractx->frame);
43 avctx->coded_frame = &ractx->frame;
44
41 return 0;45 return 0;
42}46}
43 47
@@ -54,8 +58,8 @@ static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs, · 10 unmodified lines
54}58}
55 59
56/** Uncompress one block (20 bytes -> 160*2 bytes). */60/** Uncompress one block (20 bytes -> 160*2 bytes). */
57static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,61static int ra144_decode_frame(AVCodecContext * avctx, void *data,
58 int *data_size, AVPacket *avpkt)62 int *got_frame_ptr, AVPacket *avpkt)
59{63{
60 const uint8_t *buf = avpkt->data;64 const uint8_t *buf = avpkt->data;
61 int buf_size = avpkt->size;65 int buf_size = avpkt->size;
@@ -64,23 +68,25 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, · 2 unmodified lines
64 uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block68 uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block
65 unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame69 unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame
66 int i, j;70 int i, j;
67 int out_size;71 int ret;
68 int16_t *data = vdata;72 int16_t *samples;
69 unsigned int energy;73 unsigned int energy;
70 74
71 RA144Context *ractx = avctx->priv_data;75 RA144Context *ractx = avctx->priv_data;
72 GetBitContext gb;76 GetBitContext gb;
73 77
74 out_size = NBLOCKS * BLOCKSIZE * av_get_bytes_per_sample(avctx->sample_fmt);78 /* get output buffer */
75 if (*data_size < out_size) {79 ractx->frame.nb_samples = NBLOCKS * BLOCKSIZE;
76 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");80 if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) {
77 return AVERROR(EINVAL);81 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
82 return ret;
78 }83 }
84 samples = (int16_t *)ractx->frame.data[0];
79 85
80 if(buf_size < FRAMESIZE) {86 if(buf_size < FRAMESIZE) {
81 av_log(avctx, AV_LOG_ERROR,87 av_log(avctx, AV_LOG_ERROR,
82 "Frame too small (%d bytes). Truncated file?\n", buf_size);88 "Frame too small (%d bytes). Truncated file?\n", buf_size);
83 *data_size = 0;89 *got_frame_ptr = 0;
84 return buf_size;90 return buf_size;
85 }91 }
86 init_get_bits(&gb, buf, FRAMESIZE * 8);92 init_get_bits(&gb, buf, FRAMESIZE * 8);
@@ -106,7 +112,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, · 19 unmodified lines
106 do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb);112 do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb);
107 113
108 for (j=0; j < BLOCKSIZE; j++)114 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);
110 }116 }
111 117
112 ractx->old_energy = energy;118 ractx->old_energy = energy;
@@ -114,7 +120,9 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, · 1 unmodified line
114 120
115 FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]);121 FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]);
116 122
117 *data_size = out_size;123 *got_frame_ptr = 1;
124 *(AVFrame *)data = ractx->frame;
125
118 return FRAMESIZE;126 return FRAMESIZE;
119}127}
120 128
@@ -125,5 +133,6 @@ AVCodec ff_ra_144_decoder = { · 4 unmodified lines
125 .priv_data_size = sizeof(RA144Context),133 .priv_data_size = sizeof(RA144Context),
126 .init = ra144_decode_init,134 .init = ra144_decode_init,
127 .decode = ra144_decode_frame,135 .decode = ra144_decode_frame,
136 .capabilities = CODEC_CAP_DR1,
128 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),137 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
129};138};
libavcodec/ra288.c+18−9
@@ -36,6 +36,7 @@ · 35 unmodified lines
36#define RA288_BLOCKS_PER_FRAME 3236#define RA288_BLOCKS_PER_FRAME 32
37 37
38typedef struct {38typedef struct {
39 AVFrame frame;
39 DSPContext dsp;40 DSPContext dsp;
40 DECLARE_ALIGNED(16, float, sp_lpc)[FFALIGN(36, 8)]; ///< LPC coefficients for speech data (spec: A)41 DECLARE_ALIGNED(16, float, sp_lpc)[FFALIGN(36, 8)]; ///< LPC coefficients for speech data (spec: A)
41 DECLARE_ALIGNED(16, float, gain_lpc)[FFALIGN(10, 8)]; ///< LPC coefficients for gain (spec: GB)42 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
62 RA288Context *ractx = avctx->priv_data;63 RA288Context *ractx = avctx->priv_data;
63 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;64 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
64 dsputil_init(&ractx->dsp, avctx);65 dsputil_init(&ractx->dsp, avctx);
66
67 avcodec_get_frame_defaults(&ractx->frame);
68 avctx->coded_frame = &ractx->frame;
69
65 return 0;70 return 0;
66}71}
67 72
@@ -165,12 +170,12 @@ static void backward_filter(RA288Context *ractx, · 97 unmodified lines
165}170}
166 171
167static int ra288_decode_frame(AVCodecContext * avctx, void *data,172static int ra288_decode_frame(AVCodecContext * avctx, void *data,
168 int *data_size, AVPacket *avpkt)173 int *got_frame_ptr, AVPacket *avpkt)
169{174{
170 const uint8_t *buf = avpkt->data;175 const uint8_t *buf = avpkt->data;
171 int buf_size = avpkt->size;176 int buf_size = avpkt->size;
172 float *out = data;177 float *out;
173 int i, out_size;178 int i, ret;
174 RA288Context *ractx = avctx->priv_data;179 RA288Context *ractx = avctx->priv_data;
175 GetBitContext gb;180 GetBitContext gb;
176 181
@@ -181,12 +186,13 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, · 4 unmodified lines
181 return AVERROR_INVALIDDATA;186 return AVERROR_INVALIDDATA;
182 }187 }
183 188
184 out_size = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME *189 /* get output buffer */
185 av_get_bytes_per_sample(avctx->sample_fmt);190 ractx->frame.nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME;
186 if (*data_size < out_size) {191 if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) {
187 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");192 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
188 return AVERROR(EINVAL);193 return ret;
189 }194 }
195 out = (float *)ractx->frame.data[0];
190 196
191 init_get_bits(&gb, buf, avctx->block_align * 8);197 init_get_bits(&gb, buf, avctx->block_align * 8);
192 198
@@ -208,7 +214,9 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, · 15 unmodified lines
208 }214 }
209 }215 }
210 216
211 *data_size = out_size;217 *got_frame_ptr = 1;
218 *(AVFrame *)data = ractx->frame;
219
212 return avctx->block_align;220 return avctx->block_align;
213}221}
214 222
@@ -219,5 +227,6 @@ AVCodec ff_ra_288_decoder = { · 4 unmodified lines
219 .priv_data_size = sizeof(RA288Context),227 .priv_data_size = sizeof(RA288Context),
220 .init = ra288_decode_init,228 .init = ra288_decode_init,
221 .decode = ra288_decode_frame,229 .decode = ra288_decode_frame,
230 .capabilities = CODEC_CAP_DR1,
222 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"),231 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"),
223};232};
libavcodec/s302m.c+36−10
@@ -25,6 +25,10 @@ · 24 unmodified lines
25 25
26#define AES3_HEADER_LEN 426#define AES3_HEADER_LEN 4
27 27
28typedef struct S302MDecodeContext {
29 AVFrame frame;
30} S302MDecodeContext;
31
28static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,32static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
29 int buf_size)33 int buf_size)
30{34{
@@ -83,10 +87,12 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf, · 52 unmodified lines
83}87}
84 88
85static int s302m_decode_frame(AVCodecContext *avctx, void *data,89static int s302m_decode_frame(AVCodecContext *avctx, void *data,
86 int *data_size, AVPacket *avpkt)90 int *got_frame_ptr, AVPacket *avpkt)
87{91{
92 S302MDecodeContext *s = avctx->priv_data;
88 const uint8_t *buf = avpkt->data;93 const uint8_t *buf = avpkt->data;
89 int buf_size = avpkt->size;94 int buf_size = avpkt->size;
95 int block_size, ret;
90 96
91 int frame_size = s302m_parse_frame_header(avctx, buf, buf_size);97 int frame_size = s302m_parse_frame_header(avctx, buf, buf_size);
92 if (frame_size < 0)98 if (frame_size < 0)
@@ -95,11 +101,18 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 2 unmodified lines
95 buf_size -= AES3_HEADER_LEN;101 buf_size -= AES3_HEADER_LEN;
96 buf += AES3_HEADER_LEN;102 buf += AES3_HEADER_LEN;
97 103
98 if (*data_size < 4 * buf_size * 8 / (avctx->bits_per_coded_sample + 4))104 /* get output buffer */
99 return -1;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;
100 113
101 if (avctx->bits_per_coded_sample == 24) {114 if (avctx->bits_per_coded_sample == 24) {
102 uint32_t *o = data;115 uint32_t *o = (uint32_t *)s->frame.data[0];
103 for (; buf_size > 6; buf_size -= 7) {116 for (; buf_size > 6; buf_size -= 7) {
104 *o++ = (av_reverse[buf[2]] << 24) |117 *o++ = (av_reverse[buf[2]] << 24) |
105 (av_reverse[buf[1]] << 16) |118 (av_reverse[buf[1]] << 16) |
@@ -110,9 +123,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines
110 (av_reverse[buf[3] & 0x0f] << 4);123 (av_reverse[buf[3] & 0x0f] << 4);
111 buf += 7;124 buf += 7;
112 }125 }
113 *data_size = (uint8_t*) o - (uint8_t*) data;
114 } else if (avctx->bits_per_coded_sample == 20) {126 } else if (avctx->bits_per_coded_sample == 20) {
115 uint32_t *o = data;127 uint32_t *o = (uint32_t *)s->frame.data[0];
116 for (; buf_size > 5; buf_size -= 6) {128 for (; buf_size > 5; buf_size -= 6) {
117 *o++ = (av_reverse[buf[2] & 0xf0] << 28) |129 *o++ = (av_reverse[buf[2] & 0xf0] << 28) |
118 (av_reverse[buf[1]] << 20) |130 (av_reverse[buf[1]] << 20) |
@@ -122,9 +134,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 3 unmodified lines
122 (av_reverse[buf[3]] << 12);134 (av_reverse[buf[3]] << 12);
123 buf += 6;135 buf += 6;
124 }136 }
125 *data_size = (uint8_t*) o - (uint8_t*) data;
126 } else {137 } else {
127 uint16_t *o = data;138 uint16_t *o = (uint16_t *)s->frame.data[0];
128 for (; buf_size > 4; buf_size -= 5) {139 for (; buf_size > 4; buf_size -= 5) {
129 *o++ = (av_reverse[buf[1]] << 8) |140 *o++ = (av_reverse[buf[1]] << 8) |
130 av_reverse[buf[0]];141 av_reverse[buf[0]];
@@ -133,10 +144,22 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 2 unmodified lines
133 (av_reverse[buf[2]] >> 4);144 (av_reverse[buf[2]] >> 4);
134 buf += 5;145 buf += 5;
135 }146 }
136 *data_size = (uint8_t*) o - (uint8_t*) data;
137 }147 }
138 148
139 return buf - avpkt->data;149 *got_frame_ptr = 1;
150 *(AVFrame *)data = s->frame;
151
152 return avpkt->size;
153}
154
155static 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;
140}163}
141 164
142 165
@@ -144,6 +167,9 @@ AVCodec ff_s302m_decoder = { · 1 unmodified line
144 .name = "s302m",167 .name = "s302m",
145 .type = AVMEDIA_TYPE_AUDIO,168 .type = AVMEDIA_TYPE_AUDIO,
146 .id = CODEC_ID_S302M,169 .id = CODEC_ID_S302M,
170 .priv_data_size = sizeof(S302MDecodeContext),
171 .init = s302m_decode_init,
147 .decode = s302m_decode_frame,172 .decode = s302m_decode_frame,
173 .capabilities = CODEC_CAP_DR1,
148 .long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"),174 .long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"),
149};175};
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
79 79
80typedef struct ShortenContext {80typedef struct ShortenContext {
81 AVCodecContext *avctx;81 AVCodecContext *avctx;
82 AVFrame frame;
82 GetBitContext gb;83 GetBitContext gb;
83 84
84 int min_framesize, max_framesize;85 int min_framesize, max_framesize;
@@ -112,6 +113,9 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx) · 27 unmodified lines
112 s->avctx = avctx;113 s->avctx = avctx;
113 avctx->sample_fmt = AV_SAMPLE_FMT_S16;114 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
114 115
116 avcodec_get_frame_defaults(&s->frame);
117 avctx->coded_frame = &s->frame;
118
115 return 0;119 return 0;
116}120}
117 121
@@ -394,15 +398,13 @@ static int read_header(ShortenContext *s) · 276 unmodified lines
394 return 0;398 return 0;
395}399}
396 400
397static int shorten_decode_frame(AVCodecContext *avctx,401static int shorten_decode_frame(AVCodecContext *avctx, void *data,
398 void *data, int *data_size,402 int *got_frame_ptr, AVPacket *avpkt)
399 AVPacket *avpkt)
400{403{
401 const uint8_t *buf = avpkt->data;404 const uint8_t *buf = avpkt->data;
402 int buf_size = avpkt->size;405 int buf_size = avpkt->size;
403 ShortenContext *s = avctx->priv_data;406 ShortenContext *s = avctx->priv_data;
404 int i, input_buf_size = 0;407 int i, input_buf_size = 0;
405 int16_t *samples = data;
406 int ret;408 int ret;
407 409
408 /* allocate internal bitstream buffer */410 /* allocate internal bitstream buffer */
@@ -436,7 +438,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 27 unmodified lines
436 /* do not decode until buffer has at least max_framesize bytes or438 /* do not decode until buffer has at least max_framesize bytes or
437 the end of the file has been reached */439 the end of the file has been reached */
438 if (buf_size < s->max_framesize && avpkt->data) {440 if (buf_size < s->max_framesize && avpkt->data) {
439 *data_size = 0;441 *got_frame_ptr = 0;
440 return input_buf_size;442 return input_buf_size;
441 }443 }
442 }444 }
@@ -448,13 +450,13 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 5 unmodified lines
448 if (!s->got_header) {450 if (!s->got_header) {
449 if ((ret = read_header(s)) < 0)451 if ((ret = read_header(s)) < 0)
450 return ret;452 return ret;
451 *data_size = 0;453 *got_frame_ptr = 0;
452 goto finish_frame;454 goto finish_frame;
453 }455 }
454 456
455 /* if quit command was read previously, don't decode anything */457 /* if quit command was read previously, don't decode anything */
456 if (s->got_quit_command) {458 if (s->got_quit_command) {
457 *data_size = 0;459 *got_frame_ptr = 0;
458 return avpkt->size;460 return avpkt->size;
459 }461 }
460 462
@@ -464,7 +466,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 3 unmodified lines
464 int len;466 int len;
465 467
466 if (get_bits_left(&s->gb) < 3+FNSIZE) {468 if (get_bits_left(&s->gb) < 3+FNSIZE) {
467 *data_size = 0;469 *got_frame_ptr = 0;
468 break;470 break;
469 }471 }
470 472
@@ -472,7 +474,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 1 unmodified line
472 474
473 if (cmd > FN_VERBATIM) {475 if (cmd > FN_VERBATIM) {
474 av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);476 av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);
475 *data_size = 0;477 *got_frame_ptr = 0;
476 break;478 break;
477 }479 }
478 480
@@ -507,7 +509,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 28 unmodified lines
507 break;509 break;
508 }510 }
509 if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {511 if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {
510 *data_size = 0;512 *got_frame_ptr = 0;
511 break;513 break;
512 }514 }
513 } else {515 } else {
@@ -571,19 +573,23 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 57 unmodified lines
571 /* if this is the last channel in the block, output the samples */573 /* if this is the last channel in the block, output the samples */
572 s->cur_chan++;574 s->cur_chan++;
573 if (s->cur_chan == s->channels) {575 if (s->cur_chan == s->channels) {
574 int out_size = s->blocksize * s->channels *576 /* get output buffer */
575 av_get_bytes_per_sample(avctx->sample_fmt);577 s->frame.nb_samples = s->blocksize;
576 if (*data_size < out_size) {578 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
577 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");579 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
578 return AVERROR(EINVAL);580 return ret;
579 }581 }
580 interleave_buffer(samples, s->channels, s->blocksize, s->decoded);582 /* interleave output */
581 *data_size = out_size;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;
582 }588 }
583 }589 }
584 }590 }
585 if (s->cur_chan < s->channels)591 if (s->cur_chan < s->channels)
586 *data_size = 0;592 *got_frame_ptr = 0;
587 593
588finish_frame:594finish_frame:
589 s->bitindex = get_bits_count(&s->gb) - 8*((get_bits_count(&s->gb))/8);595 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
614 }620 }
615 av_freep(&s->bitstream);621 av_freep(&s->bitstream);
616 av_freep(&s->coeffs);622 av_freep(&s->coeffs);
623
617 return 0;624 return 0;
618}625}
619 626
@@ -625,6 +632,6 @@ AVCodec ff_shorten_decoder = { · 5 unmodified lines
625 .init = shorten_decode_init,632 .init = shorten_decode_init,
626 .close = shorten_decode_close,633 .close = shorten_decode_close,
627 .decode = shorten_decode_frame,634 .decode = shorten_decode_frame,
628 .capabilities = CODEC_CAP_DELAY,635 .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
629 .long_name= NULL_IF_CONFIG_SMALL("Shorten"),636 .long_name= NULL_IF_CONFIG_SMALL("Shorten"),
630};637};
libavcodec/sipr.c+19−15
@@ -507,20 +507,23 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx) · 506 unmodified lines
507 507
508 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;508 avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
509 509
510 avcodec_get_frame_defaults(&ctx->frame);
511 avctx->coded_frame = &ctx->frame;
512
510 return 0;513 return 0;
511}514}
512 515
513static int sipr_decode_frame(AVCodecContext *avctx, void *datap,516static int sipr_decode_frame(AVCodecContext *avctx, void *data,
514 int *data_size, AVPacket *avpkt)517 int *got_frame_ptr, AVPacket *avpkt)
515{518{
516 SiprContext *ctx = avctx->priv_data;519 SiprContext *ctx = avctx->priv_data;
517 const uint8_t *buf=avpkt->data;520 const uint8_t *buf=avpkt->data;
518 SiprParameters parm;521 SiprParameters parm;
519 const SiprModeParam *mode_par = &modes[ctx->mode];522 const SiprModeParam *mode_par = &modes[ctx->mode];
520 GetBitContext gb;523 GetBitContext gb;
521 float *data = datap;524 float *samples;
522 int subframe_size = ctx->mode == MODE_16k ? L_SUBFR_16k : SUBFR_SIZE;525 int subframe_size = ctx->mode == MODE_16k ? L_SUBFR_16k : SUBFR_SIZE;
523 int i, out_size;526 int i, ret;
524 527
525 ctx->avctx = avctx;528 ctx->avctx = avctx;
526 if (avpkt->size < (mode_par->bits_per_frame >> 3)) {529 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
530 return -1;533 return -1;
531 }534 }
532 535
533 out_size = mode_par->frames_per_packet * subframe_size *536 /* get output buffer */
534 mode_par->subframe_count *537 ctx->frame.nb_samples = mode_par->frames_per_packet * subframe_size *
535 av_get_bytes_per_sample(avctx->sample_fmt);538 mode_par->subframe_count;
536 if (*data_size < out_size) {539 if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
537 av_log(avctx, AV_LOG_ERROR,540 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
538 "Error processing packet: output buffer (%d) too small\n",541 return ret;
539 *data_size);
540 return -1;
541 }542 }
543 samples = (float *)ctx->frame.data[0];
542 544
543 init_get_bits(&gb, buf, mode_par->bits_per_frame);545 init_get_bits(&gb, buf, mode_par->bits_per_frame);
544 546
545 for (i = 0; i < mode_par->frames_per_packet; i++) {547 for (i = 0; i < mode_par->frames_per_packet; i++) {
546 decode_parameters(&parm, &gb, mode_par);548 decode_parameters(&parm, &gb, mode_par);
547 549
548 ctx->decode_frame(ctx, &parm, data);550 ctx->decode_frame(ctx, &parm, samples);
549 551
550 data += subframe_size * mode_par->subframe_count;552 samples += subframe_size * mode_par->subframe_count;
551 }553 }
552 554
553 *data_size = out_size;555 *got_frame_ptr = 1;
556 *(AVFrame *)data = ctx->frame;
554 557
555 return mode_par->bits_per_frame >> 3;558 return mode_par->bits_per_frame >> 3;
556}559}
@@ -562,5 +565,6 @@ AVCodec ff_sipr_decoder = { · 5 unmodified lines
562 .priv_data_size = sizeof(SiprContext),565 .priv_data_size = sizeof(SiprContext),
563 .init = sipr_decoder_init,566 .init = sipr_decoder_init,
564 .decode = sipr_decode_frame,567 .decode = sipr_decode_frame,
568 .capabilities = CODEC_CAP_DR1,
565 .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),569 .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
566};570};
libavcodec/smacker.c+31−10
@@ -559,31 +559,43 @@ static av_cold int decode_end(AVCodecContext *avctx) · 558 unmodified lines
559}559}
560 560
561 561
562typedef struct SmackerAudioContext {
563 AVFrame frame;
564} SmackerAudioContext;
565
562static av_cold int smka_decode_init(AVCodecContext *avctx)566static av_cold int smka_decode_init(AVCodecContext *avctx)
563{567{
568 SmackerAudioContext *s = avctx->priv_data;
569
564 if (avctx->channels < 1 || avctx->channels > 2) {570 if (avctx->channels < 1 || avctx->channels > 2) {
565 av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n");571 av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n");
566 return AVERROR(EINVAL);572 return AVERROR(EINVAL);
567 }573 }
568 avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;574 avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
569 avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16;575 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
570 return 0;580 return 0;
571}581}
572 582
573/**583/**
574 * Decode Smacker audio data584 * Decode Smacker audio data
575 */585 */
576static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)586static int smka_decode_frame(AVCodecContext *avctx, void *data,
587 int *got_frame_ptr, AVPacket *avpkt)
577{588{
589 SmackerAudioContext *s = avctx->priv_data;
578 const uint8_t *buf = avpkt->data;590 const uint8_t *buf = avpkt->data;
579 int buf_size = avpkt->size;591 int buf_size = avpkt->size;
580 GetBitContext gb;592 GetBitContext gb;
581 HuffContext h[4];593 HuffContext h[4];
582 VLC vlc[4];594 VLC vlc[4];
583 int16_t *samples = data;595 int16_t *samples;
584 uint8_t *samples8 = data;596 uint8_t *samples8;
585 int val;597 int val;
586 int i, res;598 int i, res, ret;
587 int unp_size;599 int unp_size;
588 int bits, stereo;600 int bits, stereo;
589 int pred[2] = {0, 0};601 int pred[2] = {0, 0};
@@ -599,15 +611,11 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 9 unmodified lines
599 611
600 if(!get_bits1(&gb)){612 if(!get_bits1(&gb)){
601 av_log(avctx, AV_LOG_INFO, "Sound: no data\n");613 av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
602 *data_size = 0;614 *got_frame_ptr = 0;
603 return 1;615 return 1;
604 }616 }
605 stereo = get_bits1(&gb);617 stereo = get_bits1(&gb);
606 bits = get_bits1(&gb);618 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 }
611 if (stereo ^ (avctx->channels != 1)) {619 if (stereo ^ (avctx->channels != 1)) {
612 av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");620 av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
613 return AVERROR(EINVAL);621 return AVERROR(EINVAL);
@@ -617,6 +625,15 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 3 unmodified lines
617 return AVERROR(EINVAL);625 return AVERROR(EINVAL);
618 }626 }
619 627
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
620 memset(vlc, 0, sizeof(VLC) * 4);637 memset(vlc, 0, sizeof(VLC) * 4);
621 memset(h, 0, sizeof(HuffContext) * 4);638 memset(h, 0, sizeof(HuffContext) * 4);
622 // Initialize639 // Initialize
@@ -706,7 +723,9 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 83 unmodified lines
706 av_free(h[i].values);723 av_free(h[i].values);
707 }724 }
708 725
709 *data_size = unp_size;726 *got_frame_ptr = 1;
727 *(AVFrame *)data = s->frame;
728
710 return buf_size;729 return buf_size;
711}730}
712 731
@@ -726,8 +745,10 @@ AVCodec ff_smackaud_decoder = { · 13 unmodified lines
726 .name = "smackaud",745 .name = "smackaud",
727 .type = AVMEDIA_TYPE_AUDIO,746 .type = AVMEDIA_TYPE_AUDIO,
728 .id = CODEC_ID_SMACKAUDIO,747 .id = CODEC_ID_SMACKAUDIO,
748 .priv_data_size = sizeof(SmackerAudioContext),
729 .init = smka_decode_init,749 .init = smka_decode_init,
730 .decode = smka_decode_frame,750 .decode = smka_decode_frame,
751 .capabilities = CODEC_CAP_DR1,
731 .long_name = NULL_IF_CONFIG_SMALL("Smacker audio"),752 .long_name = NULL_IF_CONFIG_SMALL("Smacker audio"),
732};753};
733 754
libavcodec/svq1dec.c+2−1
@@ -195,7 +195,8 @@ static const uint8_t string_table[256] = { · 194 unmodified lines
195 195
196#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)\196#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)\
197 codebook = (const uint32_t *) cbook[level];\197 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);\
199 /* calculate codebook entries for this vector */\200 /* calculate codebook entries for this vector */\
200 for (j=0; j < stages; j++) {\201 for (j=0; j < stages; j++) {\
201 entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1);\202 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
34 * TrueSpeech decoder context34 * TrueSpeech decoder context
35 */35 */
36typedef struct {36typedef struct {
37 AVFrame frame;
37 DSPContext dsp;38 DSPContext dsp;
38 /* input data */39 /* input data */
39 uint8_t buffer[32];40 uint8_t buffer[32];
@@ -69,6 +70,9 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx) · 29 unmodified lines
69 70
70 dsputil_init(&c->dsp, avctx);71 dsputil_init(&c->dsp, avctx);
71 72
73 avcodec_get_frame_defaults(&c->frame);
74 avctx->coded_frame = &c->frame;
75
72 return 0;76 return 0;
73}77}
74 78
@@ -299,17 +303,16 @@ static void truespeech_save_prevvec(TSContext *c) · 224 unmodified lines
299 c->prevfilt[i] = c->cvector[i];303 c->prevfilt[i] = c->cvector[i];
300}304}
301 305
302static int truespeech_decode_frame(AVCodecContext *avctx,306static int truespeech_decode_frame(AVCodecContext *avctx, void *data,
303 void *data, int *data_size,307 int *got_frame_ptr, AVPacket *avpkt)
304 AVPacket *avpkt)
305{308{
306 const uint8_t *buf = avpkt->data;309 const uint8_t *buf = avpkt->data;
307 int buf_size = avpkt->size;310 int buf_size = avpkt->size;
308 TSContext *c = avctx->priv_data;311 TSContext *c = avctx->priv_data;
309 312
310 int i, j;313 int i, j;
311 short *samples = data;314 int16_t *samples;
312 int iterations, out_size;315 int iterations, ret;
313 316
314 iterations = buf_size / 32;317 iterations = buf_size / 32;
315 318
@@ -319,13 +322,15 @@ static int truespeech_decode_frame(AVCodecContext *avctx, · 3 unmodified lines
319 return -1;322 return -1;
320 }323 }
321 324
322 out_size = iterations * 240 * av_get_bytes_per_sample(avctx->sample_fmt);325 /* get output buffer */
323 if (*data_size < out_size) {326 c->frame.nb_samples = iterations * 240;
324 av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");327 if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
325 return AVERROR(EINVAL);328 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
329 return ret;
326 }330 }
331 samples = (int16_t *)c->frame.data[0];
327 332
328 memset(samples, 0, out_size);333 memset(samples, 0, iterations * 240 * sizeof(*samples));
329 334
330 for(j = 0; j < iterations; j++) {335 for(j = 0; j < iterations; j++) {
331 truespeech_read_frame(c, buf);336 truespeech_read_frame(c, buf);
@@ -345,7 +350,8 @@ static int truespeech_decode_frame(AVCodecContext *avctx, · 13 unmodified lines
345 truespeech_save_prevvec(c);350 truespeech_save_prevvec(c);
346 }351 }
347 352
348 *data_size = out_size;353 *got_frame_ptr = 1;
354 *(AVFrame *)data = c->frame;
349 355
350 return buf_size;356 return buf_size;
351}357}
@@ -357,5 +363,6 @@ AVCodec ff_truespeech_decoder = { · 5 unmodified lines
357 .priv_data_size = sizeof(TSContext),363 .priv_data_size = sizeof(TSContext),
358 .init = truespeech_decode_init,364 .init = truespeech_decode_init,
359 .decode = truespeech_decode_frame,365 .decode = truespeech_decode_frame,
366 .capabilities = CODEC_CAP_DR1,
360 .long_name = NULL_IF_CONFIG_SMALL("DSP Group TrueSpeech"),367 .long_name = NULL_IF_CONFIG_SMALL("DSP Group TrueSpeech"),
361};368};
libavcodec/tta.c+18−12
@@ -56,6 +56,7 @@ typedef struct TTAChannel { · 55 unmodified lines
56 56
57typedef struct TTAContext {57typedef struct TTAContext {
58 AVCodecContext *avctx;58 AVCodecContext *avctx;
59 AVFrame frame;
59 GetBitContext gb;60 GetBitContext gb;
60 61
61 int format, channels, bps, data_length;62 int format, channels, bps, data_length;
@@ -288,17 +289,19 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) · 226 unmodified lines
288 return -1;289 return -1;
289 }290 }
290 291
292 avcodec_get_frame_defaults(&s->frame);
293 avctx->coded_frame = &s->frame;
294
291 return 0;295 return 0;
292}296}
293 297
294static int tta_decode_frame(AVCodecContext *avctx,298static int tta_decode_frame(AVCodecContext *avctx, void *data,
295 void *data, int *data_size,299 int *got_frame_ptr, AVPacket *avpkt)
296 AVPacket *avpkt)
297{300{
298 const uint8_t *buf = avpkt->data;301 const uint8_t *buf = avpkt->data;
299 int buf_size = avpkt->size;302 int buf_size = avpkt->size;
300 TTAContext *s = avctx->priv_data;303 TTAContext *s = avctx->priv_data;
301 int i, out_size;304 int i, ret;
302 int cur_chan = 0, framelen = s->frame_length;305 int cur_chan = 0, framelen = s->frame_length;
303 int32_t *p;306 int32_t *p;
304 307
@@ -309,10 +312,11 @@ static int tta_decode_frame(AVCodecContext *avctx, · 4 unmodified lines
309 if (!s->total_frames && s->last_frame_length)312 if (!s->total_frames && s->last_frame_length)
310 framelen = s->last_frame_length;313 framelen = s->last_frame_length;
311 314
312 out_size = framelen * s->channels * av_get_bytes_per_sample(avctx->sample_fmt);315 /* get output buffer */
313 if (*data_size < out_size) {316 s->frame.nb_samples = framelen;
314 av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n");317 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
315 return -1;318 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
319 return ret;
316 }320 }
317 321
318 // decode directly to output buffer for 24-bit sample format322 // decode directly to output buffer for 24-bit sample format
@@ -409,20 +413,20 @@ static int tta_decode_frame(AVCodecContext *avctx, · 90 unmodified lines
409 // convert to output buffer413 // convert to output buffer
410 switch(s->bps) {414 switch(s->bps) {
411 case 1: {415 case 1: {
412 uint8_t *samples = data;416 uint8_t *samples = (int16_t *)s->frame.data[0];
413 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)417 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
414 *samples++ = *p + 0x80;418 *samples++ = *p + 0x80;
415 break;419 break;
416 }420 }
417 case 2: {421 case 2: {
418 uint16_t *samples = data;422 uint16_t *samples = (int16_t *)s->frame.data[0];
419 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)423 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
420 *samples++ = *p;424 *samples++ = *p;
421 break;425 break;
422 }426 }
423 case 3: {427 case 3: {
424 // shift samples for 24-bit sample format428 // shift samples for 24-bit sample format
425 int32_t *samples = data;429 int32_t *samples = (int16_t *)s->frame.data[0];
426 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)430 for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
427 *samples++ <<= 8;431 *samples++ <<= 8;
428 // reset decode buffer432 // reset decode buffer
@@ -433,7 +437,8 @@ static int tta_decode_frame(AVCodecContext *avctx, · 4 unmodified lines
433 av_log(s->avctx, AV_LOG_ERROR, "Error, only 16bit samples supported!\n");437 av_log(s->avctx, AV_LOG_ERROR, "Error, only 16bit samples supported!\n");
434 }438 }
435 439
436 *data_size = out_size;440 *got_frame_ptr = 1;
441 *(AVFrame *)data = s->frame;
437 442
438 return buf_size;443 return buf_size;
439}444}
@@ -455,5 +460,6 @@ AVCodec ff_tta_decoder = { · 15 unmodified lines
455 .init = tta_decode_init,460 .init = tta_decode_init,
456 .close = tta_decode_close,461 .close = tta_decode_close,
457 .decode = tta_decode_frame,462 .decode = tta_decode_frame,
463 .capabilities = CODEC_CAP_DR1,
458 .long_name = NULL_IF_CONFIG_SMALL("True Audio (TTA)"),464 .long_name = NULL_IF_CONFIG_SMALL("True Audio (TTA)"),
459};465};
libavcodec/twinvq.c+25−11
@@ -174,6 +174,7 @@ static const ModeTab mode_44_48 = { · 173 unmodified lines
174 174
175typedef struct TwinContext {175typedef struct TwinContext {
176 AVCodecContext *avctx;176 AVCodecContext *avctx;
177 AVFrame frame;
177 DSPContext dsp;178 DSPContext dsp;
178 FFTContext mdct_ctx[3];179 FFTContext mdct_ctx[3];
179 180
@@ -195,6 +196,7 @@ typedef struct TwinContext { · 15 unmodified lines
195 float *curr_frame; ///< non-interleaved output196 float *curr_frame; ///< non-interleaved output
196 float *prev_frame; ///< non-interleaved previous frame197 float *prev_frame; ///< non-interleaved previous frame
197 int last_block_pos[2];198 int last_block_pos[2];
199 int discarded_packets;
198 200
199 float *cos_tabs[3];201 float *cos_tabs[3];
200 202
@@ -676,6 +678,9 @@ static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, · 475 unmodified lines
676 i);678 i);
677 }679 }
678 680
681 if (!out)
682 return;
683
679 size2 = tctx->last_block_pos[0];684 size2 = tctx->last_block_pos[0];
680 size1 = mtab->size - size2;685 size1 = mtab->size - size2;
681 if (tctx->avctx->channels == 2) {686 if (tctx->avctx->channels == 2) {
@@ -811,16 +816,16 @@ static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb, · 129 unmodified lines
811}816}
812 817
813static int twin_decode_frame(AVCodecContext * avctx, void *data,818static int twin_decode_frame(AVCodecContext * avctx, void *data,
814 int *data_size, AVPacket *avpkt)819 int *got_frame_ptr, AVPacket *avpkt)
815{820{
816 const uint8_t *buf = avpkt->data;821 const uint8_t *buf = avpkt->data;
817 int buf_size = avpkt->size;822 int buf_size = avpkt->size;
818 TwinContext *tctx = avctx->priv_data;823 TwinContext *tctx = avctx->priv_data;
819 GetBitContext gb;824 GetBitContext gb;
820 const ModeTab *mtab = tctx->mtab;825 const ModeTab *mtab = tctx->mtab;
821 float *out = data;826 float *out = NULL;
822 enum FrameType ftype;827 enum FrameType ftype;
823 int window_type, out_size;828 int window_type, ret;
824 static const enum FrameType wtype_to_ftype_table[] = {829 static const enum FrameType wtype_to_ftype_table[] = {
825 FT_LONG, FT_LONG, FT_SHORT, FT_LONG,830 FT_LONG, FT_LONG, FT_SHORT, FT_LONG,
826 FT_MEDIUM, FT_LONG, FT_LONG, FT_MEDIUM, FT_MEDIUM831 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
832 return AVERROR(EINVAL);837 return AVERROR(EINVAL);
833 }838 }
834 839
835 out_size = mtab->size * avctx->channels *840 /* get output buffer */
836 av_get_bytes_per_sample(avctx->sample_fmt);841 if (tctx->discarded_packets >= 2) {
837 if (*data_size < out_size) {842 tctx->frame.nb_samples = mtab->size;
838 av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");843 if ((ret = avctx->get_buffer(avctx, &tctx->frame)) < 0) {
839 return AVERROR(EINVAL);844 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
845 return ret;
846 }
847 out = (float *)tctx->frame.data[0];
840 }848 }
841 849
842 init_get_bits(&gb, buf, buf_size * 8);850 init_get_bits(&gb, buf, buf_size * 8);
@@ -856,12 +864,14 @@ static int twin_decode_frame(AVCodecContext * avctx, void *data, · 13 unmodified lines
856 864
857 FFSWAP(float*, tctx->curr_frame, tctx->prev_frame);865 FFSWAP(float*, tctx->curr_frame, tctx->prev_frame);
858 866
859 if (tctx->avctx->frame_number < 2) {867 if (tctx->discarded_packets < 2) {
860 *data_size=0;868 tctx->discarded_packets++;
869 *got_frame_ptr = 0;
861 return buf_size;870 return buf_size;
862 }871 }
863 872
864 *data_size = out_size;873 *got_frame_ptr = 1;
874 *(AVFrame *)data = tctx->frame;;
865 875
866 return buf_size;876 return buf_size;
867}877}
@@ -1153,6 +1163,9 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) · 285 unmodified lines
1153 1163
1154 memset_float(tctx->bark_hist[0][0], 0.1, FF_ARRAY_ELEMS(tctx->bark_hist));1164 memset_float(tctx->bark_hist[0][0], 0.1, FF_ARRAY_ELEMS(tctx->bark_hist));
1155 1165
1166 avcodec_get_frame_defaults(&tctx->frame);
1167 avctx->coded_frame = &tctx->frame;
1168
1156 return 0;1169 return 0;
1157}1170}
1158 1171
@@ -1164,5 +1177,6 @@ AVCodec ff_twinvq_decoder = { · 5 unmodified lines
1164 .init = twin_decode_init,1177 .init = twin_decode_init,
1165 .close = twin_decode_close,1178 .close = twin_decode_close,
1166 .decode = twin_decode_frame,1179 .decode = twin_decode_frame,
1180 .capabilities = CODEC_CAP_DR1,
1167 .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"),1181 .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"),
1168};1182};
libavcodec/utils.c+224−33
@@ -127,7 +127,10 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height){ · 126 unmodified lines
127 127
128#define INTERNAL_BUFFER_SIZE (32+1)128#define INTERNAL_BUFFER_SIZE (32+1)
129 129
130void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){130void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
131 int linesize_align[AV_NUM_DATA_POINTERS])
132{
133 int i;
131 int w_align= 1;134 int w_align= 1;
132 int h_align= 1;135 int h_align= 1;
133 136
@@ -213,10 +216,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l · 79 unmodified lines
213 *height+=2; // some of the optimized chroma MC reads one line too much216 *height+=2; // some of the optimized chroma MC reads one line too much
214 // which is also done in mpeg decoders with lowres > 0217 // which is also done in mpeg decoders with lowres > 0
215 218
216 linesize_align[0] =219 for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
217 linesize_align[1] =220 linesize_align[i] = STRIDE_ALIGN;
218 linesize_align[2] =
219 linesize_align[3] = STRIDE_ALIGN;
220//STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes221//STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes
221//we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the222//we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the
222//picture size unneccessarily in some cases. The solution here is not223//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
225 if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||226 if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||
226 s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||227 s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||
227 s->codec_id == CODEC_ID_VP6A || s->codec_id == CODEC_ID_DIRAC) {228 s->codec_id == CODEC_ID_VP6A || s->codec_id == CODEC_ID_DIRAC) {
228 linesize_align[0] =229 for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
229 linesize_align[1] =230 linesize_align[i] = 16;
230 linesize_align[2] = 16;
231 }231 }
232#endif232#endif
233}233}
234 234
235void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){235void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
236 int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w;236 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];
238 int align;238 int align;
239 avcodec_align_dimensions2(s, width, height, linesize_align);239 avcodec_align_dimensions2(s, width, height, linesize_align);
240 align = FFMAX(linesize_align[0], linesize_align[3]);240 align = FFMAX(linesize_align[0], linesize_align[3]);
@@ -260,7 +260,108 @@ void ff_init_buffer_info(AVCodecContext *s, AVFrame *pic) · 19 unmodified lines
260 pic->format = s->pix_fmt;260 pic->format = s->pix_fmt;
261}261}
262 262
263int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){263static 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
363static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
364{
264 int i;365 int i;
265 int w= s->width;366 int w= s->width;
266 int h= s->height;367 int h= s->height;
@@ -295,7 +396,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 28 unmodified lines
295 return -1;396 return -1;
296 }397 }
297 398
298 for(i=0; i<4; i++){399 for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
299 av_freep(&buf->base[i]);400 av_freep(&buf->base[i]);
300 buf->data[i]= NULL;401 buf->data[i]= NULL;
301 }402 }
@@ -310,7 +411,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 8 unmodified lines
310 int tmpsize;411 int tmpsize;
311 int unaligned;412 int unaligned;
312 AVPicture picture;413 AVPicture picture;
313 int stride_align[4];414 int stride_align[AV_NUM_DATA_POINTERS];
314 const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;415 const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
315 416
316 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);417 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
363 else464 else
364 buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (pixel_size*EDGE_WIDTH>>h_shift), stride_align[i]);465 buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (pixel_size*EDGE_WIDTH>>h_shift), stride_align[i]);
365 }466 }
467 for (; i < AV_NUM_DATA_POINTERS; i++) {
468 buf->base[i] = buf->data[i] = NULL;
469 buf->linesize[i] = 0;
470 }
366 if(size[1] && !size[2])471 if(size[1] && !size[2])
367 ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt);472 ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt);
368 buf->width = s->width;473 buf->width = s->width;
@@ -372,11 +477,12 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 3 unmodified lines
372 }477 }
373 pic->type= FF_BUFFER_TYPE_INTERNAL;478 pic->type= FF_BUFFER_TYPE_INTERNAL;
374 479
375 for(i=0; i<4; i++){480 for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
376 pic->base[i]= buf->base[i];481 pic->base[i]= buf->base[i];
377 pic->data[i]= buf->data[i];482 pic->data[i]= buf->data[i];
378 pic->linesize[i]= buf->linesize[i];483 pic->linesize[i]= buf->linesize[i];
379 }484 }
485 pic->extended_data = pic->data;
380 avci->buffer_count++;486 avci->buffer_count++;
381 487
382 if (s->pkt) {488 if (s->pkt) {
@@ -399,11 +505,25 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 16 unmodified lines
399 return 0;505 return 0;
400}506}
401 507
508int 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
402void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){520void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
403 int i;521 int i;
404 InternalBuffer *buf, *last;522 InternalBuffer *buf, *last;
405 AVCodecInternal *avci = s->internal;523 AVCodecInternal *avci = s->internal;
406 524
525 assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
526
407 assert(pic->type==FF_BUFFER_TYPE_INTERNAL);527 assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
408 assert(avci->buffer_count);528 assert(avci->buffer_count);
409 529
@@ -421,7 +541,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ · 11 unmodified lines
421 FFSWAP(InternalBuffer, *buf, *last);541 FFSWAP(InternalBuffer, *buf, *last);
422 }542 }
423 543
424 for(i=0; i<4; i++){544 for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
425 pic->data[i]=NULL;545 pic->data[i]=NULL;
426// pic->base[i]=NULL;546// pic->base[i]=NULL;
427 }547 }
@@ -436,6 +556,8 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ · 8 unmodified lines
436 AVFrame temp_pic;556 AVFrame temp_pic;
437 int i;557 int i;
438 558
559 assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
560
439 /* If no picture return a new buffer */561 /* If no picture return a new buffer */
440 if(pic->data[0] == NULL) {562 if(pic->data[0] == NULL) {
441 /* We will copy from buffer, so must be readable */563 /* 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
455 * Not internal type and reget_buffer not overridden, emulate cr buffer577 * Not internal type and reget_buffer not overridden, emulate cr buffer
456 */578 */
457 temp_pic = *pic;579 temp_pic = *pic;
458 for(i = 0; i < 4; i++)580 for(i = 0; i < AV_NUM_DATA_POINTERS; i++)
459 pic->data[i] = pic->base[i] = NULL;581 pic->data[i] = pic->base[i] = NULL;
460 pic->opaque = NULL;582 pic->opaque = NULL;
461 /* Allocate new frame */583 /* Allocate new frame */
@@ -862,36 +984,73 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi · 400 unmodified lines
862 return ret;984 return ret;
863}985}
864 986
987#if FF_API_OLD_DECODE_AUDIO
865int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,988int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
866 int *frame_size_ptr,989 int *frame_size_ptr,
867 AVPacket *avpkt)990 AVPacket *avpkt)
868{991{
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
1032int 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;
870 1040
871 if (!avpkt->data && avpkt->size) {1041 if (!avpkt->data && avpkt->size) {
872 av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");1042 av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
873 return AVERROR(EINVAL);1043 return AVERROR(EINVAL);
874 }1044 }
875 1045
876 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){1046 if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
877 av_packet_split_side_data(avpkt);1047 av_packet_split_side_data(avpkt);
878 avctx->pkt = avpkt;1048 avctx->pkt = avpkt;
879 //FIXME remove the check below _after_ ensuring that all audio check that the available space is enough1049 ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
880 if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){1050 if (ret >= 0 && *got_frame_ptr) {
881 av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n");1051 avctx->frame_number++;
882 return -1;1052 frame->pkt_dts = avpkt->dts;
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;
888 }1053 }
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;
895 }1054 }
896 return ret;1055 return ret;
897}1056}
@@ -1230,7 +1389,8 @@ void avcodec_flush_buffers(AVCodecContext *avctx) · 332 unmodified lines
1230 avctx->codec->flush(avctx);1389 avctx->codec->flush(avctx);
1231}1390}
1232 1391
1233void avcodec_default_free_buffers(AVCodecContext *s){1392static void video_free_buffers(AVCodecContext *s)
1393{
1234 AVCodecInternal *avci = s->internal;1394 AVCodecInternal *avci = s->internal;
1235 int i, j;1395 int i, j;
1236 1396
@@ -1252,6 +1412,37 @@ void avcodec_default_free_buffers(AVCodecContext *s){ · 15 unmodified lines
1252 avci->buffer_count=0;1412 avci->buffer_count=0;
1253}1413}
1254 1414
1415static 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
1432void 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
1255#if FF_API_OLD_FF_PICT_TYPES1446#if FF_API_OLD_FF_PICT_TYPES
1256char av_get_pict_type_char(int pict_type){1447char av_get_pict_type_char(int pict_type){
1257 return av_get_picture_type_char(pict_type);1448 return av_get_picture_type_char(pict_type);
libavcodec/version.h+8−3
@@ -21,8 +21,8 @@ · 20 unmodified lines
21#define AVCODEC_VERSION_H21#define AVCODEC_VERSION_H
22 22
23#define LIBAVCODEC_VERSION_MAJOR 5323#define LIBAVCODEC_VERSION_MAJOR 53
24#define LIBAVCODEC_VERSION_MINOR 3924#define LIBAVCODEC_VERSION_MINOR 40
25#define LIBAVCODEC_VERSION_MICRO 125#define LIBAVCODEC_VERSION_MICRO 0
26 26
27#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \27#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
28 LIBAVCODEC_VERSION_MINOR, \28 LIBAVCODEC_VERSION_MINOR, \
@@ -110,6 +110,11 @@ · 81 unmodified lines
110#ifndef FF_API_TIFFENC_COMPLEVEL110#ifndef FF_API_TIFFENC_COMPLEVEL
111#define FF_API_TIFFENC_COMPLEVEL (LIBAVCODEC_VERSION_MAJOR < 54)111#define FF_API_TIFFENC_COMPLEVEL (LIBAVCODEC_VERSION_MAJOR < 54)
112#endif112#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
114 119
115#endif /* AVCODEC_VERSION_H */120#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
466#define BLOCK_TYPE_SILENCE 3466#define BLOCK_TYPE_SILENCE 3
467 467
468typedef struct VmdAudioContext {468typedef struct VmdAudioContext {
469 AVFrame frame;
469 int out_bps;470 int out_bps;
470 int chunk_size;471 int chunk_size;
471} VmdAudioContext;472} VmdAudioContext;
@@ -507,6 +508,9 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx) · 35 unmodified lines
507 508
508 s->chunk_size = avctx->block_align + avctx->channels * (s->out_bps == 2);509 s->chunk_size = avctx->block_align + avctx->channels * (s->out_bps == 2);
509 510
511 avcodec_get_frame_defaults(&s->frame);
512 avctx->coded_frame = &s->frame;
513
510 av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, "514 av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, "
511 "block align = %d, sample rate = %d\n",515 "block align = %d, sample rate = %d\n",
512 avctx->channels, avctx->bits_per_coded_sample, avctx->block_align,516 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
544 }548 }
545}549}
546 550
547static int vmdaudio_decode_frame(AVCodecContext *avctx,551static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
548 void *data, int *data_size,552 int *got_frame_ptr, AVPacket *avpkt)
549 AVPacket *avpkt)
550{553{
551 const uint8_t *buf = avpkt->data;554 const uint8_t *buf = avpkt->data;
552 const uint8_t *buf_end;555 const uint8_t *buf_end;
553 int buf_size = avpkt->size;556 int buf_size = avpkt->size;
554 VmdAudioContext *s = avctx->priv_data;557 VmdAudioContext *s = avctx->priv_data;
555 int block_type, silent_chunks, audio_chunks;558 int block_type, silent_chunks, audio_chunks;
556 int nb_samples, out_size;559 int ret;
557 uint8_t *output_samples_u8 = data;560 uint8_t *output_samples_u8;
558 int16_t *output_samples_s16 = data;561 int16_t *output_samples_s16;
559 562
560 if (buf_size < 16) {563 if (buf_size < 16) {
561 av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");564 av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
562 *data_size = 0;565 *got_frame_ptr = 0;
563 return buf_size;566 return buf_size;
564 }567 }
565 568
@@ -590,10 +593,15 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, · 24 unmodified lines
590 593
591 /* ensure output buffer is large enough */594 /* ensure output buffer is large enough */
592 audio_chunks = buf_size / s->chunk_size;595 audio_chunks = buf_size / s->chunk_size;
593 nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels;596
594 out_size = nb_samples * avctx->channels * s->out_bps;597 /* get output buffer */
595 if (*data_size < out_size)598 s->frame.nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels;
596 return -1;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];
597 605
598 /* decode silent chunks */606 /* decode silent chunks */
599 if (silent_chunks > 0) {607 if (silent_chunks > 0) {
@@ -623,7 +631,9 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, · 23 unmodified lines
623 }631 }
624 }632 }
625 633
626 *data_size = out_size;634 *got_frame_ptr = 1;
635 *(AVFrame *)data = s->frame;
636
627 return avpkt->size;637 return avpkt->size;
628}638}
629 639
@@ -651,5 +661,6 @@ AVCodec ff_vmdaudio_decoder = { · 21 unmodified lines
651 .priv_data_size = sizeof(VmdAudioContext),661 .priv_data_size = sizeof(VmdAudioContext),
652 .init = vmdaudio_decode_init,662 .init = vmdaudio_decode_init,
653 .decode = vmdaudio_decode_frame,663 .decode = vmdaudio_decode_frame,
664 .capabilities = CODEC_CAP_DR1,
654 .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"),665 .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"),
655};666};
libavcodec/vorbisdec.c+20−13
@@ -125,6 +125,7 @@ typedef struct { · 124 unmodified lines
125 125
126typedef struct vorbis_context_s {126typedef struct vorbis_context_s {
127 AVCodecContext *avccontext;127 AVCodecContext *avccontext;
128 AVFrame frame;
128 GetBitContext gb;129 GetBitContext gb;
129 DSPContext dsp;130 DSPContext dsp;
130 FmtConvertContext fmt_conv;131 FmtConvertContext fmt_conv;
@@ -1037,6 +1038,9 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext) · 906 unmodified lines
1037 avccontext->sample_rate = vc->audio_samplerate;1038 avccontext->sample_rate = vc->audio_samplerate;
1038 avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2;1039 avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2;
1039 1040
1041 avcodec_get_frame_defaults(&vc->frame);
1042 avccontext->coded_frame = &vc->frame;
1043
1040 return 0;1044 return 0;
1041}1045}
1042 1046
@@ -1609,16 +1613,15 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) · 566 unmodified lines
1609 1613
1610// Return the decoded audio packet through the standard api1614// Return the decoded audio packet through the standard api
1611 1615
1612static int vorbis_decode_frame(AVCodecContext *avccontext,1616static int vorbis_decode_frame(AVCodecContext *avccontext, void *data,
1613 void *data, int *data_size,1617 int *got_frame_ptr, AVPacket *avpkt)
1614 AVPacket *avpkt)
1615{1618{
1616 const uint8_t *buf = avpkt->data;1619 const uint8_t *buf = avpkt->data;
1617 int buf_size = avpkt->size;1620 int buf_size = avpkt->size;
1618 vorbis_context *vc = avccontext->priv_data;1621 vorbis_context *vc = avccontext->priv_data;
1619 GetBitContext *gb = &(vc->gb);1622 GetBitContext *gb = &(vc->gb);
1620 const float *channel_ptrs[255];1623 const float *channel_ptrs[255];
1621 int i, len, out_size;1624 int i, len, ret;
1622 1625
1623 av_dlog(NULL, "packet length %d \n", buf_size);1626 av_dlog(NULL, "packet length %d \n", buf_size);
1624 1627
@@ -1629,18 +1632,18 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, · 4 unmodified lines
1629 1632
1630 if (!vc->first_frame) {1633 if (!vc->first_frame) {
1631 vc->first_frame = 1;1634 vc->first_frame = 1;
1632 *data_size = 0;1635 *got_frame_ptr = 0;
1633 return buf_size;1636 return buf_size;
1634 }1637 }
1635 1638
1636 av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n",1639 av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n",
1637 get_bits_count(gb) / 8, get_bits_count(gb) % 8, len);1640 get_bits_count(gb) / 8, get_bits_count(gb) % 8, len);
1638 1641
1639 out_size = len * vc->audio_channels *1642 /* get output buffer */
1640 av_get_bytes_per_sample(avccontext->sample_fmt);1643 vc->frame.nb_samples = len;
1641 if (*data_size < out_size) {1644 if ((ret = avccontext->get_buffer(avccontext, &vc->frame)) < 0) {
1642 av_log(avccontext, AV_LOG_ERROR, "output buffer is too small\n");1645 av_log(avccontext, AV_LOG_ERROR, "get_buffer() failed\n");
1643 return AVERROR(EINVAL);1646 return ret;
1644 }1647 }
1645 1648
1646 if (vc->audio_channels > 8) {1649 if (vc->audio_channels > 8) {
@@ -1653,12 +1656,15 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, · 6 unmodified lines
1653 }1656 }
1654 1657
1655 if (avccontext->sample_fmt == AV_SAMPLE_FMT_FLT)1658 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);
1657 else1661 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,
1659 vc->audio_channels);1664 vc->audio_channels);
1660 1665
1661 *data_size = out_size;1666 *got_frame_ptr = 1;
1667 *(AVFrame *)data = vc->frame;
1662 1668
1663 return buf_size;1669 return buf_size;
1664}1670}
@@ -1682,6 +1688,7 @@ AVCodec ff_vorbis_decoder = { · 17 unmodified lines
1682 .init = vorbis_decode_init,1688 .init = vorbis_decode_init,
1683 .close = vorbis_decode_close,1689 .close = vorbis_decode_close,
1684 .decode = vorbis_decode_frame,1690 .decode = vorbis_decode_frame,
1691 .capabilities = CODEC_CAP_DR1,
1685 .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),1692 .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
1686 .channel_layouts = ff_vorbis_channel_layouts,1693 .channel_layouts = ff_vorbis_channel_layouts,
1687 .sample_fmts = (const enum AVSampleFormat[]) {1694 .sample_fmts = (const enum AVSampleFormat[]) {
libavcodec/vp3.c+4−3
@@ -1335,8 +1335,8 @@ end: · 1334 unmodified lines
1335 */1335 */
1336static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)1336static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
1337{1337{
1338 int h, cy;1338 int h, cy, i;
1339 int offset[4];1339 int offset[AV_NUM_DATA_POINTERS];
1340 1340
1341 if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {1341 if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
1342 int y_flipped = s->flipped_image ? s->avctx->height-y : y;1342 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
1362 offset[0] = s->current_frame.linesize[0]*y;1362 offset[0] = s->current_frame.linesize[0]*y;
1363 offset[1] = s->current_frame.linesize[1]*cy;1363 offset[1] = s->current_frame.linesize[1]*cy;
1364 offset[2] = s->current_frame.linesize[2]*cy;1364 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;
1366 1367
1367 emms_c();1368 emms_c();
1368 s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h);1369 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
51 int ret;51 int ret;
52 if ((ret = ff_thread_get_buffer(s->avctx, f)) < 0)52 if ((ret = ff_thread_get_buffer(s->avctx, f)) < 0)
53 return ret;53 return ret;
54 if (s->num_maps_to_be_freed) {54 if (s->num_maps_to_be_freed && !s->maps_are_invalid) {
55 assert(!s->maps_are_invalid);
56 f->ref_index[0] = s->segmentation_maps[--s->num_maps_to_be_freed];55 f->ref_index[0] = s->segmentation_maps[--s->num_maps_to_be_freed];
57 } else if (!(f->ref_index[0] = av_mallocz(s->mb_width * s->mb_height))) {56 } else if (!(f->ref_index[0] = av_mallocz(s->mb_width * s->mb_height))) {
58 ff_thread_release_buffer(s->avctx, f);57 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
1568 VP8Context *s = avctx->priv_data;1567 VP8Context *s = avctx->priv_data;
1569 int ret, mb_x, mb_y, i, y, referenced;1568 int ret, mb_x, mb_y, i, y, referenced;
1570 enum AVDiscard skip_thresh;1569 enum AVDiscard skip_thresh;
1571 AVFrame *av_uninit(curframe), *prev_frame = s->framep[VP56_FRAME_CURRENT];1570 AVFrame *av_uninit(curframe), *prev_frame;
1572 1571
1573 release_queued_segmaps(s, 0);1572 release_queued_segmaps(s, 0);
1574 1573
1575 if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0)1574 if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0)
1576 return ret;1575 return ret;
1577 1576
1577 prev_frame = s->framep[VP56_FRAME_CURRENT];
1578
1578 referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT1579 referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT
1579 || s->update_altref == VP56_FRAME_CURRENT;1580 || s->update_altref == VP56_FRAME_CURRENT;
1580 1581
@@ -1815,6 +1816,7 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo · 234 unmodified lines
1815 if (s->macroblocks_base &&1816 if (s->macroblocks_base &&
1816 (s_src->mb_width != s->mb_width || s_src->mb_height != s->mb_height)) {1817 (s_src->mb_width != s->mb_width || s_src->mb_height != s->mb_height)) {
1817 free_buffers(s);1818 free_buffers(s);
1819 s->maps_are_invalid = 1;
1818 }1820 }
1819 1821
1820 s->prob[0] = s_src->prob[!s_src->update_probabilities];1822 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
115 int float_shift;115 int float_shift;
116 int float_max_exp;116 int float_max_exp;
117 WvChannel ch[2];117 WvChannel ch[2];
118 int samples_left;
119 int max_samples;
120 int pos;118 int pos;
121 SavedContext sc, extra_sc;119 SavedContext sc, extra_sc;
122} WavpackFrameContext;120} WavpackFrameContext;
@@ -125,6 +123,7 @@ typedef struct WavpackFrameContext { · 2 unmodified lines
125 123
126typedef struct WavpackContext {124typedef struct WavpackContext {
127 AVCodecContext *avctx;125 AVCodecContext *avctx;
126 AVFrame frame;
128 127
129 WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS];128 WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS];
130 int fdec_num;129 int fdec_num;
@@ -133,7 +132,6 @@ typedef struct WavpackContext { · 2 unmodified lines
133 int mkv_mode;132 int mkv_mode;
134 int block;133 int block;
135 int samples;134 int samples;
136 int samples_left;
137 int ch_offset;135 int ch_offset;
138} WavpackContext;136} WavpackContext;
139 137
@@ -485,7 +483,6 @@ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) · 345 unmodified lines
485static void wv_reset_saved_context(WavpackFrameContext *s)483static void wv_reset_saved_context(WavpackFrameContext *s)
486{484{
487 s->pos = 0;485 s->pos = 0;
488 s->samples_left = 0;
489 s->sc.crc = s->extra_sc.crc = 0xFFFFFFFF;486 s->sc.crc = s->extra_sc.crc = 0xFFFFFFFF;
490}487}
491 488
@@ -502,8 +499,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo · 10 unmodified lines
502 float *dstfl = dst;499 float *dstfl = dst;
503 const int channel_pad = s->avctx->channels - 2;500 const int channel_pad = s->avctx->channels - 2;
504 501
505 if(s->samples_left == s->samples)502 s->one = s->zero = s->zeroes = 0;
506 s->one = s->zero = s->zeroes = 0;
507 do{503 do{
508 L = wv_get_value(s, gb, 0, &last);504 L = wv_get_value(s, gb, 0, &last);
509 if(last) break;505 if(last) break;
@@ -594,13 +590,8 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo · 84 unmodified lines
594 dst16 += channel_pad;590 dst16 += channel_pad;
595 }591 }
596 count++;592 count++;
597 }while(!last && count < s->max_samples);593 } while (!last && count < s->samples);
598 594
599 if (last)
600 s->samples_left = 0;
601 else
602 s->samples_left -= count;
603 if(!s->samples_left){
604 wv_reset_saved_context(s);595 wv_reset_saved_context(s);
605 if(crc != s->CRC){596 if(crc != s->CRC){
606 av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");597 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
610 av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");601 av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
611 return -1;602 return -1;
612 }603 }
613 }else{604
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 }
622 return count * 2;605 return count * 2;
623}606}
624 607
@@ -635,8 +618,7 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void · 10 unmodified lines
635 float *dstfl = dst;618 float *dstfl = dst;
636 const int channel_stride = s->avctx->channels;619 const int channel_stride = s->avctx->channels;
637 620
638 if(s->samples_left == s->samples)621 s->one = s->zero = s->zeroes = 0;
639 s->one = s->zero = s->zeroes = 0;
640 do{622 do{
641 T = wv_get_value(s, gb, 0, &last);623 T = wv_get_value(s, gb, 0, &last);
642 S = 0;624 S = 0;
@@ -675,13 +657,8 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void · 32 unmodified lines
675 dst16 += channel_stride;657 dst16 += channel_stride;
676 }658 }
677 count++;659 count++;
678 }while(!last && count < s->max_samples);660 } while (!last && count < s->samples);
679 661
680 if (last)
681 s->samples_left = 0;
682 else
683 s->samples_left -= count;
684 if(!s->samples_left){
685 wv_reset_saved_context(s);662 wv_reset_saved_context(s);
686 if(crc != s->CRC){663 if(crc != s->CRC){
687 av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");664 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
691 av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");668 av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
692 return -1;669 return -1;
693 }670 }
694 }else{671
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 }
703 return count;672 return count;
704}673}
705 674
@@ -743,6 +712,9 @@ static av_cold int wavpack_decode_init(AVCodecContext *avctx) · 37 unmodified lines
743 712
744 s->fdec_num = 0;713 s->fdec_num = 0;
745 714
715 avcodec_get_frame_defaults(&s->frame);
716 avctx->coded_frame = &s->frame;
717
746 return 0;718 return 0;
747}719}
748 720
@@ -759,7 +731,7 @@ static av_cold int wavpack_decode_end(AVCodecContext *avctx) · 10 unmodified lines
759}731}
760 732
761static int wavpack_decode_block(AVCodecContext *avctx, int block_no,733static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
762 void *data, int *data_size,734 void *data, int *got_frame_ptr,
763 const uint8_t *buf, int buf_size)735 const uint8_t *buf, int buf_size)
764{736{
765 WavpackContext *wc = avctx->priv_data;737 WavpackContext *wc = avctx->priv_data;
@@ -774,7 +746,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 8 unmodified lines
774 int bpp, chan, chmask;746 int bpp, chan, chmask;
775 747
776 if (buf_size == 0){748 if (buf_size == 0){
777 *data_size = 0;749 *got_frame_ptr = 0;
778 return 0;750 return 0;
779 }751 }
780 752
@@ -789,18 +761,16 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 8 unmodified lines
789 return -1;761 return -1;
790 }762 }
791 763
792 if(!s->samples_left){
793 memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));764 memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
794 memset(s->ch, 0, sizeof(s->ch));765 memset(s->ch, 0, sizeof(s->ch));
795 s->extra_bits = 0;766 s->extra_bits = 0;
796 s->and = s->or = s->shift = 0;767 s->and = s->or = s->shift = 0;
797 s->got_extra_bits = 0;768 s->got_extra_bits = 0;
798 }
799 769
800 if(!wc->mkv_mode){770 if(!wc->mkv_mode){
801 s->samples = AV_RL32(buf); buf += 4;771 s->samples = AV_RL32(buf); buf += 4;
802 if(!s->samples){772 if(!s->samples){
803 *data_size = 0;773 *got_frame_ptr = 0;
804 return 0;774 return 0;
805 }775 }
806 }else{776 }else{
@@ -829,13 +799,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 22 unmodified lines
829 799
830 wc->ch_offset += 1 + s->stereo;800 wc->ch_offset += 1 + s->stereo;
831 801
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
839 // parse metadata blocks802 // parse metadata blocks
840 while(buf < buf_end){803 while(buf < buf_end){
841 id = *buf++;804 id = *buf++;
@@ -1064,7 +1027,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 222 unmodified lines
1064 }1027 }
1065 if(id & WP_IDF_ODD) buf++;1028 if(id & WP_IDF_ODD) buf++;
1066 }1029 }
1067 if(!s->samples_left){1030
1068 if(!got_terms){1031 if(!got_terms){
1069 av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n");1032 av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n");
1070 return -1;1033 return -1;
@@ -1101,16 +1064,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 30 unmodified lines
1101 s->got_extra_bits = 0;1064 s->got_extra_bits = 0;
1102 }1065 }
1103 }1066 }
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 }
1114 1067
1115 if(s->stereo_in){1068 if(s->stereo_in){
1116 if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)1069 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
1167 }1120 }
1168 }1121 }
1169 1122
1170 wc->samples_left = s->samples_left;1123 *got_frame_ptr = 1;
1171 1124
1172 return samplecount * bpp;1125 return samplecount * bpp;
1173}1126}
@@ -1181,23 +1134,40 @@ static void wavpack_decode_flush(AVCodecContext *avctx) · 7 unmodified lines
1181 wv_reset_saved_context(s->fdec[i]);1134 wv_reset_saved_context(s->fdec[i]);
1182}1135}
1183 1136
1184static int wavpack_decode_frame(AVCodecContext *avctx,1137static int wavpack_decode_frame(AVCodecContext *avctx, void *data,
1185 void *data, int *data_size,1138 int *got_frame_ptr, AVPacket *avpkt)
1186 AVPacket *avpkt)
1187{1139{
1188 WavpackContext *s = avctx->priv_data;1140 WavpackContext *s = avctx->priv_data;
1189 const uint8_t *buf = avpkt->data;1141 const uint8_t *buf = avpkt->data;
1190 int buf_size = avpkt->size;1142 int buf_size = avpkt->size;
1191 int frame_size;1143 int frame_size, ret;
1192 int samplecount = 0;1144 int samplecount = 0;
1193 1145
1194 s->block = 0;1146 s->block = 0;
1195 s->samples_left = 0;
1196 s->ch_offset = 0;1147 s->ch_offset = 0;
1197 1148
1149 /* determine number of samples */
1198 if(s->mkv_mode){1150 if(s->mkv_mode){
1199 s->samples = AV_RL32(buf); buf += 4;1151 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;
1200 }1169 }
1170
1201 while(buf_size > 0){1171 while(buf_size > 0){
1202 if(!s->multichannel){1172 if(!s->multichannel){
1203 frame_size = buf_size;1173 frame_size = buf_size;
@@ -1216,17 +1186,19 @@ static int wavpack_decode_frame(AVCodecContext *avctx, · 12 unmodified lines
1216 wavpack_decode_flush(avctx);1186 wavpack_decode_flush(avctx);
1217 return -1;1187 return -1;
1218 }1188 }
1219 if((samplecount = wavpack_decode_block(avctx, s->block, data,1189 if((samplecount = wavpack_decode_block(avctx, s->block, s->frame.data[0],
1220 data_size, buf, frame_size)) < 0) {1190 got_frame_ptr, buf, frame_size)) < 0) {
1221 wavpack_decode_flush(avctx);1191 wavpack_decode_flush(avctx);
1222 return -1;1192 return -1;
1223 }1193 }
1224 s->block++;1194 s->block++;
1225 buf += frame_size; buf_size -= frame_size;1195 buf += frame_size; buf_size -= frame_size;
1226 }1196 }
1227 *data_size = samplecount * avctx->channels;
1228 1197
1229 return s->samples_left > 0 ? 0 : avpkt->size;1198 if (*got_frame_ptr)
1199 *(AVFrame *)data = s->frame;
1200
1201 return avpkt->size;
1230}1202}
1231 1203
1232AVCodec ff_wavpack_decoder = {1204AVCodec ff_wavpack_decoder = {
@@ -1238,6 +1210,6 @@ AVCodec ff_wavpack_decoder = { · 5 unmodified lines
1238 .close = wavpack_decode_end,1210 .close = wavpack_decode_end,
1239 .decode = wavpack_decode_frame,1211 .decode = wavpack_decode_frame,
1240 .flush = wavpack_decode_flush,1212 .flush = wavpack_decode_flush,
1241 .capabilities = CODEC_CAP_SUBFRAMES,1213 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
1242 .long_name = NULL_IF_CONFIG_SMALL("WavPack"),1214 .long_name = NULL_IF_CONFIG_SMALL("WavPack"),
1243};1215};
libavcodec/wma.h+1−0
@@ -65,6 +65,7 @@ typedef struct CoefVLCTable { · 64 unmodified lines
65 65
66typedef struct WMACodecContext {66typedef struct WMACodecContext {
67 AVCodecContext* avctx;67 AVCodecContext* avctx;
68 AVFrame frame;
68 GetBitContext gb;69 GetBitContext gb;
69 PutBitContext pb;70 PutBitContext pb;
70 int sample_rate;71 int sample_rate;
libavcodec/wmadec.c+19−12
@@ -136,6 +136,10 @@ static int wma_decode_init(AVCodecContext * avctx) · 135 unmodified lines
136 }136 }
137 137
138 avctx->sample_fmt = AV_SAMPLE_FMT_S16;138 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
139
140 avcodec_get_frame_defaults(&s->frame);
141 avctx->coded_frame = &s->frame;
142
139 return 0;143 return 0;
140}144}
141 145
@@ -814,14 +818,13 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples) · 672 unmodified lines
814 return 0;818 return 0;
815}819}
816 820
817static int wma_decode_superframe(AVCodecContext *avctx,821static int wma_decode_superframe(AVCodecContext *avctx, void *data,
818 void *data, int *data_size,822 int *got_frame_ptr, AVPacket *avpkt)
819 AVPacket *avpkt)
820{823{
821 const uint8_t *buf = avpkt->data;824 const uint8_t *buf = avpkt->data;
822 int buf_size = avpkt->size;825 int buf_size = avpkt->size;
823 WMACodecContext *s = avctx->priv_data;826 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;
825 uint8_t *q;828 uint8_t *q;
826 int16_t *samples;829 int16_t *samples;
827 830
@@ -836,8 +839,6 @@ static int wma_decode_superframe(AVCodecContext *avctx, · 8 unmodified lines
836 if(s->block_align)839 if(s->block_align)
837 buf_size = s->block_align;840 buf_size = s->block_align;
838 841
839 samples = data;
840
841 init_get_bits(&s->gb, buf, buf_size*8);842 init_get_bits(&s->gb, buf, buf_size*8);
842 843
843 if (s->use_bit_reservoir) {844 if (s->use_bit_reservoir) {
@@ -848,12 +849,13 @@ static int wma_decode_superframe(AVCodecContext *avctx, · 4 unmodified lines
848 nb_frames = 1;849 nb_frames = 1;
849 }850 }
850 851
851 out_size = nb_frames * s->frame_len * s->nb_channels *852 /* get output buffer */
852 av_get_bytes_per_sample(avctx->sample_fmt);853 s->frame.nb_samples = nb_frames * s->frame_len;
853 if (*data_size < out_size) {854 if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
854 av_log(s->avctx, AV_LOG_ERROR, "Insufficient output space\n");855 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
855 goto fail;856 return ret;
856 }857 }
858 samples = (int16_t *)s->frame.data[0];
857 859
858 if (s->use_bit_reservoir) {860 if (s->use_bit_reservoir) {
859 bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3);861 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
920 }922 }
921 923
922//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);924//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
924 return buf_size;929 return buf_size;
925 fail:930 fail:
926 /* when error, we reset the bit reservoir */931 /* when error, we reset the bit reservoir */
@@ -945,6 +950,7 @@ AVCodec ff_wmav1_decoder = { · 18 unmodified lines
945 .close = ff_wma_end,950 .close = ff_wma_end,
946 .decode = wma_decode_superframe,951 .decode = wma_decode_superframe,
947 .flush = flush,952 .flush = flush,
953 .capabilities = CODEC_CAP_DR1,
948 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),954 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
949};955};
950 956
@@ -957,5 +963,6 @@ AVCodec ff_wmav2_decoder = { · 6 unmodified lines
957 .close = ff_wma_end,963 .close = ff_wma_end,
958 .decode = wma_decode_superframe,964 .decode = wma_decode_superframe,
959 .flush = flush,965 .flush = flush,
966 .capabilities = CODEC_CAP_DR1,
960 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),967 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
961};968};
libavcodec/wmaprodec.c+36−27
@@ -167,6 +167,7 @@ typedef struct { · 166 unmodified lines
167typedef struct WMAProDecodeCtx {167typedef struct WMAProDecodeCtx {
168 /* generic decoder variables */168 /* generic decoder variables */
169 AVCodecContext* avctx; ///< codec context for av_log169 AVCodecContext* avctx; ///< codec context for av_log
170 AVFrame frame; ///< AVFrame for decoded output
170 DSPContext dsp; ///< accelerated DSP functions171 DSPContext dsp; ///< accelerated DSP functions
171 FmtConvertContext fmt_conv;172 FmtConvertContext fmt_conv;
172 uint8_t frame_data[MAX_FRAMESIZE +173 uint8_t frame_data[MAX_FRAMESIZE +
@@ -209,8 +210,6 @@ typedef struct WMAProDecodeCtx { · 36 unmodified lines
209 uint32_t frame_num; ///< current frame number (not used for decoding)210 uint32_t frame_num; ///< current frame number (not used for decoding)
210 GetBitContext gb; ///< bitstream reader context211 GetBitContext gb; ///< bitstream reader context
211 int buf_bit_size; ///< buffer size in bits212 int buf_bit_size; ///< buffer size in bits
212 float* samples; ///< current samplebuffer pointer
213 float* samples_end; ///< maximum samplebuffer pointer
214 uint8_t drc_gain; ///< gain for the DRC tool213 uint8_t drc_gain; ///< gain for the DRC tool
215 int8_t skip_frame; ///< skip output step214 int8_t skip_frame; ///< skip output step
216 int8_t parsed_all_subframes; ///< all subframes decoded?215 int8_t parsed_all_subframes; ///< all subframes decoded?
@@ -453,6 +452,10 @@ static av_cold int decode_init(AVCodecContext *avctx) · 236 unmodified lines
453 dump_context(s);452 dump_context(s);
454 453
455 avctx->channel_layout = channel_mask;454 avctx->channel_layout = channel_mask;
455
456 avcodec_get_frame_defaults(&s->frame);
457 avctx->coded_frame = &s->frame;
458
456 return 0;459 return 0;
457}460}
458 461
@@ -1279,22 +1282,15 @@ static int decode_subframe(WMAProDecodeCtx *s) · 820 unmodified lines
1279 *@return 0 if the trailer bit indicates that this is the last frame,1282 *@return 0 if the trailer bit indicates that this is the last frame,
1280 * 1 if there are additional frames1283 * 1 if there are additional frames
1281 */1284 */
1282static int decode_frame(WMAProDecodeCtx *s)1285static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
1283{1286{
1287 AVCodecContext *avctx = s->avctx;
1284 GetBitContext* gb = &s->gb;1288 GetBitContext* gb = &s->gb;
1285 int more_frames = 0;1289 int more_frames = 0;
1286 int len = 0;1290 int len = 0;
1287 int i;1291 int i, ret;
1288 const float *out_ptr[WMAPRO_MAX_CHANNELS];1292 const float *out_ptr[WMAPRO_MAX_CHANNELS];
1289 1293 float *samples;
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 }
1298 1294
1299 /** get frame length */1295 /** get frame length */
1300 if (s->len_prefix)1296 if (s->len_prefix)
@@ -1360,10 +1356,19 @@ static int decode_frame(WMAProDecodeCtx *s) · 59 unmodified lines
1360 }1356 }
1361 }1357 }
1362 1358
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
1363 /** interleave samples and write them to the output buffer */1368 /** interleave samples and write them to the output buffer */
1364 for (i = 0; i < s->num_channels; i++)1369 for (i = 0; i < s->num_channels; i++)
1365 out_ptr[i] = s->channel[i].out;1370 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,
1367 s->num_channels);1372 s->num_channels);
1368 1373
1369 for (i = 0; i < s->num_channels; i++) {1374 for (i = 0; i < s->num_channels; i++) {
@@ -1375,8 +1380,10 @@ static int decode_frame(WMAProDecodeCtx *s) · 5 unmodified lines
1375 1380
1376 if (s->skip_frame) {1381 if (s->skip_frame) {
1377 s->skip_frame = 0;1382 s->skip_frame = 0;
1378 } else1383 *got_frame_ptr = 0;
1379 s->samples += s->num_channels * s->samples_per_frame;1384 } else {
1385 *got_frame_ptr = 1;
1386 }
1380 1387
1381 if (s->len_prefix) {1388 if (s->len_prefix) {
1382 if (len != (get_bits_count(gb) - s->frame_offset) + 2) {1389 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
1473 *@param avpkt input packet1480 *@param avpkt input packet
1474 *@return number of bytes that were read from the input buffer1481 *@return number of bytes that were read from the input buffer
1475 */1482 */
1476static int decode_packet(AVCodecContext *avctx,1483static int decode_packet(AVCodecContext *avctx, void *data,
1477 void *data, int *data_size, AVPacket* avpkt)1484 int *got_frame_ptr, AVPacket* avpkt)
1478{1485{
1479 WMAProDecodeCtx *s = avctx->priv_data;1486 WMAProDecodeCtx *s = avctx->priv_data;
1480 GetBitContext* gb = &s->pgb;1487 GetBitContext* gb = &s->pgb;
@@ -1483,9 +1490,7 @@ static int decode_packet(AVCodecContext *avctx, · 2 unmodified lines
1483 int num_bits_prev_frame;1490 int num_bits_prev_frame;
1484 int packet_sequence_number;1491 int packet_sequence_number;
1485 1492
1486 s->samples = data;1493 *got_frame_ptr = 0;
1487 s->samples_end = (float*)((int8_t*)data + *data_size);
1488 *data_size = 0;
1489 1494
1490 if (s->packet_done || s->packet_loss) {1495 if (s->packet_done || s->packet_loss) {
1491 s->packet_done = 0;1496 s->packet_done = 0;
@@ -1532,7 +1537,7 @@ static int decode_packet(AVCodecContext *avctx, · 40 unmodified lines
1532 1537
1533 /** decode the cross packet frame if it is valid */1538 /** decode the cross packet frame if it is valid */
1534 if (!s->packet_loss)1539 if (!s->packet_loss)
1535 decode_frame(s);1540 decode_frame(s, got_frame_ptr);
1536 } else if (s->num_saved_bits - s->frame_offset) {1541 } else if (s->num_saved_bits - s->frame_offset) {
1537 av_dlog(avctx, "ignoring %x previously saved bits\n",1542 av_dlog(avctx, "ignoring %x previously saved bits\n",
1538 s->num_saved_bits - s->frame_offset);1543 s->num_saved_bits - s->frame_offset);
@@ -1555,7 +1560,7 @@ static int decode_packet(AVCodecContext *avctx, · 16 unmodified lines
1555 (frame_size = show_bits(gb, s->log2_frame_size)) &&1560 (frame_size = show_bits(gb, s->log2_frame_size)) &&
1556 frame_size <= remaining_bits(s, gb)) {1561 frame_size <= remaining_bits(s, gb)) {
1557 save_bits(s, gb, frame_size, 0);1562 save_bits(s, gb, frame_size, 0);
1558 s->packet_done = !decode_frame(s);1563 s->packet_done = !decode_frame(s, got_frame_ptr);
1559 } else if (!s->len_prefix1564 } else if (!s->len_prefix
1560 && s->num_saved_bits > get_bits_count(&s->gb)) {1565 && s->num_saved_bits > get_bits_count(&s->gb)) {
1561 /** when the frames do not have a length prefix, we don't know1566 /** 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
1565 therefore we save the incoming packet first, then we append1570 therefore we save the incoming packet first, then we append
1566 the "previous frame" data from the next packet so that1571 the "previous frame" data from the next packet so that
1567 we get a buffer that only contains full frames */1572 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);
1569 } else1574 } else
1570 s->packet_done = 1;1575 s->packet_done = 1;
1571 }1576 }
@@ -1577,10 +1582,14 @@ static int decode_packet(AVCodecContext *avctx, · 5 unmodified lines
1577 save_bits(s, gb, remaining_bits(s, gb), 0);1582 save_bits(s, gb, remaining_bits(s, gb), 0);
1578 }1583 }
1579 1584
1580 *data_size = (int8_t *)s->samples - (int8_t *)data;
1581 s->packet_offset = get_bits_count(gb) & 7;1585 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;
1582 1591
1583 return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;1592 return get_bits_count(gb) >> 3;
1584}1593}
1585 1594
1586/**1595/**
@@ -1611,7 +1620,7 @@ AVCodec ff_wmapro_decoder = { · 24 unmodified lines
1611 .init = decode_init,1620 .init = decode_init,
1612 .close = decode_end,1621 .close = decode_end,
1613 .decode = decode_packet,1622 .decode = decode_packet,
1614 .capabilities = CODEC_CAP_SUBFRAMES,1623 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
1615 .flush= flush,1624 .flush= flush,
1616 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"),1625 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"),
1617};1626};
libavcodec/wmavoice.c+26−20
@@ -131,6 +131,7 @@ typedef struct { · 130 unmodified lines
131 * @name Global values specified in the stream header / extradata or used all over.131 * @name Global values specified in the stream header / extradata or used all over.
132 * @{132 * @{
133 */133 */
134 AVFrame frame;
134 GetBitContext gb; ///< packet bitreader. During decoder init,135 GetBitContext gb; ///< packet bitreader. During decoder init,
135 ///< it contains the extradata from the136 ///< it contains the extradata from the
136 ///< demuxer. During decoding, it contains137 ///< demuxer. During decoding, it contains
@@ -438,6 +439,9 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) · 301 unmodified lines
438 439
439 ctx->sample_fmt = AV_SAMPLE_FMT_FLT;440 ctx->sample_fmt = AV_SAMPLE_FMT_FLT;
440 441
442 avcodec_get_frame_defaults(&s->frame);
443 ctx->coded_frame = &s->frame;
444
441 return 0;445 return 0;
442}446}
443 447
@@ -1725,17 +1729,17 @@ static int check_bits_for_superframe(GetBitContext *orig_gb, · 1281 unmodified lines
1725 * @return 0 on success, <0 on error or 1 if there was not enough data to1729 * @return 0 on success, <0 on error or 1 if there was not enough data to
1726 * fully parse the superframe1730 * fully parse the superframe
1727 */1731 */
1728static int synth_superframe(AVCodecContext *ctx,1732static int synth_superframe(AVCodecContext *ctx, int *got_frame_ptr)
1729 float *samples, int *data_size)
1730{1733{
1731 WMAVoiceContext *s = ctx->priv_data;1734 WMAVoiceContext *s = ctx->priv_data;
1732 GetBitContext *gb = &s->gb, s_gb;1735 GetBitContext *gb = &s->gb, s_gb;
1733 int n, res, out_size, n_samples = 480;1736 int n, res, n_samples = 480;
1734 double lsps[MAX_FRAMES][MAX_LSPS];1737 double lsps[MAX_FRAMES][MAX_LSPS];
1735 const double *mean_lsf = s->lsps == 16 ?1738 const double *mean_lsf = s->lsps == 16 ?
1736 wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode];1739 wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode];
1737 float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12];1740 float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12];
1738 float synth[MAX_LSPS + MAX_SFRAMESIZE];1741 float synth[MAX_LSPS + MAX_SFRAMESIZE];
1742 float *samples;
1739 1743
1740 memcpy(synth, s->synth_history,1744 memcpy(synth, s->synth_history,
1741 s->lsps * sizeof(*synth));1745 s->lsps * sizeof(*synth));
@@ -1749,7 +1753,7 @@ static int synth_superframe(AVCodecContext *ctx, · 7 unmodified lines
1749 }1753 }
1750 1754
1751 if ((res = check_bits_for_superframe(gb, s)) == 1) {1755 if ((res = check_bits_for_superframe(gb, s)) == 1) {
1752 *data_size = 0;1756 *got_frame_ptr = 0;
1753 return 1;1757 return 1;
1754 }1758 }
1755 1759
@@ -1792,13 +1796,14 @@ static int synth_superframe(AVCodecContext *ctx, · 36 unmodified lines
1792 stabilize_lsps(lsps[n], s->lsps);1796 stabilize_lsps(lsps[n], s->lsps);
1793 }1797 }
1794 1798
1795 out_size = n_samples * av_get_bytes_per_sample(ctx->sample_fmt);1799 /* get output buffer */
1796 if (*data_size < out_size) {1800 s->frame.nb_samples = 480;
1797 av_log(ctx, AV_LOG_ERROR,1801 if ((res = ctx->get_buffer(ctx, &s->frame)) < 0) {
1798 "Output buffer too small (%d given - %d needed)\n",1802 av_log(ctx, AV_LOG_ERROR, "get_buffer() failed\n");
1799 *data_size, out_size);1803 return res;
1800 return -1;
1801 }1804 }
1805 s->frame.nb_samples = n_samples;
1806 samples = (float *)s->frame.data[0];
1802 1807
1803 /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */1808 /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */
1804 for (n = 0; n < 3; n++) {1809 for (n = 0; n < 3; n++) {
@@ -1820,7 +1825,7 @@ static int synth_superframe(AVCodecContext *ctx, · 15 unmodified lines
1820 lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1],1825 lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1],
1821 &excitation[s->history_nsamples + n * MAX_FRAMESIZE],1826 &excitation[s->history_nsamples + n * MAX_FRAMESIZE],
1822 &synth[s->lsps + n * MAX_FRAMESIZE]))) {1827 &synth[s->lsps + n * MAX_FRAMESIZE]))) {
1823 *data_size = 0;1828 *got_frame_ptr = 0;
1824 return res;1829 return res;
1825 }1830 }
1826 }1831 }
@@ -1833,8 +1838,7 @@ static int synth_superframe(AVCodecContext *ctx, · 6 unmodified lines
1833 skip_bits(gb, 10 * (res + 1));1838 skip_bits(gb, 10 * (res + 1));
1834 }1839 }
1835 1840
1836 /* Specify nr. of output samples */1841 *got_frame_ptr = 1;
1837 *data_size = out_size;
1838 1842
1839 /* Update history */1843 /* Update history */
1840 memcpy(s->prev_lsps, lsps[2],1844 memcpy(s->prev_lsps, lsps[2],
@@ -1922,7 +1926,7 @@ static void copy_bits(PutBitContext *pb, · 81 unmodified lines
1922 * For more information about frames, see #synth_superframe().1926 * For more information about frames, see #synth_superframe().
1923 */1927 */
1924static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,1928static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
1925 int *data_size, AVPacket *avpkt)1929 int *got_frame_ptr, AVPacket *avpkt)
1926{1930{
1927 WMAVoiceContext *s = ctx->priv_data;1931 WMAVoiceContext *s = ctx->priv_data;
1928 GetBitContext *gb = &s->gb;1932 GetBitContext *gb = &s->gb;
@@ -1935,7 +1939,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, · 6 unmodified lines
1935 * capping the packet size at ctx->block_align. */1939 * capping the packet size at ctx->block_align. */
1936 for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align);1940 for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align);
1937 if (!size) {1941 if (!size) {
1938 *data_size = 0;1942 *got_frame_ptr = 0;
1939 return 0;1943 return 0;
1940 }1944 }
1941 init_get_bits(&s->gb, avpkt->data, size << 3);1945 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
1956 copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits);1960 copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits);
1957 flush_put_bits(&s->pb);1961 flush_put_bits(&s->pb);
1958 s->sframe_cache_size += s->spillover_nbits;1962 s->sframe_cache_size += s->spillover_nbits;
1959 if ((res = synth_superframe(ctx, data, data_size)) == 0 &&1963 if ((res = synth_superframe(ctx, got_frame_ptr)) == 0 &&
1960 *data_size > 0) {1964 *got_frame_ptr) {
1961 cnt += s->spillover_nbits;1965 cnt += s->spillover_nbits;
1962 s->skip_bits_next = cnt & 7;1966 s->skip_bits_next = cnt & 7;
1967 *(AVFrame *)data = s->frame;
1963 return cnt >> 3;1968 return cnt >> 3;
1964 } else1969 } else
1965 skip_bits_long (gb, s->spillover_nbits - cnt +1970 skip_bits_long (gb, s->spillover_nbits - cnt +
@@ -1974,11 +1979,12 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, · 8 unmodified lines
1974 s->sframe_cache_size = 0;1979 s->sframe_cache_size = 0;
1975 s->skip_bits_next = 0;1980 s->skip_bits_next = 0;
1976 pos = get_bits_left(gb);1981 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) {
1978 return res;1983 return res;
1979 } else if (*data_size > 0) {1984 } else if (*got_frame_ptr) {
1980 int cnt = get_bits_count(gb);1985 int cnt = get_bits_count(gb);
1981 s->skip_bits_next = cnt & 7;1986 s->skip_bits_next = cnt & 7;
1987 *(AVFrame *)data = s->frame;
1982 return cnt >> 3;1988 return cnt >> 3;
1983 } else if ((s->sframe_cache_size = pos) > 0) {1989 } else if ((s->sframe_cache_size = pos) > 0) {
1984 /* rewind bit reader to start of last (incomplete) superframe... */1990 /* rewind bit reader to start of last (incomplete) superframe... */
@@ -2046,7 +2052,7 @@ AVCodec ff_wmavoice_decoder = { · 61 unmodified lines
2046 .init = wmavoice_decode_init,2052 .init = wmavoice_decode_init,
2047 .close = wmavoice_decode_end,2053 .close = wmavoice_decode_end,
2048 .decode = wmavoice_decode_packet,2054 .decode = wmavoice_decode_packet,
2049 .capabilities = CODEC_CAP_SUBFRAMES,2055 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
2050 .flush = wmavoice_flush,2056 .flush = wmavoice_flush,
2051 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),2057 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),
2052};2058};
libavcodec/ws-snd1.c+29−9
@@ -37,26 +37,37 @@ static const int8_t ws_adpcm_4bit[] = { · 36 unmodified lines
37 0, 1, 2, 3, 4, 5, 6, 837 0, 1, 2, 3, 4, 5, 6, 8
38};38};
39 39
40typedef struct WSSndContext {
41 AVFrame frame;
42} WSSndContext;
43
40static av_cold int ws_snd_decode_init(AVCodecContext *avctx)44static av_cold int ws_snd_decode_init(AVCodecContext *avctx)
41{45{
46 WSSndContext *s = avctx->priv_data;
47
42 if (avctx->channels != 1) {48 if (avctx->channels != 1) {
43 av_log_ask_for_sample(avctx, "unsupported number of channels\n");49 av_log_ask_for_sample(avctx, "unsupported number of channels\n");
44 return AVERROR(EINVAL);50 return AVERROR(EINVAL);
45 }51 }
46 52
47 avctx->sample_fmt = AV_SAMPLE_FMT_U8;53 avctx->sample_fmt = AV_SAMPLE_FMT_U8;
54
55 avcodec_get_frame_defaults(&s->frame);
56 avctx->coded_frame = &s->frame;
57
48 return 0;58 return 0;
49}59}
50 60
51static int ws_snd_decode_frame(AVCodecContext *avctx, void *data,61static int ws_snd_decode_frame(AVCodecContext *avctx, void *data,
52 int *data_size, AVPacket *avpkt)62 int *got_frame_ptr, AVPacket *avpkt)
53{63{
64 WSSndContext *s = avctx->priv_data;
54 const uint8_t *buf = avpkt->data;65 const uint8_t *buf = avpkt->data;
55 int buf_size = avpkt->size;66 int buf_size = avpkt->size;
56 67
57 int in_size, out_size;68 int in_size, out_size, ret;
58 int sample = 128;69 int sample = 128;
59 uint8_t *samples = data;70 uint8_t *samples;
60 uint8_t *samples_end;71 uint8_t *samples_end;
61 72
62 if (!buf_size)73 if (!buf_size)
@@ -71,19 +82,24 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, void *data, · 8 unmodified lines
71 in_size = AV_RL16(&buf[2]);82 in_size = AV_RL16(&buf[2]);
72 buf += 4;83 buf += 4;
73 84
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 }
78 if (in_size > buf_size) {85 if (in_size > buf_size) {
79 av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n");86 av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n");
80 return -1;87 return -1;
81 }88 }
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];
82 samples_end = samples + out_size;97 samples_end = samples + out_size;
83 98
84 if (in_size == out_size) {99 if (in_size == out_size) {
85 memcpy(samples, buf, out_size);100 memcpy(samples, buf, out_size);
86 *data_size = out_size;101 *got_frame_ptr = 1;
102 *(AVFrame *)data = s->frame;
87 return buf_size;103 return buf_size;
88 }104 }
89 105
@@ -159,7 +175,9 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, void *data, · 69 unmodified lines
159 }175 }
160 }176 }
161 177
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;
163 181
164 return buf_size;182 return buf_size;
165}183}
@@ -168,7 +186,9 @@ AVCodec ff_ws_snd1_decoder = { · 2 unmodified lines
168 .name = "ws_snd1",186 .name = "ws_snd1",
169 .type = AVMEDIA_TYPE_AUDIO,187 .type = AVMEDIA_TYPE_AUDIO,
170 .id = CODEC_ID_WESTWOOD_SND1,188 .id = CODEC_ID_WESTWOOD_SND1,
189 .priv_data_size = sizeof(WSSndContext),
171 .init = ws_snd_decode_init,190 .init = ws_snd_decode_init,
172 .decode = ws_snd_decode_frame,191 .decode = ws_snd_decode_frame,
192 .capabilities = CODEC_CAP_DR1,
173 .long_name = NULL_IF_CONFIG_SMALL("Westwood Audio (SND1)"),193 .long_name = NULL_IF_CONFIG_SMALL("Westwood Audio (SND1)"),
174};194};
libavformat/adtsenc.c+1−1
@@ -37,7 +37,7 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf · 36 unmodified lines
37 int off;37 int off;
38 38
39 init_get_bits(&gb, buf, size * 8);39 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);
41 if (off < 0)41 if (off < 0)
42 return off;42 return off;
43 skip_bits_long(&gb, off);43 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
1182 return AV_NOPTS_VALUE;1182 return AV_NOPTS_VALUE;
1183 }1183 }
1184 1184
1185 pts= pkt->dts;1185 pts = pkt->dts;
1186 1186
1187 av_free_packet(pkt);1187 av_free_packet(pkt);
1188 if(pkt->flags&AV_PKT_FLAG_KEY){1188 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
550 if (st->codec->codec_id == CODEC_ID_AAC) {550 if (st->codec->codec_id == CODEC_ID_AAC) {
551 MPEG4AudioConfig cfg;551 MPEG4AudioConfig cfg;
552 avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,552 avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
553 st->codec->extradata_size);553 st->codec->extradata_size * 8, 1);
554 st->codec->channels = cfg.channels;554 st->codec->channels = cfg.channels;
555 if (cfg.ext_sample_rate)555 if (cfg.ext_sample_rate)
556 st->codec->sample_rate = cfg.ext_sample_rate;556 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
438 if (st->codec->codec_id == CODEC_ID_AAC) {438 if (st->codec->codec_id == CODEC_ID_AAC) {
439 MPEG4AudioConfig cfg;439 MPEG4AudioConfig cfg;
440 avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,440 avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
441 st->codec->extradata_size);441 st->codec->extradata_size * 8, 1);
442 st->codec->channels = cfg.channels;442 st->codec->channels = cfg.channels;
443 if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4443 if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
444 st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];444 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
55 MPEG4AudioConfig m4ac;55 MPEG4AudioConfig m4ac;
56 56
57 init_get_bits(&gb, buf, size * 8);57 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);
59 if (ctx->off < 0)59 if (ctx->off < 0)
60 return ctx->off;60 return ctx->off;
61 skip_bits_long(&gb, ctx->off);61 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
448{448{
449 MPEG4AudioConfig mp4ac;449 MPEG4AudioConfig mp4ac;
450 450
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) {
452 av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n");453 av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n");
453 return;454 return;
454 }455 }
libavformat/nullenc.c+1−1
@@ -32,5 +32,5 @@ AVOutputFormat ff_null_muxer = { · 31 unmodified lines
32 .audio_codec = AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),32 .audio_codec = AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),
33 .video_codec = CODEC_ID_RAWVIDEO,33 .video_codec = CODEC_ID_RAWVIDEO,
34 .write_packet = null_write_packet,34 .write_packet = null_write_packet,
35 .flags = AVFMT_NOFILE | AVFMT_NOTIMESTAMPS,35 .flags = AVFMT_NOFILE | AVFMT_NOTIMESTAMPS | AVFMT_RAWPICTURE,
36};36};
libavformat/rtsp.c+3−0
@@ -1934,6 +1934,7 @@ static int rtp_read_header(AVFormatContext *s, · 1933 unmodified lines
1934 struct sockaddr_storage addr;1934 struct sockaddr_storage addr;
1935 AVIOContext pb;1935 AVIOContext pb;
1936 socklen_t addrlen = sizeof(addr);1936 socklen_t addrlen = sizeof(addr);
1937 RTSPState *rt = s->priv_data;
1937 1938
1938 if (!ff_network_init())1939 if (!ff_network_init())
1939 return AVERROR(EIO);1940 return AVERROR(EIO);
@@ -1997,6 +1998,8 @@ static int rtp_read_header(AVFormatContext *s, · 57 unmodified lines
1997 /* sdp_read_header initializes this again */1998 /* sdp_read_header initializes this again */
1998 ff_network_close();1999 ff_network_close();
1999 2000
2001 rt->media_type_mask = (1 << (AVMEDIA_TYPE_DATA+1)) - 1;
2002
2000 ret = sdp_read_header(s, ap);2003 ret = sdp_read_header(s, ap);
2001 s->pb = NULL;2004 s->pb = NULL;
2002 return ret;2005 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