* 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
Unified · Split
| @@ -1267,7 +1267,8 @@ static void do_video_out(AVFormatContext *s, · 1266 unmodified lines | ||
| 1267 | 1267 | av_init_packet(&pkt); |
| 1268 | 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 | 1272 | /* raw pictures are written as AVPicture structure to |
| 1272 | 1273 | avoid any copies. We support temporarily the older |
| 1273 | 1274 | method. */ |
| @@ -1528,7 +1529,7 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams) · 254 unmodified lines | ||
| 1528 | 1529 | |
| 1529 | 1530 | if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1) |
| 1530 | 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 | 1533 | continue; |
| 1533 | 1534 | |
| 1534 | 1535 | for(;;) { |
| @@ -22,6 +22,19 @@ API changes, most recent first: · 21 unmodified lines | ||
| 22 | 22 | 2011-10-20 - b35e9e1 - lavu 51.22.0 |
| 23 | 23 | Add av_strtok() to avstring.h. |
| 24 | 24 | |
| 25 | +2011-xx-xx - xxxxxxx - lavc 53.25.0 | |
| 26 | + Add nb_samples and extended_data fields to AVFrame. | |
| 27 | + Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE. | |
| 28 | + Deprecate avcodec_decode_audio3() in favor of avcodec_decode_audio4(). | |
| 29 | + avcodec_decode_audio4() writes output samples to an AVFrame, which allows | |
| 30 | + audio decoders to use get_buffer(). | |
| 31 | + | |
| 32 | +2011-xx-xx - xxxxxxx - lavc 53.24.0 | |
| 33 | + Change AVFrame.data[4]/base[4]/linesize[4]/error[4] to [8] at next major bump. | |
| 34 | + Change AVPicture.data[4]/linesize[4] to [8] at next major bump. | |
| 35 | + Change AVCodecContext.error[4] to [8] at next major bump. | |
| 36 | + Add AV_NUM_DATA_POINTERS to simplify the bump transition. | |
| 37 | + | |
| 25 | 38 | 2011-11-23 - bbb46f3 - lavu 51.18.0 |
| 26 | 39 | Add av_samples_get_buffer_size(), av_samples_fill_arrays(), and |
| 27 | 40 | av_samples_alloc(), to samplefmt.h. |
| @@ -53,48 +53,26 @@ and should try to fix issues their commit causes. · 52 unmodified lines | ||
| 53 | 53 | @anchor{Coding Rules} |
| 54 | 54 | @section Coding Rules |
| 55 | 55 | |
| 56 | −FFmpeg is programmed in the ISO C90 language with a few additional | |
| 57 | −features from ISO C99, namely: | |
| 58 | −@itemize @bullet | |
| 59 | −@item | |
| 60 | −the @samp{inline} keyword; | |
| 61 | −@item | |
| 62 | −@samp{//} comments; | |
| 63 | −@item | |
| 64 | −designated struct initializers (@samp{struct s x = @{ .i = 17 @};}) | |
| 65 | −@item | |
| 66 | −compound literals (@samp{x = (struct s) @{ 17, 23 @};}) | |
| 67 | −@end itemize | |
| 68 | − | |
| 69 | −These features are supported by all compilers we care about, so we will not | |
| 70 | −accept patches to remove their use unless they absolutely do not impair | |
| 71 | −clarity and performance. | |
| 56 | +@subsection Code formatting conventions | |
| 72 | 57 | |
| 73 | −All code must compile with recent versions of GCC and a number of other | |
| 74 | −currently supported compilers. To ensure compatibility, please do not use | |
| 75 | −additional C99 features or GCC extensions. Especially watch out for: | |
| 58 | +There are the following guidelines regarding the indentation in files: | |
| 76 | 59 | @itemize @bullet |
| 77 | 60 | @item |
| 78 | −mixing statements and declarations; | |
| 79 | −@item | |
| 80 | −@samp{long long} (use @samp{int64_t} instead); | |
| 81 | −@item | |
| 82 | −@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar; | |
| 83 | −@item | |
| 84 | −GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}). | |
| 85 | −@end itemize | |
| 86 | − | |
| 87 | 61 | Indent size is 4. |
| 88 | −The presentation is one inspired by 'indent -i4 -kr -nut'. | |
| 62 | +@item | |
| 89 | 63 | The TAB character is forbidden outside of Makefiles as is any |
| 90 | 64 | form of trailing whitespace. Commits containing either will be |
| 91 | 65 | rejected by the git repository. |
| 66 | +@item | |
| 67 | +You should try to limit your code lines to 80 characters; however, do so if and only if this improves readability. | |
| 68 | +@end itemize | |
| 69 | +The presentation is one inspired by 'indent -i4 -kr -nut'. | |
| 92 | 70 | |
| 93 | 71 | The main priority in FFmpeg is simplicity and small code size in order to |
| 94 | 72 | minimize the bug count. |
| 95 | 73 | |
| 96 | −Comments: Use the JavaDoc/Doxygen | |
| 97 | −format (see examples below) so that code documentation | |
| 74 | +@subsection Comments | |
| 75 | +Use the JavaDoc/Doxygen format (see examples below) so that code documentation | |
| 98 | 76 | can be generated automatically. All nontrivial functions should have a comment |
| 99 | 77 | above them explaining what the function does, even if it is just one sentence. |
| 100 | 78 | All structures and their member variables should be documented, too. |
| @@ -128,11 +106,69 @@ int myfunc(int my_parameter) · 27 unmodified lines | ||
| 128 | 106 | ... |
| 129 | 107 | @end example |
| 130 | 108 | |
| 109 | +@subsection C language features | |
| 110 | + | |
| 111 | +FFmpeg is programmed in the ISO C90 language with a few additional | |
| 112 | +features from ISO C99, namely: | |
| 113 | +@itemize @bullet | |
| 114 | +@item | |
| 115 | +the @samp{inline} keyword; | |
| 116 | +@item | |
| 117 | +@samp{//} comments; | |
| 118 | +@item | |
| 119 | +designated struct initializers (@samp{struct s x = @{ .i = 17 @};}) | |
| 120 | +@item | |
| 121 | +compound literals (@samp{x = (struct s) @{ 17, 23 @};}) | |
| 122 | +@end itemize | |
| 123 | + | |
| 124 | +These features are supported by all compilers we care about, so we will not | |
| 125 | +accept patches to remove their use unless they absolutely do not impair | |
| 126 | +clarity and performance. | |
| 127 | + | |
| 128 | +All code must compile with recent versions of GCC and a number of other | |
| 129 | +currently supported compilers. To ensure compatibility, please do not use | |
| 130 | +additional C99 features or GCC extensions. Especially watch out for: | |
| 131 | +@itemize @bullet | |
| 132 | +@item | |
| 133 | +mixing statements and declarations; | |
| 134 | +@item | |
| 135 | +@samp{long long} (use @samp{int64_t} instead); | |
| 136 | +@item | |
| 137 | +@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar; | |
| 138 | +@item | |
| 139 | +GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}). | |
| 140 | +@end itemize | |
| 141 | + | |
| 142 | +@subsection Naming conventions | |
| 143 | +All names are using underscores (_), not CamelCase. For example, @samp{avfilter_get_video_buffer} is | |
| 144 | +a valid function name and @samp{AVFilterGetVideo} is not. The only exception from this are structure names; | |
| 145 | +they should always be in the CamelCase | |
| 146 | + | |
| 147 | +There are following conventions for naming variables and functions: | |
| 148 | +@itemize @bullet | |
| 149 | +@item | |
| 150 | +For local variables no prefix is required. | |
| 151 | +@item | |
| 152 | +For variables and functions declared as @code{static} no prefixes are required. | |
| 153 | +@item | |
| 154 | +For variables and functions used internally by the library, @code{ff_} prefix should be used. | |
| 155 | +For example, @samp{ff_w64_demuxer}. | |
| 156 | +@item | |
| 157 | +For variables and functions used internally across multiple libraries, use @code{avpriv_}. For example, | |
| 158 | +@samp{avpriv_aac_parse_header}. | |
| 159 | +@item | |
| 160 | +For exported names, each library has its own prefixes. Just check the existing code and name accordingly. | |
| 161 | +@end itemize | |
| 162 | + | |
| 163 | +@subsection Miscellanous conventions | |
| 164 | +@itemize @bullet | |
| 165 | +@item | |
| 131 | 166 | fprintf and printf are forbidden in libavformat and libavcodec, |
| 132 | 167 | please use av_log() instead. |
| 133 | − | |
| 168 | +@item | |
| 134 | 169 | Casts should be used only when necessary. Unneeded parentheses |
| 135 | 170 | should also be avoided if they don't make the code easier to understand. |
| 171 | +@end itemize | |
| 136 | 172 | |
| 137 | 173 | @section Development Policy |
| 138 | 174 | |
| @@ -840,13 +840,22 @@ bash directly to work around this: · 839 unmodified lines | ||
| 840 | 840 | bash ./configure |
| 841 | 841 | @end example |
| 842 | 842 | |
| 843 | −@subsection Darwin (MacOS X, iPhone) | |
| 843 | +@anchor{Darwin} | |
| 844 | +@subsection Darwin (OSX, iPhone) | |
| 844 | 845 | |
| 845 | −MacOS X on PowerPC or ARM (iPhone) requires a preprocessor from | |
| 846 | +The toolchain provided with Xcode is sufficient to build the basic | |
| 847 | +unacelerated code. | |
| 848 | + | |
| 849 | +OSX on PowerPC or ARM (iPhone) requires a preprocessor from | |
| 846 | 850 | @url{http://github.com/yuvi/gas-preprocessor} to build the optimized |
| 847 | 851 | assembler functions. Just download the Perl script and put it somewhere |
| 848 | 852 | in your PATH, FFmpeg's configure will pick it up automatically. |
| 849 | 853 | |
| 854 | +OSX on amd64 and x86 requires @command{yasm} to build most of the | |
| 855 | +optimized assembler functions @url{http://mxcl.github.com/homebrew/, Homebrew}, | |
| 856 | +@url{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix} | |
| 857 | +or @url{http://www.macports.org, MacPorts} can easily provide it. | |
| 858 | + | |
| 850 | 859 | @section Windows |
| 851 | 860 | |
| 852 | 861 | To get help and instructions for building FFmpeg under Windows, check out |
| @@ -1295,7 +1295,8 @@ static void do_video_out(AVFormatContext *s, · 1294 unmodified lines | ||
| 1295 | 1295 | av_init_packet(&pkt); |
| 1296 | 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 | 1300 | /* raw pictures are written as AVPicture structure to |
| 1300 | 1301 | avoid any copies. We support temporarily the older |
| 1301 | 1302 | method. */ |
| @@ -1560,7 +1561,7 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams) · 258 unmodified lines | ||
| 1560 | 1561 | |
| 1561 | 1562 | if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1) |
| 1562 | 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 | 1565 | continue; |
| 1565 | 1566 | |
| 1566 | 1567 | for(;;) { |
| @@ -41,6 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | /** decoder context */ |
| 43 | 43 | typedef struct EightSvxContext { |
| 44 | + AVFrame frame; | |
| 44 | 45 | const int8_t *table; |
| 45 | 46 | |
| 46 | 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 | 100 | return dst-dst0; |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | −static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |
| 103 | − AVPacket *avpkt) | |
| 103 | +/** decode a frame */ | |
| 104 | +static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, | |
| 105 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 104 | 106 | { |
| 105 | 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 | 110 | uint8_t *src, *dst; |
| 108 | 111 | |
| 109 | 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 | 148 | memcpy(esc->samples, deinterleaved_samples, esc->samples_size); |
| 146 | 149 | } |
| 147 | 150 | |
| 148 | − /* return single packed with fixed size */ | |
| 149 | − out_data_size = FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx); | |
| 150 | − if (*data_size < out_data_size) { | |
| 151 | − av_log(avctx, AV_LOG_ERROR, "Provided buffer with size %d is too small.\n", *data_size); | |
| 152 | − return AVERROR(EINVAL); | |
| 151 | + /* get output buffer */ | |
| 152 | + esc->frame.nb_samples = (FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx) +avctx->channels-1) / avctx->channels; | |
| 153 | + if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) { | |
| 154 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 155 | + return ret; | |
| 153 | 156 | } |
| 154 | 157 | |
| 155 | − *data_size = out_data_size; | |
| 156 | − dst = data; | |
| 158 | + *got_frame_ptr = 1; | |
| 159 | + *(AVFrame *)data = esc->frame; | |
| 160 | + | |
| 161 | + dst = esc->frame.data[0]; | |
| 157 | 162 | src = esc->samples + esc->samples_idx; |
| 163 | + out_data_size = esc->frame.nb_samples * avctx->channels; | |
| 158 | 164 | for (n = out_data_size; n > 0; n--) |
| 159 | 165 | *dst++ = *src++ + 128; |
| 160 | − esc->samples_idx += *data_size; | |
| 166 | + esc->samples_idx += out_data_size; | |
| 161 | 167 | |
| 162 | 168 | return avctx->codec->id == CODEC_ID_8SVX_FIB || avctx->codec->id == CODEC_ID_8SVX_EXP ? |
| 163 | 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 | 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 | 196 | return 0; |
| 188 | 197 | } |
| 189 | 198 | |
| @@ -206,6 +215,7 @@ AVCodec ff_eightsvx_fib_decoder = { · 16 unmodified lines | ||
| 206 | 215 | .init = eightsvx_decode_init, |
| 207 | 216 | .decode = eightsvx_decode_frame, |
| 208 | 217 | .close = eightsvx_decode_close, |
| 218 | + .capabilities = CODEC_CAP_DR1, | |
| 209 | 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 | 227 | .init = eightsvx_decode_init, |
| 218 | 228 | .decode = eightsvx_decode_frame, |
| 219 | 229 | .close = eightsvx_decode_close, |
| 230 | + .capabilities = CODEC_CAP_DR1, | |
| 220 | 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 | 239 | .init = eightsvx_decode_init, |
| 229 | 240 | .close = eightsvx_decode_close, |
| 230 | 241 | .decode = eightsvx_decode_frame, |
| 242 | + .capabilities = CODEC_CAP_DR1, | |
| 231 | 243 | .long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"), |
| 232 | 244 | }; |
| @@ -251,6 +251,7 @@ typedef struct { · 250 unmodified lines | ||
| 251 | 251 | */ |
| 252 | 252 | typedef struct { |
| 253 | 253 | AVCodecContext *avctx; |
| 254 | + AVFrame frame; | |
| 254 | 255 | |
| 255 | 256 | MPEG4AudioConfig m4ac; |
| 256 | 257 | |
| @@ -471,15 +471,17 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, · 470 unmodified lines | ||
| 471 | 471 | * @param ac pointer to AACContext, may be null |
| 472 | 472 | * @param avctx pointer to AVCCodecContext, used for logging |
| 473 | 473 | * @param m4ac pointer to MPEG4AudioConfig, used for parsing |
| 474 | − * @param data pointer to AVCodecContext extradata | |
| 475 | − * @param data_size size of AVCCodecContext extradata | |
| 474 | + * @param data pointer to buffer holding an audio specific config | |
| 475 | + * @param bit_size size of audio specific config or data in bits | |
| 476 | + * @param sync_extension look for an appended sync extension | |
| 476 | 477 | * |
| 477 | 478 | * @return Returns error status or number of consumed bits. <0 - error |
| 478 | 479 | */ |
| 479 | 480 | static int decode_audio_specific_config(AACContext *ac, |
| 480 | 481 | AVCodecContext *avctx, |
| 481 | 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 | 486 | GetBitContext gb; |
| 485 | 487 | int i; |
| @@ -489,9 +491,9 @@ static int decode_audio_specific_config(AACContext *ac, · 3 unmodified lines | ||
| 489 | 491 | av_dlog(avctx, "%02x ", avctx->extradata[i]); |
| 490 | 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 | 497 | return -1; |
| 496 | 498 | if (m4ac->sampling_index > 12) { |
| 497 | 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 | 593 | if (avctx->extradata_size > 0) { |
| 592 | 594 | if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, |
| 593 | 595 | avctx->extradata, |
| 594 | − avctx->extradata_size, 8*avctx->extradata_size) < 0) | |
| 596 | + avctx->extradata_size*8, 1) < 0) | |
| 595 | 597 | return -1; |
| 596 | 598 | } else { |
| 597 | 599 | int sr, i; |
| @@ -665,6 +667,9 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) · 67 unmodified lines | ||
| 665 | 667 | |
| 666 | 668 | cbrt_tableinit(); |
| 667 | 669 | |
| 670 | + avcodec_get_frame_defaults(&ac->frame); | |
| 671 | + avctx->coded_frame = &ac->frame; | |
| 672 | + | |
| 668 | 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 | |
| 2134 | 2139 | static 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 | 2142 | AACContext *ac = avctx->priv_data; |
| 2138 | 2143 | ChannelElement *che = NULL, *che_prev = NULL; |
| 2139 | 2144 | enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; |
| 2140 | − int err, elem_id, data_size_tmp; | |
| 2145 | + int err, elem_id; | |
| 2141 | 2146 | int samples = 0, multiplier, audio_found = 0; |
| 2142 | 2147 | |
| 2143 | 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 | 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 | 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 | 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 | 2269 | samples, avctx->channels); |
| 2267 | 2270 | 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 | 2273 | samples, avctx->channels); |
| 2274 | + | |
| 2275 | + *(AVFrame *)data = ac->frame; | |
| 2270 | 2276 | } |
| 2277 | + *got_frame_ptr = !!samples; | |
| 2271 | 2278 | |
| 2272 | 2279 | if (ac->output_configured && audio_found) |
| 2273 | 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 | |
| 2278 | 2285 | static int aac_decode_frame(AVCodecContext *avctx, void *data, |
| 2279 | − int *data_size, AVPacket *avpkt) | |
| 2286 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 2280 | 2287 | { |
| 2281 | 2288 | const uint8_t *buf = avpkt->data; |
| 2282 | 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 | 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 | 2298 | return err; |
| 2292 | 2299 | |
| 2293 | 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 | ||
| 2340 | 2347 | static int latm_decode_audio_specific_config(struct LATMContext *latmctx, |
| 2341 | 2348 | GetBitContext *gb, int asclen) |
| 2342 | 2349 | { |
| 2343 | − AVCodecContext *avctx = latmctx->aac_ctx.avctx; | |
| 2344 | − AACContext *ac= &latmctx->aac_ctx; | |
| 2345 | − MPEG4AudioConfig m4ac=ac->m4ac; | |
| 2346 | − int config_start_bit = get_bits_count(gb); | |
| 2347 | − int bits_consumed, esize; | |
| 2350 | + AACContext *ac = &latmctx->aac_ctx; | |
| 2351 | + AVCodecContext *avctx = ac->avctx; | |
| 2352 | + MPEG4AudioConfig m4ac = {0}; | |
| 2353 | + int config_start_bit = get_bits_count(gb); | |
| 2354 | + int sync_extension = 0; | |
| 2355 | + int bits_consumed, esize; | |
| 2356 | + | |
| 2357 | + if (asclen) { | |
| 2358 | + sync_extension = 1; | |
| 2359 | + asclen = FFMIN(asclen, get_bits_left(gb)); | |
| 2360 | + } else | |
| 2361 | + asclen = get_bits_left(gb); | |
| 2348 | 2362 | |
| 2349 | 2363 | if (config_start_bit % 8) { |
| 2350 | 2364 | av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific " |
| 2351 | 2365 | "config not byte aligned.\n", 1); |
| 2352 | 2366 | return AVERROR_INVALIDDATA; |
| 2353 | − } else { | |
| 2354 | − bits_consumed = | |
| 2355 | − decode_audio_specific_config(ac, avctx, &m4ac, | |
| 2367 | + } | |
| 2368 | + bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac, | |
| 2356 | 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) | |
| 2360 | − return AVERROR_INVALIDDATA; | |
| 2361 | − if(ac->m4ac.sample_rate != m4ac.sample_rate || m4ac.chan_config != ac->m4ac.chan_config) | |
| 2362 | − ac->m4ac= m4ac; | |
| 2372 | + if (bits_consumed < 0) | |
| 2373 | + return AVERROR_INVALIDDATA; | |
| 2374 | + | |
| 2375 | + if (ac->m4ac.sample_rate != m4ac.sample_rate || | |
| 2376 | + ac->m4ac.chan_config != m4ac.chan_config) { | |
| 2377 | + | |
| 2378 | + av_log(avctx, AV_LOG_INFO, "audio config changed\n"); | |
| 2379 | + latmctx->initialized = 0; | |
| 2363 | 2380 | |
| 2364 | 2381 | esize = (bits_consumed+7) / 8; |
| 2365 | 2382 | |
| 2366 | − if (avctx->extradata_size <= esize) { | |
| 2383 | + if (avctx->extradata_size < esize) { | |
| 2367 | 2384 | av_free(avctx->extradata); |
| 2368 | 2385 | avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE); |
| 2369 | 2386 | if (!avctx->extradata) |
| @@ -2373,9 +2390,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 3 unmodified lines | ||
| 2373 | 2390 | avctx->extradata_size = esize; |
| 2374 | 2391 | memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize); |
| 2375 | 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 | 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 | |
| 2515 | −static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, | |
| 2516 | − AVPacket *avpkt) | |
| 2531 | +static int latm_decode_frame(AVCodecContext *avctx, void *out, | |
| 2532 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 2517 | 2533 | { |
| 2518 | 2534 | struct LATMContext *latmctx = avctx->priv_data; |
| 2519 | 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 | 2552 | if (!latmctx->initialized) { |
| 2537 | 2553 | if (!avctx->extradata) { |
| 2538 | − *out_size = 0; | |
| 2554 | + *got_frame_ptr = 0; | |
| 2539 | 2555 | return avpkt->size; |
| 2540 | 2556 | } else { |
| 2541 | 2557 | if ((err = decode_audio_specific_config( |
| 2542 | 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 | 2560 | return err; |
| 2545 | 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 | 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 | 2573 | return err; |
| 2558 | 2574 | |
| 2559 | 2575 | return muxlength; |
| @@ -2583,7 +2599,7 @@ AVCodec ff_aac_decoder = { · 23 unmodified lines | ||
| 2583 | 2599 | .sample_fmts = (const enum AVSampleFormat[]) { |
| 2584 | 2600 | 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 | 2603 | .channel_layouts = aac_channel_layout, |
| 2588 | 2604 | }; |
| 2589 | 2605 | |
| @@ -2604,7 +2620,7 @@ AVCodec ff_aac_latm_decoder = { · 14 unmodified lines | ||
| 2604 | 2620 | .sample_fmts = (const enum AVSampleFormat[]) { |
| 2605 | 2621 | 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 | 2624 | .channel_layouts = aac_channel_layout, |
| 2609 | 2625 | .flush = flush, |
| 2610 | 2626 | }; |
| @@ -208,6 +208,9 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) · 207 unmodified lines | ||
| 208 | 208 | } |
| 209 | 209 | s->downmixed = 1; |
| 210 | 210 | |
| 211 | + avcodec_get_frame_defaults(&s->frame); | |
| 212 | + avctx->coded_frame = &s->frame; | |
| 213 | + | |
| 211 | 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 | 1300 | * Decode a single AC-3 frame. |
| 1298 | 1301 | */ |
| 1299 | −static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, | |
| 1300 | − AVPacket *avpkt) | |
| 1302 | +static int ac3_decode_frame(AVCodecContext * avctx, void *data, | |
| 1303 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1301 | 1304 | { |
| 1302 | 1305 | const uint8_t *buf = avpkt->data; |
| 1303 | 1306 | int buf_size = avpkt->size; |
| 1304 | 1307 | AC3DecodeContext *s = avctx->priv_data; |
| 1305 | − float *out_samples_flt = data; | |
| 1306 | − int16_t *out_samples_s16 = data; | |
| 1307 | − int blk, ch, err; | |
| 1308 | − int data_size_orig, data_size_tmp; | |
| 1308 | + float *out_samples_flt; | |
| 1309 | + int16_t *out_samples_s16; | |
| 1310 | + int blk, ch, err, ret; | |
| 1309 | 1311 | const uint8_t *channel_map; |
| 1310 | 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 | 1324 | init_get_bits(&s->gbc, buf, buf_size * 8); |
| 1323 | 1325 | |
| 1324 | 1326 | /* parse the syncinfo */ |
| 1325 | − data_size_orig = *data_size; | |
| 1326 | − *data_size = 0; | |
| 1327 | 1327 | err = parse_frame_header(s); |
| 1328 | 1328 | |
| 1329 | 1329 | if (err) { |
| @@ -1345,6 +1345,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 15 unmodified lines | ||
| 1345 | 1345 | /* TODO: add support for substreams and dependent frames */ |
| 1346 | 1346 | if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) { |
| 1347 | 1347 | av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n"); |
| 1348 | + *got_frame_ptr = 0; | |
| 1348 | 1349 | return s->frame_size; |
| 1349 | 1350 | } else { |
| 1350 | 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 | 1407 | if (s->bitstream_mode == 0x7 && s->channels > 1) |
| 1407 | 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 | 1419 | /* decode the audio blocks */ |
| 1410 | 1420 | channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on]; |
| 1411 | 1421 | for (ch = 0; ch < s->out_channels; ch++) |
| 1412 | 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 | 1423 | for (blk = 0; blk < s->num_blocks; blk++) { |
| 1419 | 1424 | if (!err && decode_audio_block(s, blk)) { |
| 1420 | 1425 | av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n"); |
| 1421 | 1426 | err = 1; |
| 1422 | 1427 | } |
| 1423 | − | |
| 1424 | 1428 | if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { |
| 1425 | 1429 | s->fmt_conv.float_interleave(out_samples_flt, output, 256, |
| 1426 | 1430 | s->out_channels); |
| @@ -1431,8 +1435,10 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 4 unmodified lines | ||
| 1431 | 1435 | out_samples_s16 += 256 * s->out_channels; |
| 1432 | 1436 | } |
| 1433 | 1437 | } |
| 1434 | − *data_size = s->num_blocks * 256 * avctx->channels * | |
| 1435 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 1438 | + | |
| 1439 | + *got_frame_ptr = 1; | |
| 1440 | + *(AVFrame *)data = s->frame; | |
| 1441 | + | |
| 1436 | 1442 | return FFMIN(buf_size, s->frame_size); |
| 1437 | 1443 | } |
| 1438 | 1444 | |
| @@ -1477,6 +1483,7 @@ AVCodec ff_ac3_decoder = { · 38 unmodified lines | ||
| 1477 | 1483 | .init = ac3_decode_init, |
| 1478 | 1484 | .close = ac3_decode_end, |
| 1479 | 1485 | .decode = ac3_decode_frame, |
| 1486 | + .capabilities = CODEC_CAP_DR1, | |
| 1480 | 1487 | .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), |
| 1481 | 1488 | .sample_fmts = (const enum AVSampleFormat[]) { |
| 1482 | 1489 | AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
| @@ -1499,6 +1506,7 @@ AVCodec ff_eac3_decoder = { · 16 unmodified lines | ||
| 1499 | 1506 | .init = ac3_decode_init, |
| 1500 | 1507 | .close = ac3_decode_end, |
| 1501 | 1508 | .decode = ac3_decode_frame, |
| 1509 | + .capabilities = CODEC_CAP_DR1, | |
| 1502 | 1510 | .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"), |
| 1503 | 1511 | .sample_fmts = (const enum AVSampleFormat[]) { |
| 1504 | 1512 | AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
| @@ -68,6 +68,7 @@ · 67 unmodified lines | ||
| 68 | 68 | typedef struct { |
| 69 | 69 | AVClass *class; ///< class for AVOptions |
| 70 | 70 | AVCodecContext *avctx; ///< parent context |
| 71 | + AVFrame frame; ///< AVFrame for decoded output | |
| 71 | 72 | GetBitContext gbc; ///< bitstream reader |
| 72 | 73 | |
| 73 | 74 | ///@name Bit stream information |
| @@ -84,6 +84,7 @@ static const int swf_index_tables[4][16] = { · 83 unmodified lines | ||
| 84 | 84 | /* end of tables */ |
| 85 | 85 | |
| 86 | 86 | typedef struct ADPCMDecodeContext { |
| 87 | + AVFrame frame; | |
| 87 | 88 | ADPCMChannelStatus status[6]; |
| 88 | 89 | } ADPCMDecodeContext; |
| 89 | 90 | |
| @@ -124,6 +125,10 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 34 unmodified lines | ||
| 124 | 125 | break; |
| 125 | 126 | } |
| 126 | 127 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 128 | + | |
| 129 | + avcodec_get_frame_defaults(&c->frame); | |
| 130 | + avctx->coded_frame = &c->frame; | |
| 131 | + | |
| 127 | 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 | 506 | decode_top_nibble_next = 1; \ |
| 502 | 507 | } |
| 503 | 508 | |
| 504 | −static int adpcm_decode_frame(AVCodecContext *avctx, | |
| 505 | − void *data, int *data_size, | |
| 506 | − AVPacket *avpkt) | |
| 509 | +static int adpcm_decode_frame(AVCodecContext *avctx, void *data, | |
| 510 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 507 | 511 | { |
| 508 | 512 | const uint8_t *buf = avpkt->data; |
| 509 | 513 | int buf_size = avpkt->size; |
| @@ -514,7 +518,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 4 unmodified lines | ||
| 514 | 518 | const uint8_t *src; |
| 515 | 519 | int st; /* stereo */ |
| 516 | 520 | int count1, count2; |
| 517 | − int nb_samples, coded_samples, out_bps, out_size; | |
| 521 | + int nb_samples, coded_samples, ret; | |
| 518 | 522 | |
| 519 | 523 | nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples); |
| 520 | 524 | if (nb_samples <= 0) { |
| @@ -522,22 +526,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 1 unmodified line | ||
| 522 | 526 | return AVERROR_INVALIDDATA; |
| 523 | 527 | } |
| 524 | 528 | |
| 525 | − out_bps = av_get_bytes_per_sample(avctx->sample_fmt); | |
| 526 | − out_size = nb_samples * avctx->channels * out_bps; | |
| 527 | − if (*data_size < out_size) { | |
| 528 | − av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); | |
| 529 | − return AVERROR(EINVAL); | |
| 529 | + /* get output buffer */ | |
| 530 | + c->frame.nb_samples = nb_samples; | |
| 531 | + if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { | |
| 532 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 533 | + return ret; | |
| 530 | 534 | } |
| 535 | + samples = (short *)c->frame.data[0]; | |
| 536 | + | |
| 531 | 537 | /* use coded_samples when applicable */ |
| 532 | 538 | /* it is always <= nb_samples, so the output buffer will be large enough */ |
| 533 | 539 | if (coded_samples) { |
| 534 | 540 | if (coded_samples != nb_samples) |
| 535 | 541 | av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n"); |
| 536 | − nb_samples = coded_samples; | |
| 537 | − out_size = nb_samples * avctx->channels * out_bps; | |
| 542 | + c->frame.nb_samples = nb_samples = coded_samples; | |
| 538 | 543 | } |
| 539 | 544 | |
| 540 | − samples = data; | |
| 541 | 545 | src = buf; |
| 542 | 546 | |
| 543 | 547 | st = avctx->channels == 2 ? 1 : 0; |
| @@ -576,7 +580,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 32 unmodified lines | ||
| 576 | 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 | 585 | for (m = 0; m < 32; m++) { |
| 582 | 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 | 634 | for (i = 0; i < avctx->channels; i++) { |
| 631 | − samples = (short*)data + i; | |
| 635 | + samples = (short *)c->frame.data[0] + i; | |
| 632 | 636 | cs = &c->status[i]; |
| 633 | 637 | for (n = nb_samples >> 1; n > 0; n--, src++) { |
| 634 | 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 | 973 | src = src_end; |
| 970 | 974 | break; |
| 971 | 975 | } |
| @@ -1144,7 +1148,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 172 unmodified lines | ||
| 1144 | 1148 | prev[0][i] = (int16_t)bytestream_get_be16(&src); |
| 1145 | 1149 | |
| 1146 | 1150 | for (ch = 0; ch <= st; ch++) { |
| 1147 | − samples = (unsigned short *) data + ch; | |
| 1151 | + samples = (short *)c->frame.data[0] + ch; | |
| 1148 | 1152 | |
| 1149 | 1153 | /* Read in every sample for this channel. */ |
| 1150 | 1154 | for (i = 0; i < nb_samples / 14; i++) { |
| @@ -1177,7 +1181,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx, · 26 unmodified lines | ||
| 1177 | 1181 | default: |
| 1178 | 1182 | return -1; |
| 1179 | 1183 | } |
| 1180 | − *data_size = out_size; | |
| 1184 | + | |
| 1185 | + *got_frame_ptr = 1; | |
| 1186 | + *(AVFrame *)data = c->frame; | |
| 1187 | + | |
| 1181 | 1188 | return src - buf; |
| 1182 | 1189 | } |
| 1183 | 1190 | |
| @@ -1190,6 +1197,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 6 unmodified lines | ||
| 1190 | 1197 | .priv_data_size = sizeof(ADPCMDecodeContext), \ |
| 1191 | 1198 | .init = adpcm_decode_init, \ |
| 1192 | 1199 | .decode = adpcm_decode_frame, \ |
| 1200 | + .capabilities = CODEC_CAP_DR1, \ | |
| 1193 | 1201 | .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ |
| 1194 | 1202 | } |
| 1195 | 1203 | |
| @@ -40,6 +40,7 @@ typedef struct { · 39 unmodified lines | ||
| 40 | 40 | } ADXChannelState; |
| 41 | 41 | |
| 42 | 42 | typedef struct { |
| 43 | + AVFrame frame; | |
| 43 | 44 | int channels; |
| 44 | 45 | ADXChannelState prev[2]; |
| 45 | 46 | int header_parsed; |
| @@ -50,6 +50,10 @@ static av_cold int adx_decode_init(AVCodecContext *avctx) · 49 unmodified lines | ||
| 50 | 50 | c->channels = avctx->channels; |
| 51 | 51 | |
| 52 | 52 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 53 | + | |
| 54 | + avcodec_get_frame_defaults(&c->frame); | |
| 55 | + avctx->coded_frame = &c->frame; | |
| 56 | + | |
| 53 | 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 | 93 | return 0; |
| 90 | 94 | } |
| 91 | 95 | |
| 92 | −static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |
| 93 | − AVPacket *avpkt) | |
| 96 | +static int adx_decode_frame(AVCodecContext *avctx, void *data, | |
| 97 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 94 | 98 | { |
| 95 | 99 | int buf_size = avpkt->size; |
| 96 | 100 | ADXContext *c = avctx->priv_data; |
| 97 | − int16_t *samples = data; | |
| 101 | + int16_t *samples; | |
| 98 | 102 | const uint8_t *buf = avpkt->data; |
| 99 | − int num_blocks, ch; | |
| 103 | + int num_blocks, ch, ret; | |
| 100 | 104 | |
| 101 | 105 | if (c->eof) { |
| 102 | − *data_size = 0; | |
| 106 | + *got_frame_ptr = 0; | |
| 103 | 107 | return buf_size; |
| 104 | 108 | } |
| 105 | 109 | |
| 106 | − /* 18 bytes of data are expanded into 32*2 bytes of audio, | |
| 107 | − so guard against buffer overflows */ | |
| 110 | + /* calculate number of blocks in the packet */ | |
| 108 | 111 | num_blocks = buf_size / (BLOCK_SIZE * c->channels); |
| 109 | − if (num_blocks > *data_size / (BLOCK_SAMPLES * c->channels)) { | |
| 110 | − buf_size = (*data_size / (BLOCK_SAMPLES * c->channels)) * BLOCK_SIZE; | |
| 111 | − num_blocks = buf_size / (BLOCK_SIZE * c->channels); | |
| 112 | − } | |
| 113 | − if (!buf_size || buf_size % (BLOCK_SIZE * avctx->channels)) { | |
| 112 | + | |
| 113 | + /* if the packet is not an even multiple of BLOCK_SIZE, check for an EOF | |
| 114 | + packet */ | |
| 115 | + if (!num_blocks || buf_size % (BLOCK_SIZE * avctx->channels)) { | |
| 114 | 116 | if (buf_size >= 4 && (AV_RB16(buf) & 0x8000)) { |
| 115 | 117 | c->eof = 1; |
| 116 | − *data_size = 0; | |
| 118 | + *got_frame_ptr = 0; | |
| 117 | 119 | return avpkt->size; |
| 118 | 120 | } |
| 119 | 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 | 132 | while (num_blocks--) { |
| 123 | 133 | for (ch = 0; ch < c->channels; ch++) { |
| 124 | 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 | 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 | 148 | return buf - avpkt->data; |
| 137 | 149 | } |
| 138 | 150 | |
| @@ -143,5 +155,6 @@ AVCodec ff_adpcm_adx_decoder = { · 4 unmodified lines | ||
| 143 | 155 | .priv_data_size = sizeof(ADXContext), |
| 144 | 156 | .init = adx_decode_init, |
| 145 | 157 | .decode = adx_decode_frame, |
| 158 | + .capabilities = CODEC_CAP_DR1, | |
| 146 | 159 | .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), |
| 147 | 160 | }; |
| @@ -62,10 +62,10 @@ · 61 unmodified lines | ||
| 62 | 62 | typedef struct { |
| 63 | 63 | |
| 64 | 64 | AVCodecContext *avctx; |
| 65 | + AVFrame frame; | |
| 65 | 66 | GetBitContext gb; |
| 66 | 67 | |
| 67 | 68 | int numchannels; |
| 68 | − int bytespersample; | |
| 69 | 69 | |
| 70 | 70 | /* buffers */ |
| 71 | 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 | |
| 354 | −static int alac_decode_frame(AVCodecContext *avctx, | |
| 355 | − void *outbuffer, int *outputsize, | |
| 356 | − AVPacket *avpkt) | |
| 354 | +static int alac_decode_frame(AVCodecContext *avctx, void *data, | |
| 355 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 357 | 356 | { |
| 358 | 357 | const uint8_t *inbuffer = avpkt->data; |
| 359 | 358 | int input_buffer_size = avpkt->size; |
| @@ -366,7 +365,7 @@ static int alac_decode_frame(AVCodecContext *avctx, · 6 unmodified lines | ||
| 366 | 365 | int isnotcompressed; |
| 367 | 366 | uint8_t interlacing_shift; |
| 368 | 367 | uint8_t interlacing_leftweight; |
| 369 | − int i, ch; | |
| 368 | + int i, ch, ret; | |
| 370 | 369 | |
| 371 | 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 | 400 | } else |
| 402 | 401 | outputsamples = alac->setinfo_max_samples_per_frame; |
| 403 | 402 | |
| 404 | − alac->bytespersample = channels * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 405 | − | |
| 406 | − if(outputsamples > *outputsize / alac->bytespersample){ | |
| 407 | − av_log(avctx, AV_LOG_ERROR, "sample buffer too small\n"); | |
| 408 | − return -1; | |
| 403 | + /* get output buffer */ | |
| 404 | + if (outputsamples > INT32_MAX) { | |
| 405 | + av_log(avctx, AV_LOG_ERROR, "unsupported block size: %u\n", outputsamples); | |
| 406 | + return AVERROR_INVALIDDATA; | |
| 407 | + } | |
| 408 | + alac->frame.nb_samples = outputsamples; | |
| 409 | + if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) { | |
| 410 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 411 | + return ret; | |
| 409 | 412 | } |
| 410 | 413 | |
| 411 | − *outputsize = outputsamples * alac->bytespersample; | |
| 412 | 414 | readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1; |
| 413 | 415 | if (readsamplesize > MIN_CACHE_BITS) { |
| 414 | 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 | 503 | switch(alac->setinfo_sample_size) { |
| 502 | 504 | case 16: |
| 503 | 505 | if (channels == 2) { |
| 504 | − interleave_stereo_16(alac->outputsamples_buffer, outbuffer, | |
| 505 | − outputsamples); | |
| 506 | + interleave_stereo_16(alac->outputsamples_buffer, | |
| 507 | + (int16_t *)alac->frame.data[0], outputsamples); | |
| 506 | 508 | } else { |
| 509 | + int16_t *outbuffer = (int16_t *)alac->frame.data[0]; | |
| 507 | 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 | 514 | break; |
| 512 | 515 | case 24: |
| 513 | 516 | if (channels == 2) { |
| 514 | − interleave_stereo_24(alac->outputsamples_buffer, outbuffer, | |
| 515 | − outputsamples); | |
| 517 | + interleave_stereo_24(alac->outputsamples_buffer, | |
| 518 | + (int32_t *)alac->frame.data[0], outputsamples); | |
| 516 | 519 | } else { |
| 520 | + int32_t *outbuffer = (int32_t *)alac->frame.data[0]; | |
| 517 | 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 | 524 | break; |
| 521 | 525 | } |
| @@ -523,6 +527,9 @@ static int alac_decode_frame(AVCodecContext *avctx, · 1 unmodified line | ||
| 523 | 527 | if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8) |
| 524 | 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 | 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 | 644 | return ret; |
| 638 | 645 | } |
| 639 | 646 | |
| 647 | + avcodec_get_frame_defaults(&alac->frame); | |
| 648 | + avctx->coded_frame = &alac->frame; | |
| 649 | + | |
| 640 | 650 | return 0; |
| 641 | 651 | } |
| 642 | 652 | |
| @@ -648,5 +658,6 @@ AVCodec ff_alac_decoder = { · 5 unmodified lines | ||
| 648 | 658 | .init = alac_decode_init, |
| 649 | 659 | .close = alac_decode_close, |
| 650 | 660 | .decode = alac_decode_frame, |
| 661 | + .capabilities = CODEC_CAP_DR1, | |
| 651 | 662 | .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), |
| 652 | 663 | }; |
| @@ -75,20 +75,22 @@ typedef struct AlacEncodeContext { · 74 unmodified lines | ||
| 75 | 75 | } AlacEncodeContext; |
| 76 | 76 | |
| 77 | 77 | |
| 78 | −static void init_sample_buffers(AlacEncodeContext *s, const int16_t *input_samples) | |
| 78 | +static void init_sample_buffers(AlacEncodeContext *s, | |
| 79 | + const int16_t *input_samples) | |
| 79 | 80 | { |
| 80 | 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 | 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 | 86 | s->sample_buf[ch][i] = *sptr; |
| 86 | 87 | sptr += s->avctx->channels; |
| 87 | 88 | } |
| 88 | 89 | } |
| 89 | 90 | } |
| 90 | 91 | |
| 91 | −static void encode_scalar(AlacEncodeContext *s, int x, int k, int write_sample_size) | |
| 92 | +static void encode_scalar(AlacEncodeContext *s, int x, | |
| 93 | + int k, int write_sample_size) | |
| 92 | 94 | { |
| 93 | 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 | 99 | q = x / divisor; |
| 98 | 100 | r = x % divisor; |
| 99 | 101 | |
| 100 | − if(q > 8) { | |
| 102 | + if (q > 8) { | |
| 101 | 103 | // write escape code and sample value directly |
| 102 | 104 | put_bits(&s->pbctx, 9, ALAC_ESCAPE_CODE); |
| 103 | 105 | put_bits(&s->pbctx, write_sample_size, x); |
| 104 | 106 | } else { |
| 105 | − if(q) | |
| 107 | + if (q) | |
| 106 | 108 | put_bits(&s->pbctx, q, (1<<q) - 1); |
| 107 | 109 | put_bits(&s->pbctx, 1, 0); |
| 108 | 110 | |
| 109 | − if(k != 1) { | |
| 110 | − if(r > 0) | |
| 111 | + if (k != 1) { | |
| 112 | + if (r > 0) | |
| 111 | 113 | put_bits(&s->pbctx, k, r+1); |
| 112 | 114 | else |
| 113 | 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 | 167 | /* calculate sum of 2nd order residual for each channel */ |
| 166 | 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 | 170 | lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2]; |
| 169 | 171 | rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2]; |
| 170 | 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 | 184 | /* return mode with lowest score */ |
| 183 | 185 | best = 0; |
| 184 | − for(i=1; i<4; i++) { | |
| 185 | − if(score[i] < score[best]) { | |
| 186 | + for (i = 1; i < 4; i++) { | |
| 187 | + if (score[i] < score[best]) { | |
| 186 | 188 | best = i; |
| 187 | 189 | } |
| 188 | 190 | } |
| @@ -205,7 +207,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 16 unmodified lines | ||
| 205 | 207 | break; |
| 206 | 208 | |
| 207 | 209 | case ALAC_CHMODE_LEFT_SIDE: |
| 208 | − for(i=0; i<n; i++) { | |
| 210 | + for (i = 0; i < n; i++) { | |
| 209 | 211 | right[i] = left[i] - right[i]; |
| 210 | 212 | } |
| 211 | 213 | s->interlacing_leftweight = 1; |
| @@ -213,7 +215,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 1 unmodified line | ||
| 213 | 215 | break; |
| 214 | 216 | |
| 215 | 217 | case ALAC_CHMODE_RIGHT_SIDE: |
| 216 | − for(i=0; i<n; i++) { | |
| 218 | + for (i = 0; i < n; i++) { | |
| 217 | 219 | tmp = right[i]; |
| 218 | 220 | right[i] = left[i] - right[i]; |
| 219 | 221 | left[i] = tmp + (right[i] >> 31); |
| @@ -223,7 +225,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) · 3 unmodified lines | ||
| 223 | 225 | break; |
| 224 | 226 | |
| 225 | 227 | default: |
| 226 | − for(i=0; i<n; i++) { | |
| 228 | + for (i = 0; i < n; i++) { | |
| 227 | 229 | tmp = left[i]; |
| 228 | 230 | left[i] = (tmp + right[i]) >> 1; |
| 229 | 231 | right[i] = tmp - right[i]; |
| @@ -239,10 +241,10 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) · 9 unmodified lines | ||
| 239 | 241 | int i; |
| 240 | 242 | AlacLPCContext lpc = s->lpc[ch]; |
| 241 | 243 | |
| 242 | − if(lpc.lpc_order == 31) { | |
| 244 | + if (lpc.lpc_order == 31) { | |
| 243 | 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 | 248 | s->predictor_buf[i] = s->sample_buf[ch][i] - s->sample_buf[ch][i-1]; |
| 247 | 249 | |
| 248 | 250 | return; |
| @@ -250,17 +252,17 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) · 1 unmodified line | ||
| 250 | 252 | |
| 251 | 253 | // generalised linear predictor |
| 252 | 254 | |
| 253 | − if(lpc.lpc_order > 0) { | |
| 255 | + if (lpc.lpc_order > 0) { | |
| 254 | 256 | int32_t *samples = s->sample_buf[ch]; |
| 255 | 257 | int32_t *residual = s->predictor_buf; |
| 256 | 258 | |
| 257 | 259 | // generate warm-up samples |
| 258 | 260 | residual[0] = samples[0]; |
| 259 | − for(i=1;i<=lpc.lpc_order;i++) | |
| 261 | + for (i = 1; i <= lpc.lpc_order; i++) | |
| 260 | 262 | residual[i] = samples[i] - samples[i-1]; |
| 261 | 263 | |
| 262 | 264 | // 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 | 266 | int sum = 1 << (lpc.lpc_quant - 1), res_val, j; |
| 265 | 267 | |
| 266 | 268 | for (j = 0; j < lpc.lpc_order; j++) { |
| @@ -303,7 +305,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 36 unmodified lines | ||
| 303 | 305 | int sign_modifier = 0, i, k; |
| 304 | 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 | 309 | int x; |
| 308 | 310 | |
| 309 | 311 | k = av_log2((history >> 9) + 3); |
| @@ -320,15 +322,15 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 10 unmodified lines | ||
| 320 | 322 | - ((history * s->rc.history_mult) >> 9); |
| 321 | 323 | |
| 322 | 324 | sign_modifier = 0; |
| 323 | − if(x > 0xFFFF) | |
| 325 | + if (x > 0xFFFF) | |
| 324 | 326 | history = 0xFFFF; |
| 325 | 327 | |
| 326 | − if((history < 128) && (i < s->avctx->frame_size)) { | |
| 328 | + if (history < 128 && i < s->avctx->frame_size) { | |
| 327 | 329 | unsigned int block_size = 0; |
| 328 | 330 | |
| 329 | 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 | 334 | samples++; |
| 333 | 335 | i++; |
| 334 | 336 | block_size++; |
| @@ -347,12 +349,12 @@ static void write_compressed_frame(AlacEncodeContext *s) · 12 unmodified lines | ||
| 347 | 349 | { |
| 348 | 350 | int i, j; |
| 349 | 351 | |
| 350 | − if(s->avctx->channels == 2) | |
| 352 | + if (s->avctx->channels == 2) | |
| 351 | 353 | alac_stereo_decorrelation(s); |
| 352 | 354 | put_bits(&s->pbctx, 8, s->interlacing_shift); |
| 353 | 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 | 359 | calc_predictor_params(s, i); |
| 358 | 360 | |
| @@ -362,14 +364,14 @@ static void write_compressed_frame(AlacEncodeContext *s) · 3 unmodified lines | ||
| 362 | 364 | put_bits(&s->pbctx, 3, s->rc.rice_modifier); |
| 363 | 365 | put_bits(&s->pbctx, 5, s->lpc[i].lpc_order); |
| 364 | 366 | // 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 | 368 | put_sbits(&s->pbctx, 16, s->lpc[i].lpc_coeff[j]); |
| 367 | 369 | } |
| 368 | 370 | } |
| 369 | 371 | |
| 370 | 372 | // 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 | 375 | alac_linear_predictor(s, i); |
| 374 | 376 | alac_entropy_coder(s); |
| 375 | 377 | } |
| @@ -384,7 +386,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 8 unmodified lines | ||
| 384 | 386 | avctx->frame_size = DEFAULT_FRAME_SIZE; |
| 385 | 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 | 390 | av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n"); |
| 389 | 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 | 399 | // Set default compression level |
| 398 | − if(avctx->compression_level == FF_COMPRESSION_DEFAULT) | |
| 400 | + if (avctx->compression_level == FF_COMPRESSION_DEFAULT) | |
| 399 | 401 | s->compression_level = 2; |
| 400 | 402 | else |
| 401 | 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 | 418 | AV_WB8 (alac_extradata+17, avctx->bits_per_coded_sample); |
| 417 | 419 | AV_WB8 (alac_extradata+21, avctx->channels); |
| 418 | 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 bitrate | |
| 421 | + AV_WB32(alac_extradata+28, | |
| 422 | + avctx->sample_rate * avctx->channels * avctx->bits_per_coded_sample); // average bitrate | |
| 420 | 423 | AV_WB32(alac_extradata+32, avctx->sample_rate); |
| 421 | 424 | |
| 422 | 425 | // Set relevant extradata fields |
| 423 | − if(s->compression_level > 0) { | |
| 426 | + if (s->compression_level > 0) { | |
| 424 | 427 | AV_WB8(alac_extradata+18, s->rc.history_mult); |
| 425 | 428 | AV_WB8(alac_extradata+19, s->rc.initial_history); |
| 426 | 429 | AV_WB8(alac_extradata+20, s->rc.k_modifier); |
| 427 | 430 | } |
| 428 | 431 | |
| 429 | 432 | s->min_prediction_order = DEFAULT_MIN_PRED_ORDER; |
| 430 | − if(avctx->min_prediction_order >= 0) { | |
| 431 | − if(avctx->min_prediction_order < MIN_LPC_ORDER || | |
| 433 | + if (avctx->min_prediction_order >= 0) { | |
| 434 | + if (avctx->min_prediction_order < MIN_LPC_ORDER || | |
| 432 | 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 | 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 | 444 | s->max_prediction_order = DEFAULT_MAX_PRED_ORDER; |
| 441 | − if(avctx->max_prediction_order >= 0) { | |
| 442 | − if(avctx->max_prediction_order < MIN_LPC_ORDER || | |
| 443 | − avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) { | |
| 444 | − av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", avctx->max_prediction_order); | |
| 445 | + if (avctx->max_prediction_order >= 0) { | |
| 446 | + if (avctx->max_prediction_order < MIN_LPC_ORDER || | |
| 447 | + avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) { | |
| 448 | + av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", | |
| 449 | + avctx->max_prediction_order); | |
| 445 | 450 | return -1; |
| 446 | 451 | } |
| 447 | 452 | |
| 448 | 453 | s->max_prediction_order = avctx->max_prediction_order; |
| 449 | 454 | } |
| 450 | 455 | |
| 451 | − if(s->max_prediction_order < s->min_prediction_order) { | |
| 452 | − av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n", | |
| 456 | + if (s->max_prediction_order < s->min_prediction_order) { | |
| 457 | + av_log(avctx, AV_LOG_ERROR, | |
| 458 | + "invalid prediction orders: min=%d max=%d\n", | |
| 453 | 459 | s->min_prediction_order, s->max_prediction_order); |
| 454 | 460 | return -1; |
| 455 | 461 | } |
| @@ -474,12 +480,12 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 18 unmodified lines | ||
| 474 | 480 | PutBitContext *pb = &s->pbctx; |
| 475 | 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 | 484 | av_log(avctx, AV_LOG_ERROR, "input frame size exceeded\n"); |
| 479 | 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 | 489 | av_log(avctx, AV_LOG_ERROR, "buffer size is too small\n"); |
| 484 | 490 | return -1; |
| 485 | 491 | } |
| @@ -487,11 +493,11 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 1 unmodified line | ||
| 487 | 493 | verbatim: |
| 488 | 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 | 497 | // Verbatim mode |
| 492 | 498 | const int16_t *samples = data; |
| 493 | 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 | 501 | put_sbits(pb, 16, *samples++); |
| 496 | 502 | } |
| 497 | 503 | } else { |
| @@ -504,9 +510,9 @@ verbatim: · 6 unmodified lines | ||
| 504 | 510 | flush_put_bits(pb); |
| 505 | 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 | 514 | /* frame too large. use verbatim mode */ |
| 509 | − if(verbatim_flag || (s->compression_level == 0)) { | |
| 515 | + if (verbatim_flag || s->compression_level == 0) { | |
| 510 | 516 | /* still too large. must be an error. */ |
| 511 | 517 | av_log(avctx, AV_LOG_ERROR, "error encoding frame\n"); |
| 512 | 518 | return -1; |
| @@ -537,6 +543,7 @@ AVCodec ff_alac_encoder = { · 24 unmodified lines | ||
| 537 | 543 | .encode = alac_encode_frame, |
| 538 | 544 | .close = alac_encode_close, |
| 539 | 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 | 548 | .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), |
| 542 | 549 | }; |
| @@ -191,6 +191,7 @@ typedef struct { · 190 unmodified lines | ||
| 191 | 191 | |
| 192 | 192 | typedef struct { |
| 193 | 193 | AVCodecContext *avctx; |
| 194 | + AVFrame frame; | |
| 194 | 195 | ALSSpecificConfig sconf; |
| 195 | 196 | GetBitContext gb; |
| 196 | 197 | DSPContext dsp; |
| @@ -290,7 +291,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 93 unmodified lines | ||
| 290 | 291 | init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8); |
| 291 | 292 | |
| 292 | 293 | config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata, |
| 293 | − avctx->extradata_size); | |
| 294 | + avctx->extradata_size * 8, 1); | |
| 294 | 295 | |
| 295 | 296 | if (config_offset < 0) |
| 296 | 297 | return -1; |
| @@ -1415,15 +1416,14 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 1118 unmodified lines | ||
| 1415 | 1416 | |
| 1416 | 1417 | /** Decode an ALS frame. |
| 1417 | 1418 | */ |
| 1418 | −static int decode_frame(AVCodecContext *avctx, | |
| 1419 | − void *data, int *data_size, | |
| 1419 | +static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, | |
| 1420 | 1420 | AVPacket *avpkt) |
| 1421 | 1421 | { |
| 1422 | 1422 | ALSDecContext *ctx = avctx->priv_data; |
| 1423 | 1423 | ALSSpecificConfig *sconf = &ctx->sconf; |
| 1424 | 1424 | const uint8_t *buffer = avpkt->data; |
| 1425 | 1425 | int buffer_size = avpkt->size; |
| 1426 | − int invalid_frame, size; | |
| 1426 | + int invalid_frame, ret; | |
| 1427 | 1427 | unsigned int c, sample, ra_frame, bytes_read, shift; |
| 1428 | 1428 | |
| 1429 | 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 | 1449 | ctx->frame_id++; |
| 1450 | 1450 | |
| 1451 | − // check for size of decoded data | |
| 1452 | − size = ctx->cur_frame_length * avctx->channels * | |
| 1453 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 1454 | − | |
| 1455 | − if (size > *data_size) { | |
| 1456 | − av_log(avctx, AV_LOG_ERROR, "Decoded data exceeds buffer size.\n"); | |
| 1457 | − return -1; | |
| 1451 | + /* get output buffer */ | |
| 1452 | + ctx->frame.nb_samples = ctx->cur_frame_length; | |
| 1453 | + if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) { | |
| 1454 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 1455 | + return ret; | |
| 1458 | 1456 | } |
| 1459 | 1457 | |
| 1460 | − *data_size = size; | |
| 1461 | − | |
| 1462 | 1458 | // transform decoded frame into output format |
| 1463 | 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 | 1462 | shift = bps - ctx->avctx->bits_per_raw_sample; \ |
| 1467 | 1463 | for (sample = 0; sample < ctx->cur_frame_length; sample++) \ |
| 1468 | 1464 | for (c = 0; c < avctx->channels; c++) \ |
| @@ -1480,7 +1476,7 @@ static int decode_frame(AVCodecContext *avctx, · 11 unmodified lines | ||
| 1480 | 1476 | int swap = HAVE_BIGENDIAN != sconf->msb_first; |
| 1481 | 1477 | |
| 1482 | 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 | 1481 | for (sample = 0; |
| 1486 | 1482 | sample < ctx->cur_frame_length * avctx->channels; |
| @@ -1501,22 +1497,25 @@ static int decode_frame(AVCodecContext *avctx, · 14 unmodified lines | ||
| 1501 | 1497 | |
| 1502 | 1498 | if (swap) { |
| 1503 | 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 | 1501 | int16_t *dest = (int16_t*) ctx->crc_buffer; |
| 1506 | 1502 | for (sample = 0; |
| 1507 | 1503 | sample < ctx->cur_frame_length * avctx->channels; |
| 1508 | 1504 | sample++) |
| 1509 | 1505 | *dest++ = av_bswap16(src[sample]); |
| 1510 | 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 | 1509 | ctx->cur_frame_length * avctx->channels); |
| 1513 | 1510 | } |
| 1514 | 1511 | crc_source = ctx->crc_buffer; |
| 1515 | 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 | 1533 | bytes_read = invalid_frame ? buffer_size : |
| 1532 | 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 | 1727 | dsputil_init(&ctx->dsp, avctx); |
| 1726 | 1728 | |
| 1729 | + avcodec_get_frame_defaults(&ctx->frame); | |
| 1730 | + avctx->coded_frame = &ctx->frame; | |
| 1731 | + | |
| 1727 | 1732 | return 0; |
| 1728 | 1733 | } |
| 1729 | 1734 | |
| @@ -1747,7 +1752,7 @@ AVCodec ff_als_decoder = { · 17 unmodified lines | ||
| 1747 | 1752 | .close = decode_end, |
| 1748 | 1753 | .decode = decode_frame, |
| 1749 | 1754 | .flush = flush, |
| 1750 | − .capabilities = CODEC_CAP_SUBFRAMES, | |
| 1755 | + .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, | |
| 1751 | 1756 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"), |
| 1752 | 1757 | }; |
| 1753 | 1758 | |
| @@ -95,6 +95,7 @@ · 94 unmodified lines | ||
| 95 | 95 | #define AMR_AGC_ALPHA 0.9 |
| 96 | 96 | |
| 97 | 97 | typedef struct AMRContext { |
| 98 | + AVFrame avframe; ///< AVFrame for decoded samples | |
| 98 | 99 | AMRNBFrame frame; ///< decoded AMR parameters (lsf coefficients, codebook indexes, etc) |
| 99 | 100 | uint8_t bad_frame_indicator; ///< bad frame ? 1 : 0 |
| 100 | 101 | enum Mode cur_frame_mode; |
| @@ -167,6 +168,9 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx) · 66 unmodified lines | ||
| 167 | 168 | for (i = 0; i < 4; i++) |
| 168 | 169 | p->prediction_error[i] = MIN_ENERGY; |
| 169 | 170 | |
| 171 | + avcodec_get_frame_defaults(&p->avframe); | |
| 172 | + avctx->coded_frame = &p->avframe; | |
| 173 | + | |
| 170 | 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 | |
| 922 | −static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |
| 923 | − AVPacket *avpkt) | |
| 926 | +static int amrnb_decode_frame(AVCodecContext *avctx, void *data, | |
| 927 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 924 | 928 | { |
| 925 | 929 | |
| 926 | 930 | AMRContext *p = avctx->priv_data; // pointer to private data |
| 927 | 931 | const uint8_t *buf = avpkt->data; |
| 928 | 932 | int buf_size = avpkt->size; |
| 929 | − float *buf_out = data; // pointer to the output data buffer | |
| 930 | − int i, subframe; | |
| 933 | + float *buf_out; // pointer to the output data buffer | |
| 934 | + int i, subframe, ret; | |
| 931 | 935 | float fixed_gain_factor; |
| 932 | 936 | AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing |
| 933 | 937 | float spare_vector[AMR_SUBFRAME_SIZE]; // extra stack space to hold result from anti-sparseness processing |
| 934 | 938 | float synth_fixed_gain; // the fixed gain that synthesis should use |
| 935 | 939 | 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 | 949 | p->cur_frame_mode = unpack_bitstream(p, buf, buf_size); |
| 938 | 950 | if (p->cur_frame_mode == MODE_DTX) { |
| 939 | 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 | 1041 | ff_weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3], |
| 1030 | 1042 | 0.84, 0.16, LP_FILTER_ORDER); |
| 1031 | 1043 | |
| 1032 | − /* report how many samples we got */ | |
| 1033 | − *data_size = AMR_BLOCK_SIZE * sizeof(float); | |
| 1044 | + *got_frame_ptr = 1; | |
| 1045 | + *(AVFrame *)data = p->avframe; | |
| 1034 | 1046 | |
| 1035 | 1047 | /* return the amount of bytes consumed if everything was OK */ |
| 1036 | 1048 | 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 | 1056 | .priv_data_size = sizeof(AMRContext), |
| 1045 | 1057 | .init = amrnb_decode_init, |
| 1046 | 1058 | .decode = amrnb_decode_frame, |
| 1059 | + .capabilities = CODEC_CAP_DR1, | |
| 1047 | 1060 | .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate NarrowBand"), |
| 1048 | 1061 | .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, |
| 1049 | 1062 | }; |
| @@ -41,6 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #include "amrwbdata.h" |
| 42 | 42 | |
| 43 | 43 | typedef struct { |
| 44 | + AVFrame avframe; ///< AVFrame for decoded samples | |
| 44 | 45 | AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream |
| 45 | 46 | enum Mode fr_cur_mode; ///< mode index of current frame |
| 46 | 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 | 103 | for (i = 0; i < 4; i++) |
| 103 | 104 | ctx->prediction_error[i] = MIN_ENERGY; |
| 104 | 105 | |
| 106 | + avcodec_get_frame_defaults(&ctx->avframe); | |
| 107 | + avctx->coded_frame = &ctx->avframe; | |
| 108 | + | |
| 105 | 109 | return 0; |
| 106 | 110 | } |
| 107 | 111 | |
| @@ -1062,15 +1066,15 @@ static void update_sub_state(AMRWBContext *ctx) · 954 unmodified lines | ||
| 1062 | 1066 | LP_ORDER_16k * sizeof(float)); |
| 1063 | 1067 | } |
| 1064 | 1068 | |
| 1065 | −static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |
| 1066 | − AVPacket *avpkt) | |
| 1069 | +static int amrwb_decode_frame(AVCodecContext *avctx, void *data, | |
| 1070 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1067 | 1071 | { |
| 1068 | 1072 | AMRWBContext *ctx = avctx->priv_data; |
| 1069 | 1073 | AMRWBFrame *cf = &ctx->frame; |
| 1070 | 1074 | const uint8_t *buf = avpkt->data; |
| 1071 | 1075 | int buf_size = avpkt->size; |
| 1072 | 1076 | int expected_fr_size, header_size; |
| 1073 | − float *buf_out = data; | |
| 1077 | + float *buf_out; | |
| 1074 | 1078 | float spare_vector[AMRWB_SFR_SIZE]; // extra stack space to hold result from anti-sparseness processing |
| 1075 | 1079 | float fixed_gain_factor; // fixed gain correction factor (gamma) |
| 1076 | 1080 | 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 | 1084 | float hb_exc[AMRWB_SFR_SIZE_16k]; // excitation for the high frequency band |
| 1081 | 1085 | float hb_samples[AMRWB_SFR_SIZE_16k]; // filtered high-band samples from synthesis |
| 1082 | 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 | 1097 | header_size = decode_mime_header(ctx, buf); |
| 1086 | 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 | 1100 | if (buf_size < expected_fr_size) { |
| 1089 | 1101 | av_log(avctx, AV_LOG_ERROR, |
| 1090 | 1102 | "Frame too small (%d bytes). Truncated file?\n", buf_size); |
| 1091 | − *data_size = 0; | |
| 1103 | + *got_frame_ptr = 0; | |
| 1092 | 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 | 1231 | memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0])); |
| 1220 | 1232 | memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float)); |
| 1221 | 1233 | |
| 1222 | − /* report how many samples we got */ | |
| 1223 | − *data_size = 4 * AMRWB_SFR_SIZE_16k * sizeof(float); | |
| 1234 | + *got_frame_ptr = 1; | |
| 1235 | + *(AVFrame *)data = ctx->avframe; | |
| 1224 | 1236 | |
| 1225 | 1237 | return expected_fr_size; |
| 1226 | 1238 | } |
| @@ -1232,6 +1244,7 @@ AVCodec ff_amrwb_decoder = { · 5 unmodified lines | ||
| 1232 | 1244 | .priv_data_size = sizeof(AMRWBContext), |
| 1233 | 1245 | .init = amrwb_decode_init, |
| 1234 | 1246 | .decode = amrwb_decode_frame, |
| 1247 | + .capabilities = CODEC_CAP_DR1, | |
| 1235 | 1248 | .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"), |
| 1236 | 1249 | .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, |
| 1237 | 1250 | }; |
| @@ -129,6 +129,7 @@ typedef struct APEPredictor { · 128 unmodified lines | ||
| 129 | 129 | /** Decoder context */ |
| 130 | 130 | typedef struct APEContext { |
| 131 | 131 | AVCodecContext *avctx; |
| 132 | + AVFrame frame; | |
| 132 | 133 | DSPContext dsp; |
| 133 | 134 | int channels; |
| 134 | 135 | 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 | 216 | dsputil_init(&s->dsp, avctx); |
| 216 | 217 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 217 | 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 | 223 | return 0; |
| 219 | 224 | filter_alloc_fail: |
| 220 | 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 | |
| 808 | −static int ape_decode_frame(AVCodecContext *avctx, | |
| 809 | − void *data, int *data_size, | |
| 810 | − AVPacket *avpkt) | |
| 813 | +static int ape_decode_frame(AVCodecContext *avctx, void *data, | |
| 814 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 811 | 815 | { |
| 812 | 816 | const uint8_t *buf = avpkt->data; |
| 813 | 817 | int buf_size = avpkt->size; |
| 814 | 818 | APEContext *s = avctx->priv_data; |
| 815 | − int16_t *samples = data; | |
| 816 | − int i; | |
| 817 | − int blockstodecode, out_size; | |
| 819 | + int16_t *samples; | |
| 820 | + int i, ret; | |
| 821 | + int blockstodecode; | |
| 818 | 822 | int bytes_used = 0; |
| 819 | 823 | |
| 820 | 824 | /* 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 | 830 | void *tmp_data; |
| 827 | 831 | |
| 828 | 832 | if (!buf_size) { |
| 829 | − *data_size = 0; | |
| 833 | + *got_frame_ptr = 0; | |
| 830 | 834 | return 0; |
| 831 | 835 | } |
| 832 | 836 | if (buf_size < 8) { |
| @@ -874,18 +878,19 @@ static int ape_decode_frame(AVCodecContext *avctx, · 41 unmodified lines | ||
| 874 | 878 | } |
| 875 | 879 | |
| 876 | 880 | if (!s->data) { |
| 877 | − *data_size = 0; | |
| 881 | + *got_frame_ptr = 0; | |
| 878 | 882 | return buf_size; |
| 879 | 883 | } |
| 880 | 884 | |
| 881 | 885 | blockstodecode = FFMIN(BLOCKS_PER_LOOP, s->samples); |
| 882 | 886 | |
| 883 | − out_size = blockstodecode * avctx->channels * | |
| 884 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 885 | − if (*data_size < out_size) { | |
| 886 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small.\n"); | |
| 887 | − return AVERROR(EINVAL); | |
| 887 | + /* get output buffer */ | |
| 888 | + s->frame.nb_samples = blockstodecode; | |
| 889 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 890 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 891 | + return ret; | |
| 888 | 892 | } |
| 893 | + samples = (int16_t *)s->frame.data[0]; | |
| 889 | 894 | |
| 890 | 895 | s->error=0; |
| 891 | 896 | |
| @@ -909,7 +914,9 @@ static int ape_decode_frame(AVCodecContext *avctx, · 17 unmodified lines | ||
| 909 | 914 | |
| 910 | 915 | s->samples -= blockstodecode; |
| 911 | 916 | |
| 912 | − *data_size = out_size; | |
| 917 | + *got_frame_ptr = 1; | |
| 918 | + *(AVFrame *)data = s->frame; | |
| 919 | + | |
| 913 | 920 | return bytes_used; |
| 914 | 921 | } |
| 915 | 922 | |
| @@ -927,7 +934,7 @@ AVCodec ff_ape_decoder = { · 11 unmodified lines | ||
| 927 | 934 | .init = ape_decode_init, |
| 928 | 935 | .close = ape_decode_close, |
| 929 | 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 | 938 | .flush = ape_flush, |
| 932 | 939 | .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"), |
| 933 | 940 | }; |
| @@ -19,55 +19,16 @@ · 18 unmodified lines | ||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | #include "asm.S" |
| 22 | − | |
| 23 | − .macro transpose_8x8 r0 r1 r2 r3 r4 r5 r6 r7 | |
| 24 | − vtrn.32 \r0, \r4 | |
| 25 | − vtrn.32 \r1, \r5 | |
| 26 | − vtrn.32 \r2, \r6 | |
| 27 | − vtrn.32 \r3, \r7 | |
| 28 | − vtrn.16 \r0, \r2 | |
| 29 | − vtrn.16 \r1, \r3 | |
| 30 | − vtrn.16 \r4, \r6 | |
| 31 | − vtrn.16 \r5, \r7 | |
| 32 | − vtrn.8 \r0, \r1 | |
| 33 | − vtrn.8 \r2, \r3 | |
| 34 | − vtrn.8 \r4, \r5 | |
| 35 | − vtrn.8 \r6, \r7 | |
| 36 | − .endm | |
| 37 | − | |
| 38 | − .macro transpose_4x4 r0 r1 r2 r3 | |
| 39 | − vtrn.16 \r0, \r2 | |
| 40 | − vtrn.16 \r1, \r3 | |
| 41 | − vtrn.8 \r0, \r1 | |
| 42 | − vtrn.8 \r2, \r3 | |
| 43 | − .endm | |
| 44 | − | |
| 45 | − .macro swap4 r0 r1 r2 r3 r4 r5 r6 r7 | |
| 46 | − vswp \r0, \r4 | |
| 47 | − vswp \r1, \r5 | |
| 48 | − vswp \r2, \r6 | |
| 49 | − vswp \r3, \r7 | |
| 50 | − .endm | |
| 51 | − | |
| 52 | − .macro transpose16_4x4 r0 r1 r2 r3 r4 r5 r6 r7 | |
| 53 | − vtrn.32 \r0, \r2 | |
| 54 | − vtrn.32 \r1, \r3 | |
| 55 | − vtrn.32 \r4, \r6 | |
| 56 | − vtrn.32 \r5, \r7 | |
| 57 | − vtrn.16 \r0, \r1 | |
| 58 | − vtrn.16 \r2, \r3 | |
| 59 | − vtrn.16 \r4, \r5 | |
| 60 | − vtrn.16 \r6, \r7 | |
| 61 | − .endm | |
| 22 | +#include "neon.S" | |
| 62 | 23 | |
| 63 | 24 | /* chroma_mc8(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */ |
| 64 | − .macro h264_chroma_mc8 type | |
| 25 | +.macro h264_chroma_mc8 type | |
| 65 | 26 | function ff_\type\()_h264_chroma_mc8_neon, export=1 |
| 66 | 27 | push {r4-r7, lr} |
| 67 | 28 | ldrd r4, [sp, #20] |
| 68 | −.ifc \type,avg | |
| 29 | + .ifc \type,avg | |
| 69 | 30 | mov lr, r0 |
| 70 | −.endif | |
| 31 | + .endif | |
| 71 | 32 | pld [r1] |
| 72 | 33 | pld [r1, r2] |
| 73 | 34 | |
| @@ -75,7 +36,7 @@ A muls r7, r4, r5 · 1 unmodified line | ||
| 75 | 36 | T mul r7, r4, r5 |
| 76 | 37 | T cmp r7, #0 |
| 77 | 38 | rsb r6, r7, r5, lsl #3 |
| 78 | − rsb ip, r7, r4, lsl #3 | |
| 39 | + rsb r12, r7, r4, lsl #3 | |
| 79 | 40 | sub r4, r7, r4, lsl #3 |
| 80 | 41 | sub r4, r4, r5, lsl #3 |
| 81 | 42 | add r4, r4, #64 |
| @@ -86,10 +47,10 @@ T cmp r7, #0 · 4 unmodified lines | ||
| 86 | 47 | |
| 87 | 48 | vdup.8 d0, r4 |
| 88 | 49 | lsl r4, r2, #1 |
| 89 | − vdup.8 d1, ip | |
| 90 | − vld1.64 {d4, d5}, [r1], r4 | |
| 50 | + vdup.8 d1, r12 | |
| 51 | + vld1.8 {d4, d5}, [r1], r4 | |
| 91 | 52 | vdup.8 d2, r6 |
| 92 | − vld1.64 {d6, d7}, [r5], r4 | |
| 53 | + vld1.8 {d6, d7}, [r5], r4 | |
| 93 | 54 | vdup.8 d3, r7 |
| 94 | 55 | |
| 95 | 56 | vext.8 d5, d4, d5, #1 |
| @@ -98,7 +59,7 @@ T cmp r7, #0 · 2 unmodified lines | ||
| 98 | 59 | 1: pld [r5] |
| 99 | 60 | vmull.u8 q8, d4, d0 |
| 100 | 61 | vmlal.u8 q8, d5, d1 |
| 101 | − vld1.64 {d4, d5}, [r1], r4 | |
| 62 | + vld1.8 {d4, d5}, [r1], r4 | |
| 102 | 63 | vmlal.u8 q8, d6, d2 |
| 103 | 64 | vext.8 d5, d4, d5, #1 |
| 104 | 65 | vmlal.u8 q8, d7, d3 |
| @@ -108,57 +69,57 @@ T cmp r7, #0 · 3 unmodified lines | ||
| 108 | 69 | vmlal.u8 q9, d4, d2 |
| 109 | 70 | vmlal.u8 q9, d5, d3 |
| 110 | 71 | vrshrn.u16 d16, q8, #6 |
| 111 | − vld1.64 {d6, d7}, [r5], r4 | |
| 72 | + vld1.8 {d6, d7}, [r5], r4 | |
| 112 | 73 | pld [r1] |
| 113 | 74 | vrshrn.u16 d17, q9, #6 |
| 114 | −.ifc \type,avg | |
| 115 | − vld1.64 {d20}, [lr,:64], r2 | |
| 116 | − vld1.64 {d21}, [lr,:64], r2 | |
| 75 | + .ifc \type,avg | |
| 76 | + vld1.8 {d20}, [lr,:64], r2 | |
| 77 | + vld1.8 {d21}, [lr,:64], r2 | |
| 117 | 78 | vrhadd.u8 q8, q8, q10 |
| 118 | −.endif | |
| 79 | + .endif | |
| 119 | 80 | vext.8 d7, d6, d7, #1 |
| 120 | − vst1.64 {d16}, [r0,:64], r2 | |
| 121 | − vst1.64 {d17}, [r0,:64], r2 | |
| 81 | + vst1.8 {d16}, [r0,:64], r2 | |
| 82 | + vst1.8 {d17}, [r0,:64], r2 | |
| 122 | 83 | bgt 1b |
| 123 | 84 | |
| 124 | 85 | pop {r4-r7, pc} |
| 125 | 86 | |
| 126 | 87 | 2: tst r6, r6 |
| 127 | − add ip, ip, r6 | |
| 88 | + add r12, r12, r6 | |
| 128 | 89 | vdup.8 d0, r4 |
| 129 | − vdup.8 d1, ip | |
| 90 | + vdup.8 d1, r12 | |
| 130 | 91 | |
| 131 | 92 | beq 4f |
| 132 | 93 | |
| 133 | 94 | add r5, r1, r2 |
| 134 | 95 | lsl r4, r2, #1 |
| 135 | − vld1.64 {d4}, [r1], r4 | |
| 136 | − vld1.64 {d6}, [r5], r4 | |
| 96 | + vld1.8 {d4}, [r1], r4 | |
| 97 | + vld1.8 {d6}, [r5], r4 | |
| 137 | 98 | |
| 138 | 99 | 3: pld [r5] |
| 139 | 100 | vmull.u8 q8, d4, d0 |
| 140 | 101 | vmlal.u8 q8, d6, d1 |
| 141 | − vld1.64 {d4}, [r1], r4 | |
| 102 | + vld1.8 {d4}, [r1], r4 | |
| 142 | 103 | vmull.u8 q9, d6, d0 |
| 143 | 104 | vmlal.u8 q9, d4, d1 |
| 144 | − vld1.64 {d6}, [r5], r4 | |
| 105 | + vld1.8 {d6}, [r5], r4 | |
| 145 | 106 | vrshrn.u16 d16, q8, #6 |
| 146 | 107 | vrshrn.u16 d17, q9, #6 |
| 147 | −.ifc \type,avg | |
| 148 | − vld1.64 {d20}, [lr,:64], r2 | |
| 149 | − vld1.64 {d21}, [lr,:64], r2 | |
| 108 | + .ifc \type,avg | |
| 109 | + vld1.8 {d20}, [lr,:64], r2 | |
| 110 | + vld1.8 {d21}, [lr,:64], r2 | |
| 150 | 111 | vrhadd.u8 q8, q8, q10 |
| 151 | −.endif | |
| 112 | + .endif | |
| 152 | 113 | subs r3, r3, #2 |
| 153 | 114 | pld [r1] |
| 154 | − vst1.64 {d16}, [r0,:64], r2 | |
| 155 | − vst1.64 {d17}, [r0,:64], r2 | |
| 115 | + vst1.8 {d16}, [r0,:64], r2 | |
| 116 | + vst1.8 {d17}, [r0,:64], r2 | |
| 156 | 117 | bgt 3b |
| 157 | 118 | |
| 158 | 119 | pop {r4-r7, pc} |
| 159 | 120 | |
| 160 | −4: vld1.64 {d4, d5}, [r1], r2 | |
| 161 | − vld1.64 {d6, d7}, [r1], r2 | |
| 121 | +4: vld1.8 {d4, d5}, [r1], r2 | |
| 122 | + vld1.8 {d6, d7}, [r1], r2 | |
| 162 | 123 | vext.8 d5, d4, d5, #1 |
| 163 | 124 | vext.8 d7, d6, d7, #1 |
| 164 | 125 | |
| @@ -166,36 +127,36 @@ T cmp r7, #0 · 1 unmodified line | ||
| 166 | 127 | subs r3, r3, #2 |
| 167 | 128 | vmull.u8 q8, d4, d0 |
| 168 | 129 | vmlal.u8 q8, d5, d1 |
| 169 | − vld1.64 {d4, d5}, [r1], r2 | |
| 130 | + vld1.8 {d4, d5}, [r1], r2 | |
| 170 | 131 | vmull.u8 q9, d6, d0 |
| 171 | 132 | vmlal.u8 q9, d7, d1 |
| 172 | 133 | pld [r1] |
| 173 | 134 | vext.8 d5, d4, d5, #1 |
| 174 | 135 | vrshrn.u16 d16, q8, #6 |
| 175 | 136 | vrshrn.u16 d17, q9, #6 |
| 176 | −.ifc \type,avg | |
| 177 | − vld1.64 {d20}, [lr,:64], r2 | |
| 178 | − vld1.64 {d21}, [lr,:64], r2 | |
| 137 | + .ifc \type,avg | |
| 138 | + vld1.8 {d20}, [lr,:64], r2 | |
| 139 | + vld1.8 {d21}, [lr,:64], r2 | |
| 179 | 140 | vrhadd.u8 q8, q8, q10 |
| 180 | −.endif | |
| 181 | − vld1.64 {d6, d7}, [r1], r2 | |
| 141 | + .endif | |
| 142 | + vld1.8 {d6, d7}, [r1], r2 | |
| 182 | 143 | vext.8 d7, d6, d7, #1 |
| 183 | − vst1.64 {d16}, [r0,:64], r2 | |
| 184 | − vst1.64 {d17}, [r0,:64], r2 | |
| 144 | + vst1.8 {d16}, [r0,:64], r2 | |
| 145 | + vst1.8 {d17}, [r0,:64], r2 | |
| 185 | 146 | bgt 5b |
| 186 | 147 | |
| 187 | 148 | pop {r4-r7, pc} |
| 188 | 149 | endfunc |
| 189 | − .endm | |
| 150 | +.endm | |
| 190 | 151 | |
| 191 | 152 | /* chroma_mc4(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */ |
| 192 | − .macro h264_chroma_mc4 type | |
| 153 | +.macro h264_chroma_mc4 type | |
| 193 | 154 | function ff_\type\()_h264_chroma_mc4_neon, export=1 |
| 194 | 155 | push {r4-r7, lr} |
| 195 | 156 | ldrd r4, [sp, #20] |
| 196 | −.ifc \type,avg | |
| 157 | + .ifc \type,avg | |
| 197 | 158 | mov lr, r0 |
| 198 | −.endif | |
| 159 | + .endif | |
| 199 | 160 | pld [r1] |
| 200 | 161 | pld [r1, r2] |
| 201 | 162 | |
| @@ -203,7 +164,7 @@ A muls r7, r4, r5 · 1 unmodified line | ||
| 203 | 164 | T mul r7, r4, r5 |
| 204 | 165 | T cmp r7, #0 |
| 205 | 166 | rsb r6, r7, r5, lsl #3 |
| 206 | − rsb ip, r7, r4, lsl #3 | |
| 167 | + rsb r12, r7, r4, lsl #3 | |
| 207 | 168 | sub r4, r7, r4, lsl #3 |
| 208 | 169 | sub r4, r4, r5, lsl #3 |
| 209 | 170 | add r4, r4, #64 |
| @@ -214,10 +175,10 @@ T cmp r7, #0 · 4 unmodified lines | ||
| 214 | 175 | |
| 215 | 176 | vdup.8 d0, r4 |
| 216 | 177 | lsl r4, r2, #1 |
| 217 | − vdup.8 d1, ip | |
| 218 | − vld1.64 {d4}, [r1], r4 | |
| 178 | + vdup.8 d1, r12 | |
| 179 | + vld1.8 {d4}, [r1], r4 | |
| 219 | 180 | vdup.8 d2, r6 |
| 220 | − vld1.64 {d6}, [r5], r4 | |
| 181 | + vld1.8 {d6}, [r5], r4 | |
| 221 | 182 | vdup.8 d3, r7 |
| 222 | 183 | |
| 223 | 184 | vext.8 d5, d4, d5, #1 |
| @@ -231,22 +192,22 @@ T cmp r7, #0 · 7 unmodified lines | ||
| 231 | 192 | 1: pld [r5] |
| 232 | 193 | vmull.u8 q8, d4, d0 |
| 233 | 194 | vmlal.u8 q8, d6, d2 |
| 234 | − vld1.64 {d4}, [r1], r4 | |
| 195 | + vld1.8 {d4}, [r1], r4 | |
| 235 | 196 | vext.8 d5, d4, d5, #1 |
| 236 | 197 | vtrn.32 d4, d5 |
| 237 | 198 | vmull.u8 q9, d6, d0 |
| 238 | 199 | vmlal.u8 q9, d4, d2 |
| 239 | − vld1.64 {d6}, [r5], r4 | |
| 200 | + vld1.8 {d6}, [r5], r4 | |
| 240 | 201 | vadd.i16 d16, d16, d17 |
| 241 | 202 | vadd.i16 d17, d18, d19 |
| 242 | 203 | vrshrn.u16 d16, q8, #6 |
| 243 | 204 | subs r3, r3, #2 |
| 244 | 205 | pld [r1] |
| 245 | −.ifc \type,avg | |
| 206 | + .ifc \type,avg | |
| 246 | 207 | vld1.32 {d20[0]}, [lr,:32], r2 |
| 247 | 208 | vld1.32 {d20[1]}, [lr,:32], r2 |
| 248 | 209 | vrhadd.u8 d16, d16, d20 |
| 249 | −.endif | |
| 210 | + .endif | |
| 250 | 211 | vext.8 d7, d6, d7, #1 |
| 251 | 212 | vtrn.32 d6, d7 |
| 252 | 213 | vst1.32 {d16[0]}, [r0,:32], r2 |
| @@ -256,9 +217,9 @@ T cmp r7, #0 · 3 unmodified lines | ||
| 256 | 217 | pop {r4-r7, pc} |
| 257 | 218 | |
| 258 | 219 | 2: tst r6, r6 |
| 259 | − add ip, ip, r6 | |
| 220 | + add r12, r12, r6 | |
| 260 | 221 | vdup.8 d0, r4 |
| 261 | − vdup.8 d1, ip | |
| 222 | + vdup.8 d1, r12 | |
| 262 | 223 | vtrn.32 d0, d1 |
| 263 | 224 | |
| 264 | 225 | beq 4f |
| @@ -277,11 +238,11 @@ T cmp r7, #0 · 12 unmodified lines | ||
| 277 | 238 | vadd.i16 d16, d16, d17 |
| 278 | 239 | vadd.i16 d17, d18, d19 |
| 279 | 240 | vrshrn.u16 d16, q8, #6 |
| 280 | −.ifc \type,avg | |
| 241 | + .ifc \type,avg | |
| 281 | 242 | vld1.32 {d20[0]}, [lr,:32], r2 |
| 282 | 243 | vld1.32 {d20[1]}, [lr,:32], r2 |
| 283 | 244 | vrhadd.u8 d16, d16, d20 |
| 284 | −.endif | |
| 245 | + .endif | |
| 285 | 246 | subs r3, r3, #2 |
| 286 | 247 | pld [r1] |
| 287 | 248 | vst1.32 {d16[0]}, [r0,:32], r2 |
| @@ -290,8 +251,8 @@ T cmp r7, #0 · 2 unmodified lines | ||
| 290 | 251 | |
| 291 | 252 | pop {r4-r7, pc} |
| 292 | 253 | |
| 293 | −4: vld1.64 {d4}, [r1], r2 | |
| 294 | − vld1.64 {d6}, [r1], r2 | |
| 254 | +4: vld1.8 {d4}, [r1], r2 | |
| 255 | + vld1.8 {d6}, [r1], r2 | |
| 295 | 256 | vext.8 d5, d4, d5, #1 |
| 296 | 257 | vext.8 d7, d6, d7, #1 |
| 297 | 258 | vtrn.32 d4, d5 |
| @@ -300,19 +261,19 @@ T cmp r7, #0 · 2 unmodified lines | ||
| 300 | 261 | 5: vmull.u8 q8, d4, d0 |
| 301 | 262 | vmull.u8 q9, d6, d0 |
| 302 | 263 | subs r3, r3, #2 |
| 303 | − vld1.64 {d4}, [r1], r2 | |
| 264 | + vld1.8 {d4}, [r1], r2 | |
| 304 | 265 | vext.8 d5, d4, d5, #1 |
| 305 | 266 | vtrn.32 d4, d5 |
| 306 | 267 | vadd.i16 d16, d16, d17 |
| 307 | 268 | vadd.i16 d17, d18, d19 |
| 308 | 269 | pld [r1] |
| 309 | 270 | vrshrn.u16 d16, q8, #6 |
| 310 | −.ifc \type,avg | |
| 271 | + .ifc \type,avg | |
| 311 | 272 | vld1.32 {d20[0]}, [lr,:32], r2 |
| 312 | 273 | vld1.32 {d20[1]}, [lr,:32], r2 |
| 313 | 274 | vrhadd.u8 d16, d16, d20 |
| 314 | −.endif | |
| 315 | − vld1.64 {d6}, [r1], r2 | |
| 275 | + .endif | |
| 276 | + vld1.8 {d6}, [r1], r2 | |
| 316 | 277 | vext.8 d7, d6, d7, #1 |
| 317 | 278 | vtrn.32 d6, d7 |
| 318 | 279 | pld [r1] |
| @@ -322,9 +283,9 @@ T cmp r7, #0 · 3 unmodified lines | ||
| 322 | 283 | |
| 323 | 284 | pop {r4-r7, pc} |
| 324 | 285 | endfunc |
| 325 | − .endm | |
| 286 | +.endm | |
| 326 | 287 | |
| 327 | − .macro h264_chroma_mc2 type | |
| 288 | +.macro h264_chroma_mc2 type | |
| 328 | 289 | function ff_\type\()_h264_chroma_mc2_neon, export=1 |
| 329 | 290 | push {r4-r6, lr} |
| 330 | 291 | ldr r4, [sp, #16] |
| @@ -354,29 +315,29 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 · 23 unmodified lines | ||
| 354 | 315 | vtrn.16 q2, q3 |
| 355 | 316 | vmull.u8 q8, d4, d0 |
| 356 | 317 | vmlal.u8 q8, d5, d1 |
| 357 | −.ifc \type,avg | |
| 318 | + .ifc \type,avg | |
| 358 | 319 | vld1.16 {d18[0]}, [r0,:16], r2 |
| 359 | 320 | vld1.16 {d18[1]}, [r0,:16] |
| 360 | 321 | sub r0, r0, r2 |
| 361 | −.endif | |
| 322 | + .endif | |
| 362 | 323 | vtrn.32 d16, d17 |
| 363 | 324 | vadd.i16 d16, d16, d17 |
| 364 | 325 | vrshrn.u16 d16, q8, #6 |
| 365 | −.ifc \type,avg | |
| 326 | + .ifc \type,avg | |
| 366 | 327 | vrhadd.u8 d16, d16, d18 |
| 367 | −.endif | |
| 328 | + .endif | |
| 368 | 329 | vst1.16 {d16[0]}, [r0,:16], r2 |
| 369 | 330 | vst1.16 {d16[1]}, [r0,:16], r2 |
| 370 | 331 | subs r3, r3, #2 |
| 371 | 332 | bgt 1b |
| 372 | 333 | pop {r4-r6, pc} |
| 373 | 334 | 2: |
| 374 | −.ifc \type,put | |
| 335 | + .ifc \type,put | |
| 375 | 336 | ldrh_post r5, r1, r2 |
| 376 | 337 | strh_post r5, r0, r2 |
| 377 | 338 | ldrh_post r6, r1, r2 |
| 378 | 339 | strh_post r6, r0, r2 |
| 379 | −.else | |
| 340 | + .else | |
| 380 | 341 | vld1.16 {d16[0]}, [r1], r2 |
| 381 | 342 | vld1.16 {d16[1]}, [r1], r2 |
| 382 | 343 | vld1.16 {d18[0]}, [r0,:16], r2 |
| @@ -385,7 +346,7 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 · 2 unmodified lines | ||
| 385 | 346 | vrhadd.u8 d16, d16, d18 |
| 386 | 347 | vst1.16 {d16[0]}, [r0,:16], r2 |
| 387 | 348 | vst1.16 {d16[1]}, [r0,:16], r2 |
| 388 | −.endif | |
| 349 | + .endif | |
| 389 | 350 | subs r3, r3, #2 |
| 390 | 351 | bgt 2b |
| 391 | 352 | pop {r4-r6, pc} |
| @@ -401,22 +362,22 @@ endfunc · 9 unmodified lines | ||
| 401 | 362 | |
| 402 | 363 | /* H.264 loop filter */ |
| 403 | 364 | |
| 404 | − .macro h264_loop_filter_start | |
| 405 | − ldr ip, [sp] | |
| 365 | +.macro h264_loop_filter_start | |
| 366 | + ldr r12, [sp] | |
| 406 | 367 | tst r2, r2 |
| 407 | − ldr ip, [ip] | |
| 368 | + ldr r12, [r12] | |
| 408 | 369 | it ne |
| 409 | 370 | tstne r3, r3 |
| 410 | − vmov.32 d24[0], ip | |
| 411 | − and ip, ip, ip, lsl #16 | |
| 371 | + vmov.32 d24[0], r12 | |
| 372 | + and r12, r12, r12, lsl #16 | |
| 412 | 373 | it eq |
| 413 | 374 | bxeq lr |
| 414 | − ands ip, ip, ip, lsl #8 | |
| 375 | + ands r12, r12, r12, lsl #8 | |
| 415 | 376 | it lt |
| 416 | 377 | bxlt lr |
| 417 | − .endm | |
| 378 | +.endm | |
| 418 | 379 | |
| 419 | − .macro h264_loop_filter_luma | |
| 380 | +.macro h264_loop_filter_luma | |
| 420 | 381 | vdup.8 q11, r2 @ alpha |
| 421 | 382 | vmovl.u8 q12, d24 |
| 422 | 383 | vabd.u8 q6, q8, q0 @ abs(p0 - q0) |
| @@ -482,29 +443,29 @@ endfunc · 59 unmodified lines | ||
| 482 | 443 | vqmovun.s16 d17, q6 |
| 483 | 444 | vqmovun.s16 d0, q11 |
| 484 | 445 | vqmovun.s16 d1, q12 |
| 485 | − .endm | |
| 446 | +.endm | |
| 486 | 447 | |
| 487 | 448 | function ff_h264_v_loop_filter_luma_neon, export=1 |
| 488 | 449 | h264_loop_filter_start |
| 489 | 450 | |
| 490 | − vld1.64 {d0, d1}, [r0,:128], r1 | |
| 491 | − vld1.64 {d2, d3}, [r0,:128], r1 | |
| 492 | − vld1.64 {d4, d5}, [r0,:128], r1 | |
| 451 | + vld1.8 {d0, d1}, [r0,:128], r1 | |
| 452 | + vld1.8 {d2, d3}, [r0,:128], r1 | |
| 453 | + vld1.8 {d4, d5}, [r0,:128], r1 | |
| 493 | 454 | sub r0, r0, r1, lsl #2 |
| 494 | 455 | sub r0, r0, r1, lsl #1 |
| 495 | − vld1.64 {d20,d21}, [r0,:128], r1 | |
| 496 | − vld1.64 {d18,d19}, [r0,:128], r1 | |
| 497 | − vld1.64 {d16,d17}, [r0,:128], r1 | |
| 456 | + vld1.8 {d20,d21}, [r0,:128], r1 | |
| 457 | + vld1.8 {d18,d19}, [r0,:128], r1 | |
| 458 | + vld1.8 {d16,d17}, [r0,:128], r1 | |
| 498 | 459 | |
| 499 | 460 | vpush {d8-d15} |
| 500 | 461 | |
| 501 | 462 | h264_loop_filter_luma |
| 502 | 463 | |
| 503 | 464 | sub r0, r0, r1, lsl #1 |
| 504 | − vst1.64 {d8, d9}, [r0,:128], r1 | |
| 505 | − vst1.64 {d16,d17}, [r0,:128], r1 | |
| 506 | − vst1.64 {d0, d1}, [r0,:128], r1 | |
| 507 | − vst1.64 {d10,d11}, [r0,:128] | |
| 465 | + vst1.8 {d8, d9}, [r0,:128], r1 | |
| 466 | + vst1.8 {d16,d17}, [r0,:128], r1 | |
| 467 | + vst1.8 {d0, d1}, [r0,:128], r1 | |
| 468 | + vst1.8 {d10,d11}, [r0,:128] | |
| 508 | 469 | |
| 509 | 470 | vpop {d8-d15} |
| 510 | 471 | bx lr |
| @@ -514,22 +475,22 @@ function ff_h264_h_loop_filter_luma_neon, export=1 · 3 unmodified lines | ||
| 514 | 475 | h264_loop_filter_start |
| 515 | 476 | |
| 516 | 477 | sub r0, r0, #4 |
| 517 | − vld1.64 {d6}, [r0], r1 | |
| 518 | − vld1.64 {d20}, [r0], r1 | |
| 519 | − vld1.64 {d18}, [r0], r1 | |
| 520 | − vld1.64 {d16}, [r0], r1 | |
| 521 | − vld1.64 {d0}, [r0], r1 | |
| 522 | − vld1.64 {d2}, [r0], r1 | |
| 523 | − vld1.64 {d4}, [r0], r1 | |
| 524 | − vld1.64 {d26}, [r0], r1 | |
| 525 | − vld1.64 {d7}, [r0], r1 | |
| 526 | − vld1.64 {d21}, [r0], r1 | |
| 527 | − vld1.64 {d19}, [r0], r1 | |
| 528 | − vld1.64 {d17}, [r0], r1 | |
| 529 | − vld1.64 {d1}, [r0], r1 | |
| 530 | − vld1.64 {d3}, [r0], r1 | |
| 531 | − vld1.64 {d5}, [r0], r1 | |
| 532 | − vld1.64 {d27}, [r0], r1 | |
| 478 | + vld1.8 {d6}, [r0], r1 | |
| 479 | + vld1.8 {d20}, [r0], r1 | |
| 480 | + vld1.8 {d18}, [r0], r1 | |
| 481 | + vld1.8 {d16}, [r0], r1 | |
| 482 | + vld1.8 {d0}, [r0], r1 | |
| 483 | + vld1.8 {d2}, [r0], r1 | |
| 484 | + vld1.8 {d4}, [r0], r1 | |
| 485 | + vld1.8 {d26}, [r0], r1 | |
| 486 | + vld1.8 {d7}, [r0], r1 | |
| 487 | + vld1.8 {d21}, [r0], r1 | |
| 488 | + vld1.8 {d19}, [r0], r1 | |
| 489 | + vld1.8 {d17}, [r0], r1 | |
| 490 | + vld1.8 {d1}, [r0], r1 | |
| 491 | + vld1.8 {d3}, [r0], r1 | |
| 492 | + vld1.8 {d5}, [r0], r1 | |
| 493 | + vld1.8 {d27}, [r0], r1 | |
| 533 | 494 | |
| 534 | 495 | 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 | 523 | bx lr |
| 563 | 524 | endfunc |
| 564 | 525 | |
| 565 | − .macro h264_loop_filter_chroma | |
| 526 | +.macro h264_loop_filter_chroma | |
| 566 | 527 | vdup.8 d22, r2 @ alpha |
| 567 | 528 | vmovl.u8 q12, d24 |
| 568 | 529 | vabd.u8 d26, d16, d0 @ abs(p0 - q0) |
| @@ -591,22 +552,22 @@ endfunc · 22 unmodified lines | ||
| 591 | 552 | vsubw.s8 q11, q11, d4 |
| 592 | 553 | vqmovun.s16 d16, q14 |
| 593 | 554 | vqmovun.s16 d0, q11 |
| 594 | − .endm | |
| 555 | +.endm | |
| 595 | 556 | |
| 596 | 557 | function ff_h264_v_loop_filter_chroma_neon, export=1 |
| 597 | 558 | h264_loop_filter_start |
| 598 | 559 | |
| 599 | 560 | sub r0, r0, r1, lsl #1 |
| 600 | − vld1.64 {d18}, [r0,:64], r1 | |
| 601 | − vld1.64 {d16}, [r0,:64], r1 | |
| 602 | − vld1.64 {d0}, [r0,:64], r1 | |
| 603 | − vld1.64 {d2}, [r0,:64] | |
| 561 | + vld1.8 {d18}, [r0,:64], r1 | |
| 562 | + vld1.8 {d16}, [r0,:64], r1 | |
| 563 | + vld1.8 {d0}, [r0,:64], r1 | |
| 564 | + vld1.8 {d2}, [r0,:64] | |
| 604 | 565 | |
| 605 | 566 | h264_loop_filter_chroma |
| 606 | 567 | |
| 607 | 568 | sub r0, r0, r1, lsl #1 |
| 608 | − vst1.64 {d16}, [r0,:64], r1 | |
| 609 | − vst1.64 {d0}, [r0,:64], r1 | |
| 569 | + vst1.8 {d16}, [r0,:64], r1 | |
| 570 | + vst1.8 {d0}, [r0,:64], r1 | |
| 610 | 571 | |
| 611 | 572 | bx lr |
| 612 | 573 | endfunc |
| @@ -651,20 +612,20 @@ endfunc · 38 unmodified lines | ||
| 651 | 612 | |
| 652 | 613 | /* H.264 qpel MC */ |
| 653 | 614 | |
| 654 | − .macro lowpass_const r | |
| 615 | +.macro lowpass_const r | |
| 655 | 616 | movw \r, #5 |
| 656 | 617 | movt \r, #20 |
| 657 | 618 | vmov.32 d6[0], \r |
| 658 | − .endm | |
| 619 | +.endm | |
| 659 | 620 | |
| 660 | − .macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1 | |
| 661 | −.if \narrow | |
| 621 | +.macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1 | |
| 622 | + .if \narrow | |
| 662 | 623 | t0 .req q0 |
| 663 | 624 | t1 .req q8 |
| 664 | −.else | |
| 625 | + .else | |
| 665 | 626 | t0 .req \d0 |
| 666 | 627 | t1 .req \d1 |
| 667 | −.endif | |
| 628 | + .endif | |
| 668 | 629 | vext.8 d2, \r0, \r1, #2 |
| 669 | 630 | vext.8 d3, \r0, \r1, #3 |
| 670 | 631 | vaddl.u8 q1, d2, d3 |
| @@ -685,20 +646,20 @@ endfunc · 14 unmodified lines | ||
| 685 | 646 | vaddl.u8 t1, \r2, d31 |
| 686 | 647 | vmla.i16 t1, q9, d6[1] |
| 687 | 648 | vmls.i16 t1, q10, d6[0] |
| 688 | −.if \narrow | |
| 649 | + .if \narrow | |
| 689 | 650 | vqrshrun.s16 \d0, t0, #5 |
| 690 | 651 | vqrshrun.s16 \d1, t1, #5 |
| 691 | −.endif | |
| 652 | + .endif | |
| 692 | 653 | .unreq t0 |
| 693 | 654 | .unreq t1 |
| 694 | − .endm | |
| 655 | +.endm | |
| 695 | 656 | |
| 696 | − .macro lowpass_8_1 r0, r1, d0, narrow=1 | |
| 697 | −.if \narrow | |
| 657 | +.macro lowpass_8_1 r0, r1, d0, narrow=1 | |
| 658 | + .if \narrow | |
| 698 | 659 | t0 .req q0 |
| 699 | −.else | |
| 660 | + .else | |
| 700 | 661 | t0 .req \d0 |
| 701 | −.endif | |
| 662 | + .endif | |
| 702 | 663 | vext.8 d2, \r0, \r1, #2 |
| 703 | 664 | vext.8 d3, \r0, \r1, #3 |
| 704 | 665 | vaddl.u8 q1, d2, d3 |
| @@ -709,13 +670,13 @@ endfunc · 4 unmodified lines | ||
| 709 | 670 | vaddl.u8 t0, \r0, d30 |
| 710 | 671 | vmla.i16 t0, q1, d6[1] |
| 711 | 672 | vmls.i16 t0, q2, d6[0] |
| 712 | −.if \narrow | |
| 673 | + .if \narrow | |
| 713 | 674 | vqrshrun.s16 \d0, t0, #5 |
| 714 | −.endif | |
| 675 | + .endif | |
| 715 | 676 | .unreq t0 |
| 716 | − .endm | |
| 677 | +.endm | |
| 717 | 678 | |
| 718 | − .macro lowpass_8.16 r0, r1, l0, h0, l1, h1, d | |
| 679 | +.macro lowpass_8.16 r0, r1, l0, h0, l1, h1, d | |
| 719 | 680 | vext.16 q1, \r0, \r1, #2 |
| 720 | 681 | vext.16 q0, \r0, \r1, #3 |
| 721 | 682 | vaddl.s16 q9, d2, d0 |
| @@ -750,59 +711,59 @@ endfunc · 28 unmodified lines | ||
| 750 | 711 | vrshrn.s32 d19, q1, #10 |
| 751 | 712 | |
| 752 | 713 | vqmovun.s16 \d, q9 |
| 753 | − .endm | |
| 714 | +.endm | |
| 754 | 715 | |
| 755 | 716 | function put_h264_qpel16_h_lowpass_neon_packed |
| 756 | 717 | mov r4, lr |
| 757 | − mov ip, #16 | |
| 718 | + mov r12, #16 | |
| 758 | 719 | mov r3, #8 |
| 759 | 720 | bl put_h264_qpel8_h_lowpass_neon |
| 760 | 721 | sub r1, r1, r2, lsl #4 |
| 761 | 722 | add r1, r1, #8 |
| 762 | − mov ip, #16 | |
| 723 | + mov r12, #16 | |
| 763 | 724 | mov lr, r4 |
| 764 | 725 | b put_h264_qpel8_h_lowpass_neon |
| 765 | 726 | endfunc |
| 766 | 727 | |
| 767 | − .macro h264_qpel_h_lowpass type | |
| 728 | +.macro h264_qpel_h_lowpass type | |
| 768 | 729 | function \type\()_h264_qpel16_h_lowpass_neon |
| 769 | 730 | push {lr} |
| 770 | − mov ip, #16 | |
| 731 | + mov r12, #16 | |
| 771 | 732 | bl \type\()_h264_qpel8_h_lowpass_neon |
| 772 | 733 | sub r0, r0, r3, lsl #4 |
| 773 | 734 | sub r1, r1, r2, lsl #4 |
| 774 | 735 | add r0, r0, #8 |
| 775 | 736 | add r1, r1, #8 |
| 776 | − mov ip, #16 | |
| 737 | + mov r12, #16 | |
| 777 | 738 | pop {lr} |
| 778 | 739 | endfunc |
| 779 | 740 | |
| 780 | 741 | function \type\()_h264_qpel8_h_lowpass_neon |
| 781 | −1: vld1.64 {d0, d1}, [r1], r2 | |
| 782 | − vld1.64 {d16,d17}, [r1], r2 | |
| 783 | − subs ip, ip, #2 | |
| 742 | +1: vld1.8 {d0, d1}, [r1], r2 | |
| 743 | + vld1.8 {d16,d17}, [r1], r2 | |
| 744 | + subs r12, r12, #2 | |
| 784 | 745 | lowpass_8 d0, d1, d16, d17, d0, d16 |
| 785 | −.ifc \type,avg | |
| 746 | + .ifc \type,avg | |
| 786 | 747 | vld1.8 {d2}, [r0,:64], r3 |
| 787 | 748 | vrhadd.u8 d0, d0, d2 |
| 788 | 749 | vld1.8 {d3}, [r0,:64] |
| 789 | 750 | vrhadd.u8 d16, d16, d3 |
| 790 | 751 | sub r0, r0, r3 |
| 791 | −.endif | |
| 792 | − vst1.64 {d0}, [r0,:64], r3 | |
| 793 | − vst1.64 {d16}, [r0,:64], r3 | |
| 752 | + .endif | |
| 753 | + vst1.8 {d0}, [r0,:64], r3 | |
| 754 | + vst1.8 {d16}, [r0,:64], r3 | |
| 794 | 755 | bne 1b |
| 795 | 756 | bx lr |
| 796 | 757 | endfunc |
| 797 | − .endm | |
| 758 | +.endm | |
| 798 | 759 | |
| 799 | 760 | h264_qpel_h_lowpass put |
| 800 | 761 | h264_qpel_h_lowpass avg |
| 801 | 762 | |
| 802 | − .macro h264_qpel_h_lowpass_l2 type | |
| 763 | +.macro h264_qpel_h_lowpass_l2 type | |
| 803 | 764 | function \type\()_h264_qpel16_h_lowpass_l2_neon |
| 804 | 765 | push {lr} |
| 805 | − mov ip, #16 | |
| 766 | + mov r12, #16 | |
| 806 | 767 | bl \type\()_h264_qpel8_h_lowpass_l2_neon |
| 807 | 768 | sub r0, r0, r2, lsl #4 |
| 808 | 769 | sub r1, r1, r2, lsl #4 |
| @@ -810,31 +771,31 @@ function \type\()_h264_qpel16_h_lowpass_l2_neon · 1 unmodified line | ||
| 810 | 771 | add r0, r0, #8 |
| 811 | 772 | add r1, r1, #8 |
| 812 | 773 | add r3, r3, #8 |
| 813 | − mov ip, #16 | |
| 774 | + mov r12, #16 | |
| 814 | 775 | pop {lr} |
| 815 | 776 | endfunc |
| 816 | 777 | |
| 817 | 778 | function \type\()_h264_qpel8_h_lowpass_l2_neon |
| 818 | −1: vld1.64 {d0, d1}, [r1], r2 | |
| 819 | − vld1.64 {d16,d17}, [r1], r2 | |
| 820 | − vld1.64 {d28}, [r3], r2 | |
| 821 | − vld1.64 {d29}, [r3], r2 | |
| 822 | − subs ip, ip, #2 | |
| 779 | +1: vld1.8 {d0, d1}, [r1], r2 | |
| 780 | + vld1.8 {d16,d17}, [r1], r2 | |
| 781 | + vld1.8 {d28}, [r3], r2 | |
| 782 | + vld1.8 {d29}, [r3], r2 | |
| 783 | + subs r12, r12, #2 | |
| 823 | 784 | lowpass_8 d0, d1, d16, d17, d0, d1 |
| 824 | 785 | vrhadd.u8 q0, q0, q14 |
| 825 | −.ifc \type,avg | |
| 786 | + .ifc \type,avg | |
| 826 | 787 | vld1.8 {d2}, [r0,:64], r2 |
| 827 | 788 | vrhadd.u8 d0, d0, d2 |
| 828 | 789 | vld1.8 {d3}, [r0,:64] |
| 829 | 790 | vrhadd.u8 d1, d1, d3 |
| 830 | 791 | sub r0, r0, r2 |
| 831 | −.endif | |
| 832 | − vst1.64 {d0}, [r0,:64], r2 | |
| 833 | − vst1.64 {d1}, [r0,:64], r2 | |
| 792 | + .endif | |
| 793 | + vst1.8 {d0}, [r0,:64], r2 | |
| 794 | + vst1.8 {d1}, [r0,:64], r2 | |
| 834 | 795 | bne 1b |
| 835 | 796 | bx lr |
| 836 | 797 | endfunc |
| 837 | − .endm | |
| 798 | +.endm | |
| 838 | 799 | |
| 839 | 800 | h264_qpel_h_lowpass_l2 put |
| 840 | 801 | h264_qpel_h_lowpass_l2 avg |
| @@ -854,7 +815,7 @@ function put_h264_qpel16_v_lowpass_neon_packed · 13 unmodified lines | ||
| 854 | 815 | b put_h264_qpel8_v_lowpass_neon |
| 855 | 816 | endfunc |
| 856 | 817 | |
| 857 | − .macro h264_qpel_v_lowpass type | |
| 818 | +.macro h264_qpel_v_lowpass type | |
| 858 | 819 | function \type\()_h264_qpel16_v_lowpass_neon |
| 859 | 820 | mov r4, lr |
| 860 | 821 | bl \type\()_h264_qpel8_v_lowpass_neon |
| @@ -871,19 +832,19 @@ function \type\()_h264_qpel16_v_lowpass_neon · 10 unmodified lines | ||
| 871 | 832 | endfunc |
| 872 | 833 | |
| 873 | 834 | function \type\()_h264_qpel8_v_lowpass_neon |
| 874 | − vld1.64 {d8}, [r1], r3 | |
| 875 | − vld1.64 {d10}, [r1], r3 | |
| 876 | − vld1.64 {d12}, [r1], r3 | |
| 877 | − vld1.64 {d14}, [r1], r3 | |
| 878 | − vld1.64 {d22}, [r1], r3 | |
| 879 | − vld1.64 {d24}, [r1], r3 | |
| 880 | − vld1.64 {d26}, [r1], r3 | |
| 881 | − vld1.64 {d28}, [r1], r3 | |
| 882 | − vld1.64 {d9}, [r1], r3 | |
| 883 | − vld1.64 {d11}, [r1], r3 | |
| 884 | − vld1.64 {d13}, [r1], r3 | |
| 885 | − vld1.64 {d15}, [r1], r3 | |
| 886 | − vld1.64 {d23}, [r1] | |
| 835 | + vld1.8 {d8}, [r1], r3 | |
| 836 | + vld1.8 {d10}, [r1], r3 | |
| 837 | + vld1.8 {d12}, [r1], r3 | |
| 838 | + vld1.8 {d14}, [r1], r3 | |
| 839 | + vld1.8 {d22}, [r1], r3 | |
| 840 | + vld1.8 {d24}, [r1], r3 | |
| 841 | + vld1.8 {d26}, [r1], r3 | |
| 842 | + vld1.8 {d28}, [r1], r3 | |
| 843 | + vld1.8 {d9}, [r1], r3 | |
| 844 | + vld1.8 {d11}, [r1], r3 | |
| 845 | + vld1.8 {d13}, [r1], r3 | |
| 846 | + vld1.8 {d15}, [r1], r3 | |
| 847 | + vld1.8 {d23}, [r1] | |
| 887 | 848 | |
| 888 | 849 | transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14 |
| 889 | 850 | lowpass_8 d8, d9, d10, d11, d8, d10 |
| @@ -892,7 +853,7 @@ function \type\()_h264_qpel8_v_lowpass_neon · 2 unmodified lines | ||
| 892 | 853 | lowpass_8 d26, d27, d28, d29, d26, d28 |
| 893 | 854 | transpose_8x8 d8, d10, d12, d14, d22, d24, d26, d28 |
| 894 | 855 | |
| 895 | −.ifc \type,avg | |
| 856 | + .ifc \type,avg | |
| 896 | 857 | vld1.8 {d9}, [r0,:64], r2 |
| 897 | 858 | vrhadd.u8 d8, d8, d9 |
| 898 | 859 | vld1.8 {d11}, [r0,:64], r2 |
| @@ -910,34 +871,34 @@ function \type\()_h264_qpel8_v_lowpass_neon · 11 unmodified lines | ||
| 910 | 871 | vld1.8 {d29}, [r0,:64], r2 |
| 911 | 872 | vrhadd.u8 d28, d28, d29 |
| 912 | 873 | sub r0, r0, r2, lsl #3 |
| 913 | −.endif | |
| 874 | + .endif | |
| 914 | 875 | |
| 915 | − vst1.64 {d8}, [r0,:64], r2 | |
| 916 | − vst1.64 {d10}, [r0,:64], r2 | |
| 917 | − vst1.64 {d12}, [r0,:64], r2 | |
| 918 | − vst1.64 {d14}, [r0,:64], r2 | |
| 919 | − vst1.64 {d22}, [r0,:64], r2 | |
| 920 | − vst1.64 {d24}, [r0,:64], r2 | |
| 921 | − vst1.64 {d26}, [r0,:64], r2 | |
| 922 | − vst1.64 {d28}, [r0,:64], r2 | |
| 876 | + vst1.8 {d8}, [r0,:64], r2 | |
| 877 | + vst1.8 {d10}, [r0,:64], r2 | |
| 878 | + vst1.8 {d12}, [r0,:64], r2 | |
| 879 | + vst1.8 {d14}, [r0,:64], r2 | |
| 880 | + vst1.8 {d22}, [r0,:64], r2 | |
| 881 | + vst1.8 {d24}, [r0,:64], r2 | |
| 882 | + vst1.8 {d26}, [r0,:64], r2 | |
| 883 | + vst1.8 {d28}, [r0,:64], r2 | |
| 923 | 884 | |
| 924 | 885 | bx lr |
| 925 | 886 | endfunc |
| 926 | − .endm | |
| 887 | +.endm | |
| 927 | 888 | |
| 928 | 889 | h264_qpel_v_lowpass put |
| 929 | 890 | h264_qpel_v_lowpass avg |
| 930 | 891 | |
| 931 | − .macro h264_qpel_v_lowpass_l2 type | |
| 892 | +.macro h264_qpel_v_lowpass_l2 type | |
| 932 | 893 | function \type\()_h264_qpel16_v_lowpass_l2_neon |
| 933 | 894 | mov r4, lr |
| 934 | 895 | bl \type\()_h264_qpel8_v_lowpass_l2_neon |
| 935 | 896 | sub r1, r1, r3, lsl #2 |
| 936 | 897 | bl \type\()_h264_qpel8_v_lowpass_l2_neon |
| 937 | 898 | sub r0, r0, r3, lsl #4 |
| 938 | − sub ip, ip, r2, lsl #4 | |
| 899 | + sub r12, r12, r2, lsl #4 | |
| 939 | 900 | add r0, r0, #8 |
| 940 | − add ip, ip, #8 | |
| 901 | + add r12, r12, #8 | |
| 941 | 902 | sub r1, r1, r3, lsl #4 |
| 942 | 903 | sub r1, r1, r3, lsl #2 |
| 943 | 904 | add r1, r1, #8 |
| @@ -947,19 +908,19 @@ function \type\()_h264_qpel16_v_lowpass_l2_neon · 3 unmodified lines | ||
| 947 | 908 | endfunc |
| 948 | 909 | |
| 949 | 910 | function \type\()_h264_qpel8_v_lowpass_l2_neon |
| 950 | − vld1.64 {d8}, [r1], r3 | |
| 951 | − vld1.64 {d10}, [r1], r3 | |
| 952 | − vld1.64 {d12}, [r1], r3 | |
| 953 | − vld1.64 {d14}, [r1], r3 | |
| 954 | − vld1.64 {d22}, [r1], r3 | |
| 955 | − vld1.64 {d24}, [r1], r3 | |
| 956 | − vld1.64 {d26}, [r1], r3 | |
| 957 | − vld1.64 {d28}, [r1], r3 | |
| 958 | − vld1.64 {d9}, [r1], r3 | |
| 959 | − vld1.64 {d11}, [r1], r3 | |
| 960 | − vld1.64 {d13}, [r1], r3 | |
| 961 | − vld1.64 {d15}, [r1], r3 | |
| 962 | − vld1.64 {d23}, [r1] | |
| 911 | + vld1.8 {d8}, [r1], r3 | |
| 912 | + vld1.8 {d10}, [r1], r3 | |
| 913 | + vld1.8 {d12}, [r1], r3 | |
| 914 | + vld1.8 {d14}, [r1], r3 | |
| 915 | + vld1.8 {d22}, [r1], r3 | |
| 916 | + vld1.8 {d24}, [r1], r3 | |
| 917 | + vld1.8 {d26}, [r1], r3 | |
| 918 | + vld1.8 {d28}, [r1], r3 | |
| 919 | + vld1.8 {d9}, [r1], r3 | |
| 920 | + vld1.8 {d11}, [r1], r3 | |
| 921 | + vld1.8 {d13}, [r1], r3 | |
| 922 | + vld1.8 {d15}, [r1], r3 | |
| 923 | + vld1.8 {d23}, [r1] | |
| 963 | 924 | |
| 964 | 925 | transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14 |
| 965 | 926 | lowpass_8 d8, d9, d10, d11, d8, d9 |
| @@ -968,20 +929,20 @@ function \type\()_h264_qpel8_v_lowpass_l2_neon · 2 unmodified lines | ||
| 968 | 929 | lowpass_8 d26, d27, d28, d29, d26, d27 |
| 969 | 930 | transpose_8x8 d8, d9, d12, d13, d22, d23, d26, d27 |
| 970 | 931 | |
| 971 | − vld1.64 {d0}, [ip], r2 | |
| 972 | − vld1.64 {d1}, [ip], r2 | |
| 973 | − vld1.64 {d2}, [ip], r2 | |
| 974 | − vld1.64 {d3}, [ip], r2 | |
| 975 | − vld1.64 {d4}, [ip], r2 | |
| 932 | + vld1.8 {d0}, [r12], r2 | |
| 933 | + vld1.8 {d1}, [r12], r2 | |
| 934 | + vld1.8 {d2}, [r12], r2 | |
| 935 | + vld1.8 {d3}, [r12], r2 | |
| 936 | + vld1.8 {d4}, [r12], r2 | |
| 976 | 937 | vrhadd.u8 q0, q0, q4 |
| 977 | − vld1.64 {d5}, [ip], r2 | |
| 938 | + vld1.8 {d5}, [r12], r2 | |
| 978 | 939 | vrhadd.u8 q1, q1, q6 |
| 979 | − vld1.64 {d10}, [ip], r2 | |
| 940 | + vld1.8 {d10}, [r12], r2 | |
| 980 | 941 | vrhadd.u8 q2, q2, q11 |
| 981 | − vld1.64 {d11}, [ip], r2 | |
| 942 | + vld1.8 {d11}, [r12], r2 | |
| 982 | 943 | vrhadd.u8 q5, q5, q13 |
| 983 | 944 | |
| 984 | −.ifc \type,avg | |
| 945 | + .ifc \type,avg | |
| 985 | 946 | vld1.8 {d16}, [r0,:64], r3 |
| 986 | 947 | vrhadd.u8 d0, d0, d16 |
| 987 | 948 | vld1.8 {d17}, [r0,:64], r3 |
| @@ -999,51 +960,51 @@ function \type\()_h264_qpel8_v_lowpass_l2_neon · 11 unmodified lines | ||
| 999 | 960 | vld1.8 {d17}, [r0,:64], r3 |
| 1000 | 961 | vrhadd.u8 d11, d11, d17 |
| 1001 | 962 | sub r0, r0, r3, lsl #3 |
| 1002 | −.endif | |
| 963 | + .endif | |
| 1003 | 964 | |
| 1004 | − vst1.64 {d0}, [r0,:64], r3 | |
| 1005 | − vst1.64 {d1}, [r0,:64], r3 | |
| 1006 | − vst1.64 {d2}, [r0,:64], r3 | |
| 1007 | − vst1.64 {d3}, [r0,:64], r3 | |
| 1008 | − vst1.64 {d4}, [r0,:64], r3 | |
| 1009 | − vst1.64 {d5}, [r0,:64], r3 | |
| 1010 | − vst1.64 {d10}, [r0,:64], r3 | |
| 1011 | − vst1.64 {d11}, [r0,:64], r3 | |
| 965 | + vst1.8 {d0}, [r0,:64], r3 | |
| 966 | + vst1.8 {d1}, [r0,:64], r3 | |
| 967 | + vst1.8 {d2}, [r0,:64], r3 | |
| 968 | + vst1.8 {d3}, [r0,:64], r3 | |
| 969 | + vst1.8 {d4}, [r0,:64], r3 | |
| 970 | + vst1.8 {d5}, [r0,:64], r3 | |
| 971 | + vst1.8 {d10}, [r0,:64], r3 | |
| 972 | + vst1.8 {d11}, [r0,:64], r3 | |
| 1012 | 973 | |
| 1013 | 974 | bx lr |
| 1014 | 975 | endfunc |
| 1015 | − .endm | |
| 976 | +.endm | |
| 1016 | 977 | |
| 1017 | 978 | h264_qpel_v_lowpass_l2 put |
| 1018 | 979 | h264_qpel_v_lowpass_l2 avg |
| 1019 | 980 | |
| 1020 | 981 | function put_h264_qpel8_hv_lowpass_neon_top |
| 1021 | − lowpass_const ip | |
| 1022 | − mov ip, #12 | |
| 1023 | −1: vld1.64 {d0, d1}, [r1], r3 | |
| 1024 | − vld1.64 {d16,d17}, [r1], r3 | |
| 1025 | − subs ip, ip, #2 | |
| 982 | + lowpass_const r12 | |
| 983 | + mov r12, #12 | |
| 984 | +1: vld1.8 {d0, d1}, [r1], r3 | |
| 985 | + vld1.8 {d16,d17}, [r1], r3 | |
| 986 | + subs r12, r12, #2 | |
| 1026 | 987 | 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 | 989 | bne 1b |
| 1029 | 990 | |
| 1030 | − vld1.64 {d0, d1}, [r1] | |
| 991 | + vld1.8 {d0, d1}, [r1] | |
| 1031 | 992 | lowpass_8_1 d0, d1, q12, narrow=0 |
| 1032 | 993 | |
| 1033 | − mov ip, #-16 | |
| 1034 | − add r4, r4, ip | |
| 1035 | − vld1.64 {d30,d31}, [r4,:128], ip | |
| 1036 | − vld1.64 {d20,d21}, [r4,:128], ip | |
| 1037 | − vld1.64 {d18,d19}, [r4,:128], ip | |
| 1038 | − vld1.64 {d16,d17}, [r4,:128], ip | |
| 1039 | − vld1.64 {d14,d15}, [r4,:128], ip | |
| 1040 | − vld1.64 {d12,d13}, [r4,:128], ip | |
| 1041 | − vld1.64 {d10,d11}, [r4,:128], ip | |
| 1042 | − vld1.64 {d8, d9}, [r4,:128], ip | |
| 1043 | − vld1.64 {d6, d7}, [r4,:128], ip | |
| 1044 | − vld1.64 {d4, d5}, [r4,:128], ip | |
| 1045 | − vld1.64 {d2, d3}, [r4,:128], ip | |
| 1046 | − vld1.64 {d0, d1}, [r4,:128] | |
| 994 | + mov r12, #-16 | |
| 995 | + add r4, r4, r12 | |
| 996 | + vld1.8 {d30,d31}, [r4,:128], r12 | |
| 997 | + vld1.8 {d20,d21}, [r4,:128], r12 | |
| 998 | + vld1.8 {d18,d19}, [r4,:128], r12 | |
| 999 | + vld1.8 {d16,d17}, [r4,:128], r12 | |
| 1000 | + vld1.8 {d14,d15}, [r4,:128], r12 | |
| 1001 | + vld1.8 {d12,d13}, [r4,:128], r12 | |
| 1002 | + vld1.8 {d10,d11}, [r4,:128], r12 | |
| 1003 | + vld1.8 {d8, d9}, [r4,:128], r12 | |
| 1004 | + vld1.8 {d6, d7}, [r4,:128], r12 | |
| 1005 | + vld1.8 {d4, d5}, [r4,:128], r12 | |
| 1006 | + vld1.8 {d2, d3}, [r4,:128], r12 | |
| 1007 | + vld1.8 {d0, d1}, [r4,:128] | |
| 1047 | 1008 | |
| 1048 | 1009 | swap4 d1, d3, d5, d7, d8, d10, d12, d14 |
| 1049 | 1010 | 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 | 1012 | swap4 d17, d19, d21, d31, d24, d26, d28, d22 |
| 1052 | 1013 | transpose16_4x4 q8, q9, q10, q15, q12, q13, q14, q11 |
| 1053 | 1014 | |
| 1054 | − vst1.64 {d30,d31}, [r4,:128]! | |
| 1055 | − vst1.64 {d6, d7}, [r4,:128]! | |
| 1056 | − vst1.64 {d20,d21}, [r4,:128]! | |
| 1057 | − vst1.64 {d4, d5}, [r4,:128]! | |
| 1058 | − vst1.64 {d18,d19}, [r4,:128]! | |
| 1059 | − vst1.64 {d2, d3}, [r4,:128]! | |
| 1060 | − vst1.64 {d16,d17}, [r4,:128]! | |
| 1061 | − vst1.64 {d0, d1}, [r4,:128] | |
| 1015 | + vst1.8 {d30,d31}, [r4,:128]! | |
| 1016 | + vst1.8 {d6, d7}, [r4,:128]! | |
| 1017 | + vst1.8 {d20,d21}, [r4,:128]! | |
| 1018 | + vst1.8 {d4, d5}, [r4,:128]! | |
| 1019 | + vst1.8 {d18,d19}, [r4,:128]! | |
| 1020 | + vst1.8 {d2, d3}, [r4,:128]! | |
| 1021 | + vst1.8 {d16,d17}, [r4,:128]! | |
| 1022 | + vst1.8 {d0, d1}, [r4,:128] | |
| 1062 | 1023 | |
| 1063 | 1024 | lowpass_8.16 q4, q12, d8, d9, d24, d25, d8 |
| 1064 | 1025 | lowpass_8.16 q5, q13, d10, d11, d26, d27, d9 |
| 1065 | 1026 | lowpass_8.16 q6, q14, d12, d13, d28, d29, d10 |
| 1066 | 1027 | lowpass_8.16 q7, q11, d14, d15, d22, d23, d11 |
| 1067 | 1028 | |
| 1068 | − vld1.64 {d16,d17}, [r4,:128], ip | |
| 1069 | − vld1.64 {d30,d31}, [r4,:128], ip | |
| 1029 | + vld1.8 {d16,d17}, [r4,:128], r12 | |
| 1030 | + vld1.8 {d30,d31}, [r4,:128], r12 | |
| 1070 | 1031 | lowpass_8.16 q8, q15, d16, d17, d30, d31, d12 |
| 1071 | − vld1.64 {d16,d17}, [r4,:128], ip | |
| 1072 | − vld1.64 {d30,d31}, [r4,:128], ip | |
| 1032 | + vld1.8 {d16,d17}, [r4,:128], r12 | |
| 1033 | + vld1.8 {d30,d31}, [r4,:128], r12 | |
| 1073 | 1034 | lowpass_8.16 q8, q15, d16, d17, d30, d31, d13 |
| 1074 | − vld1.64 {d16,d17}, [r4,:128], ip | |
| 1075 | − vld1.64 {d30,d31}, [r4,:128], ip | |
| 1035 | + vld1.8 {d16,d17}, [r4,:128], r12 | |
| 1036 | + vld1.8 {d30,d31}, [r4,:128], r12 | |
| 1076 | 1037 | lowpass_8.16 q8, q15, d16, d17, d30, d31, d14 |
| 1077 | − vld1.64 {d16,d17}, [r4,:128], ip | |
| 1078 | − vld1.64 {d30,d31}, [r4,:128] | |
| 1038 | + vld1.8 {d16,d17}, [r4,:128], r12 | |
| 1039 | + vld1.8 {d30,d31}, [r4,:128] | |
| 1079 | 1040 | lowpass_8.16 q8, q15, d16, d17, d30, d31, d15 |
| 1080 | 1041 | |
| 1081 | 1042 | 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 | 1044 | bx lr |
| 1084 | 1045 | endfunc |
| 1085 | 1046 | |
| 1086 | − .macro h264_qpel8_hv_lowpass type | |
| 1047 | +.macro h264_qpel8_hv_lowpass type | |
| 1087 | 1048 | function \type\()_h264_qpel8_hv_lowpass_neon |
| 1088 | 1049 | mov r10, lr |
| 1089 | 1050 | bl put_h264_qpel8_hv_lowpass_neon_top |
| 1090 | −.ifc \type,avg | |
| 1051 | + .ifc \type,avg | |
| 1091 | 1052 | vld1.8 {d0}, [r0,:64], r2 |
| 1092 | 1053 | vrhadd.u8 d12, d12, d0 |
| 1093 | 1054 | vld1.8 {d1}, [r0,:64], r2 |
| @@ -1105,39 +1066,39 @@ function \type\()_h264_qpel8_hv_lowpass_neon · 11 unmodified lines | ||
| 1105 | 1066 | vld1.8 {d7}, [r0,:64], r2 |
| 1106 | 1067 | vrhadd.u8 d11, d11, d7 |
| 1107 | 1068 | sub r0, r0, r2, lsl #3 |
| 1108 | −.endif | |
| 1069 | + .endif | |
| 1109 | 1070 | |
| 1110 | − vst1.64 {d12}, [r0,:64], r2 | |
| 1111 | − vst1.64 {d13}, [r0,:64], r2 | |
| 1112 | − vst1.64 {d14}, [r0,:64], r2 | |
| 1113 | − vst1.64 {d15}, [r0,:64], r2 | |
| 1114 | − vst1.64 {d8}, [r0,:64], r2 | |
| 1115 | − vst1.64 {d9}, [r0,:64], r2 | |
| 1116 | − vst1.64 {d10}, [r0,:64], r2 | |
| 1117 | − vst1.64 {d11}, [r0,:64], r2 | |
| 1071 | + vst1.8 {d12}, [r0,:64], r2 | |
| 1072 | + vst1.8 {d13}, [r0,:64], r2 | |
| 1073 | + vst1.8 {d14}, [r0,:64], r2 | |
| 1074 | + vst1.8 {d15}, [r0,:64], r2 | |
| 1075 | + vst1.8 {d8}, [r0,:64], r2 | |
| 1076 | + vst1.8 {d9}, [r0,:64], r2 | |
| 1077 | + vst1.8 {d10}, [r0,:64], r2 | |
| 1078 | + vst1.8 {d11}, [r0,:64], r2 | |
| 1118 | 1079 | |
| 1119 | 1080 | mov lr, r10 |
| 1120 | 1081 | bx lr |
| 1121 | 1082 | endfunc |
| 1122 | − .endm | |
| 1083 | +.endm | |
| 1123 | 1084 | |
| 1124 | 1085 | h264_qpel8_hv_lowpass put |
| 1125 | 1086 | h264_qpel8_hv_lowpass avg |
| 1126 | 1087 | |
| 1127 | − .macro h264_qpel8_hv_lowpass_l2 type | |
| 1088 | +.macro h264_qpel8_hv_lowpass_l2 type | |
| 1128 | 1089 | function \type\()_h264_qpel8_hv_lowpass_l2_neon |
| 1129 | 1090 | mov r10, lr |
| 1130 | 1091 | bl put_h264_qpel8_hv_lowpass_neon_top |
| 1131 | 1092 | |
| 1132 | − vld1.64 {d0, d1}, [r2,:128]! | |
| 1133 | − vld1.64 {d2, d3}, [r2,:128]! | |
| 1093 | + vld1.8 {d0, d1}, [r2,:128]! | |
| 1094 | + vld1.8 {d2, d3}, [r2,:128]! | |
| 1134 | 1095 | vrhadd.u8 q0, q0, q6 |
| 1135 | − vld1.64 {d4, d5}, [r2,:128]! | |
| 1096 | + vld1.8 {d4, d5}, [r2,:128]! | |
| 1136 | 1097 | vrhadd.u8 q1, q1, q7 |
| 1137 | − vld1.64 {d6, d7}, [r2,:128]! | |
| 1098 | + vld1.8 {d6, d7}, [r2,:128]! | |
| 1138 | 1099 | vrhadd.u8 q2, q2, q4 |
| 1139 | 1100 | vrhadd.u8 q3, q3, q5 |
| 1140 | −.ifc \type,avg | |
| 1101 | + .ifc \type,avg | |
| 1141 | 1102 | vld1.8 {d16}, [r0,:64], r3 |
| 1142 | 1103 | vrhadd.u8 d0, d0, d16 |
| 1143 | 1104 | vld1.8 {d17}, [r0,:64], r3 |
| @@ -1155,25 +1116,25 @@ function \type\()_h264_qpel8_hv_lowpass_l2_neon · 11 unmodified lines | ||
| 1155 | 1116 | vld1.8 {d23}, [r0,:64], r3 |
| 1156 | 1117 | vrhadd.u8 d7, d7, d23 |
| 1157 | 1118 | sub r0, r0, r3, lsl #3 |
| 1158 | −.endif | |
| 1159 | − vst1.64 {d0}, [r0,:64], r3 | |
| 1160 | − vst1.64 {d1}, [r0,:64], r3 | |
| 1161 | − vst1.64 {d2}, [r0,:64], r3 | |
| 1162 | − vst1.64 {d3}, [r0,:64], r3 | |
| 1163 | − vst1.64 {d4}, [r0,:64], r3 | |
| 1164 | − vst1.64 {d5}, [r0,:64], r3 | |
| 1165 | − vst1.64 {d6}, [r0,:64], r3 | |
| 1166 | − vst1.64 {d7}, [r0,:64], r3 | |
| 1119 | + .endif | |
| 1120 | + vst1.8 {d0}, [r0,:64], r3 | |
| 1121 | + vst1.8 {d1}, [r0,:64], r3 | |
| 1122 | + vst1.8 {d2}, [r0,:64], r3 | |
| 1123 | + vst1.8 {d3}, [r0,:64], r3 | |
| 1124 | + vst1.8 {d4}, [r0,:64], r3 | |
| 1125 | + vst1.8 {d5}, [r0,:64], r3 | |
| 1126 | + vst1.8 {d6}, [r0,:64], r3 | |
| 1127 | + vst1.8 {d7}, [r0,:64], r3 | |
| 1167 | 1128 | |
| 1168 | 1129 | mov lr, r10 |
| 1169 | 1130 | bx lr |
| 1170 | 1131 | endfunc |
| 1171 | − .endm | |
| 1132 | +.endm | |
| 1172 | 1133 | |
| 1173 | 1134 | h264_qpel8_hv_lowpass_l2 put |
| 1174 | 1135 | h264_qpel8_hv_lowpass_l2 avg |
| 1175 | 1136 | |
| 1176 | − .macro h264_qpel16_hv type | |
| 1137 | +.macro h264_qpel16_hv type | |
| 1177 | 1138 | function \type\()_h264_qpel16_hv_lowpass_neon |
| 1178 | 1139 | mov r9, lr |
| 1179 | 1140 | bl \type\()_h264_qpel8_hv_lowpass_neon |
| @@ -1206,17 +1167,17 @@ function \type\()_h264_qpel16_hv_lowpass_l2_neon · 26 unmodified lines | ||
| 1206 | 1167 | mov lr, r9 |
| 1207 | 1168 | b \type\()_h264_qpel8_hv_lowpass_l2_neon |
| 1208 | 1169 | endfunc |
| 1209 | − .endm | |
| 1170 | +.endm | |
| 1210 | 1171 | |
| 1211 | 1172 | h264_qpel16_hv put |
| 1212 | 1173 | h264_qpel16_hv avg |
| 1213 | 1174 | |
| 1214 | − .macro h264_qpel8 type | |
| 1175 | +.macro h264_qpel8 type | |
| 1215 | 1176 | function ff_\type\()_h264_qpel8_mc10_neon, export=1 |
| 1216 | 1177 | lowpass_const r3 |
| 1217 | 1178 | mov r3, r1 |
| 1218 | 1179 | sub r1, r1, #2 |
| 1219 | − mov ip, #8 | |
| 1180 | + mov r12, #8 | |
| 1220 | 1181 | b \type\()_h264_qpel8_h_lowpass_l2_neon |
| 1221 | 1182 | endfunc |
| 1222 | 1183 | |
| @@ -1224,7 +1185,7 @@ function ff_\type\()_h264_qpel8_mc20_neon, export=1 · 1 unmodified line | ||
| 1224 | 1185 | lowpass_const r3 |
| 1225 | 1186 | sub r1, r1, #2 |
| 1226 | 1187 | mov r3, r2 |
| 1227 | − mov ip, #8 | |
| 1188 | + mov r12, #8 | |
| 1228 | 1189 | b \type\()_h264_qpel8_h_lowpass_neon |
| 1229 | 1190 | endfunc |
| 1230 | 1191 | |
| @@ -1232,13 +1193,13 @@ function ff_\type\()_h264_qpel8_mc30_neon, export=1 · 1 unmodified line | ||
| 1232 | 1193 | lowpass_const r3 |
| 1233 | 1194 | add r3, r1, #1 |
| 1234 | 1195 | sub r1, r1, #2 |
| 1235 | − mov ip, #8 | |
| 1196 | + mov r12, #8 | |
| 1236 | 1197 | b \type\()_h264_qpel8_h_lowpass_l2_neon |
| 1237 | 1198 | endfunc |
| 1238 | 1199 | |
| 1239 | 1200 | function ff_\type\()_h264_qpel8_mc01_neon, export=1 |
| 1240 | 1201 | push {lr} |
| 1241 | − mov ip, r1 | |
| 1202 | + mov r12, r1 | |
| 1242 | 1203 | \type\()_h264_qpel8_mc01: |
| 1243 | 1204 | lowpass_const r3 |
| 1244 | 1205 | mov r3, r2 |
| @@ -1261,12 +1222,12 @@ T mov sp, r0 · 16 unmodified lines | ||
| 1261 | 1222 | mov r0, sp |
| 1262 | 1223 | sub r1, r1, #2 |
| 1263 | 1224 | mov r3, #8 |
| 1264 | − mov ip, #8 | |
| 1225 | + mov r12, #8 | |
| 1265 | 1226 | vpush {d8-d15} |
| 1266 | 1227 | bl put_h264_qpel8_h_lowpass_neon |
| 1267 | 1228 | ldrd r0, [r11], #8 |
| 1268 | 1229 | mov r3, r2 |
| 1269 | − add ip, sp, #64 | |
| 1230 | + add r12, sp, #64 | |
| 1270 | 1231 | sub r1, r1, r2, lsl #1 |
| 1271 | 1232 | mov r2, #8 |
| 1272 | 1233 | bl \type\()_h264_qpel8_v_lowpass_l2_neon |
| @@ -1287,7 +1248,7 @@ T mov sp, r0 · 14 unmodified lines | ||
| 1287 | 1248 | sub r1, r1, #2 |
| 1288 | 1249 | mov r3, #8 |
| 1289 | 1250 | mov r0, sp |
| 1290 | − mov ip, #8 | |
| 1251 | + mov r12, #8 | |
| 1291 | 1252 | vpush {d8-d15} |
| 1292 | 1253 | bl put_h264_qpel8_h_lowpass_neon |
| 1293 | 1254 | mov r4, r0 |
| @@ -1372,7 +1333,7 @@ endfunc · 78 unmodified lines | ||
| 1372 | 1333 | |
| 1373 | 1334 | function ff_\type\()_h264_qpel8_mc03_neon, export=1 |
| 1374 | 1335 | push {lr} |
| 1375 | − add ip, r1, r2 | |
| 1336 | + add r12, r1, r2 | |
| 1376 | 1337 | b \type\()_h264_qpel8_mc01 |
| 1377 | 1338 | endfunc |
| 1378 | 1339 | |
| @@ -1395,12 +1356,12 @@ function ff_\type\()_h264_qpel8_mc33_neon, export=1 · 16 unmodified lines | ||
| 1395 | 1356 | sub r1, r1, #1 |
| 1396 | 1357 | b \type\()_h264_qpel8_mc11 |
| 1397 | 1358 | endfunc |
| 1398 | − .endm | |
| 1359 | +.endm | |
| 1399 | 1360 | |
| 1400 | 1361 | h264_qpel8 put |
| 1401 | 1362 | h264_qpel8 avg |
| 1402 | 1363 | |
| 1403 | − .macro h264_qpel16 type | |
| 1364 | +.macro h264_qpel16 type | |
| 1404 | 1365 | function ff_\type\()_h264_qpel16_mc10_neon, export=1 |
| 1405 | 1366 | lowpass_const r3 |
| 1406 | 1367 | mov r3, r1 |
| @@ -1424,7 +1385,7 @@ endfunc · 17 unmodified lines | ||
| 1424 | 1385 | |
| 1425 | 1386 | function ff_\type\()_h264_qpel16_mc01_neon, export=1 |
| 1426 | 1387 | push {r4, lr} |
| 1427 | − mov ip, r1 | |
| 1388 | + mov r12, r1 | |
| 1428 | 1389 | \type\()_h264_qpel16_mc01: |
| 1429 | 1390 | lowpass_const r3 |
| 1430 | 1391 | mov r3, r2 |
| @@ -1451,7 +1412,7 @@ T mov sp, r0 · 20 unmodified lines | ||
| 1451 | 1412 | bl put_h264_qpel16_h_lowpass_neon |
| 1452 | 1413 | ldrd r0, [r11], #8 |
| 1453 | 1414 | mov r3, r2 |
| 1454 | − add ip, sp, #64 | |
| 1415 | + add r12, sp, #64 | |
| 1455 | 1416 | sub r1, r1, r2, lsl #1 |
| 1456 | 1417 | mov r2, #16 |
| 1457 | 1418 | bl \type\()_h264_qpel16_v_lowpass_l2_neon |
| @@ -1554,7 +1515,7 @@ endfunc · 96 unmodified lines | ||
| 1554 | 1515 | |
| 1555 | 1516 | function ff_\type\()_h264_qpel16_mc03_neon, export=1 |
| 1556 | 1517 | push {r4, lr} |
| 1557 | − add ip, r1, r2 | |
| 1518 | + add r12, r1, r2 | |
| 1558 | 1519 | b \type\()_h264_qpel16_mc01 |
| 1559 | 1520 | endfunc |
| 1560 | 1521 | |
| @@ -1577,14 +1538,14 @@ function ff_\type\()_h264_qpel16_mc33_neon, export=1 · 16 unmodified lines | ||
| 1577 | 1538 | sub r1, r1, #1 |
| 1578 | 1539 | b \type\()_h264_qpel16_mc11 |
| 1579 | 1540 | endfunc |
| 1580 | − .endm | |
| 1541 | +.endm | |
| 1581 | 1542 | |
| 1582 | 1543 | h264_qpel16 put |
| 1583 | 1544 | h264_qpel16 avg |
| 1584 | 1545 | |
| 1585 | 1546 | @ Biweighted prediction |
| 1586 | 1547 | |
| 1587 | − .macro biweight_16 macs, macd | |
| 1548 | +.macro biweight_16 macs, macd | |
| 1588 | 1549 | vdup.8 d0, r4 |
| 1589 | 1550 | vdup.8 d1, r5 |
| 1590 | 1551 | vmov q2, q8 |
| @@ -1622,9 +1583,9 @@ endfunc · 31 unmodified lines | ||
| 1622 | 1583 | vst1.8 {d24-d25},[r6,:128], r2 |
| 1623 | 1584 | bne 1b |
| 1624 | 1585 | pop {r4-r6, pc} |
| 1625 | − .endm | |
| 1586 | +.endm | |
| 1626 | 1587 | |
| 1627 | − .macro biweight_8 macs, macd | |
| 1588 | +.macro biweight_8 macs, macd | |
| 1628 | 1589 | vdup.8 d0, r4 |
| 1629 | 1590 | vdup.8 d1, r5 |
| 1630 | 1591 | vmov q1, q8 |
| @@ -1652,9 +1613,9 @@ endfunc · 21 unmodified lines | ||
| 1652 | 1613 | vst1.8 {d4},[r6,:64], r2 |
| 1653 | 1614 | bne 1b |
| 1654 | 1615 | pop {r4-r6, pc} |
| 1655 | − .endm | |
| 1616 | +.endm | |
| 1656 | 1617 | |
| 1657 | − .macro biweight_4 macs, macd | |
| 1618 | +.macro biweight_4 macs, macd | |
| 1658 | 1619 | vdup.8 d0, r4 |
| 1659 | 1620 | vdup.8 d1, r5 |
| 1660 | 1621 | vmov q1, q8 |
| @@ -1694,9 +1655,9 @@ endfunc · 33 unmodified lines | ||
| 1694 | 1655 | vst1.32 {d2[0]},[r6,:32], r2 |
| 1695 | 1656 | vst1.32 {d2[1]},[r6,:32], r2 |
| 1696 | 1657 | pop {r4-r6, pc} |
| 1697 | − .endm | |
| 1658 | +.endm | |
| 1698 | 1659 | |
| 1699 | − .macro biweight_func w | |
| 1660 | +.macro biweight_func w | |
| 1700 | 1661 | function ff_biweight_h264_pixels_\w\()_neon, export=1 |
| 1701 | 1662 | push {r4-r6, lr} |
| 1702 | 1663 | ldr r12, [sp, #16] |
| @@ -1726,7 +1687,7 @@ function ff_biweight_h264_pixels_\w\()_neon, export=1 · 23 unmodified lines | ||
| 1726 | 1687 | 40: rsb r5, r5, #0 |
| 1727 | 1688 | biweight_\w vmlsl.u8, vmlal.u8 |
| 1728 | 1689 | endfunc |
| 1729 | − .endm | |
| 1690 | +.endm | |
| 1730 | 1691 | |
| 1731 | 1692 | biweight_func 16 |
| 1732 | 1693 | biweight_func 8 |
| @@ -1734,7 +1695,7 @@ endfunc · 1 unmodified line | ||
| 1734 | 1695 | |
| 1735 | 1696 | @ Weighted prediction |
| 1736 | 1697 | |
| 1737 | − .macro weight_16 add | |
| 1698 | +.macro weight_16 add | |
| 1738 | 1699 | vdup.8 d0, r12 |
| 1739 | 1700 | 1: subs r2, r2, #2 |
| 1740 | 1701 | vld1.8 {d20-d21},[r0,:128], r1 |
| @@ -1761,9 +1722,9 @@ endfunc · 20 unmodified lines | ||
| 1761 | 1722 | vst1.8 {d24-d25},[r4,:128], r1 |
| 1762 | 1723 | bne 1b |
| 1763 | 1724 | pop {r4, pc} |
| 1764 | − .endm | |
| 1725 | +.endm | |
| 1765 | 1726 | |
| 1766 | − .macro weight_8 add | |
| 1727 | +.macro weight_8 add | |
| 1767 | 1728 | vdup.8 d0, r12 |
| 1768 | 1729 | 1: subs r2, r2, #2 |
| 1769 | 1730 | vld1.8 {d4},[r0,:64], r1 |
| @@ -1782,9 +1743,9 @@ endfunc · 12 unmodified lines | ||
| 1782 | 1743 | vst1.8 {d4},[r4,:64], r1 |
| 1783 | 1744 | bne 1b |
| 1784 | 1745 | pop {r4, pc} |
| 1785 | − .endm | |
| 1746 | +.endm | |
| 1786 | 1747 | |
| 1787 | − .macro weight_4 add | |
| 1748 | +.macro weight_4 add | |
| 1788 | 1749 | vdup.8 d0, r12 |
| 1789 | 1750 | vmov q1, q8 |
| 1790 | 1751 | vmov q10, q8 |
| @@ -1818,9 +1779,9 @@ endfunc · 27 unmodified lines | ||
| 1818 | 1779 | vst1.32 {d2[0]},[r4,:32], r1 |
| 1819 | 1780 | vst1.32 {d2[1]},[r4,:32], r1 |
| 1820 | 1781 | pop {r4, pc} |
| 1821 | − .endm | |
| 1782 | +.endm | |
| 1822 | 1783 | |
| 1823 | − .macro weight_func w | |
| 1784 | +.macro weight_func w | |
| 1824 | 1785 | function ff_weight_h264_pixels_\w\()_neon, export=1 |
| 1825 | 1786 | push {r4, lr} |
| 1826 | 1787 | ldr r12, [sp, #8] |
| @@ -1845,7 +1806,7 @@ function ff_weight_h264_pixels_\w\()_neon, export=1 · 18 unmodified lines | ||
| 1845 | 1806 | 10: rsb r12, r12, #0 |
| 1846 | 1807 | weight_\w vsub.s16 |
| 1847 | 1808 | endfunc |
| 1848 | − .endm | |
| 1809 | +.endm | |
| 1849 | 1810 | |
| 1850 | 1811 | weight_func 16 |
| 1851 | 1812 | weight_func 8 |
| @@ -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 | |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | 24 | #include "asm.S" |
| 25 | +#include "neon.S" | |
| 25 | 26 | |
| 26 | 27 | function ff_vp8_luma_dc_wht_neon, export=1 |
| 27 | 28 | vld1.16 {q0-q1}, [r1,:128] |
| @@ -442,23 +443,6 @@ endfunc · 414 unmodified lines | ||
| 442 | 443 | .endif |
| 443 | 444 | .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 | 446 | .macro vp8_v_loop_filter16 name, inner=0, simple=0 |
| 463 | 447 | function ff_vp8_v_loop_filter16\name\()_neon, export=1 |
| 464 | 448 | vpush {q4-q7} |
| @@ -593,7 +577,7 @@ function ff_vp8_h_loop_filter16\name\()_neon, export=1 · 128 unmodified lines | ||
| 593 | 577 | vld1.8 {d13}, [r0], r1 |
| 594 | 578 | vld1.8 {d15}, [r0], r1 |
| 595 | 579 | |
| 596 | − transpose8x16matrix | |
| 580 | + transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7 | |
| 597 | 581 | |
| 598 | 582 | vdup.8 q14, r2 @ flim_E |
| 599 | 583 | .if !\simple |
| @@ -604,7 +588,7 @@ function ff_vp8_h_loop_filter16\name\()_neon, export=1 · 4 unmodified lines | ||
| 604 | 588 | |
| 605 | 589 | sub r0, r0, r1, lsl #4 @ backup 16 rows |
| 606 | 590 | |
| 607 | − transpose8x16matrix | |
| 591 | + transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7 | |
| 608 | 592 | |
| 609 | 593 | @ Store pixels: |
| 610 | 594 | vst1.8 {d0}, [r0], r1 |
| @@ -658,7 +642,7 @@ function ff_vp8_h_loop_filter8uv\name\()_neon, export=1 · 47 unmodified lines | ||
| 658 | 642 | vld1.8 {d14}, [r0], r2 |
| 659 | 643 | vld1.8 {d15}, [r1], r2 |
| 660 | 644 | |
| 661 | − transpose8x16matrix | |
| 645 | + transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7 | |
| 662 | 646 | |
| 663 | 647 | vdup.8 q14, r3 @ flim_E |
| 664 | 648 | vdup.8 q15, r12 @ flim_I |
| @@ -669,7 +653,7 @@ function ff_vp8_h_loop_filter8uv\name\()_neon, export=1 · 4 unmodified lines | ||
| 669 | 653 | sub r0, r0, r2, lsl #3 @ backup u 8 rows |
| 670 | 654 | sub r1, r1, r2, lsl #3 @ backup v 8 rows |
| 671 | 655 | |
| 672 | − transpose8x16matrix | |
| 656 | + transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7 | |
| 673 | 657 | |
| 674 | 658 | @ Store pixels: |
| 675 | 659 | vst1.8 {d0}, [r0], r2 |
| @@ -72,6 +72,7 @@ typedef struct { · 71 unmodified lines | ||
| 72 | 72 | * The atrac1 context, holds all needed parameters for decoding |
| 73 | 73 | */ |
| 74 | 74 | typedef struct { |
| 75 | + AVFrame frame; | |
| 75 | 76 | AT1SUCtx SUs[AT1_MAX_CHANNELS]; ///< channel sound unit |
| 76 | 77 | 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 | |
| 275 | 276 | static int atrac1_decode_frame(AVCodecContext *avctx, void *data, |
| 276 | − int *data_size, AVPacket *avpkt) | |
| 277 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 277 | 278 | { |
| 278 | 279 | const uint8_t *buf = avpkt->data; |
| 279 | 280 | int buf_size = avpkt->size; |
| 280 | 281 | AT1Ctx *q = avctx->priv_data; |
| 281 | − int ch, ret, out_size; | |
| 282 | + int ch, ret; | |
| 282 | 283 | GetBitContext gb; |
| 283 | − float* samples = data; | |
| 284 | + float *samples; | |
| 284 | 285 | |
| 285 | 286 | |
| 286 | 287 | if (buf_size < 212 * q->channels) { |
| @@ -288,12 +289,13 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data, · 1 unmodified line | ||
| 288 | 289 | return AVERROR_INVALIDDATA; |
| 289 | 290 | } |
| 290 | 291 | |
| 291 | − out_size = q->channels * AT1_SU_SAMPLES * | |
| 292 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 293 | − if (*data_size < out_size) { | |
| 294 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 295 | − return AVERROR(EINVAL); | |
| 292 | + /* get output buffer */ | |
| 293 | + q->frame.nb_samples = AT1_SU_SAMPLES; | |
| 294 | + if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { | |
| 295 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 296 | + return ret; | |
| 296 | 297 | } |
| 298 | + samples = (float *)q->frame.data[0]; | |
| 297 | 299 | |
| 298 | 300 | for (ch = 0; ch < q->channels; ch++) { |
| 299 | 301 | AT1SUCtx* su = &q->SUs[ch]; |
| @@ -321,7 +323,9 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data, · 21 unmodified lines | ||
| 321 | 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 | 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 | 393 | q->SUs[1].spectrum[0] = q->SUs[1].spec1; |
| 390 | 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 | 399 | return 0; |
| 393 | 400 | } |
| 394 | 401 | |
| @@ -401,5 +408,6 @@ AVCodec ff_atrac1_decoder = { · 6 unmodified lines | ||
| 401 | 408 | .init = atrac1_decode_init, |
| 402 | 409 | .close = atrac1_decode_end, |
| 403 | 410 | .decode = atrac1_decode_frame, |
| 411 | + .capabilities = CODEC_CAP_DR1, | |
| 404 | 412 | .long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Coding)"), |
| 405 | 413 | }; |
| @@ -86,6 +86,7 @@ typedef struct { · 85 unmodified lines | ||
| 86 | 86 | } channel_unit; |
| 87 | 87 | |
| 88 | 88 | typedef struct { |
| 89 | + AVFrame frame; | |
| 89 | 90 | GetBitContext gb; |
| 90 | 91 | //@{ |
| 91 | 92 | /** stream data */ |
| @@ -823,16 +824,16 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, · 731 unmodified lines | ||
| 823 | 824 | * @param avctx pointer to the AVCodecContext |
| 824 | 825 | */ |
| 825 | 826 | |
| 826 | −static int atrac3_decode_frame(AVCodecContext *avctx, | |
| 827 | − void *data, int *data_size, | |
| 828 | − AVPacket *avpkt) { | |
| 827 | +static int atrac3_decode_frame(AVCodecContext *avctx, void *data, | |
| 828 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 829 | +{ | |
| 829 | 830 | const uint8_t *buf = avpkt->data; |
| 830 | 831 | int buf_size = avpkt->size; |
| 831 | 832 | ATRAC3Context *q = avctx->priv_data; |
| 832 | − int result = 0, out_size; | |
| 833 | + int result; | |
| 833 | 834 | const uint8_t* databuf; |
| 834 | − float *samples_flt = data; | |
| 835 | − int16_t *samples_s16 = data; | |
| 835 | + float *samples_flt; | |
| 836 | + int16_t *samples_s16; | |
| 836 | 837 | |
| 837 | 838 | if (buf_size < avctx->block_align) { |
| 838 | 839 | av_log(avctx, AV_LOG_ERROR, |
| @@ -840,12 +841,14 @@ static int atrac3_decode_frame(AVCodecContext *avctx, · 1 unmodified line | ||
| 840 | 841 | return AVERROR_INVALIDDATA; |
| 841 | 842 | } |
| 842 | 843 | |
| 843 | − out_size = SAMPLES_PER_FRAME * q->channels * | |
| 844 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 845 | − if (*data_size < out_size) { | |
| 846 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 847 | − return AVERROR(EINVAL); | |
| 844 | + /* get output buffer */ | |
| 845 | + q->frame.nb_samples = SAMPLES_PER_FRAME; | |
| 846 | + if ((result = avctx->get_buffer(avctx, &q->frame)) < 0) { | |
| 847 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 848 | + return result; | |
| 848 | 849 | } |
| 850 | + samples_flt = (float *)q->frame.data[0]; | |
| 851 | + samples_s16 = (int16_t *)q->frame.data[0]; | |
| 849 | 852 | |
| 850 | 853 | /* Check if we need to descramble and what buffer to pass on. */ |
| 851 | 854 | if (q->scrambled_stream) { |
| @@ -875,7 +878,9 @@ static int atrac3_decode_frame(AVCodecContext *avctx, · 23 unmodified lines | ||
| 875 | 878 | (const float **)q->outSamples, |
| 876 | 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 | 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 | 1058 | return 0; |
| 1051 | 1059 | } |
| 1052 | 1060 | |
| @@ -1060,6 +1068,6 @@ AVCodec ff_atrac3_decoder = · 7 unmodified lines | ||
| 1060 | 1068 | .init = atrac3_decode_init, |
| 1061 | 1069 | .close = atrac3_decode_close, |
| 1062 | 1070 | .decode = atrac3_decode_frame, |
| 1063 | − .capabilities = CODEC_CAP_SUBFRAMES, | |
| 1071 | + .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, | |
| 1064 | 1072 | .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"), |
| 1065 | 1073 | }; |
| @@ -491,8 +491,10 @@ enum CodecID { · 490 unmodified lines | ||
| 491 | 491 | #define CH_LAYOUT_STEREO_DOWNMIX AV_CH_LAYOUT_STEREO_DOWNMIX |
| 492 | 492 | #endif |
| 493 | 493 | |
| 494 | +#if FF_API_OLD_DECODE_AUDIO | |
| 494 | 495 | /* in bytes */ |
| 495 | 496 | #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio |
| 497 | +#endif | |
| 496 | 498 | |
| 497 | 499 | /** |
| 498 | 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 | 949 | * sizeof(AVFrame) must not be used outside libav*. |
| 948 | 950 | */ |
| 949 | 951 | typedef struct AVFrame { |
| 952 | +#if FF_API_DATA_POINTERS | |
| 953 | +#define AV_NUM_DATA_POINTERS 4 | |
| 954 | +#else | |
| 955 | +#define AV_NUM_DATA_POINTERS 8 | |
| 956 | +#endif | |
| 950 | 957 | /** |
| 951 | − * pointer to the picture planes. | |
| 958 | + * pointer to the picture/channel planes. | |
| 952 | 959 | * This might be different from the first allocated byte |
| 953 | − * - encoding: | |
| 954 | − * - decoding: | |
| 960 | + * - encoding: Set by user | |
| 961 | + * - decoding: set by AVCodecContext.get_buffer() | |
| 962 | + */ | |
| 963 | + uint8_t *data[AV_NUM_DATA_POINTERS]; | |
| 964 | + | |
| 965 | + /** | |
| 966 | + * Size, in bytes, of the data for each picture/channel plane. | |
| 967 | + * | |
| 968 | + * For audio, only linesize[0] may be set. For planar audio, each channel | |
| 969 | + * plane must be the same size. | |
| 970 | + * | |
| 971 | + * - encoding: Set by user (video only) | |
| 972 | + * - decoding: set by AVCodecContext.get_buffer() | |
| 955 | 973 | */ |
| 956 | − uint8_t *data[4]; | |
| 957 | − int linesize[4]; | |
| 974 | + int linesize[AV_NUM_DATA_POINTERS]; | |
| 975 | + | |
| 958 | 976 | /** |
| 959 | 977 | * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer. |
| 960 | 978 | * This isn't used by libavcodec unless the default get/release_buffer() is used. |
| 961 | 979 | * - encoding: |
| 962 | 980 | * - decoding: |
| 963 | 981 | */ |
| 964 | − uint8_t *base[4]; | |
| 982 | + uint8_t *base[AV_NUM_DATA_POINTERS]; | |
| 965 | 983 | /** |
| 966 | 984 | * 1 -> keyframe, 0-> not |
| 967 | 985 | * - encoding: Set by libavcodec. |
| @@ -1008,7 +1026,7 @@ typedef struct AVFrame { · 40 unmodified lines | ||
| 1008 | 1026 | * buffer age (1->was last buffer and dint change, 2->..., ...). |
| 1009 | 1027 | * Set to INT_MAX if the buffer has not been used yet. |
| 1010 | 1028 | * - encoding: unused |
| 1011 | − * - decoding: MUST be set by get_buffer(). | |
| 1029 | + * - decoding: MUST be set by get_buffer() for video. | |
| 1012 | 1030 | */ |
| 1013 | 1031 | int age; |
| 1014 | 1032 | |
| @@ -1085,7 +1103,7 @@ typedef struct AVFrame { · 70 unmodified lines | ||
| 1085 | 1103 | * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR. |
| 1086 | 1104 | * - decoding: unused |
| 1087 | 1105 | */ |
| 1088 | − uint64_t error[4]; | |
| 1106 | + uint64_t error[AV_NUM_DATA_POINTERS]; | |
| 1089 | 1107 | |
| 1090 | 1108 | /** |
| 1091 | 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 | 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 | 1255 | * frame timestamp estimated using various heuristics, in stream time base |
| 1211 | 1256 | * - encoding: unused |
| @@ -1379,7 +1424,7 @@ typedef struct AVCodecContext { · 167 unmodified lines | ||
| 1379 | 1424 | * @param offset offset into the AVFrame.data from which the slice should be read |
| 1380 | 1425 | */ |
| 1381 | 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 | 1428 | int y, int type, int height); |
| 1384 | 1429 | |
| 1385 | 1430 | /* audio only */ |
| @@ -1602,15 +1647,56 @@ typedef struct AVCodecContext { · 216 unmodified lines | ||
| 1602 | 1647 | |
| 1603 | 1648 | /** |
| 1604 | 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. | |
| 1606 | − * avcodec_align_dimensions2() should be used to find the required width and | |
| 1607 | − * height, as they normally need to be rounded up to the next multiple of 16. | |
| 1650 | + * | |
| 1651 | + * The function will set AVFrame.data[], AVFrame.linesize[]. | |
| 1652 | + * AVFrame.extended_data[] must also be set, but it should be the same as | |
| 1653 | + * AVFrame.data[] except for planar audio with more channels than can fit | |
| 1654 | + * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as | |
| 1655 | + * many data pointers as it can hold. | |
| 1656 | + * | |
| 1608 | 1657 | * if CODEC_CAP_DR1 is not set then get_buffer() must call |
| 1609 | 1658 | * avcodec_default_get_buffer() instead of providing buffers allocated by |
| 1610 | 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 | 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. | |
| 1613 | − * Does not need to be reentrant. | |
| 1675 | + * it may be called from a different thread, but not from more than one at | |
| 1676 | + * once. Does not need to be reentrant. | |
| 1677 | + * | |
| 1678 | + * @see release_buffer(), reget_buffer() | |
| 1679 | + * @see avcodec_align_dimensions2() | |
| 1680 | + * | |
| 1681 | + * Audio: | |
| 1682 | + * | |
| 1683 | + * Decoders request a buffer of a particular size by setting | |
| 1684 | + * AVFrame.nb_samples prior to calling get_buffer(). The decoder may, | |
| 1685 | + * however, utilize only part of the buffer by setting AVFrame.nb_samples | |
| 1686 | + * to a smaller value in the output frame. | |
| 1687 | + * | |
| 1688 | + * Decoders cannot use the buffer after returning from | |
| 1689 | + * avcodec_decode_audio4(), so they will not call release_buffer(), as it | |
| 1690 | + * is assumed to be released immediately upon return. | |
| 1691 | + * | |
| 1692 | + * As a convenience, av_samples_get_buffer_size() and | |
| 1693 | + * av_samples_fill_arrays() in libavutil may be used by custom get_buffer() | |
| 1694 | + * functions to find the required data size and to fill data pointers and | |
| 1695 | + * linesize. In AVFrame.linesize, only linesize[0] may be set for audio | |
| 1696 | + * since all planes must be the same size. | |
| 1697 | + * | |
| 1698 | + * @see av_samples_get_buffer_size(), av_samples_fill_arrays() | |
| 1699 | + * | |
| 1614 | 1700 | * - encoding: unused |
| 1615 | 1701 | * - decoding: Set by libavcodec, user can override. |
| 1616 | 1702 | */ |
| @@ -1929,7 +2015,7 @@ typedef struct AVCodecContext { · 312 unmodified lines | ||
| 1929 | 2015 | * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. |
| 1930 | 2016 | * - decoding: unused |
| 1931 | 2017 | */ |
| 1932 | − uint64_t error[4]; | |
| 2018 | + uint64_t error[AV_NUM_DATA_POINTERS]; | |
| 1933 | 2019 | |
| 1934 | 2020 | /** |
| 1935 | 2021 | * motion estimation comparison function |
| @@ -3253,8 +3339,8 @@ typedef struct AVHWAccel { · 1317 unmodified lines | ||
| 3253 | 3339 | * the last component is alpha |
| 3254 | 3340 | */ |
| 3255 | 3341 | typedef struct AVPicture { |
| 3256 | − uint8_t *data[4]; | |
| 3257 | − int linesize[4]; ///< number of bytes per line | |
| 3342 | + uint8_t *data[AV_NUM_DATA_POINTERS]; | |
| 3343 | + int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line | |
| 3258 | 3344 | } AVPicture; |
| 3259 | 3345 | |
| 3260 | 3346 | #define AVPALETTE_SIZE 1024 |
| @@ -3922,7 +4008,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); · 661 unmodified lines | ||
| 3922 | 4008 | * according to avcodec_get_edge_width() before. |
| 3923 | 4009 | */ |
| 3924 | 4010 | void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, |
| 3925 | − int linesize_align[4]); | |
| 4011 | + int linesize_align[AV_NUM_DATA_POINTERS]); | |
| 3926 | 4012 | |
| 3927 | 4013 | enum 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 | */ |
| 4006 | 4092 | int 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 | 4100 | * Decode the audio frame of size avpkt->size from avpkt->data into samples. |
| 4010 | 4101 | * Some decoders may support multiple frames in a single AVPacket, such |
| 4011 | 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 | 4132 | * @param avctx the codec context |
| 4042 | 4133 | * @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 | 4136 | * @param[in,out] frame_size_ptr the output buffer size in bytes |
| 4044 | 4137 | * @param[in] avpkt The input AVPacket containing the input buffer. |
| 4045 | 4138 | * 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 | 4141 | * @return On error a negative value is returned, otherwise the number of bytes |
| 4049 | 4142 | * used or zero if no frame data was decompressed (used) from the input AVPacket. |
| 4050 | 4143 | */ |
| 4051 | −int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, | |
| 4144 | +attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, | |
| 4052 | 4145 | int *frame_size_ptr, |
| 4053 | 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 | + */ | |
| 4182 | +int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, | |
| 4183 | + int *got_frame_ptr, AVPacket *avpkt); | |
| 4054 | 4184 | |
| 4055 | 4185 | /** |
| 4056 | 4186 | * Decode the video frame of size avpkt->size from avpkt->data into picture. |
| @@ -45,6 +45,7 @@ static float quant_table[96]; · 44 unmodified lines | ||
| 45 | 45 | #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11) |
| 46 | 46 | |
| 47 | 47 | typedef struct { |
| 48 | + AVFrame frame; | |
| 48 | 49 | GetBitContext gb; |
| 49 | 50 | DSPContext dsp; |
| 50 | 51 | FmtConvertContext fmt_conv; |
| @@ -147,6 +148,9 @@ static av_cold int decode_init(AVCodecContext *avctx) · 96 unmodified lines | ||
| 147 | 148 | else |
| 148 | 149 | return -1; |
| 149 | 150 | |
| 151 | + avcodec_get_frame_defaults(&s->frame); | |
| 152 | + avctx->coded_frame = &s->frame; | |
| 153 | + | |
| 150 | 154 | return 0; |
| 151 | 155 | } |
| 152 | 156 | |
| @@ -293,6 +297,7 @@ static av_cold int decode_end(AVCodecContext *avctx) · 140 unmodified lines | ||
| 293 | 297 | ff_rdft_end(&s->trans.rdft); |
| 294 | 298 | else if (CONFIG_BINKAUDIO_DCT_DECODER) |
| 295 | 299 | ff_dct_end(&s->trans.dct); |
| 300 | + | |
| 296 | 301 | return 0; |
| 297 | 302 | } |
| 298 | 303 | |
| @@ -302,20 +307,19 @@ static void get_bits_align32(GetBitContext *s) · 3 unmodified lines | ||
| 302 | 307 | if (n) skip_bits(s, n); |
| 303 | 308 | } |
| 304 | 309 | |
| 305 | −static int decode_frame(AVCodecContext *avctx, | |
| 306 | − void *data, int *data_size, | |
| 307 | − AVPacket *avpkt) | |
| 310 | +static int decode_frame(AVCodecContext *avctx, void *data, | |
| 311 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 308 | 312 | { |
| 309 | 313 | BinkAudioContext *s = avctx->priv_data; |
| 310 | − int16_t *samples = data; | |
| 314 | + int16_t *samples; | |
| 311 | 315 | GetBitContext *gb = &s->gb; |
| 312 | − int out_size, consumed = 0; | |
| 316 | + int ret, consumed = 0; | |
| 313 | 317 | |
| 314 | 318 | if (!get_bits_left(gb)) { |
| 315 | 319 | uint8_t *buf; |
| 316 | 320 | /* handle end-of-stream */ |
| 317 | 321 | if (!avpkt->size) { |
| 318 | − *data_size = 0; | |
| 322 | + *got_frame_ptr = 0; | |
| 319 | 323 | return 0; |
| 320 | 324 | } |
| 321 | 325 | if (avpkt->size < 4) { |
| @@ -334,11 +338,13 @@ static int decode_frame(AVCodecContext *avctx, · 12 unmodified lines | ||
| 334 | 338 | skip_bits_long(gb, 32); |
| 335 | 339 | } |
| 336 | 340 | |
| 337 | − out_size = s->block_size * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 338 | − if (*data_size < out_size) { | |
| 339 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 340 | − return AVERROR(EINVAL); | |
| 341 | + /* get output buffer */ | |
| 342 | + s->frame.nb_samples = s->block_size / avctx->channels; | |
| 343 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 344 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 345 | + return ret; | |
| 341 | 346 | } |
| 347 | + samples = (int16_t *)s->frame.data[0]; | |
| 342 | 348 | |
| 343 | 349 | if (decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT)) { |
| 344 | 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 | 353 | get_bits_align32(gb); |
| 348 | 354 | |
| 349 | − *data_size = out_size; | |
| 355 | + *got_frame_ptr = 1; | |
| 356 | + *(AVFrame *)data = s->frame; | |
| 357 | + | |
| 350 | 358 | return consumed; |
| 351 | 359 | } |
| 352 | 360 | |
| @@ -358,7 +366,7 @@ AVCodec ff_binkaudio_rdft_decoder = { · 5 unmodified lines | ||
| 358 | 366 | .init = decode_init, |
| 359 | 367 | .close = decode_end, |
| 360 | 368 | .decode = decode_frame, |
| 361 | − .capabilities = CODEC_CAP_DELAY, | |
| 369 | + .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, | |
| 362 | 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 | 378 | .init = decode_init, |
| 371 | 379 | .close = decode_end, |
| 372 | 380 | .decode = decode_frame, |
| 373 | − .capabilities = CODEC_CAP_DELAY, | |
| 381 | + .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, | |
| 374 | 382 | .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)") |
| 375 | 383 | }; |
| @@ -122,6 +122,7 @@ typedef struct cook { · 121 unmodified lines | ||
| 122 | 122 | void (* saturate_output) (struct cook *q, int chan, float *out); |
| 123 | 123 | |
| 124 | 124 | AVCodecContext* avctx; |
| 125 | + AVFrame frame; | |
| 125 | 126 | GetBitContext gb; |
| 126 | 127 | /* stream data */ |
| 127 | 128 | int nb_channels; |
| @@ -131,6 +132,7 @@ typedef struct cook { · 3 unmodified lines | ||
| 131 | 132 | int samples_per_channel; |
| 132 | 133 | /* states */ |
| 133 | 134 | AVLFG random_state; |
| 135 | + int discarded_packets; | |
| 134 | 136 | |
| 135 | 137 | /* transform data */ |
| 136 | 138 | FFTContext mdct_ctx; |
| @@ -896,7 +898,8 @@ mlt_compensate_output(COOKContext *q, float *decode_buffer, · 759 unmodified lines | ||
| 896 | 898 | float *out, int chan) |
| 897 | 899 | { |
| 898 | 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 | 956 | * @param avctx pointer to the AVCodecContext |
| 954 | 957 | */ |
| 955 | 958 | |
| 956 | −static int cook_decode_frame(AVCodecContext *avctx, | |
| 957 | − void *data, int *data_size, | |
| 958 | − AVPacket *avpkt) { | |
| 959 | +static int cook_decode_frame(AVCodecContext *avctx, void *data, | |
| 960 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 961 | +{ | |
| 959 | 962 | const uint8_t *buf = avpkt->data; |
| 960 | 963 | int buf_size = avpkt->size; |
| 961 | 964 | COOKContext *q = avctx->priv_data; |
| 962 | − int i, out_size; | |
| 965 | + float *samples = NULL; | |
| 966 | + int i, ret; | |
| 963 | 967 | int offset = 0; |
| 964 | 968 | int chidx = 0; |
| 965 | 969 | |
| 966 | 970 | if (buf_size < avctx->block_align) |
| 967 | 971 | return buf_size; |
| 968 | 972 | |
| 969 | − out_size = q->nb_channels * q->samples_per_channel * | |
| 970 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 971 | − if (*data_size < out_size) { | |
| 972 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 973 | − return AVERROR(EINVAL); | |
| 973 | + /* get output buffer */ | |
| 974 | + if (q->discarded_packets >= 2) { | |
| 975 | + q->frame.nb_samples = q->samples_per_channel; | |
| 976 | + if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { | |
| 977 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 978 | + return ret; | |
| 979 | + } | |
| 980 | + samples = (float *)q->frame.data[0]; | |
| 974 | 981 | } |
| 975 | 982 | |
| 976 | 983 | /* estimate subpacket sizes */ |
| @@ -990,15 +997,21 @@ static int cook_decode_frame(AVCodecContext *avctx, · 13 unmodified lines | ||
| 990 | 997 | q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv; |
| 991 | 998 | q->subpacket[i].ch_idx = chidx; |
| 992 | 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 | 1001 | offset += q->subpacket[i].size; |
| 995 | 1002 | chidx += q->subpacket[i].num_channels; |
| 996 | 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 | 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 | 1016 | return avctx->block_align; |
| 1004 | 1017 | } |
| @@ -1246,6 +1259,9 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 241 unmodified lines | ||
| 1246 | 1259 | else |
| 1247 | 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 | 1265 | #ifdef DEBUG |
| 1250 | 1266 | dump_cook_context(q); |
| 1251 | 1267 | #endif |
| @@ -1262,5 +1278,6 @@ AVCodec ff_cook_decoder = · 10 unmodified lines | ||
| 1262 | 1278 | .init = cook_decode_init, |
| 1263 | 1279 | .close = cook_decode_close, |
| 1264 | 1280 | .decode = cook_decode_frame, |
| 1281 | + .capabilities = CODEC_CAP_DR1, | |
| 1265 | 1282 | .long_name = NULL_IF_CONFIG_SMALL("COOK"), |
| 1266 | 1283 | }; |
| @@ -261,6 +261,7 @@ static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int id · 260 unmodified lines | ||
| 261 | 261 | |
| 262 | 262 | typedef struct { |
| 263 | 263 | AVCodecContext *avctx; |
| 264 | + AVFrame frame; | |
| 264 | 265 | /* Frame header */ |
| 265 | 266 | int frame_type; ///< type of the current frame |
| 266 | 267 | int samples_deficit; ///< deficit sample count |
| @@ -1634,9 +1635,8 @@ static void dca_exss_parse_header(DCAContext *s) · 1367 unmodified lines | ||
| 1634 | 1635 | * Main frame decoding function |
| 1635 | 1636 | * FIXME add arguments |
| 1636 | 1637 | */ |
| 1637 | −static int dca_decode_frame(AVCodecContext * avctx, | |
| 1638 | − void *data, int *data_size, | |
| 1639 | − AVPacket *avpkt) | |
| 1638 | +static int dca_decode_frame(AVCodecContext *avctx, void *data, | |
| 1639 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1640 | 1640 | { |
| 1641 | 1641 | const uint8_t *buf = avpkt->data; |
| 1642 | 1642 | int buf_size = avpkt->size; |
| @@ -1644,9 +1644,8 @@ static int dca_decode_frame(AVCodecContext * avctx, · 1 unmodified line | ||
| 1644 | 1644 | int lfe_samples; |
| 1645 | 1645 | int num_core_channels = 0; |
| 1646 | 1646 | int i, ret; |
| 1647 | − float *samples_flt = data; | |
| 1648 | − int16_t *samples_s16 = data; | |
| 1649 | − int out_size; | |
| 1647 | + float *samples_flt; | |
| 1648 | + int16_t *samples_s16; | |
| 1650 | 1649 | DCAContext *s = avctx->priv_data; |
| 1651 | 1650 | int channels; |
| 1652 | 1651 | int core_ss_end; |
| @@ -1832,11 +1831,14 @@ static int dca_decode_frame(AVCodecContext * avctx, · 179 unmodified lines | ||
| 1832 | 1831 | avctx->channels = channels; |
| 1833 | 1832 | } |
| 1834 | 1833 | |
| 1835 | − out_size = 256 / 8 * s->sample_blocks * channels * | |
| 1836 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 1837 | − if (*data_size < out_size) | |
| 1838 | − return AVERROR(EINVAL); | |
| 1839 | − *data_size = out_size; | |
| 1834 | + /* get output buffer */ | |
| 1835 | + s->frame.nb_samples = 256 * (s->sample_blocks / 8); | |
| 1836 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 1837 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 1838 | + return ret; | |
| 1839 | + } | |
| 1840 | + samples_flt = (float *)s->frame.data[0]; | |
| 1841 | + samples_s16 = (int16_t *)s->frame.data[0]; | |
| 1840 | 1842 | |
| 1841 | 1843 | /* filter to get final output */ |
| 1842 | 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 | 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 | 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 | 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 | 1923 | return 0; |
| 1916 | 1924 | } |
| 1917 | 1925 | |
| @@ -1940,7 +1948,7 @@ AVCodec ff_dca_decoder = { · 22 unmodified lines | ||
| 1940 | 1948 | .decode = dca_decode_frame, |
| 1941 | 1949 | .close = dca_decode_end, |
| 1942 | 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 | 1952 | .sample_fmts = (const enum AVSampleFormat[]) { |
| 1945 | 1953 | AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
| 1946 | 1954 | }, |
| @@ -42,6 +42,7 @@ · 41 unmodified lines | ||
| 42 | 42 | #include "bytestream.h" |
| 43 | 43 | |
| 44 | 44 | typedef struct DPCMContext { |
| 45 | + AVFrame frame; | |
| 45 | 46 | int channels; |
| 46 | 47 | int16_t roq_square_array[256]; |
| 47 | 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 | 163 | else |
| 163 | 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 | 169 | return 0; |
| 166 | 170 | } |
| 167 | 171 | |
| 168 | 172 | |
| 169 | −static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |
| 170 | − AVPacket *avpkt) | |
| 173 | +static int dpcm_decode_frame(AVCodecContext *avctx, void *data, | |
| 174 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 171 | 175 | { |
| 172 | 176 | const uint8_t *buf = avpkt->data; |
| 173 | 177 | int buf_size = avpkt->size; |
| 174 | 178 | const uint8_t *buf_end = buf + buf_size; |
| 175 | 179 | DPCMContext *s = avctx->priv_data; |
| 176 | − int out = 0; | |
| 180 | + int out = 0, ret; | |
| 177 | 181 | int predictor[2]; |
| 178 | 182 | int ch = 0; |
| 179 | 183 | int stereo = s->channels - 1; |
| 180 | − int16_t *output_samples = data; | |
| 184 | + int16_t *output_samples; | |
| 181 | 185 | |
| 182 | 186 | /* calculate output size */ |
| 183 | 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 | 201 | out = buf_size; |
| 198 | 202 | break; |
| 199 | 203 | } |
| 200 | − out *= av_get_bytes_per_sample(avctx->sample_fmt); | |
| 201 | 204 | if (out <= 0) { |
| 202 | 205 | av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); |
| 203 | 206 | return AVERROR(EINVAL); |
| 204 | 207 | } |
| 205 | − if (*data_size < out) { | |
| 206 | − av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); | |
| 207 | − return AVERROR(EINVAL); | |
| 208 | + | |
| 209 | + /* get output buffer */ | |
| 210 | + s->frame.nb_samples = out / s->channels; | |
| 211 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 212 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 213 | + return ret; | |
| 208 | 214 | } |
| 215 | + output_samples = (int16_t *)s->frame.data[0]; | |
| 209 | 216 | |
| 210 | 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 | 314 | break; |
| 308 | 315 | } |
| 309 | 316 | |
| 310 | − *data_size = out; | |
| 317 | + *got_frame_ptr = 1; | |
| 318 | + *(AVFrame *)data = s->frame; | |
| 319 | + | |
| 311 | 320 | return buf_size; |
| 312 | 321 | } |
| 313 | 322 | |
| @@ -319,6 +328,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 5 unmodified lines | ||
| 319 | 328 | .priv_data_size = sizeof(DPCMContext), \ |
| 320 | 329 | .init = dpcm_decode_init, \ |
| 321 | 330 | .decode = dpcm_decode_frame, \ |
| 331 | + .capabilities = CODEC_CAP_DR1, \ | |
| 322 | 332 | .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ |
| 323 | 333 | } |
| 324 | 334 | |
| @@ -44,6 +44,7 @@ typedef struct CinVideoContext { · 43 unmodified lines | ||
| 44 | 44 | } CinVideoContext; |
| 45 | 45 | |
| 46 | 46 | typedef struct CinAudioContext { |
| 47 | + AVFrame frame; | |
| 47 | 48 | int initial_decode_frame; |
| 48 | 49 | int delta; |
| 49 | 50 | } CinAudioContext; |
| @@ -318,25 +319,28 @@ static av_cold int cinaudio_decode_init(AVCodecContext *avctx) · 268 unmodified lines | ||
| 318 | 319 | cin->delta = 0; |
| 319 | 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 | 325 | return 0; |
| 322 | 326 | } |
| 323 | 327 | |
| 324 | −static int cinaudio_decode_frame(AVCodecContext *avctx, | |
| 325 | − void *data, int *data_size, | |
| 326 | − AVPacket *avpkt) | |
| 328 | +static int cinaudio_decode_frame(AVCodecContext *avctx, void *data, | |
| 329 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 327 | 330 | { |
| 328 | 331 | const uint8_t *buf = avpkt->data; |
| 329 | 332 | CinAudioContext *cin = avctx->priv_data; |
| 330 | 333 | const uint8_t *buf_end = buf + avpkt->size; |
| 331 | − int16_t *samples = data; | |
| 332 | − int delta, out_size; | |
| 333 | − | |
| 334 | − out_size = (avpkt->size - cin->initial_decode_frame) * | |
| 335 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 336 | − if (*data_size < out_size) { | |
| 337 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 338 | − return AVERROR(EINVAL); | |
| 334 | + int16_t *samples; | |
| 335 | + int delta, ret; | |
| 336 | + | |
| 337 | + /* get output buffer */ | |
| 338 | + cin->frame.nb_samples = avpkt->size - cin->initial_decode_frame; | |
| 339 | + if ((ret = avctx->get_buffer(avctx, &cin->frame)) < 0) { | |
| 340 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 341 | + return ret; | |
| 339 | 342 | } |
| 343 | + samples = (int16_t *)cin->frame.data[0]; | |
| 340 | 344 | |
| 341 | 345 | delta = cin->delta; |
| 342 | 346 | if (cin->initial_decode_frame) { |
| @@ -352,7 +356,8 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, · 9 unmodified lines | ||
| 352 | 356 | } |
| 353 | 357 | cin->delta = delta; |
| 354 | 358 | |
| 355 | − *data_size = out_size; | |
| 359 | + *got_frame_ptr = 1; | |
| 360 | + *(AVFrame *)data = cin->frame; | |
| 356 | 361 | |
| 357 | 362 | return avpkt->size; |
| 358 | 363 | } |
| @@ -377,5 +382,6 @@ AVCodec ff_dsicinaudio_decoder = { · 18 unmodified lines | ||
| 377 | 382 | .priv_data_size = sizeof(CinAudioContext), |
| 378 | 383 | .init = cinaudio_decode_init, |
| 379 | 384 | .decode = cinaudio_decode_frame, |
| 385 | + .capabilities = CODEC_CAP_DR1, | |
| 380 | 386 | .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"), |
| 381 | 387 | }; |
| @@ -49,6 +49,7 @@ typedef struct FLACContext { · 48 unmodified lines | ||
| 49 | 49 | FLACSTREAMINFO |
| 50 | 50 | |
| 51 | 51 | AVCodecContext *avctx; ///< parent AVCodecContext |
| 52 | + AVFrame frame; | |
| 52 | 53 | GetBitContext gb; ///< GetBitContext initialized to start at the current frame |
| 53 | 54 | |
| 54 | 55 | 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 | 117 | allocate_buffers(s); |
| 117 | 118 | s->got_streaminfo = 1; |
| 118 | 119 | |
| 120 | + avcodec_get_frame_defaults(&s->frame); | |
| 121 | + avctx->coded_frame = &s->frame; | |
| 122 | + | |
| 119 | 123 | return 0; |
| 120 | 124 | } |
| 121 | 125 | |
| @@ -542,20 +546,18 @@ static int decode_frame(FLACContext *s) · 420 unmodified lines | ||
| 542 | 546 | return 0; |
| 543 | 547 | } |
| 544 | 548 | |
| 545 | −static int flac_decode_frame(AVCodecContext *avctx, | |
| 546 | − void *data, int *data_size, | |
| 547 | − AVPacket *avpkt) | |
| 549 | +static int flac_decode_frame(AVCodecContext *avctx, void *data, | |
| 550 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 548 | 551 | { |
| 549 | 552 | const uint8_t *buf = avpkt->data; |
| 550 | 553 | int buf_size = avpkt->size; |
| 551 | 554 | FLACContext *s = avctx->priv_data; |
| 552 | 555 | int i, j = 0, bytes_read = 0; |
| 553 | − int16_t *samples_16 = data; | |
| 554 | − int32_t *samples_32 = data; | |
| 555 | − int alloc_data_size= *data_size; | |
| 556 | − int output_size; | |
| 556 | + int16_t *samples_16; | |
| 557 | + int32_t *samples_32; | |
| 558 | + int ret; | |
| 557 | 559 | |
| 558 | − *data_size=0; | |
| 560 | + *got_frame_ptr = 0; | |
| 559 | 561 | |
| 560 | 562 | if (s->max_framesize == 0) { |
| 561 | 563 | s->max_framesize = |
| @@ -586,15 +588,14 @@ static int flac_decode_frame(AVCodecContext *avctx, · 24 unmodified lines | ||
| 586 | 588 | } |
| 587 | 589 | bytes_read = (get_bits_count(&s->gb)+7)/8; |
| 588 | 590 | |
| 589 | − /* check if allocated data size is large enough for output */ | |
| 590 | − output_size = s->blocksize * s->channels * | |
| 591 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 592 | − if (output_size > alloc_data_size) { | |
| 593 | − av_log(s->avctx, AV_LOG_ERROR, "output data size is larger than " | |
| 594 | − "allocated data size\n"); | |
| 595 | − return -1; | |
| 591 | + /* get output buffer */ | |
| 592 | + s->frame.nb_samples = s->blocksize; | |
| 593 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 594 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 595 | + return ret; | |
| 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 | 600 | #define DECORRELATE(left, right)\ |
| 600 | 601 | assert(s->channels == 2);\ |
| @@ -639,6 +640,9 @@ static int flac_decode_frame(AVCodecContext *avctx, · 38 unmodified lines | ||
| 639 | 640 | buf_size - bytes_read, buf_size); |
| 640 | 641 | } |
| 641 | 642 | |
| 643 | + *got_frame_ptr = 1; | |
| 644 | + *(AVFrame *)data = s->frame; | |
| 645 | + | |
| 642 | 646 | return bytes_read; |
| 643 | 647 | } |
| 644 | 648 | |
| @@ -662,5 +666,6 @@ AVCodec ff_flac_decoder = { · 17 unmodified lines | ||
| 662 | 666 | .init = flac_decode_init, |
| 663 | 667 | .close = flac_decode_close, |
| 664 | 668 | .decode = flac_decode_frame, |
| 669 | + .capabilities = CODEC_CAP_DR1, | |
| 665 | 670 | .long_name= NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), |
| 666 | 671 | }; |
| @@ -26,10 +26,12 @@ · 25 unmodified lines | ||
| 26 | 26 | #define AVCODEC_G722_H |
| 27 | 27 | |
| 28 | 28 | #include <stdint.h> |
| 29 | +#include "avcodec.h" | |
| 29 | 30 | |
| 30 | 31 | #define PREV_SAMPLES_BUF_SIZE 1024 |
| 31 | 32 | |
| 32 | 33 | typedef struct { |
| 34 | + AVFrame frame; | |
| 33 | 35 | int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples |
| 34 | 36 | int prev_samples_pos; ///< the number of values in prev_samples |
| 35 | 37 | |
| @@ -66,6 +66,9 @@ static av_cold int g722_decode_init(AVCodecContext * avctx) · 65 unmodified lines | ||
| 66 | 66 | c->band[1].scale_factor = 2; |
| 67 | 67 | c->prev_samples_pos = 22; |
| 68 | 68 | |
| 69 | + avcodec_get_frame_defaults(&c->frame); | |
| 70 | + avctx->coded_frame = &c->frame; | |
| 71 | + | |
| 69 | 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 | 84 | ff_g722_low_inv_quant4 }; |
| 82 | 85 | |
| 83 | 86 | static int g722_decode_frame(AVCodecContext *avctx, void *data, |
| 84 | − int *data_size, AVPacket *avpkt) | |
| 87 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 85 | 88 | { |
| 86 | 89 | G722Context *c = avctx->priv_data; |
| 87 | − int16_t *out_buf = data; | |
| 88 | − int j, out_len; | |
| 90 | + int16_t *out_buf; | |
| 91 | + int j, ret; | |
| 89 | 92 | const int skip = 8 - avctx->bits_per_coded_sample; |
| 90 | 93 | const int16_t *quantizer_table = low_inv_quants[skip]; |
| 91 | 94 | GetBitContext gb; |
| 92 | 95 | |
| 93 | − out_len = avpkt->size * 2 * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 94 | − if (*data_size < out_len) { | |
| 95 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 96 | − return AVERROR(EINVAL); | |
| 96 | + /* get output buffer */ | |
| 97 | + c->frame.nb_samples = avpkt->size * 2; | |
| 98 | + if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { | |
| 99 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 100 | + return ret; | |
| 97 | 101 | } |
| 102 | + out_buf = (int16_t *)c->frame.data[0]; | |
| 98 | 103 | |
| 99 | 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 | 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 | 140 | return avpkt->size; |
| 133 | 141 | } |
| 134 | 142 | |
| @@ -139,5 +147,6 @@ AVCodec ff_adpcm_g722_decoder = { · 4 unmodified lines | ||
| 139 | 147 | .priv_data_size = sizeof(G722Context), |
| 140 | 148 | .init = g722_decode_init, |
| 141 | 149 | .decode = g722_decode_frame, |
| 150 | + .capabilities = CODEC_CAP_DR1, | |
| 142 | 151 | .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), |
| 143 | 152 | }; |
| @@ -75,6 +75,7 @@ typedef struct G726Tables { · 74 unmodified lines | ||
| 75 | 75 | |
| 76 | 76 | typedef struct G726Context { |
| 77 | 77 | AVClass *class; |
| 78 | + AVFrame frame; | |
| 78 | 79 | G726Tables tbls; /**< static tables needed for computation */ |
| 79 | 80 | |
| 80 | 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 | 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 | 434 | return 0; |
| 431 | 435 | } |
| 432 | 436 | |
| 433 | −static int g726_decode_frame(AVCodecContext *avctx, | |
| 434 | − void *data, int *data_size, | |
| 435 | − AVPacket *avpkt) | |
| 437 | +static int g726_decode_frame(AVCodecContext *avctx, void *data, | |
| 438 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 436 | 439 | { |
| 437 | 440 | const uint8_t *buf = avpkt->data; |
| 438 | 441 | int buf_size = avpkt->size; |
| 439 | 442 | G726Context *c = avctx->priv_data; |
| 440 | − int16_t *samples = data; | |
| 443 | + int16_t *samples; | |
| 441 | 444 | GetBitContext gb; |
| 442 | − int out_samples, out_size; | |
| 445 | + int out_samples, ret; | |
| 443 | 446 | |
| 444 | 447 | out_samples = buf_size * 8 / c->code_size; |
| 445 | − out_size = out_samples * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 446 | − if (*data_size < out_size) { | |
| 447 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 448 | − return AVERROR(EINVAL); | |
| 448 | + | |
| 449 | + /* get output buffer */ | |
| 450 | + c->frame.nb_samples = out_samples; | |
| 451 | + if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { | |
| 452 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 453 | + return ret; | |
| 449 | 454 | } |
| 455 | + samples = (int16_t *)c->frame.data[0]; | |
| 450 | 456 | |
| 451 | 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 | 462 | if (get_bits_left(&gb) > 0) |
| 457 | 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 | 468 | return buf_size; |
| 461 | 469 | } |
| 462 | 470 | |
| @@ -474,6 +482,7 @@ AVCodec ff_adpcm_g726_decoder = { · 11 unmodified lines | ||
| 474 | 482 | .init = g726_decode_init, |
| 475 | 483 | .decode = g726_decode_frame, |
| 476 | 484 | .flush = g726_decode_flush, |
| 485 | + .capabilities = CODEC_CAP_DR1, | |
| 477 | 486 | .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), |
| 478 | 487 | }; |
| 479 | 488 | #endif |
| @@ -32,6 +32,8 @@ · 31 unmodified lines | ||
| 32 | 32 | |
| 33 | 33 | static av_cold int gsm_init(AVCodecContext *avctx) |
| 34 | 34 | { |
| 35 | + GSMContext *s = avctx->priv_data; | |
| 36 | + | |
| 35 | 37 | avctx->channels = 1; |
| 36 | 38 | if (!avctx->sample_rate) |
| 37 | 39 | avctx->sample_rate = 8000; |
| @@ -47,30 +49,35 @@ static av_cold int gsm_init(AVCodecContext *avctx) · 9 unmodified lines | ||
| 47 | 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 | 55 | return 0; |
| 51 | 56 | } |
| 52 | 57 | |
| 53 | 58 | static 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 | 62 | int res; |
| 57 | 63 | GetBitContext gb; |
| 58 | 64 | const uint8_t *buf = avpkt->data; |
| 59 | 65 | int buf_size = avpkt->size; |
| 60 | − int16_t *samples = data; | |
| 61 | − int frame_bytes = avctx->frame_size * | |
| 62 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 63 | − | |
| 64 | − if (*data_size < frame_bytes) { | |
| 65 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 66 | − return AVERROR(EINVAL); | |
| 67 | − } | |
| 66 | + int16_t *samples; | |
| 68 | 67 | |
| 69 | 68 | if (buf_size < avctx->block_align) { |
| 70 | 69 | av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); |
| 71 | 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 | 81 | switch (avctx->codec_id) { |
| 75 | 82 | case CODEC_ID_GSM: |
| 76 | 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 | 92 | if (res < 0) |
| 86 | 93 | return res; |
| 87 | 94 | } |
| 88 | − *data_size = frame_bytes; | |
| 95 | + | |
| 96 | + *got_frame_ptr = 1; | |
| 97 | + *(AVFrame *)data = s->frame; | |
| 98 | + | |
| 89 | 99 | return avctx->block_align; |
| 90 | 100 | } |
| 91 | 101 | |
| @@ -103,6 +113,7 @@ AVCodec ff_gsm_decoder = { · 11 unmodified lines | ||
| 103 | 113 | .init = gsm_init, |
| 104 | 114 | .decode = gsm_decode_frame, |
| 105 | 115 | .flush = gsm_flush, |
| 116 | + .capabilities = CODEC_CAP_DR1, | |
| 106 | 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 | 125 | .init = gsm_init, |
| 115 | 126 | .decode = gsm_decode_frame, |
| 116 | 127 | .flush = gsm_flush, |
| 128 | + .capabilities = CODEC_CAP_DR1, | |
| 117 | 129 | .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"), |
| 118 | 130 | }; |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | #define AVCODEC_GSMDEC_DATA |
| 24 | 24 | |
| 25 | 25 | #include <stdint.h> |
| 26 | +#include "avcodec.h" | |
| 26 | 27 | |
| 27 | 28 | // input and output sizes in byte |
| 28 | 29 | #define GSM_BLOCK_SIZE 33 |
| @@ -30,6 +31,7 @@ · 1 unmodified line | ||
| 30 | 31 | #define GSM_FRAME_SIZE 160 |
| 31 | 32 | |
| 32 | 33 | typedef struct { |
| 34 | + AVFrame frame; | |
| 33 | 35 | // Contains first 120 elements from the previous frame |
| 34 | 36 | // (used by long_term_synth according to the "lag"), |
| 35 | 37 | // then in the following 160 elements the current |
| @@ -956,8 +956,8 @@ static inline int encode_bgra_bitstream(HYuvContext *s, int count, int planes){ · 955 unmodified lines | ||
| 956 | 956 | |
| 957 | 957 | #if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER |
| 958 | 958 | static void draw_slice(HYuvContext *s, int y){ |
| 959 | − int h, cy; | |
| 960 | − int offset[4]; | |
| 959 | + int h, cy, i; | |
| 960 | + int offset[AV_NUM_DATA_POINTERS]; | |
| 961 | 961 | |
| 962 | 962 | if(s->avctx->draw_horiz_band==NULL) |
| 963 | 963 | return; |
| @@ -974,7 +974,8 @@ static void draw_slice(HYuvContext *s, int y){ · 10 unmodified lines | ||
| 974 | 974 | offset[0] = s->picture.linesize[0]*y; |
| 975 | 975 | offset[1] = s->picture.linesize[1]*cy; |
| 976 | 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 | 979 | emms_c(); |
| 979 | 980 | |
| 980 | 981 | s->avctx->draw_horiz_band(s->avctx, &s->picture, offset, y, 3, h); |
| @@ -51,6 +51,8 @@ · 50 unmodified lines | ||
| 51 | 51 | #define COEFFS 256 |
| 52 | 52 | |
| 53 | 53 | typedef struct { |
| 54 | + AVFrame frame; | |
| 55 | + | |
| 54 | 56 | float old_floor[BANDS]; |
| 55 | 57 | float flcoeffs1[BANDS]; |
| 56 | 58 | float flcoeffs2[BANDS]; |
| @@ -168,6 +170,10 @@ static av_cold int imc_decode_init(AVCodecContext * avctx) · 111 unmodified lines | ||
| 168 | 170 | dsputil_init(&q->dsp, avctx); |
| 169 | 171 | avctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
| 170 | 172 | avctx->channel_layout = AV_CH_LAYOUT_MONO; |
| 173 | + | |
| 174 | + avcodec_get_frame_defaults(&q->frame); | |
| 175 | + avctx->coded_frame = &q->frame; | |
| 176 | + | |
| 171 | 177 | return 0; |
| 172 | 178 | } |
| 173 | 179 | |
| @@ -649,9 +655,8 @@ static int imc_get_coeffs (IMCContext* q) { · 475 unmodified lines | ||
| 649 | 655 | return 0; |
| 650 | 656 | } |
| 651 | 657 | |
| 652 | −static int imc_decode_frame(AVCodecContext * avctx, | |
| 653 | − void *data, int *data_size, | |
| 654 | − AVPacket *avpkt) | |
| 658 | +static int imc_decode_frame(AVCodecContext * avctx, void *data, | |
| 659 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 655 | 660 | { |
| 656 | 661 | const uint8_t *buf = avpkt->data; |
| 657 | 662 | int buf_size = avpkt->size; |
| @@ -659,7 +664,7 @@ static int imc_decode_frame(AVCodecContext * avctx, · 1 unmodified line | ||
| 659 | 664 | IMCContext *q = avctx->priv_data; |
| 660 | 665 | |
| 661 | 666 | int stream_format_code; |
| 662 | − int imc_hdr, i, j, out_size, ret; | |
| 667 | + int imc_hdr, i, j, ret; | |
| 663 | 668 | int flag; |
| 664 | 669 | int bits, summer; |
| 665 | 670 | int counter, bitscount; |
| @@ -670,15 +675,16 @@ static int imc_decode_frame(AVCodecContext * avctx, · 4 unmodified lines | ||
| 670 | 675 | return AVERROR_INVALIDDATA; |
| 671 | 676 | } |
| 672 | 677 | |
| 673 | − out_size = COEFFS * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 674 | − if (*data_size < out_size) { | |
| 675 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 676 | − return AVERROR(EINVAL); | |
| 678 | + /* get output buffer */ | |
| 679 | + q->frame.nb_samples = COEFFS; | |
| 680 | + if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { | |
| 681 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 682 | + return ret; | |
| 677 | 683 | } |
| 684 | + q->out_samples = (float *)q->frame.data[0]; | |
| 678 | 685 | |
| 679 | 686 | q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2); |
| 680 | 687 | |
| 681 | − q->out_samples = data; | |
| 682 | 688 | init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); |
| 683 | 689 | |
| 684 | 690 | /* Check the frame header */ |
| @@ -823,7 +829,8 @@ static int imc_decode_frame(AVCodecContext * avctx, · 138 unmodified lines | ||
| 823 | 829 | |
| 824 | 830 | imc_imdct256(q); |
| 825 | 831 | |
| 826 | − *data_size = out_size; | |
| 832 | + *got_frame_ptr = 1; | |
| 833 | + *(AVFrame *)data = q->frame; | |
| 827 | 834 | |
| 828 | 835 | return IMC_BLOCK_SIZE; |
| 829 | 836 | } |
| @@ -834,6 +841,7 @@ static av_cold int imc_decode_close(AVCodecContext * avctx) · 4 unmodified lines | ||
| 834 | 841 | IMCContext *q = avctx->priv_data; |
| 835 | 842 | |
| 836 | 843 | ff_fft_end(&q->fft); |
| 844 | + | |
| 837 | 845 | return 0; |
| 838 | 846 | } |
| 839 | 847 | |
| @@ -846,5 +854,6 @@ AVCodec ff_imc_decoder = { · 6 unmodified lines | ||
| 846 | 854 | .init = imc_decode_init, |
| 847 | 855 | .close = imc_decode_close, |
| 848 | 856 | .decode = imc_decode_frame, |
| 857 | + .capabilities = CODEC_CAP_DR1, | |
| 849 | 858 | .long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"), |
| 850 | 859 | }; |
| @@ -31,12 +31,15 @@ · 30 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | typedef struct InternalBuffer { |
| 33 | 33 | int last_pic_num; |
| 34 | − uint8_t *base[4]; | |
| 35 | − uint8_t *data[4]; | |
| 36 | − int linesize[4]; | |
| 34 | + uint8_t *base[AV_NUM_DATA_POINTERS]; | |
| 35 | + uint8_t *data[AV_NUM_DATA_POINTERS]; | |
| 36 | + int linesize[AV_NUM_DATA_POINTERS]; | |
| 37 | 37 | int width; |
| 38 | 38 | int height; |
| 39 | 39 | enum PixelFormat pix_fmt; |
| 40 | + uint8_t **extended_data; | |
| 41 | + int audio_data_size; | |
| 42 | + int nb_channels; | |
| 40 | 43 | } InternalBuffer; |
| 41 | 44 | |
| 42 | 45 | typedef struct AVCodecInternal { |
| @@ -124,7 +124,14 @@ AVCodec ff_libgsm_ms_encoder = { · 123 unmodified lines | ||
| 124 | 124 | .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), |
| 125 | 125 | }; |
| 126 | 126 | |
| 127 | +typedef struct LibGSMDecodeContext { | |
| 128 | + AVFrame frame; | |
| 129 | + struct gsm_state *state; | |
| 130 | +} LibGSMDecodeContext; | |
| 131 | + | |
| 127 | 132 | static av_cold int libgsm_decode_init(AVCodecContext *avctx) { |
| 133 | + LibGSMDecodeContext *s = avctx->priv_data; | |
| 134 | + | |
| 128 | 135 | if (avctx->channels > 1) { |
| 129 | 136 | av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", |
| 130 | 137 | avctx->channels); |
| @@ -139,7 +146,7 @@ static av_cold int libgsm_decode_init(AVCodecContext *avctx) { · 8 unmodified lines | ||
| 139 | 146 | |
| 140 | 147 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 141 | 148 | |
| 142 | − avctx->priv_data = gsm_create(); | |
| 149 | + s->state = gsm_create(); | |
| 143 | 150 | |
| 144 | 151 | switch(avctx->codec_id) { |
| 145 | 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 | 167 | return 0; |
| 158 | 168 | } |
| 159 | 169 | |
| 160 | 170 | static av_cold int libgsm_decode_close(AVCodecContext *avctx) { |
| 161 | − gsm_destroy(avctx->priv_data); | |
| 162 | − avctx->priv_data = NULL; | |
| 171 | + LibGSMDecodeContext *s = avctx->priv_data; | |
| 172 | + | |
| 173 | + gsm_destroy(s->state); | |
| 174 | + s->state = NULL; | |
| 163 | 175 | return 0; |
| 164 | 176 | } |
| 165 | 177 | |
| 166 | −static int libgsm_decode_frame(AVCodecContext *avctx, | |
| 167 | − void *data, int *data_size, | |
| 168 | − AVPacket *avpkt) { | |
| 178 | +static int libgsm_decode_frame(AVCodecContext *avctx, void *data, | |
| 179 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 180 | +{ | |
| 169 | 181 | int i, ret; |
| 170 | − struct gsm_state *s = avctx->priv_data; | |
| 182 | + LibGSMDecodeContext *s = avctx->priv_data; | |
| 171 | 183 | uint8_t *buf = avpkt->data; |
| 172 | 184 | int buf_size = avpkt->size; |
| 173 | − int16_t *samples = data; | |
| 174 | − int out_size = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 175 | − | |
| 176 | − if (*data_size < out_size) { | |
| 177 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 178 | − return AVERROR(EINVAL); | |
| 179 | − } | |
| 185 | + int16_t *samples; | |
| 180 | 186 | |
| 181 | 187 | if (buf_size < avctx->block_align) { |
| 182 | 188 | av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); |
| 183 | 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 | 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 | 202 | return -1; |
| 189 | 203 | buf += GSM_BLOCK_SIZE; |
| 190 | 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 | 210 | return avctx->block_align; |
| 195 | 211 | } |
| 196 | 212 | |
| 197 | 213 | static void libgsm_flush(AVCodecContext *avctx) { |
| 198 | − gsm_destroy(avctx->priv_data); | |
| 199 | − avctx->priv_data = gsm_create(); | |
| 214 | + LibGSMDecodeContext *s = avctx->priv_data; | |
| 215 | + | |
| 216 | + gsm_destroy(s->state); | |
| 217 | + s->state = gsm_create(); | |
| 200 | 218 | } |
| 201 | 219 | |
| 202 | 220 | AVCodec ff_libgsm_decoder = { |
| 203 | 221 | .name = "libgsm", |
| 204 | 222 | .type = AVMEDIA_TYPE_AUDIO, |
| 205 | 223 | .id = CODEC_ID_GSM, |
| 224 | + .priv_data_size = sizeof(LibGSMDecodeContext), | |
| 206 | 225 | .init = libgsm_decode_init, |
| 207 | 226 | .close = libgsm_decode_close, |
| 208 | 227 | .decode = libgsm_decode_frame, |
| 209 | 228 | .flush = libgsm_flush, |
| 229 | + .capabilities = CODEC_CAP_DR1, | |
| 210 | 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 | 234 | .name = "libgsm_ms", |
| 215 | 235 | .type = AVMEDIA_TYPE_AUDIO, |
| 216 | 236 | .id = CODEC_ID_GSM_MS, |
| 237 | + .priv_data_size = sizeof(LibGSMDecodeContext), | |
| 217 | 238 | .init = libgsm_decode_init, |
| 218 | 239 | .close = libgsm_decode_close, |
| 219 | 240 | .decode = libgsm_decode_frame, |
| 220 | 241 | .flush = libgsm_flush, |
| 242 | + .capabilities = CODEC_CAP_DR1, | |
| 221 | 243 | .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), |
| 222 | 244 | }; |
| @@ -79,6 +79,7 @@ static int get_bitrate_mode(int bitrate, void *log_ctx) · 78 unmodified lines | ||
| 79 | 79 | |
| 80 | 80 | typedef struct AMRContext { |
| 81 | 81 | AVClass *av_class; |
| 82 | + AVFrame frame; | |
| 82 | 83 | void *dec_state; |
| 83 | 84 | void *enc_state; |
| 84 | 85 | int enc_bitrate; |
| @@ -112,6 +113,9 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx) · 27 unmodified lines | ||
| 112 | 113 | return AVERROR(ENOSYS); |
| 113 | 114 | } |
| 114 | 115 | |
| 116 | + avcodec_get_frame_defaults(&s->frame); | |
| 117 | + avctx->coded_frame = &s->frame; | |
| 118 | + | |
| 115 | 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 | 124 | AMRContext *s = avctx->priv_data; |
| 121 | 125 | |
| 122 | 126 | Decoder_Interface_exit(s->dec_state); |
| 127 | + | |
| 123 | 128 | return 0; |
| 124 | 129 | } |
| 125 | 130 | |
| 126 | 131 | static 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 | 134 | const uint8_t *buf = avpkt->data; |
| 130 | 135 | int buf_size = avpkt->size; |
| 131 | 136 | AMRContext *s = avctx->priv_data; |
| 132 | 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 | 138 | enum Mode dec_mode; |
| 134 | − int packet_size, out_size; | |
| 139 | + int packet_size, ret; | |
| 135 | 140 | |
| 136 | 141 | av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n", |
| 137 | 142 | buf, buf_size, avctx->frame_number); |
| 138 | 143 | |
| 139 | − out_size = 160 * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 140 | − if (*data_size < out_size) { | |
| 141 | − av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); | |
| 142 | − return AVERROR(EINVAL); | |
| 144 | + /* get output buffer */ | |
| 145 | + s->frame.nb_samples = 160; | |
| 146 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 147 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 148 | + return ret; | |
| 143 | 149 | } |
| 144 | 150 | |
| 145 | 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 | 160 | av_dlog(avctx, "packet_size=%d buf= 0x%X %X %X %X\n", |
| 155 | 161 | packet_size, buf[0], buf[1], buf[2], buf[3]); |
| 156 | 162 | /* call decoder */ |
| 157 | − Decoder_Interface_Decode(s->dec_state, buf, data, 0); | |
| 158 | − *data_size = out_size; | |
| 163 | + Decoder_Interface_Decode(s->dec_state, buf, (short *)s->frame.data[0], 0); | |
| 164 | + | |
| 165 | + *got_frame_ptr = 1; | |
| 166 | + *(AVFrame *)data = s->frame; | |
| 159 | 167 | |
| 160 | 168 | return packet_size; |
| 161 | 169 | } |
| @@ -168,6 +176,7 @@ AVCodec ff_libopencore_amrnb_decoder = { · 6 unmodified lines | ||
| 168 | 176 | .init = amr_nb_decode_init, |
| 169 | 177 | .close = amr_nb_decode_close, |
| 170 | 178 | .decode = amr_nb_decode_frame, |
| 179 | + .capabilities = CODEC_CAP_DR1, | |
| 171 | 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 | 260 | #include <opencore-amrwb/if_rom.h> |
| 252 | 261 | |
| 253 | 262 | typedef struct AMRWBContext { |
| 263 | + AVFrame frame; | |
| 254 | 264 | void *state; |
| 255 | 265 | } AMRWBContext; |
| 256 | 266 | |
| @@ -267,23 +277,27 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx) · 10 unmodified lines | ||
| 267 | 277 | return AVERROR(ENOSYS); |
| 268 | 278 | } |
| 269 | 279 | |
| 280 | + avcodec_get_frame_defaults(&s->frame); | |
| 281 | + avctx->coded_frame = &s->frame; | |
| 282 | + | |
| 270 | 283 | return 0; |
| 271 | 284 | } |
| 272 | 285 | |
| 273 | 286 | static 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 | 289 | const uint8_t *buf = avpkt->data; |
| 277 | 290 | int buf_size = avpkt->size; |
| 278 | 291 | AMRWBContext *s = avctx->priv_data; |
| 279 | − int mode; | |
| 280 | − int packet_size, out_size; | |
| 292 | + int mode, ret; | |
| 293 | + int packet_size; | |
| 281 | 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); | |
| 284 | − if (*data_size < out_size) { | |
| 285 | − av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); | |
| 286 | − return AVERROR(EINVAL); | |
| 296 | + /* get output buffer */ | |
| 297 | + s->frame.nb_samples = 320; | |
| 298 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 299 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 300 | + return ret; | |
| 287 | 301 | } |
| 288 | 302 | |
| 289 | 303 | mode = (buf[0] >> 3) & 0x000F; |
| @@ -295,8 +309,11 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data, · 5 unmodified lines | ||
| 295 | 309 | return AVERROR_INVALIDDATA; |
| 296 | 310 | } |
| 297 | 311 | |
| 298 | − D_IF_decode(s->state, buf, data, _good_frame); | |
| 299 | − *data_size = out_size; | |
| 312 | + D_IF_decode(s->state, buf, (short *)s->frame.data[0], _good_frame); | |
| 313 | + | |
| 314 | + *got_frame_ptr = 1; | |
| 315 | + *(AVFrame *)data = s->frame; | |
| 316 | + | |
| 300 | 317 | return packet_size; |
| 301 | 318 | } |
| 302 | 319 | |
| @@ -316,6 +333,7 @@ AVCodec ff_libopencore_amrwb_decoder = { · 13 unmodified lines | ||
| 316 | 333 | .init = amr_wb_decode_init, |
| 317 | 334 | .close = amr_wb_decode_close, |
| 318 | 335 | .decode = amr_wb_decode_frame, |
| 336 | + .capabilities = CODEC_CAP_DR1, | |
| 319 | 337 | .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"), |
| 320 | 338 | }; |
| 321 | 339 | |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "avcodec.h" |
| 26 | 26 | |
| 27 | 27 | typedef struct { |
| 28 | + AVFrame frame; | |
| 28 | 29 | SpeexBits bits; |
| 29 | 30 | SpeexStereoState stereo; |
| 30 | 31 | void *dec_state; |
| @@ -89,26 +90,29 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx) · 58 unmodified lines | ||
| 89 | 90 | s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT; |
| 90 | 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 | 97 | return 0; |
| 93 | 98 | } |
| 94 | 99 | |
| 95 | −static int libspeex_decode_frame(AVCodecContext *avctx, | |
| 96 | − void *data, int *data_size, | |
| 97 | − AVPacket *avpkt) | |
| 100 | +static int libspeex_decode_frame(AVCodecContext *avctx, void *data, | |
| 101 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 98 | 102 | { |
| 99 | 103 | uint8_t *buf = avpkt->data; |
| 100 | 104 | int buf_size = avpkt->size; |
| 101 | 105 | LibSpeexContext *s = avctx->priv_data; |
| 102 | − int16_t *output = data; | |
| 103 | − int out_size, ret, consumed = 0; | |
| 104 | − | |
| 105 | − /* check output buffer size */ | |
| 106 | − out_size = s->frame_size * avctx->channels * | |
| 107 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 108 | − if (*data_size < out_size) { | |
| 109 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 110 | − return AVERROR(EINVAL); | |
| 106 | + int16_t *output; | |
| 107 | + int ret, consumed = 0; | |
| 108 | + | |
| 109 | + /* get output buffer */ | |
| 110 | + s->frame.nb_samples = s->frame_size; | |
| 111 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 112 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 113 | + return ret; | |
| 111 | 114 | } |
| 115 | + output = (int16_t *)s->frame.data[0]; | |
| 112 | 116 | |
| 113 | 117 | /* if there is not enough data left for the smallest possible frame, |
| 114 | 118 | 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 | 120 | if (speex_bits_remaining(&s->bits) < 43) { |
| 117 | 121 | /* check for flush packet */ |
| 118 | 122 | if (!buf || !buf_size) { |
| 119 | − *data_size = 0; | |
| 123 | + *got_frame_ptr = 0; | |
| 120 | 124 | return buf_size; |
| 121 | 125 | } |
| 122 | 126 | /* set new buffer */ |
| @@ -133,7 +137,9 @@ static int libspeex_decode_frame(AVCodecContext *avctx, · 10 unmodified lines | ||
| 133 | 137 | if (avctx->channels == 2) |
| 134 | 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 | 143 | return consumed; |
| 138 | 144 | } |
| 139 | 145 | |
| @@ -163,6 +169,6 @@ AVCodec ff_libspeex_decoder = { · 23 unmodified lines | ||
| 163 | 169 | .close = libspeex_decode_close, |
| 164 | 170 | .decode = libspeex_decode_frame, |
| 165 | 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 | 173 | .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), |
| 168 | 174 | }; |
| @@ -153,6 +153,7 @@ typedef struct ChannelData { · 152 unmodified lines | ||
| 153 | 153 | } ChannelData; |
| 154 | 154 | |
| 155 | 155 | typedef struct MACEContext { |
| 156 | + AVFrame frame; | |
| 156 | 157 | ChannelData chd[2]; |
| 157 | 158 | } MACEContext; |
| 158 | 159 | |
| @@ -228,30 +229,35 @@ static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, · 69 unmodified lines | ||
| 228 | 229 | |
| 229 | 230 | static av_cold int mace_decode_init(AVCodecContext * avctx) |
| 230 | 231 | { |
| 232 | + MACEContext *ctx = avctx->priv_data; | |
| 233 | + | |
| 231 | 234 | if (avctx->channels > 2) |
| 232 | 235 | return -1; |
| 233 | 236 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 237 | + | |
| 238 | + avcodec_get_frame_defaults(&ctx->frame); | |
| 239 | + avctx->coded_frame = &ctx->frame; | |
| 240 | + | |
| 234 | 241 | return 0; |
| 235 | 242 | } |
| 236 | 243 | |
| 237 | −static int mace_decode_frame(AVCodecContext *avctx, | |
| 238 | − void *data, int *data_size, | |
| 239 | − AVPacket *avpkt) | |
| 244 | +static int mace_decode_frame(AVCodecContext *avctx, void *data, | |
| 245 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 240 | 246 | { |
| 241 | 247 | const uint8_t *buf = avpkt->data; |
| 242 | 248 | int buf_size = avpkt->size; |
| 243 | − int16_t *samples = data; | |
| 249 | + int16_t *samples; | |
| 244 | 250 | MACEContext *ctx = avctx->priv_data; |
| 245 | − int i, j, k, l; | |
| 246 | − int out_size; | |
| 251 | + int i, j, k, l, ret; | |
| 247 | 252 | int is_mace3 = (avctx->codec_id == CODEC_ID_MACE3); |
| 248 | 253 | |
| 249 | − out_size = 3 * (buf_size << (1 - is_mace3)) * | |
| 250 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 251 | − if (*data_size < out_size) { | |
| 252 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 253 | − return AVERROR(EINVAL); | |
| 254 | + /* get output buffer */ | |
| 255 | + ctx->frame.nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels; | |
| 256 | + if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) { | |
| 257 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 258 | + return ret; | |
| 254 | 259 | } |
| 260 | + samples = (int16_t *)ctx->frame.data[0]; | |
| 255 | 261 | |
| 256 | 262 | for(i = 0; i < avctx->channels; i++) { |
| 257 | 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 | 289 | return buf_size; |
| 283 | 290 | } |
| @@ -289,6 +296,7 @@ AVCodec ff_mace3_decoder = { · 5 unmodified lines | ||
| 289 | 296 | .priv_data_size = sizeof(MACEContext), |
| 290 | 297 | .init = mace_decode_init, |
| 291 | 298 | .decode = mace_decode_frame, |
| 299 | + .capabilities = CODEC_CAP_DR1, | |
| 292 | 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 | 307 | .priv_data_size = sizeof(MACEContext), |
| 300 | 308 | .init = mace_decode_init, |
| 301 | 309 | .decode = mace_decode_frame, |
| 310 | + .capabilities = CODEC_CAP_DR1, | |
| 302 | 311 | .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"), |
| 303 | 312 | }; |
| 304 | 313 | |
| @@ -120,6 +120,7 @@ typedef struct SubStream { · 119 unmodified lines | ||
| 120 | 120 | |
| 121 | 121 | typedef struct MLPDecodeContext { |
| 122 | 122 | AVCodecContext *avctx; |
| 123 | + AVFrame frame; | |
| 123 | 124 | |
| 124 | 125 | //! Current access unit being read has a major sync. |
| 125 | 126 | int is_major_sync_unit; |
| @@ -242,6 +243,9 @@ static av_cold int mlp_decode_init(AVCodecContext *avctx) · 116 unmodified lines | ||
| 242 | 243 | m->substream[substr].lossless_check_data = 0xffffffff; |
| 243 | 244 | dsputil_init(&m->dsp, avctx); |
| 244 | 245 | |
| 246 | + avcodec_get_frame_defaults(&m->frame); | |
| 247 | + avctx->coded_frame = &m->frame; | |
| 248 | + | |
| 245 | 249 | return 0; |
| 246 | 250 | } |
| 247 | 251 | |
| @@ -946,13 +950,14 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) · 698 unmodified lines | ||
| 946 | 950 | /** Write the audio data into the output buffer. */ |
| 947 | 951 | |
| 948 | 952 | static 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 | 956 | SubStream *s = &m->substream[substr]; |
| 952 | 957 | unsigned int i, out_ch = 0; |
| 953 | − int out_size; | |
| 954 | − int32_t *data_32 = (int32_t*) data; | |
| 955 | − int16_t *data_16 = (int16_t*) data; | |
| 958 | + int32_t *data_32; | |
| 959 | + int16_t *data_16; | |
| 960 | + int ret; | |
| 956 | 961 | int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); |
| 957 | 962 | |
| 958 | 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 | 965 | return AVERROR_INVALIDDATA; |
| 961 | 966 | } |
| 962 | 967 | |
| 963 | − out_size = s->blockpos * m->avctx->channels * | |
| 964 | − av_get_bytes_per_sample(m->avctx->sample_fmt); | |
| 965 | − | |
| 966 | − if (*data_size < out_size) | |
| 967 | − return AVERROR(EINVAL); | |
| 968 | + /* get output buffer */ | |
| 969 | + m->frame.nb_samples = s->blockpos; | |
| 970 | + if ((ret = avctx->get_buffer(avctx, &m->frame)) < 0) { | |
| 971 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 972 | + return ret; | |
| 973 | + } | |
| 974 | + data_32 = (int32_t *)m->frame.data[0]; | |
| 975 | + data_16 = (int16_t *)m->frame.data[0]; | |
| 968 | 976 | |
| 969 | 977 | for (i = 0; i < s->blockpos; i++) { |
| 970 | 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 | 991 | return 0; |
| 983 | 992 | } |
| @@ -986,8 +995,8 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 2 unmodified lines | ||
| 986 | 995 | * @return negative on error, 0 if not enough data is present in the input stream, |
| 987 | 996 | * otherwise the number of bytes consumed. */ |
| 988 | 997 | |
| 989 | −static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size, | |
| 990 | − AVPacket *avpkt) | |
| 998 | +static int read_access_unit(AVCodecContext *avctx, void* data, | |
| 999 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 991 | 1000 | { |
| 992 | 1001 | const uint8_t *buf = avpkt->data; |
| 993 | 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 | 1032 | if (!m->params_valid) { |
| 1024 | 1033 | av_log(m->avctx, AV_LOG_WARNING, |
| 1025 | 1034 | "Stream parameters not seen; skipping frame.\n"); |
| 1026 | − *data_size = 0; | |
| 1035 | + *got_frame_ptr = 0; | |
| 1027 | 1036 | return length; |
| 1028 | 1037 | } |
| 1029 | 1038 | |
| @@ -1168,7 +1177,7 @@ next_substr: · 138 unmodified lines | ||
| 1168 | 1177 | |
| 1169 | 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 | 1181 | return ret; |
| 1173 | 1182 | |
| 1174 | 1183 | return length; |
| @@ -1189,6 +1198,7 @@ AVCodec ff_mlp_decoder = { · 14 unmodified lines | ||
| 1189 | 1198 | .priv_data_size = sizeof(MLPDecodeContext), |
| 1190 | 1199 | .init = mlp_decode_init, |
| 1191 | 1200 | .decode = read_access_unit, |
| 1201 | + .capabilities = CODEC_CAP_DR1, | |
| 1192 | 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 | 1210 | .priv_data_size = sizeof(MLPDecodeContext), |
| 1201 | 1211 | .init = mlp_decode_init, |
| 1202 | 1212 | .decode = read_access_unit, |
| 1213 | + .capabilities = CODEC_CAP_DR1, | |
| 1203 | 1214 | .long_name = NULL_IF_CONFIG_SMALL("TrueHD"), |
| 1204 | 1215 | }; |
| 1205 | 1216 | #endif /* CONFIG_TRUEHD_DECODER */ |
| @@ -50,6 +50,7 @@ typedef struct { · 49 unmodified lines | ||
| 50 | 50 | }Band; |
| 51 | 51 | |
| 52 | 52 | typedef struct { |
| 53 | + AVFrame frame; | |
| 53 | 54 | DSPContext dsp; |
| 54 | 55 | MPADSPContext mpadsp; |
| 55 | 56 | GetBitContext gb; |
| @@ -136,6 +136,10 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) · 135 unmodified lines | ||
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | vlc_initialized = 1; |
| 139 | + | |
| 140 | + avcodec_get_frame_defaults(&c->frame); | |
| 141 | + avctx->coded_frame = &c->frame; | |
| 142 | + | |
| 139 | 143 | return 0; |
| 140 | 144 | } |
| 141 | 145 | |
| @@ -192,9 +196,8 @@ static int get_scale_idx(GetBitContext *gb, int ref) · 50 unmodified lines | ||
| 192 | 196 | return ref + t; |
| 193 | 197 | } |
| 194 | 198 | |
| 195 | −static int mpc7_decode_frame(AVCodecContext * avctx, | |
| 196 | − void *data, int *data_size, | |
| 197 | − AVPacket *avpkt) | |
| 199 | +static int mpc7_decode_frame(AVCodecContext * avctx, void *data, | |
| 200 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 198 | 201 | { |
| 199 | 202 | const uint8_t *buf = avpkt->data; |
| 200 | 203 | int buf_size = avpkt->size; |
| @@ -204,7 +207,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 3 unmodified lines | ||
| 204 | 207 | int i, ch; |
| 205 | 208 | int mb = -1; |
| 206 | 209 | Band *bands = c->bands; |
| 207 | − int off, out_size; | |
| 210 | + int off, ret; | |
| 208 | 211 | int bits_used, bits_avail; |
| 209 | 212 | |
| 210 | 213 | memset(bands, 0, sizeof(*bands) * (c->maxbands + 1)); |
| @@ -213,10 +216,11 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 2 unmodified lines | ||
| 213 | 216 | return AVERROR(EINVAL); |
| 214 | 217 | } |
| 215 | 218 | |
| 216 | − out_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4; | |
| 217 | − if (*data_size < out_size) { | |
| 218 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 219 | − return AVERROR(EINVAL); | |
| 219 | + /* get output buffer */ | |
| 220 | + c->frame.nb_samples = buf[1] ? c->lastframelen : MPC_FRAME_SIZE; | |
| 221 | + if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { | |
| 222 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 223 | + return ret; | |
| 220 | 224 | } |
| 221 | 225 | |
| 222 | 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 | 280 | for(ch = 0; ch < 2; ch++) |
| 277 | 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 | 285 | av_free(bits); |
| 282 | 286 | |
| @@ -288,10 +292,12 @@ static int mpc7_decode_frame(AVCodecContext * avctx, · 5 unmodified lines | ||
| 288 | 292 | } |
| 289 | 293 | if(c->frames_to_skip){ |
| 290 | 294 | c->frames_to_skip--; |
| 291 | − *data_size = 0; | |
| 295 | + *got_frame_ptr = 0; | |
| 292 | 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 | 302 | return buf_size; |
| 297 | 303 | } |
| @@ -312,5 +318,6 @@ AVCodec ff_mpc7_decoder = { · 14 unmodified lines | ||
| 312 | 318 | .init = mpc7_decode_init, |
| 313 | 319 | .decode = mpc7_decode_frame, |
| 314 | 320 | .flush = mpc7_decode_flush, |
| 321 | + .capabilities = CODEC_CAP_DR1, | |
| 315 | 322 | .long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"), |
| 316 | 323 | }; |
| @@ -230,12 +230,15 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) · 229 unmodified lines | ||
| 230 | 230 | &mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); |
| 231 | 231 | } |
| 232 | 232 | vlc_initialized = 1; |
| 233 | + | |
| 234 | + avcodec_get_frame_defaults(&c->frame); | |
| 235 | + avctx->coded_frame = &c->frame; | |
| 236 | + | |
| 233 | 237 | return 0; |
| 234 | 238 | } |
| 235 | 239 | |
| 236 | −static int mpc8_decode_frame(AVCodecContext * avctx, | |
| 237 | − void *data, int *data_size, | |
| 238 | − AVPacket *avpkt) | |
| 240 | +static int mpc8_decode_frame(AVCodecContext * avctx, void *data, | |
| 241 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 239 | 242 | { |
| 240 | 243 | const uint8_t *buf = avpkt->data; |
| 241 | 244 | int buf_size = avpkt->size; |
| @@ -243,14 +246,15 @@ static int mpc8_decode_frame(AVCodecContext * avctx, · 1 unmodified line | ||
| 243 | 246 | GetBitContext gb2, *gb = &gb2; |
| 244 | 247 | int i, j, k, ch, cnt, res, t; |
| 245 | 248 | Band *bands = c->bands; |
| 246 | − int off, out_size; | |
| 249 | + int off; | |
| 247 | 250 | int maxband, keyframe; |
| 248 | 251 | int last[2]; |
| 249 | 252 | |
| 250 | − out_size = MPC_FRAME_SIZE * 2 * avctx->channels; | |
| 251 | − if (*data_size < out_size) { | |
| 252 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 253 | − return AVERROR(EINVAL); | |
| 253 | + /* get output buffer */ | |
| 254 | + c->frame.nb_samples = MPC_FRAME_SIZE; | |
| 255 | + if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) { | |
| 256 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 257 | + return res; | |
| 254 | 258 | } |
| 255 | 259 | |
| 256 | 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 | 412 | c->cur_frame++; |
| 409 | 413 | |
| 410 | 414 | c->last_bits_used = get_bits_count(gb); |
| 411 | 415 | if(c->cur_frame >= c->frames) |
| 412 | 416 | c->cur_frame = 0; |
| 413 | − *data_size = out_size; | |
| 417 | + | |
| 418 | + *got_frame_ptr = 1; | |
| 419 | + *(AVFrame *)data = c->frame; | |
| 414 | 420 | |
| 415 | 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 | 428 | .priv_data_size = sizeof(MPCContext), |
| 423 | 429 | .init = mpc8_decode_init, |
| 424 | 430 | .decode = mpc8_decode_frame, |
| 431 | + .capabilities = CODEC_CAP_DR1, | |
| 425 | 432 | .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"), |
| 426 | 433 | }; |
| @@ -76,12 +76,13 @@ static inline int get_sample_rate(GetBitContext *gb, int *index) · 75 unmodified lines | ||
| 76 | 76 | avpriv_mpeg4audio_sample_rates[*index]; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | −int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) | |
| 79 | +int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, | |
| 80 | + int bit_size, int sync_extension) | |
| 80 | 81 | { |
| 81 | 82 | GetBitContext gb; |
| 82 | 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 | 86 | c->object_type = get_object_type(&gb); |
| 86 | 87 | c->sample_rate = get_sample_rate(&gb, &c->sampling_index); |
| 87 | 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 | 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 | 122 | while (get_bits_left(&gb) > 15) { |
| 122 | 123 | if (show_bits(&gb, 11) == 0x2b7) { // sync extension |
| 123 | 124 | get_bits(&gb, 11); |
| @@ -42,14 +42,17 @@ typedef struct { · 41 unmodified lines | ||
| 42 | 42 | |
| 43 | 43 | extern const int avpriv_mpeg4audio_sample_rates[16]; |
| 44 | 44 | extern const uint8_t ff_mpeg4audio_channels[8]; |
| 45 | + | |
| 45 | 46 | /** |
| 46 | 47 | * Parse MPEG-4 systems extradata to retrieve audio configuration. |
| 47 | 48 | * @param[in] c MPEG4AudioConfig structure to fill. |
| 48 | 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 | 52 | * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata. |
| 51 | 53 | */ |
| 52 | −int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size); | |
| 54 | +int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, | |
| 55 | + int bit_size, int sync_extension); | |
| 53 | 56 | |
| 54 | 57 | enum AudioObjectType { |
| 55 | 58 | AOT_NULL, |
| @@ -79,6 +79,7 @@ typedef struct MPADecodeContext { · 78 unmodified lines | ||
| 79 | 79 | int err_recognition; |
| 80 | 80 | AVCodecContext* avctx; |
| 81 | 81 | MPADSPContext mpadsp; |
| 82 | + AVFrame frame; | |
| 82 | 83 | } MPADecodeContext; |
| 83 | 84 | |
| 84 | 85 | #if CONFIG_FLOAT |
| @@ -479,6 +480,10 @@ static av_cold int decode_init(AVCodecContext * avctx) · 394 unmodified lines | ||
| 479 | 480 | |
| 480 | 481 | if (avctx->codec_id == CODEC_ID_MP3ADU) |
| 481 | 482 | s->adu_mode = 1; |
| 483 | + | |
| 484 | + avcodec_get_frame_defaults(&s->frame); | |
| 485 | + avctx->coded_frame = &s->frame; | |
| 486 | + | |
| 482 | 487 | return 0; |
| 483 | 488 | } |
| 484 | 489 | |
| @@ -1581,7 +1586,7 @@ static int mp_decode_layer3(MPADecodeContext *s) · 1096 unmodified lines | ||
| 1581 | 1586 | static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples, |
| 1582 | 1587 | const uint8_t *buf, int buf_size) |
| 1583 | 1588 | { |
| 1584 | − int i, nb_frames, ch; | |
| 1589 | + int i, nb_frames, ch, ret; | |
| 1585 | 1590 | OUT_INT *samples_ptr; |
| 1586 | 1591 | |
| 1587 | 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 | 1634 | assert(i <= buf_size - HEADER_SIZE && i >= 0); |
| 1630 | 1635 | memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i); |
| 1631 | 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 | 1649 | /* apply the synthesis filter */ |
| @@ -1650,7 +1663,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples, · 13 unmodified lines | ||
| 1650 | 1663 | return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; |
| 1651 | 1664 | } |
| 1652 | 1665 | |
| 1653 | −static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, | |
| 1666 | +static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, | |
| 1654 | 1667 | AVPacket *avpkt) |
| 1655 | 1668 | { |
| 1656 | 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 | 1671 | MPADecodeContext *s = avctx->priv_data; |
| 1659 | 1672 | uint32_t header; |
| 1660 | 1673 | int out_size; |
| 1661 | − OUT_INT *out_samples = data; | |
| 1662 | 1674 | |
| 1663 | 1675 | if (buf_size < HEADER_SIZE) |
| 1664 | 1676 | return AVERROR_INVALIDDATA; |
| @@ -1681,10 +1693,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 16 unmodified lines | ||
| 1681 | 1693 | avctx->bit_rate = s->bit_rate; |
| 1682 | 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 | 1696 | if (s->frame_size <= 0 || s->frame_size > buf_size) { |
| 1689 | 1697 | av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); |
| 1690 | 1698 | return AVERROR_INVALIDDATA; |
| @@ -1693,9 +1701,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 2 unmodified lines | ||
| 1693 | 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 | 1705 | if (out_size >= 0) { |
| 1698 | − *data_size = out_size; | |
| 1706 | + *got_frame_ptr = 1; | |
| 1707 | + *(AVFrame *)data = s->frame; | |
| 1699 | 1708 | avctx->sample_rate = s->sample_rate; |
| 1700 | 1709 | //FIXME maybe move the other codec info stuff from above here too |
| 1701 | 1710 | } else { |
| @@ -1704,6 +1713,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, · 2 unmodified lines | ||
| 1704 | 1713 | If there is more data in the packet, just consume the bad frame |
| 1705 | 1714 | instead of returning an error, which would discard the whole |
| 1706 | 1715 | packet. */ |
| 1716 | + *got_frame_ptr = 0; | |
| 1707 | 1717 | if (buf_size == avpkt->size) |
| 1708 | 1718 | return out_size; |
| 1709 | 1719 | } |
| @@ -1719,15 +1729,14 @@ static void flush(AVCodecContext *avctx) · 9 unmodified lines | ||
| 1719 | 1729 | } |
| 1720 | 1730 | |
| 1721 | 1731 | #if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER |
| 1722 | −static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, | |
| 1723 | − AVPacket *avpkt) | |
| 1732 | +static int decode_frame_adu(AVCodecContext *avctx, void *data, | |
| 1733 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1724 | 1734 | { |
| 1725 | 1735 | const uint8_t *buf = avpkt->data; |
| 1726 | 1736 | int buf_size = avpkt->size; |
| 1727 | 1737 | MPADecodeContext *s = avctx->priv_data; |
| 1728 | 1738 | uint32_t header; |
| 1729 | 1739 | int len, out_size; |
| 1730 | − OUT_INT *out_samples = data; | |
| 1731 | 1740 | |
| 1732 | 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 | 1766 | avctx->bit_rate = s->bit_rate; |
| 1758 | 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 | 1769 | s->frame_size = len; |
| 1764 | 1770 | |
| 1765 | 1771 | #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 | 1773 | out_size = buf_size; |
| 1768 | 1774 | else |
| 1769 | 1775 | #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 | 1781 | return buf_size; |
| 1774 | 1782 | } |
| 1775 | 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 | 1788 | * Context for MP3On4 decoder |
| 1781 | 1789 | */ |
| 1782 | 1790 | typedef struct MP3On4DecodeContext { |
| 1791 | + AVFrame *frame; | |
| 1783 | 1792 | int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) |
| 1784 | 1793 | int syncword; ///< syncword patch |
| 1785 | 1794 | const uint8_t *coff; ///< channel offsets in output buffer |
| @@ -1843,7 +1852,8 @@ static int decode_init_mp3on4(AVCodecContext * avctx) · 57 unmodified lines | ||
| 1843 | 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 | 1857 | if (!cfg.chan_config || cfg.chan_config > 7) { |
| 1848 | 1858 | av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n"); |
| 1849 | 1859 | return AVERROR_INVALIDDATA; |
| @@ -1870,6 +1880,7 @@ static int decode_init_mp3on4(AVCodecContext * avctx) · 20 unmodified lines | ||
| 1870 | 1880 | // Put decoder context in place to make init_decode() happy |
| 1871 | 1881 | avctx->priv_data = s->mp3decctx[0]; |
| 1872 | 1882 | decode_init(avctx); |
| 1883 | + s->frame = avctx->coded_frame; | |
| 1873 | 1884 | // Restore mp3on4 context pointer |
| 1874 | 1885 | avctx->priv_data = s; |
| 1875 | 1886 | 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 | |
| 1917 | −static int decode_frame_mp3on4(AVCodecContext * avctx, | |
| 1918 | − void *data, int *data_size, | |
| 1919 | − AVPacket *avpkt) | |
| 1928 | +static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, | |
| 1929 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1920 | 1930 | { |
| 1921 | 1931 | const uint8_t *buf = avpkt->data; |
| 1922 | 1932 | int buf_size = avpkt->size; |
| @@ -1924,14 +1934,17 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, · 1 unmodified line | ||
| 1924 | 1934 | MPADecodeContext *m; |
| 1925 | 1935 | int fsize, len = buf_size, out_size = 0; |
| 1926 | 1936 | uint32_t header; |
| 1927 | − OUT_INT *out_samples = data; | |
| 1937 | + OUT_INT *out_samples; | |
| 1928 | 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)) { | |
| 1932 | − av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); | |
| 1933 | − return AVERROR(EINVAL); | |
| 1941 | + /* get output buffer */ | |
| 1942 | + s->frame->nb_samples = MPA_FRAME_SIZE; | |
| 1943 | + if ((ret = avctx->get_buffer(avctx, s->frame)) < 0) { | |
| 1944 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 1945 | + return ret; | |
| 1934 | 1946 | } |
| 1947 | + out_samples = (OUT_INT *)s->frame->data[0]; | |
| 1935 | 1948 | |
| 1936 | 1949 | // Discard too short frames |
| 1937 | 1950 | if (buf_size < HEADER_SIZE) |
| @@ -1990,7 +2003,10 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, · 52 unmodified lines | ||
| 1990 | 2003 | /* update codec info */ |
| 1991 | 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 | 2010 | return buf_size; |
| 1995 | 2011 | } |
| 1996 | 2012 | #endif /* CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER */ |
| @@ -2005,7 +2021,9 @@ AVCodec ff_mp1_decoder = { · 8 unmodified lines | ||
| 2005 | 2021 | .init = decode_init, |
| 2006 | 2022 | .decode = decode_frame, |
| 2007 | 2023 | #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 | 2027 | #endif |
| 2010 | 2028 | .flush = flush, |
| 2011 | 2029 | .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), |
| @@ -2020,7 +2038,9 @@ AVCodec ff_mp2_decoder = { · 8 unmodified lines | ||
| 2020 | 2038 | .init = decode_init, |
| 2021 | 2039 | .decode = decode_frame, |
| 2022 | 2040 | #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 | 2044 | #endif |
| 2025 | 2045 | .flush = flush, |
| 2026 | 2046 | .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), |
| @@ -2035,7 +2055,9 @@ AVCodec ff_mp3_decoder = { · 8 unmodified lines | ||
| 2035 | 2055 | .init = decode_init, |
| 2036 | 2056 | .decode = decode_frame, |
| 2037 | 2057 | #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 | 2061 | #endif |
| 2040 | 2062 | .flush = flush, |
| 2041 | 2063 | .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), |
| @@ -2050,7 +2072,9 @@ AVCodec ff_mp3adu_decoder = { · 8 unmodified lines | ||
| 2050 | 2072 | .init = decode_init, |
| 2051 | 2073 | .decode = decode_frame_adu, |
| 2052 | 2074 | #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 | 2078 | #endif |
| 2055 | 2079 | .flush = flush, |
| 2056 | 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 | 2089 | .init = decode_init_mp3on4, |
| 2066 | 2090 | .close = decode_close_mp3on4, |
| 2067 | 2091 | .decode = decode_frame_mp3on4, |
| 2092 | + .capabilities = CODEC_CAP_DR1, | |
| 2068 | 2093 | .flush = flush_mp3on4, |
| 2069 | 2094 | .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), |
| 2070 | 2095 | }; |
| @@ -31,7 +31,9 @@ AVCodec ff_mp1float_decoder = { · 30 unmodified lines | ||
| 31 | 31 | .init = decode_init, |
| 32 | 32 | .decode = decode_frame, |
| 33 | 33 | #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 | 37 | #endif |
| 36 | 38 | .flush = flush, |
| 37 | 39 | .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), |
| @@ -46,7 +48,9 @@ AVCodec ff_mp2float_decoder = { · 8 unmodified lines | ||
| 46 | 48 | .init = decode_init, |
| 47 | 49 | .decode = decode_frame, |
| 48 | 50 | #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 | 54 | #endif |
| 51 | 55 | .flush = flush, |
| 52 | 56 | .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), |
| @@ -61,7 +65,9 @@ AVCodec ff_mp3float_decoder = { · 8 unmodified lines | ||
| 61 | 65 | .init = decode_init, |
| 62 | 66 | .decode = decode_frame, |
| 63 | 67 | #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 | 71 | #endif |
| 66 | 72 | .flush = flush, |
| 67 | 73 | .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), |
| @@ -76,7 +82,9 @@ AVCodec ff_mp3adufloat_decoder = { · 8 unmodified lines | ||
| 76 | 82 | .init = decode_init, |
| 77 | 83 | .decode = decode_frame_adu, |
| 78 | 84 | #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 | 88 | #endif |
| 81 | 89 | .flush = flush, |
| 82 | 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 | 99 | .init = decode_init_mp3on4, |
| 92 | 100 | .close = decode_close_mp3on4, |
| 93 | 101 | .decode = decode_frame_mp3on4, |
| 102 | + .capabilities = CODEC_CAP_DR1, | |
| 94 | 103 | .flush = flush_mp3on4, |
| 95 | 104 | .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), |
| 96 | 105 | }; |
| @@ -2351,7 +2351,8 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ · 2350 unmodified lines | ||
| 2351 | 2351 | |
| 2352 | 2352 | if (s->avctx->draw_horiz_band) { |
| 2353 | 2353 | AVFrame *src; |
| 2354 | − int offset[4]; | |
| 2354 | + int offset[AV_NUM_DATA_POINTERS]; | |
| 2355 | + int i; | |
| 2355 | 2356 | |
| 2356 | 2357 | if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER)) |
| 2357 | 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 | 2362 | return; |
| 2362 | 2363 | |
| 2363 | 2364 | if(s->pict_type==AV_PICTURE_TYPE_B && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){ |
| 2364 | − offset[0]= | |
| 2365 | − offset[1]= | |
| 2366 | − offset[2]= | |
| 2367 | − offset[3]= 0; | |
| 2365 | + for (i = 0; i < AV_NUM_DATA_POINTERS; i++) | |
| 2366 | + offset[i] = 0; | |
| 2368 | 2367 | }else{ |
| 2369 | 2368 | offset[0]= y * s->linesize; |
| 2370 | 2369 | offset[1]= |
| 2371 | 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 | 2375 | emms_c(); |
| @@ -47,6 +47,7 @@ · 46 unmodified lines | ||
| 47 | 47 | |
| 48 | 48 | typedef struct NellyMoserDecodeContext { |
| 49 | 49 | AVCodecContext* avctx; |
| 50 | + AVFrame frame; | |
| 50 | 51 | float *float_buf; |
| 51 | 52 | DECLARE_ALIGNED(16, float, state)[NELLY_BUF_LEN]; |
| 52 | 53 | AVLFG random_state; |
| @@ -142,33 +143,31 @@ static av_cold int decode_init(AVCodecContext * avctx) { · 89 unmodified lines | ||
| 142 | 143 | ff_init_ff_sine_windows(7); |
| 143 | 144 | |
| 144 | 145 | avctx->channel_layout = AV_CH_LAYOUT_MONO; |
| 146 | + | |
| 147 | + avcodec_get_frame_defaults(&s->frame); | |
| 148 | + avctx->coded_frame = &s->frame; | |
| 149 | + | |
| 145 | 150 | return 0; |
| 146 | 151 | } |
| 147 | 152 | |
| 148 | −static int decode_tag(AVCodecContext * avctx, | |
| 149 | − void *data, int *data_size, | |
| 150 | − AVPacket *avpkt) { | |
| 153 | +static int decode_tag(AVCodecContext *avctx, void *data, | |
| 154 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 155 | +{ | |
| 151 | 156 | const uint8_t *buf = avpkt->data; |
| 152 | 157 | const uint8_t *side=av_packet_get_side_data(avpkt, 'F', NULL); |
| 153 | 158 | int buf_size = avpkt->size; |
| 154 | 159 | NellyMoserDecodeContext *s = avctx->priv_data; |
| 155 | − int data_max = *data_size; | |
| 156 | − int blocks, i, block_size; | |
| 157 | − int16_t *samples_s16 = data; | |
| 158 | − float *samples_flt = data; | |
| 159 | − *data_size = 0; | |
| 160 | + int blocks, i, ret; | |
| 161 | + int16_t *samples_s16; | |
| 162 | + float *samples_flt; | |
| 160 | 163 | |
| 161 | − block_size = NELLY_SAMPLES * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 162 | 164 | blocks = buf_size / NELLY_BLOCK_LEN; |
| 163 | 165 | |
| 164 | 166 | if (blocks <= 0) { |
| 165 | 167 | av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); |
| 166 | 168 | return AVERROR_INVALIDDATA; |
| 167 | 169 | } |
| 168 | − if (data_max < blocks * block_size) { | |
| 169 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 170 | − return AVERROR(EINVAL); | |
| 171 | − } | |
| 170 | + | |
| 172 | 171 | if (buf_size % NELLY_BLOCK_LEN) { |
| 173 | 172 | av_log(avctx, AV_LOG_WARNING, "Leftover bytes: %d.\n", |
| 174 | 173 | buf_size % NELLY_BLOCK_LEN); |
| @@ -183,6 +182,15 @@ static int decode_tag(AVCodecContext * avctx, · 8 unmodified lines | ||
| 183 | 182 | if(side && blocks>1 && avctx->sample_rate%11025==0 && (1<<((side[0]>>2)&3)) == blocks) |
| 184 | 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 | 194 | for (i=0 ; i<blocks ; i++) { |
| 187 | 195 | if (avctx->sample_fmt == SAMPLE_FMT_FLT) { |
| 188 | 196 | nelly_decode_block(s, buf, samples_flt); |
| @@ -194,7 +202,9 @@ static int decode_tag(AVCodecContext * avctx, · 5 unmodified lines | ||
| 194 | 202 | } |
| 195 | 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 | 209 | return buf_size; |
| 200 | 210 | } |
| @@ -204,6 +214,7 @@ static av_cold int decode_end(AVCodecContext * avctx) { · 3 unmodified lines | ||
| 204 | 214 | |
| 205 | 215 | av_freep(&s->float_buf); |
| 206 | 216 | ff_mdct_end(&s->imdct_ctx); |
| 217 | + | |
| 207 | 218 | return 0; |
| 208 | 219 | } |
| 209 | 220 | |
| @@ -215,6 +226,7 @@ AVCodec ff_nellymoser_decoder = { · 5 unmodified lines | ||
| 215 | 226 | .init = decode_init, |
| 216 | 227 | .close = decode_end, |
| 217 | 228 | .decode = decode_tag, |
| 229 | + .capabilities = CODEC_CAP_DR1, | |
| 218 | 230 | .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), |
| 219 | 231 | .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, |
| 220 | 232 | AV_SAMPLE_FMT_S16, |
| @@ -192,6 +192,7 @@ static int pcm_encode_frame(AVCodecContext *avctx, · 191 unmodified lines | ||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | typedef struct PCMDecode { |
| 195 | + AVFrame frame; | |
| 195 | 196 | short table[256]; |
| 196 | 197 | } PCMDecode; |
| 197 | 198 | |
| @@ -223,6 +224,9 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx) · 25 unmodified lines | ||
| 223 | 224 | if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) |
| 224 | 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 | 230 | return 0; |
| 227 | 231 | } |
| 228 | 232 | |
| @@ -243,22 +247,20 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx) · 14 unmodified lines | ||
| 243 | 247 | dst += size / 8; \ |
| 244 | 248 | } |
| 245 | 249 | |
| 246 | −static int pcm_decode_frame(AVCodecContext *avctx, | |
| 247 | − void *data, int *data_size, | |
| 248 | − AVPacket *avpkt) | |
| 250 | +static int pcm_decode_frame(AVCodecContext *avctx, void *data, | |
| 251 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 249 | 252 | { |
| 250 | 253 | const uint8_t *src = avpkt->data; |
| 251 | 254 | int buf_size = avpkt->size; |
| 252 | 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 | 257 | uint8_t *samples; |
| 255 | 258 | int32_t *dst_int32_t; |
| 256 | 259 | |
| 257 | − samples = data; | |
| 258 | − | |
| 259 | 260 | sample_size = av_get_bits_per_sample(avctx->codec_id)/8; |
| 260 | 261 | |
| 261 | 262 | /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */ |
| 263 | + samples_per_block = 1; | |
| 262 | 264 | if (CODEC_ID_PCM_DVD == avctx->codec_id) { |
| 263 | 265 | if (avctx->bits_per_coded_sample != 20 && |
| 264 | 266 | avctx->bits_per_coded_sample != 24) { |
| @@ -268,10 +270,13 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 3 unmodified lines | ||
| 268 | 270 | return AVERROR(EINVAL); |
| 269 | 271 | } |
| 270 | 272 | /* 2 samples are interleaved per block in PCM_DVD */ |
| 273 | + samples_per_block = 2; | |
| 271 | 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 | 276 | /* we process 40-bit blocks per channel for LXF */ |
| 277 | + samples_per_block = 2; | |
| 274 | 278 | sample_size = 5; |
| 279 | + } | |
| 275 | 280 | |
| 276 | 281 | if (sample_size == 0) { |
| 277 | 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 | 296 | n = buf_size/sample_size; |
| 292 | 297 | |
| 293 | − out_size = n * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 294 | − if (avctx->codec_id == CODEC_ID_PCM_DVD || | |
| 295 | − avctx->codec_id == CODEC_ID_PCM_LXF) | |
| 296 | − out_size *= 2; | |
| 297 | − if (*data_size < out_size) { | |
| 298 | − av_log(avctx, AV_LOG_ERROR, "output buffer too small\n"); | |
| 299 | − return AVERROR(EINVAL); | |
| 298 | + /* get output buffer */ | |
| 299 | + s->frame.nb_samples = n * samples_per_block / avctx->channels; | |
| 300 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 301 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 302 | + return ret; | |
| 300 | 303 | } |
| 304 | + samples = s->frame.data[0]; | |
| 301 | 305 | |
| 302 | 306 | switch(avctx->codec->id) { |
| 303 | 307 | case CODEC_ID_PCM_U32LE: |
| @@ -403,7 +407,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 99 unmodified lines | ||
| 403 | 407 | case CODEC_ID_PCM_DVD: |
| 404 | 408 | { |
| 405 | 409 | const uint8_t *src8; |
| 406 | − dst_int32_t = data; | |
| 410 | + dst_int32_t = (int32_t *)s->frame.data[0]; | |
| 407 | 411 | n /= avctx->channels; |
| 408 | 412 | switch (avctx->bits_per_coded_sample) { |
| 409 | 413 | case 20: |
| @@ -435,7 +439,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 25 unmodified lines | ||
| 435 | 439 | { |
| 436 | 440 | int i; |
| 437 | 441 | const uint8_t *src8; |
| 438 | − dst_int32_t = data; | |
| 442 | + dst_int32_t = (int32_t *)s->frame.data[0]; | |
| 439 | 443 | n /= avctx->channels; |
| 440 | 444 | //unpack and de-planerize |
| 441 | 445 | for (i = 0; i < n; i++) { |
| @@ -456,7 +460,10 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 14 unmodified lines | ||
| 456 | 460 | default: |
| 457 | 461 | return -1; |
| 458 | 462 | } |
| 459 | − *data_size = out_size; | |
| 463 | + | |
| 464 | + *got_frame_ptr = 1; | |
| 465 | + *(AVFrame *)data = s->frame; | |
| 466 | + | |
| 460 | 467 | return buf_size; |
| 461 | 468 | } |
| 462 | 469 | |
| @@ -485,6 +492,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 22 unmodified lines | ||
| 485 | 492 | .priv_data_size = sizeof(PCMDecode), \ |
| 486 | 493 | .init = pcm_decode_init, \ |
| 487 | 494 | .decode = pcm_decode_frame, \ |
| 495 | + .capabilities = CODEC_CAP_DR1, \ | |
| 488 | 496 | .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \ |
| 489 | 497 | .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ |
| 490 | 498 | } |
| @@ -56,6 +56,7 @@ typedef enum · 55 unmodified lines | ||
| 56 | 56 | |
| 57 | 57 | typedef struct |
| 58 | 58 | { |
| 59 | + AVFrame avframe; | |
| 59 | 60 | GetBitContext gb; |
| 60 | 61 | qcelp_packet_rate bitrate; |
| 61 | 62 | QCELPFrame frame; /**< unpacked data frame */ |
| @@ -97,6 +98,9 @@ static av_cold int qcelp_decode_init(AVCodecContext *avctx) · 35 unmodified lines | ||
| 97 | 98 | for(i=0; i<10; i++) |
| 98 | 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 | 104 | return 0; |
| 101 | 105 | } |
| 102 | 106 | |
| @@ -682,23 +686,25 @@ static void postfilter(QCELPContext *q, float *samples, float *lpc) · 579 unmodified lines | ||
| 682 | 686 | 160, 0.9375, &q->postfilter_agc_mem); |
| 683 | 687 | } |
| 684 | 688 | |
| 685 | −static int qcelp_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |
| 686 | − AVPacket *avpkt) | |
| 689 | +static int qcelp_decode_frame(AVCodecContext *avctx, void *data, | |
| 690 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 687 | 691 | { |
| 688 | 692 | const uint8_t *buf = avpkt->data; |
| 689 | 693 | int buf_size = avpkt->size; |
| 690 | 694 | QCELPContext *q = avctx->priv_data; |
| 691 | − float *outbuffer = data; | |
| 692 | − int i, out_size; | |
| 695 | + float *outbuffer; | |
| 696 | + int i, ret; | |
| 693 | 697 | float quantized_lspf[10], lpc[10]; |
| 694 | 698 | float gain[16]; |
| 695 | 699 | float *formant_mem; |
| 696 | 700 | |
| 697 | − out_size = 160 * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 698 | − if (*data_size < out_size) { | |
| 699 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 700 | − return AVERROR(EINVAL); | |
| 701 | + /* get output buffer */ | |
| 702 | + q->avframe.nb_samples = 160; | |
| 703 | + if ((ret = avctx->get_buffer(avctx, &q->avframe)) < 0) { | |
| 704 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 705 | + return ret; | |
| 701 | 706 | } |
| 707 | + outbuffer = (float *)q->avframe.data[0]; | |
| 702 | 708 | |
| 703 | 709 | if ((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) { |
| 704 | 710 | warn_insufficient_frame_quality(avctx, "bitrate cannot be determined."); |
| @@ -783,7 +789,8 @@ erasure: · 78 unmodified lines | ||
| 783 | 789 | memcpy(q->prev_lspf, quantized_lspf, sizeof(q->prev_lspf)); |
| 784 | 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 | 795 | return buf_size; |
| 789 | 796 | } |
| @@ -795,6 +802,7 @@ AVCodec ff_qcelp_decoder = · 5 unmodified lines | ||
| 795 | 802 | .id = CODEC_ID_QCELP, |
| 796 | 803 | .init = qcelp_decode_init, |
| 797 | 804 | .decode = qcelp_decode_frame, |
| 805 | + .capabilities = CODEC_CAP_DR1, | |
| 798 | 806 | .priv_data_size = sizeof(QCELPContext), |
| 799 | 807 | .long_name = NULL_IF_CONFIG_SMALL("QCELP / PureVoice"), |
| 800 | 808 | }; |
| @@ -130,6 +130,8 @@ typedef struct { · 129 unmodified lines | ||
| 130 | 130 | * QDM2 decoder context |
| 131 | 131 | */ |
| 132 | 132 | typedef struct { |
| 133 | + AVFrame frame; | |
| 134 | + | |
| 133 | 135 | /// Parameters from codec header, do not change during playback |
| 134 | 136 | int nb_channels; ///< number of channels |
| 135 | 137 | int channels; ///< number of channels |
| @@ -1876,6 +1878,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) · 1740 unmodified lines | ||
| 1876 | 1878 | |
| 1877 | 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 | 1884 | // dump_context(s); |
| 1880 | 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 | |
| 1959 | −static int qdm2_decode_frame(AVCodecContext *avctx, | |
| 1960 | − void *data, int *data_size, | |
| 1961 | − AVPacket *avpkt) | |
| 1964 | +static int qdm2_decode_frame(AVCodecContext *avctx, void *data, | |
| 1965 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1962 | 1966 | { |
| 1963 | 1967 | const uint8_t *buf = avpkt->data; |
| 1964 | 1968 | int buf_size = avpkt->size; |
| 1965 | 1969 | QDM2Context *s = avctx->priv_data; |
| 1966 | − int16_t *out = data; | |
| 1967 | − int i, out_size; | |
| 1970 | + int16_t *out; | |
| 1971 | + int i, ret; | |
| 1968 | 1972 | |
| 1969 | 1973 | if(!buf) |
| 1970 | 1974 | return 0; |
| 1971 | 1975 | if(buf_size < s->checksum_size) |
| 1972 | 1976 | return -1; |
| 1973 | 1977 | |
| 1974 | − out_size = 16 * s->channels * s->frame_size * | |
| 1975 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 1976 | − if (*data_size < out_size) { | |
| 1977 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 1978 | − return AVERROR(EINVAL); | |
| 1978 | + /* get output buffer */ | |
| 1979 | + s->frame.nb_samples = 16 * s->frame_size; | |
| 1980 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 1981 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 1982 | + return ret; | |
| 1979 | 1983 | } |
| 1980 | − | |
| 1981 | − av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n", | |
| 1982 | − buf_size, buf, s->checksum_size, data, *data_size); | |
| 1984 | + out = (int16_t *)s->frame.data[0]; | |
| 1983 | 1985 | |
| 1984 | 1986 | for (i = 0; i < 16; i++) { |
| 1985 | 1987 | if (qdm2_decode(s, buf, out) < 0) |
| @@ -1987,7 +1989,8 @@ static int qdm2_decode_frame(AVCodecContext *avctx, · 1 unmodified line | ||
| 1987 | 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 | 1995 | return s->checksum_size; |
| 1993 | 1996 | } |
| @@ -2001,5 +2004,6 @@ AVCodec ff_qdm2_decoder = · 7 unmodified lines | ||
| 2001 | 2004 | .init = qdm2_decode_init, |
| 2002 | 2005 | .close = qdm2_decode_close, |
| 2003 | 2006 | .decode = qdm2_decode_frame, |
| 2007 | + .capabilities = CODEC_CAP_DR1, | |
| 2004 | 2008 | .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"), |
| 2005 | 2009 | }; |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | |
| 35 | 35 | typedef struct { |
| 36 | 36 | AVCodecContext *avctx; |
| 37 | + AVFrame frame; | |
| 37 | 38 | LPCContext lpc_ctx; |
| 38 | 39 | |
| 39 | 40 | unsigned int old_energy; ///< previous frame energy |
| @@ -38,6 +38,10 @@ static av_cold int ra144_decode_init(AVCodecContext * avctx) · 37 unmodified lines | ||
| 38 | 38 | ractx->lpc_coef[1] = ractx->lpc_tables[1]; |
| 39 | 39 | |
| 40 | 40 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 41 | + | |
| 42 | + avcodec_get_frame_defaults(&ractx->frame); | |
| 43 | + avctx->coded_frame = &ractx->frame; | |
| 44 | + | |
| 41 | 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 | 60 | /** Uncompress one block (20 bytes -> 160*2 bytes). */ |
| 57 | −static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, | |
| 58 | − int *data_size, AVPacket *avpkt) | |
| 61 | +static int ra144_decode_frame(AVCodecContext * avctx, void *data, | |
| 62 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 59 | 63 | { |
| 60 | 64 | const uint8_t *buf = avpkt->data; |
| 61 | 65 | int buf_size = avpkt->size; |
| @@ -64,23 +68,25 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, · 2 unmodified lines | ||
| 64 | 68 | uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block |
| 65 | 69 | unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame |
| 66 | 70 | int i, j; |
| 67 | − int out_size; | |
| 68 | − int16_t *data = vdata; | |
| 71 | + int ret; | |
| 72 | + int16_t *samples; | |
| 69 | 73 | unsigned int energy; |
| 70 | 74 | |
| 71 | 75 | RA144Context *ractx = avctx->priv_data; |
| 72 | 76 | GetBitContext gb; |
| 73 | 77 | |
| 74 | − out_size = NBLOCKS * BLOCKSIZE * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 75 | − if (*data_size < out_size) { | |
| 76 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 77 | − return AVERROR(EINVAL); | |
| 78 | + /* get output buffer */ | |
| 79 | + ractx->frame.nb_samples = NBLOCKS * BLOCKSIZE; | |
| 80 | + if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) { | |
| 81 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 82 | + return ret; | |
| 78 | 83 | } |
| 84 | + samples = (int16_t *)ractx->frame.data[0]; | |
| 79 | 85 | |
| 80 | 86 | if(buf_size < FRAMESIZE) { |
| 81 | 87 | av_log(avctx, AV_LOG_ERROR, |
| 82 | 88 | "Frame too small (%d bytes). Truncated file?\n", buf_size); |
| 83 | − *data_size = 0; | |
| 89 | + *got_frame_ptr = 0; | |
| 84 | 90 | return buf_size; |
| 85 | 91 | } |
| 86 | 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 | 112 | do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb); |
| 107 | 113 | |
| 108 | 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 | 118 | ractx->old_energy = energy; |
| @@ -114,7 +120,9 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, · 1 unmodified line | ||
| 114 | 120 | |
| 115 | 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 | 126 | return FRAMESIZE; |
| 119 | 127 | } |
| 120 | 128 | |
| @@ -125,5 +133,6 @@ AVCodec ff_ra_144_decoder = { · 4 unmodified lines | ||
| 125 | 133 | .priv_data_size = sizeof(RA144Context), |
| 126 | 134 | .init = ra144_decode_init, |
| 127 | 135 | .decode = ra144_decode_frame, |
| 136 | + .capabilities = CODEC_CAP_DR1, | |
| 128 | 137 | .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), |
| 129 | 138 | }; |
| @@ -36,6 +36,7 @@ · 35 unmodified lines | ||
| 36 | 36 | #define RA288_BLOCKS_PER_FRAME 32 |
| 37 | 37 | |
| 38 | 38 | typedef struct { |
| 39 | + AVFrame frame; | |
| 39 | 40 | DSPContext dsp; |
| 40 | 41 | DECLARE_ALIGNED(16, float, sp_lpc)[FFALIGN(36, 8)]; ///< LPC coefficients for speech data (spec: A) |
| 41 | 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 | 63 | RA288Context *ractx = avctx->priv_data; |
| 63 | 64 | avctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
| 64 | 65 | dsputil_init(&ractx->dsp, avctx); |
| 66 | + | |
| 67 | + avcodec_get_frame_defaults(&ractx->frame); | |
| 68 | + avctx->coded_frame = &ractx->frame; | |
| 69 | + | |
| 65 | 70 | return 0; |
| 66 | 71 | } |
| 67 | 72 | |
| @@ -165,12 +170,12 @@ static void backward_filter(RA288Context *ractx, · 97 unmodified lines | ||
| 165 | 170 | } |
| 166 | 171 | |
| 167 | 172 | static int ra288_decode_frame(AVCodecContext * avctx, void *data, |
| 168 | − int *data_size, AVPacket *avpkt) | |
| 173 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 169 | 174 | { |
| 170 | 175 | const uint8_t *buf = avpkt->data; |
| 171 | 176 | int buf_size = avpkt->size; |
| 172 | − float *out = data; | |
| 173 | − int i, out_size; | |
| 177 | + float *out; | |
| 178 | + int i, ret; | |
| 174 | 179 | RA288Context *ractx = avctx->priv_data; |
| 175 | 180 | GetBitContext gb; |
| 176 | 181 | |
| @@ -181,12 +186,13 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, · 4 unmodified lines | ||
| 181 | 186 | return AVERROR_INVALIDDATA; |
| 182 | 187 | } |
| 183 | 188 | |
| 184 | − out_size = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME * | |
| 185 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 186 | − if (*data_size < out_size) { | |
| 187 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 188 | − return AVERROR(EINVAL); | |
| 189 | + /* get output buffer */ | |
| 190 | + ractx->frame.nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME; | |
| 191 | + if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) { | |
| 192 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 193 | + return ret; | |
| 189 | 194 | } |
| 195 | + out = (float *)ractx->frame.data[0]; | |
| 190 | 196 | |
| 191 | 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 | 220 | return avctx->block_align; |
| 213 | 221 | } |
| 214 | 222 | |
| @@ -219,5 +227,6 @@ AVCodec ff_ra_288_decoder = { · 4 unmodified lines | ||
| 219 | 227 | .priv_data_size = sizeof(RA288Context), |
| 220 | 228 | .init = ra288_decode_init, |
| 221 | 229 | .decode = ra288_decode_frame, |
| 230 | + .capabilities = CODEC_CAP_DR1, | |
| 222 | 231 | .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"), |
| 223 | 232 | }; |
| @@ -25,6 +25,10 @@ · 24 unmodified lines | ||
| 25 | 25 | |
| 26 | 26 | #define AES3_HEADER_LEN 4 |
| 27 | 27 | |
| 28 | +typedef struct S302MDecodeContext { | |
| 29 | + AVFrame frame; | |
| 30 | +} S302MDecodeContext; | |
| 31 | + | |
| 28 | 32 | static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf, |
| 29 | 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 | |
| 85 | 89 | static 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 | 93 | const uint8_t *buf = avpkt->data; |
| 89 | 94 | int buf_size = avpkt->size; |
| 95 | + int block_size, ret; | |
| 90 | 96 | |
| 91 | 97 | int frame_size = s302m_parse_frame_header(avctx, buf, buf_size); |
| 92 | 98 | if (frame_size < 0) |
| @@ -95,11 +101,18 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 2 unmodified lines | ||
| 95 | 101 | buf_size -= AES3_HEADER_LEN; |
| 96 | 102 | buf += AES3_HEADER_LEN; |
| 97 | 103 | |
| 98 | − if (*data_size < 4 * buf_size * 8 / (avctx->bits_per_coded_sample + 4)) | |
| 99 | − return -1; | |
| 104 | + /* get output buffer */ | |
| 105 | + block_size = (avctx->bits_per_coded_sample + 4) / 4; | |
| 106 | + s->frame.nb_samples = 2 * (buf_size / block_size) / avctx->channels; | |
| 107 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 108 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 109 | + return ret; | |
| 110 | + } | |
| 111 | + | |
| 112 | + buf_size = (s->frame.nb_samples * avctx->channels / 2) * block_size; | |
| 100 | 113 | |
| 101 | 114 | if (avctx->bits_per_coded_sample == 24) { |
| 102 | − uint32_t *o = data; | |
| 115 | + uint32_t *o = (uint32_t *)s->frame.data[0]; | |
| 103 | 116 | for (; buf_size > 6; buf_size -= 7) { |
| 104 | 117 | *o++ = (av_reverse[buf[2]] << 24) | |
| 105 | 118 | (av_reverse[buf[1]] << 16) | |
| @@ -110,9 +123,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines | ||
| 110 | 123 | (av_reverse[buf[3] & 0x0f] << 4); |
| 111 | 124 | buf += 7; |
| 112 | 125 | } |
| 113 | − *data_size = (uint8_t*) o - (uint8_t*) data; | |
| 114 | 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 | 128 | for (; buf_size > 5; buf_size -= 6) { |
| 117 | 129 | *o++ = (av_reverse[buf[2] & 0xf0] << 28) | |
| 118 | 130 | (av_reverse[buf[1]] << 20) | |
| @@ -122,9 +134,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 3 unmodified lines | ||
| 122 | 134 | (av_reverse[buf[3]] << 12); |
| 123 | 135 | buf += 6; |
| 124 | 136 | } |
| 125 | − *data_size = (uint8_t*) o - (uint8_t*) data; | |
| 126 | 137 | } else { |
| 127 | − uint16_t *o = data; | |
| 138 | + uint16_t *o = (uint16_t *)s->frame.data[0]; | |
| 128 | 139 | for (; buf_size > 4; buf_size -= 5) { |
| 129 | 140 | *o++ = (av_reverse[buf[1]] << 8) | |
| 130 | 141 | av_reverse[buf[0]]; |
| @@ -133,10 +144,22 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, · 2 unmodified lines | ||
| 133 | 144 | (av_reverse[buf[2]] >> 4); |
| 134 | 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 | + | |
| 155 | +static int s302m_decode_init(AVCodecContext *avctx) | |
| 156 | +{ | |
| 157 | + S302MDecodeContext *s = avctx->priv_data; | |
| 158 | + | |
| 159 | + avcodec_get_frame_defaults(&s->frame); | |
| 160 | + avctx->coded_frame = &s->frame; | |
| 161 | + | |
| 162 | + return 0; | |
| 140 | 163 | } |
| 141 | 164 | |
| 142 | 165 | |
| @@ -144,6 +167,9 @@ AVCodec ff_s302m_decoder = { · 1 unmodified line | ||
| 144 | 167 | .name = "s302m", |
| 145 | 168 | .type = AVMEDIA_TYPE_AUDIO, |
| 146 | 169 | .id = CODEC_ID_S302M, |
| 170 | + .priv_data_size = sizeof(S302MDecodeContext), | |
| 171 | + .init = s302m_decode_init, | |
| 147 | 172 | .decode = s302m_decode_frame, |
| 173 | + .capabilities = CODEC_CAP_DR1, | |
| 148 | 174 | .long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"), |
| 149 | 175 | }; |
| @@ -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 | |
| 80 | 80 | typedef struct ShortenContext { |
| 81 | 81 | AVCodecContext *avctx; |
| 82 | + AVFrame frame; | |
| 82 | 83 | GetBitContext gb; |
| 83 | 84 | |
| 84 | 85 | int min_framesize, max_framesize; |
| @@ -112,6 +113,9 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx) · 27 unmodified lines | ||
| 112 | 113 | s->avctx = avctx; |
| 113 | 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 | 119 | return 0; |
| 116 | 120 | } |
| 117 | 121 | |
| @@ -394,15 +398,13 @@ static int read_header(ShortenContext *s) · 276 unmodified lines | ||
| 394 | 398 | return 0; |
| 395 | 399 | } |
| 396 | 400 | |
| 397 | −static int shorten_decode_frame(AVCodecContext *avctx, | |
| 398 | − void *data, int *data_size, | |
| 399 | − AVPacket *avpkt) | |
| 401 | +static int shorten_decode_frame(AVCodecContext *avctx, void *data, | |
| 402 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 400 | 403 | { |
| 401 | 404 | const uint8_t *buf = avpkt->data; |
| 402 | 405 | int buf_size = avpkt->size; |
| 403 | 406 | ShortenContext *s = avctx->priv_data; |
| 404 | 407 | int i, input_buf_size = 0; |
| 405 | − int16_t *samples = data; | |
| 406 | 408 | int ret; |
| 407 | 409 | |
| 408 | 410 | /* allocate internal bitstream buffer */ |
| @@ -436,7 +438,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 27 unmodified lines | ||
| 436 | 438 | /* do not decode until buffer has at least max_framesize bytes or |
| 437 | 439 | the end of the file has been reached */ |
| 438 | 440 | if (buf_size < s->max_framesize && avpkt->data) { |
| 439 | − *data_size = 0; | |
| 441 | + *got_frame_ptr = 0; | |
| 440 | 442 | return input_buf_size; |
| 441 | 443 | } |
| 442 | 444 | } |
| @@ -448,13 +450,13 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 5 unmodified lines | ||
| 448 | 450 | if (!s->got_header) { |
| 449 | 451 | if ((ret = read_header(s)) < 0) |
| 450 | 452 | return ret; |
| 451 | − *data_size = 0; | |
| 453 | + *got_frame_ptr = 0; | |
| 452 | 454 | goto finish_frame; |
| 453 | 455 | } |
| 454 | 456 | |
| 455 | 457 | /* if quit command was read previously, don't decode anything */ |
| 456 | 458 | if (s->got_quit_command) { |
| 457 | − *data_size = 0; | |
| 459 | + *got_frame_ptr = 0; | |
| 458 | 460 | return avpkt->size; |
| 459 | 461 | } |
| 460 | 462 | |
| @@ -464,7 +466,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 3 unmodified lines | ||
| 464 | 466 | int len; |
| 465 | 467 | |
| 466 | 468 | if (get_bits_left(&s->gb) < 3+FNSIZE) { |
| 467 | − *data_size = 0; | |
| 469 | + *got_frame_ptr = 0; | |
| 468 | 470 | break; |
| 469 | 471 | } |
| 470 | 472 | |
| @@ -472,7 +474,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 1 unmodified line | ||
| 472 | 474 | |
| 473 | 475 | if (cmd > FN_VERBATIM) { |
| 474 | 476 | av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); |
| 475 | − *data_size = 0; | |
| 477 | + *got_frame_ptr = 0; | |
| 476 | 478 | break; |
| 477 | 479 | } |
| 478 | 480 | |
| @@ -507,7 +509,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 28 unmodified lines | ||
| 507 | 509 | break; |
| 508 | 510 | } |
| 509 | 511 | if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) { |
| 510 | − *data_size = 0; | |
| 512 | + *got_frame_ptr = 0; | |
| 511 | 513 | break; |
| 512 | 514 | } |
| 513 | 515 | } else { |
| @@ -571,19 +573,23 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 57 unmodified lines | ||
| 571 | 573 | /* if this is the last channel in the block, output the samples */ |
| 572 | 574 | s->cur_chan++; |
| 573 | 575 | if (s->cur_chan == s->channels) { |
| 574 | − int out_size = s->blocksize * s->channels * | |
| 575 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 576 | − if (*data_size < out_size) { | |
| 577 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 578 | − return AVERROR(EINVAL); | |
| 576 | + /* get output buffer */ | |
| 577 | + s->frame.nb_samples = s->blocksize; | |
| 578 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 579 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 580 | + return ret; | |
| 579 | 581 | } |
| 580 | − interleave_buffer(samples, s->channels, s->blocksize, s->decoded); | |
| 581 | − *data_size = out_size; | |
| 582 | + /* interleave output */ | |
| 583 | + interleave_buffer((int16_t *)s->frame.data[0], s->channels, | |
| 584 | + s->blocksize, s->decoded); | |
| 585 | + | |
| 586 | + *got_frame_ptr = 1; | |
| 587 | + *(AVFrame *)data = s->frame; | |
| 582 | 588 | } |
| 583 | 589 | } |
| 584 | 590 | } |
| 585 | 591 | if (s->cur_chan < s->channels) |
| 586 | − *data_size = 0; | |
| 592 | + *got_frame_ptr = 0; | |
| 587 | 593 | |
| 588 | 594 | finish_frame: |
| 589 | 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 | 621 | av_freep(&s->bitstream); |
| 616 | 622 | av_freep(&s->coeffs); |
| 623 | + | |
| 617 | 624 | return 0; |
| 618 | 625 | } |
| 619 | 626 | |
| @@ -625,6 +632,6 @@ AVCodec ff_shorten_decoder = { · 5 unmodified lines | ||
| 625 | 632 | .init = shorten_decode_init, |
| 626 | 633 | .close = shorten_decode_close, |
| 627 | 634 | .decode = shorten_decode_frame, |
| 628 | − .capabilities = CODEC_CAP_DELAY, | |
| 635 | + .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, | |
| 629 | 636 | .long_name= NULL_IF_CONFIG_SMALL("Shorten"), |
| 630 | 637 | }; |
| @@ -507,20 +507,23 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx) · 506 unmodified lines | ||
| 507 | 507 | |
| 508 | 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 | 513 | return 0; |
| 511 | 514 | } |
| 512 | 515 | |
| 513 | −static int sipr_decode_frame(AVCodecContext *avctx, void *datap, | |
| 514 | − int *data_size, AVPacket *avpkt) | |
| 516 | +static int sipr_decode_frame(AVCodecContext *avctx, void *data, | |
| 517 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 515 | 518 | { |
| 516 | 519 | SiprContext *ctx = avctx->priv_data; |
| 517 | 520 | const uint8_t *buf=avpkt->data; |
| 518 | 521 | SiprParameters parm; |
| 519 | 522 | const SiprModeParam *mode_par = &modes[ctx->mode]; |
| 520 | 523 | GetBitContext gb; |
| 521 | − float *data = datap; | |
| 524 | + float *samples; | |
| 522 | 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 | 528 | ctx->avctx = avctx; |
| 526 | 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 | 533 | return -1; |
| 531 | 534 | } |
| 532 | 535 | |
| 533 | − out_size = mode_par->frames_per_packet * subframe_size * | |
| 534 | − mode_par->subframe_count * | |
| 535 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 536 | − if (*data_size < out_size) { | |
| 537 | − av_log(avctx, AV_LOG_ERROR, | |
| 538 | − "Error processing packet: output buffer (%d) too small\n", | |
| 539 | − *data_size); | |
| 540 | − return -1; | |
| 536 | + /* get output buffer */ | |
| 537 | + ctx->frame.nb_samples = mode_par->frames_per_packet * subframe_size * | |
| 538 | + mode_par->subframe_count; | |
| 539 | + if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) { | |
| 540 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 541 | + return ret; | |
| 541 | 542 | } |
| 543 | + samples = (float *)ctx->frame.data[0]; | |
| 542 | 544 | |
| 543 | 545 | init_get_bits(&gb, buf, mode_par->bits_per_frame); |
| 544 | 546 | |
| 545 | 547 | for (i = 0; i < mode_par->frames_per_packet; i++) { |
| 546 | 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 | 558 | return mode_par->bits_per_frame >> 3; |
| 556 | 559 | } |
| @@ -562,5 +565,6 @@ AVCodec ff_sipr_decoder = { · 5 unmodified lines | ||
| 562 | 565 | .priv_data_size = sizeof(SiprContext), |
| 563 | 566 | .init = sipr_decoder_init, |
| 564 | 567 | .decode = sipr_decode_frame, |
| 568 | + .capabilities = CODEC_CAP_DR1, | |
| 565 | 569 | .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"), |
| 566 | 570 | }; |
| @@ -559,31 +559,43 @@ static av_cold int decode_end(AVCodecContext *avctx) · 558 unmodified lines | ||
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | |
| 562 | +typedef struct SmackerAudioContext { | |
| 563 | + AVFrame frame; | |
| 564 | +} SmackerAudioContext; | |
| 565 | + | |
| 562 | 566 | static av_cold int smka_decode_init(AVCodecContext *avctx) |
| 563 | 567 | { |
| 568 | + SmackerAudioContext *s = avctx->priv_data; | |
| 569 | + | |
| 564 | 570 | if (avctx->channels < 1 || avctx->channels > 2) { |
| 565 | 571 | av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n"); |
| 566 | 572 | return AVERROR(EINVAL); |
| 567 | 573 | } |
| 568 | 574 | avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; |
| 569 | 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 | 580 | return 0; |
| 571 | 581 | } |
| 572 | 582 | |
| 573 | 583 | /** |
| 574 | 584 | * Decode Smacker audio data |
| 575 | 585 | */ |
| 576 | −static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) | |
| 586 | +static int smka_decode_frame(AVCodecContext *avctx, void *data, | |
| 587 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 577 | 588 | { |
| 589 | + SmackerAudioContext *s = avctx->priv_data; | |
| 578 | 590 | const uint8_t *buf = avpkt->data; |
| 579 | 591 | int buf_size = avpkt->size; |
| 580 | 592 | GetBitContext gb; |
| 581 | 593 | HuffContext h[4]; |
| 582 | 594 | VLC vlc[4]; |
| 583 | − int16_t *samples = data; | |
| 584 | − uint8_t *samples8 = data; | |
| 595 | + int16_t *samples; | |
| 596 | + uint8_t *samples8; | |
| 585 | 597 | int val; |
| 586 | − int i, res; | |
| 598 | + int i, res, ret; | |
| 587 | 599 | int unp_size; |
| 588 | 600 | int bits, stereo; |
| 589 | 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 | 612 | if(!get_bits1(&gb)){ |
| 601 | 613 | av_log(avctx, AV_LOG_INFO, "Sound: no data\n"); |
| 602 | − *data_size = 0; | |
| 614 | + *got_frame_ptr = 0; | |
| 603 | 615 | return 1; |
| 604 | 616 | } |
| 605 | 617 | stereo = get_bits1(&gb); |
| 606 | 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 | 619 | if (stereo ^ (avctx->channels != 1)) { |
| 612 | 620 | av_log(avctx, AV_LOG_ERROR, "channels mismatch\n"); |
| 613 | 621 | return AVERROR(EINVAL); |
| @@ -617,6 +625,15 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 3 unmodified lines | ||
| 617 | 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 | 637 | memset(vlc, 0, sizeof(VLC) * 4); |
| 621 | 638 | memset(h, 0, sizeof(HuffContext) * 4); |
| 622 | 639 | // Initialize |
| @@ -706,7 +723,9 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 83 unmodified lines | ||
| 706 | 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 | 729 | return buf_size; |
| 711 | 730 | } |
| 712 | 731 | |
| @@ -726,8 +745,10 @@ AVCodec ff_smackaud_decoder = { · 13 unmodified lines | ||
| 726 | 745 | .name = "smackaud", |
| 727 | 746 | .type = AVMEDIA_TYPE_AUDIO, |
| 728 | 747 | .id = CODEC_ID_SMACKAUDIO, |
| 748 | + .priv_data_size = sizeof(SmackerAudioContext), | |
| 729 | 749 | .init = smka_decode_init, |
| 730 | 750 | .decode = smka_decode_frame, |
| 751 | + .capabilities = CODEC_CAP_DR1, | |
| 731 | 752 | .long_name = NULL_IF_CONFIG_SMALL("Smacker audio"), |
| 732 | 753 | }; |
| 733 | 754 | |
| @@ -195,7 +195,8 @@ static const uint8_t string_table[256] = { · 194 unmodified lines | ||
| 195 | 195 | |
| 196 | 196 | #define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)\ |
| 197 | 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 | 200 | /* calculate codebook entries for this vector */\ |
| 200 | 201 | for (j=0; j < stages; j++) {\ |
| 201 | 202 | entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1);\ |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | * TrueSpeech decoder context |
| 35 | 35 | */ |
| 36 | 36 | typedef struct { |
| 37 | + AVFrame frame; | |
| 37 | 38 | DSPContext dsp; |
| 38 | 39 | /* input data */ |
| 39 | 40 | uint8_t buffer[32]; |
| @@ -69,6 +70,9 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx) · 29 unmodified lines | ||
| 69 | 70 | |
| 70 | 71 | dsputil_init(&c->dsp, avctx); |
| 71 | 72 | |
| 73 | + avcodec_get_frame_defaults(&c->frame); | |
| 74 | + avctx->coded_frame = &c->frame; | |
| 75 | + | |
| 72 | 76 | return 0; |
| 73 | 77 | } |
| 74 | 78 | |
| @@ -299,17 +303,16 @@ static void truespeech_save_prevvec(TSContext *c) · 224 unmodified lines | ||
| 299 | 303 | c->prevfilt[i] = c->cvector[i]; |
| 300 | 304 | } |
| 301 | 305 | |
| 302 | −static int truespeech_decode_frame(AVCodecContext *avctx, | |
| 303 | − void *data, int *data_size, | |
| 304 | − AVPacket *avpkt) | |
| 306 | +static int truespeech_decode_frame(AVCodecContext *avctx, void *data, | |
| 307 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 305 | 308 | { |
| 306 | 309 | const uint8_t *buf = avpkt->data; |
| 307 | 310 | int buf_size = avpkt->size; |
| 308 | 311 | TSContext *c = avctx->priv_data; |
| 309 | 312 | |
| 310 | 313 | int i, j; |
| 311 | − short *samples = data; | |
| 312 | − int iterations, out_size; | |
| 314 | + int16_t *samples; | |
| 315 | + int iterations, ret; | |
| 313 | 316 | |
| 314 | 317 | iterations = buf_size / 32; |
| 315 | 318 | |
| @@ -319,13 +322,15 @@ static int truespeech_decode_frame(AVCodecContext *avctx, · 3 unmodified lines | ||
| 319 | 322 | return -1; |
| 320 | 323 | } |
| 321 | 324 | |
| 322 | − out_size = iterations * 240 * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 323 | − if (*data_size < out_size) { | |
| 324 | − av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 325 | − return AVERROR(EINVAL); | |
| 325 | + /* get output buffer */ | |
| 326 | + c->frame.nb_samples = iterations * 240; | |
| 327 | + if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { | |
| 328 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 329 | + return ret; | |
| 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 | 335 | for(j = 0; j < iterations; j++) { |
| 331 | 336 | truespeech_read_frame(c, buf); |
| @@ -345,7 +350,8 @@ static int truespeech_decode_frame(AVCodecContext *avctx, · 13 unmodified lines | ||
| 345 | 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 | 356 | return buf_size; |
| 351 | 357 | } |
| @@ -357,5 +363,6 @@ AVCodec ff_truespeech_decoder = { · 5 unmodified lines | ||
| 357 | 363 | .priv_data_size = sizeof(TSContext), |
| 358 | 364 | .init = truespeech_decode_init, |
| 359 | 365 | .decode = truespeech_decode_frame, |
| 366 | + .capabilities = CODEC_CAP_DR1, | |
| 360 | 367 | .long_name = NULL_IF_CONFIG_SMALL("DSP Group TrueSpeech"), |
| 361 | 368 | }; |
| @@ -56,6 +56,7 @@ typedef struct TTAChannel { · 55 unmodified lines | ||
| 56 | 56 | |
| 57 | 57 | typedef struct TTAContext { |
| 58 | 58 | AVCodecContext *avctx; |
| 59 | + AVFrame frame; | |
| 59 | 60 | GetBitContext gb; |
| 60 | 61 | |
| 61 | 62 | int format, channels, bps, data_length; |
| @@ -288,17 +289,19 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) · 226 unmodified lines | ||
| 288 | 289 | return -1; |
| 289 | 290 | } |
| 290 | 291 | |
| 292 | + avcodec_get_frame_defaults(&s->frame); | |
| 293 | + avctx->coded_frame = &s->frame; | |
| 294 | + | |
| 291 | 295 | return 0; |
| 292 | 296 | } |
| 293 | 297 | |
| 294 | −static int tta_decode_frame(AVCodecContext *avctx, | |
| 295 | − void *data, int *data_size, | |
| 296 | − AVPacket *avpkt) | |
| 298 | +static int tta_decode_frame(AVCodecContext *avctx, void *data, | |
| 299 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 297 | 300 | { |
| 298 | 301 | const uint8_t *buf = avpkt->data; |
| 299 | 302 | int buf_size = avpkt->size; |
| 300 | 303 | TTAContext *s = avctx->priv_data; |
| 301 | − int i, out_size; | |
| 304 | + int i, ret; | |
| 302 | 305 | int cur_chan = 0, framelen = s->frame_length; |
| 303 | 306 | int32_t *p; |
| 304 | 307 | |
| @@ -309,10 +312,11 @@ static int tta_decode_frame(AVCodecContext *avctx, · 4 unmodified lines | ||
| 309 | 312 | if (!s->total_frames && s->last_frame_length) |
| 310 | 313 | framelen = s->last_frame_length; |
| 311 | 314 | |
| 312 | − out_size = framelen * s->channels * av_get_bytes_per_sample(avctx->sample_fmt); | |
| 313 | − if (*data_size < out_size) { | |
| 314 | − av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n"); | |
| 315 | − return -1; | |
| 315 | + /* get output buffer */ | |
| 316 | + s->frame.nb_samples = framelen; | |
| 317 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 318 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 319 | + return ret; | |
| 316 | 320 | } |
| 317 | 321 | |
| 318 | 322 | // 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 | 413 | // convert to output buffer |
| 410 | 414 | switch(s->bps) { |
| 411 | 415 | case 1: { |
| 412 | − uint8_t *samples = data; | |
| 416 | + uint8_t *samples = (int16_t *)s->frame.data[0]; | |
| 413 | 417 | for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) |
| 414 | 418 | *samples++ = *p + 0x80; |
| 415 | 419 | break; |
| 416 | 420 | } |
| 417 | 421 | case 2: { |
| 418 | − uint16_t *samples = data; | |
| 422 | + uint16_t *samples = (int16_t *)s->frame.data[0]; | |
| 419 | 423 | for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) |
| 420 | 424 | *samples++ = *p; |
| 421 | 425 | break; |
| 422 | 426 | } |
| 423 | 427 | case 3: { |
| 424 | 428 | // shift samples for 24-bit sample format |
| 425 | − int32_t *samples = data; | |
| 429 | + int32_t *samples = (int16_t *)s->frame.data[0]; | |
| 426 | 430 | for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) |
| 427 | 431 | *samples++ <<= 8; |
| 428 | 432 | // reset decode buffer |
| @@ -433,7 +437,8 @@ static int tta_decode_frame(AVCodecContext *avctx, · 4 unmodified lines | ||
| 433 | 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 | 443 | return buf_size; |
| 439 | 444 | } |
| @@ -455,5 +460,6 @@ AVCodec ff_tta_decoder = { · 15 unmodified lines | ||
| 455 | 460 | .init = tta_decode_init, |
| 456 | 461 | .close = tta_decode_close, |
| 457 | 462 | .decode = tta_decode_frame, |
| 463 | + .capabilities = CODEC_CAP_DR1, | |
| 458 | 464 | .long_name = NULL_IF_CONFIG_SMALL("True Audio (TTA)"), |
| 459 | 465 | }; |
| @@ -174,6 +174,7 @@ static const ModeTab mode_44_48 = { · 173 unmodified lines | ||
| 174 | 174 | |
| 175 | 175 | typedef struct TwinContext { |
| 176 | 176 | AVCodecContext *avctx; |
| 177 | + AVFrame frame; | |
| 177 | 178 | DSPContext dsp; |
| 178 | 179 | FFTContext mdct_ctx[3]; |
| 179 | 180 | |
| @@ -195,6 +196,7 @@ typedef struct TwinContext { · 15 unmodified lines | ||
| 195 | 196 | float *curr_frame; ///< non-interleaved output |
| 196 | 197 | float *prev_frame; ///< non-interleaved previous frame |
| 197 | 198 | int last_block_pos[2]; |
| 199 | + int discarded_packets; | |
| 198 | 200 | |
| 199 | 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 | 678 | i); |
| 677 | 679 | } |
| 678 | 680 | |
| 681 | + if (!out) | |
| 682 | + return; | |
| 683 | + | |
| 679 | 684 | size2 = tctx->last_block_pos[0]; |
| 680 | 685 | size1 = mtab->size - size2; |
| 681 | 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 | |
| 813 | 818 | static int twin_decode_frame(AVCodecContext * avctx, void *data, |
| 814 | − int *data_size, AVPacket *avpkt) | |
| 819 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 815 | 820 | { |
| 816 | 821 | const uint8_t *buf = avpkt->data; |
| 817 | 822 | int buf_size = avpkt->size; |
| 818 | 823 | TwinContext *tctx = avctx->priv_data; |
| 819 | 824 | GetBitContext gb; |
| 820 | 825 | const ModeTab *mtab = tctx->mtab; |
| 821 | − float *out = data; | |
| 826 | + float *out = NULL; | |
| 822 | 827 | enum FrameType ftype; |
| 823 | − int window_type, out_size; | |
| 828 | + int window_type, ret; | |
| 824 | 829 | static const enum FrameType wtype_to_ftype_table[] = { |
| 825 | 830 | FT_LONG, FT_LONG, FT_SHORT, FT_LONG, |
| 826 | 831 | 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 | 837 | return AVERROR(EINVAL); |
| 833 | 838 | } |
| 834 | 839 | |
| 835 | − out_size = mtab->size * avctx->channels * | |
| 836 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 837 | − if (*data_size < out_size) { | |
| 838 | − av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); | |
| 839 | − return AVERROR(EINVAL); | |
| 840 | + /* get output buffer */ | |
| 841 | + if (tctx->discarded_packets >= 2) { | |
| 842 | + tctx->frame.nb_samples = mtab->size; | |
| 843 | + if ((ret = avctx->get_buffer(avctx, &tctx->frame)) < 0) { | |
| 844 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 845 | + return ret; | |
| 846 | + } | |
| 847 | + out = (float *)tctx->frame.data[0]; | |
| 840 | 848 | } |
| 841 | 849 | |
| 842 | 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 | 865 | FFSWAP(float*, tctx->curr_frame, tctx->prev_frame); |
| 858 | 866 | |
| 859 | − if (tctx->avctx->frame_number < 2) { | |
| 860 | − *data_size=0; | |
| 867 | + if (tctx->discarded_packets < 2) { | |
| 868 | + tctx->discarded_packets++; | |
| 869 | + *got_frame_ptr = 0; | |
| 861 | 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 | 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 | 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 | 1169 | return 0; |
| 1157 | 1170 | } |
| 1158 | 1171 | |
| @@ -1164,5 +1177,6 @@ AVCodec ff_twinvq_decoder = { · 5 unmodified lines | ||
| 1164 | 1177 | .init = twin_decode_init, |
| 1165 | 1178 | .close = twin_decode_close, |
| 1166 | 1179 | .decode = twin_decode_frame, |
| 1180 | + .capabilities = CODEC_CAP_DR1, | |
| 1167 | 1181 | .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"), |
| 1168 | 1182 | }; |
| @@ -127,7 +127,10 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height){ · 126 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | #define INTERNAL_BUFFER_SIZE (32+1) |
| 129 | 129 | |
| 130 | −void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){ | |
| 130 | +void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, | |
| 131 | + int linesize_align[AV_NUM_DATA_POINTERS]) | |
| 132 | +{ | |
| 133 | + int i; | |
| 131 | 134 | int w_align= 1; |
| 132 | 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 | 216 | *height+=2; // some of the optimized chroma MC reads one line too much |
| 214 | 217 | // which is also done in mpeg decoders with lowres > 0 |
| 215 | 218 | |
| 216 | − linesize_align[0] = | |
| 217 | − linesize_align[1] = | |
| 218 | − linesize_align[2] = | |
| 219 | − linesize_align[3] = STRIDE_ALIGN; | |
| 219 | + for (i = 0; i < AV_NUM_DATA_POINTERS; i++) | |
| 220 | + linesize_align[i] = STRIDE_ALIGN; | |
| 220 | 221 | //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes |
| 221 | 222 | //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the |
| 222 | 223 | //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 | 226 | if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 || |
| 226 | 227 | s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F || |
| 227 | 228 | s->codec_id == CODEC_ID_VP6A || s->codec_id == CODEC_ID_DIRAC) { |
| 228 | − linesize_align[0] = | |
| 229 | − linesize_align[1] = | |
| 230 | − linesize_align[2] = 16; | |
| 229 | + for (i = 0; i < AV_NUM_DATA_POINTERS; i++) | |
| 230 | + linesize_align[i] = 16; | |
| 231 | 231 | } |
| 232 | 232 | #endif |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ |
| 236 | 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 | 238 | int align; |
| 239 | 239 | avcodec_align_dimensions2(s, width, height, linesize_align); |
| 240 | 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 | 260 | pic->format = s->pix_fmt; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | −int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ | |
| 263 | +static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) | |
| 264 | +{ | |
| 265 | + AVCodecInternal *avci = avctx->internal; | |
| 266 | + InternalBuffer *buf; | |
| 267 | + int buf_size, ret, i, needs_extended_data; | |
| 268 | + | |
| 269 | + buf_size = av_samples_get_buffer_size(NULL, avctx->channels, | |
| 270 | + frame->nb_samples, avctx->sample_fmt, | |
| 271 | + 32); | |
| 272 | + if (buf_size < 0) | |
| 273 | + return AVERROR(EINVAL); | |
| 274 | + | |
| 275 | + needs_extended_data = av_sample_fmt_is_planar(avctx->sample_fmt) && | |
| 276 | + avctx->channels > AV_NUM_DATA_POINTERS; | |
| 277 | + | |
| 278 | + /* allocate InternalBuffer if needed */ | |
| 279 | + if (!avci->buffer) { | |
| 280 | + avci->buffer = av_mallocz(sizeof(InternalBuffer)); | |
| 281 | + if (!avci->buffer) | |
| 282 | + return AVERROR(ENOMEM); | |
| 283 | + } | |
| 284 | + buf = avci->buffer; | |
| 285 | + | |
| 286 | + /* if there is a previously-used internal buffer, check its size and | |
| 287 | + channel count to see if we can reuse it */ | |
| 288 | + if (buf->extended_data) { | |
| 289 | + /* if current buffer is too small, free it */ | |
| 290 | + if (buf->extended_data[0] && buf_size > buf->audio_data_size) { | |
| 291 | + av_free(buf->extended_data[0]); | |
| 292 | + if (buf->extended_data != buf->data) | |
| 293 | + av_free(&buf->extended_data); | |
| 294 | + buf->extended_data = NULL; | |
| 295 | + buf->data[0] = NULL; | |
| 296 | + } | |
| 297 | + /* if number of channels has changed, reset and/or free extended data | |
| 298 | + pointers but leave data buffer in buf->data[0] for reuse */ | |
| 299 | + if (buf->nb_channels != avctx->channels) { | |
| 300 | + if (buf->extended_data != buf->data) | |
| 301 | + av_free(buf->extended_data); | |
| 302 | + buf->extended_data = NULL; | |
| 303 | + } | |
| 304 | + } | |
| 305 | + | |
| 306 | + /* if there is no previous buffer or the previous buffer cannot be used | |
| 307 | + as-is, allocate a new buffer and/or rearrange the channel pointers */ | |
| 308 | + if (!buf->extended_data) { | |
| 309 | + /* if the channel pointers will fit, just set extended_data to data, | |
| 310 | + otherwise allocate the extended_data channel pointers */ | |
| 311 | + if (needs_extended_data) { | |
| 312 | + buf->extended_data = av_mallocz(avctx->channels * | |
| 313 | + sizeof(*buf->extended_data)); | |
| 314 | + if (!buf->extended_data) | |
| 315 | + return AVERROR(ENOMEM); | |
| 316 | + } else { | |
| 317 | + buf->extended_data = buf->data; | |
| 318 | + } | |
| 319 | + | |
| 320 | + /* if there is a previous buffer and it is large enough, reuse it and | |
| 321 | + just fill-in new channel pointers and linesize, otherwise allocate | |
| 322 | + a new buffer */ | |
| 323 | + if (buf->extended_data[0]) { | |
| 324 | + ret = av_samples_fill_arrays(buf->extended_data, &buf->linesize[0], | |
| 325 | + buf->extended_data[0], avctx->channels, | |
| 326 | + frame->nb_samples, avctx->sample_fmt, | |
| 327 | + 32); | |
| 328 | + } else { | |
| 329 | + ret = av_samples_alloc(buf->extended_data, &buf->linesize[0], | |
| 330 | + avctx->channels, frame->nb_samples, | |
| 331 | + avctx->sample_fmt, 32); | |
| 332 | + } | |
| 333 | + if (ret) | |
| 334 | + return ret; | |
| 335 | + | |
| 336 | + /* if data was not used for extended_data, we need to copy as many of | |
| 337 | + the extended_data channel pointers as will fit */ | |
| 338 | + if (needs_extended_data) { | |
| 339 | + for (i = 0; i < AV_NUM_DATA_POINTERS; i++) | |
| 340 | + buf->data[i] = buf->extended_data[i]; | |
| 341 | + } | |
| 342 | + buf->audio_data_size = buf_size; | |
| 343 | + buf->nb_channels = avctx->channels; | |
| 344 | + } | |
| 345 | + | |
| 346 | + /* copy InternalBuffer info to the AVFrame */ | |
| 347 | + frame->type = FF_BUFFER_TYPE_INTERNAL; | |
| 348 | + frame->extended_data = buf->extended_data; | |
| 349 | + frame->linesize[0] = buf->linesize[0]; | |
| 350 | + memcpy(frame->data, buf->data, sizeof(frame->data)); | |
| 351 | + | |
| 352 | + if (avctx->pkt) frame->pkt_pts = avctx->pkt->pts; | |
| 353 | + else frame->pkt_pts = AV_NOPTS_VALUE; | |
| 354 | + frame->reordered_opaque = avctx->reordered_opaque; | |
| 355 | + | |
| 356 | + if (avctx->debug & FF_DEBUG_BUFFERS) | |
| 357 | + av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p, " | |
| 358 | + "internal audio buffer used\n", frame); | |
| 359 | + | |
| 360 | + return 0; | |
| 361 | +} | |
| 362 | + | |
| 363 | +static int video_get_buffer(AVCodecContext *s, AVFrame *pic) | |
| 364 | +{ | |
| 264 | 365 | int i; |
| 265 | 366 | int w= s->width; |
| 266 | 367 | int h= s->height; |
| @@ -295,7 +396,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 28 unmodified lines | ||
| 295 | 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 | 400 | av_freep(&buf->base[i]); |
| 300 | 401 | buf->data[i]= NULL; |
| 301 | 402 | } |
| @@ -310,7 +411,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 8 unmodified lines | ||
| 310 | 411 | int tmpsize; |
| 311 | 412 | int unaligned; |
| 312 | 413 | AVPicture picture; |
| 313 | − int stride_align[4]; | |
| 414 | + int stride_align[AV_NUM_DATA_POINTERS]; | |
| 314 | 415 | const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; |
| 315 | 416 | |
| 316 | 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 | 464 | else |
| 364 | 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 | 471 | if(size[1] && !size[2]) |
| 367 | 472 | ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt); |
| 368 | 473 | buf->width = s->width; |
| @@ -372,11 +477,12 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 3 unmodified lines | ||
| 372 | 477 | } |
| 373 | 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 | 481 | pic->base[i]= buf->base[i]; |
| 377 | 482 | pic->data[i]= buf->data[i]; |
| 378 | 483 | pic->linesize[i]= buf->linesize[i]; |
| 379 | 484 | } |
| 485 | + pic->extended_data = pic->data; | |
| 380 | 486 | avci->buffer_count++; |
| 381 | 487 | |
| 382 | 488 | if (s->pkt) { |
| @@ -399,11 +505,25 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 16 unmodified lines | ||
| 399 | 505 | return 0; |
| 400 | 506 | } |
| 401 | 507 | |
| 508 | +int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame) | |
| 509 | +{ | |
| 510 | + switch (avctx->codec_type) { | |
| 511 | + case AVMEDIA_TYPE_VIDEO: | |
| 512 | + return video_get_buffer(avctx, frame); | |
| 513 | + case AVMEDIA_TYPE_AUDIO: | |
| 514 | + return audio_get_buffer(avctx, frame); | |
| 515 | + default: | |
| 516 | + return -1; | |
| 517 | + } | |
| 518 | +} | |
| 519 | + | |
| 402 | 520 | void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ |
| 403 | 521 | int i; |
| 404 | 522 | InternalBuffer *buf, *last; |
| 405 | 523 | AVCodecInternal *avci = s->internal; |
| 406 | 524 | |
| 525 | + assert(s->codec_type == AVMEDIA_TYPE_VIDEO); | |
| 526 | + | |
| 407 | 527 | assert(pic->type==FF_BUFFER_TYPE_INTERNAL); |
| 408 | 528 | assert(avci->buffer_count); |
| 409 | 529 | |
| @@ -421,7 +541,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ · 11 unmodified lines | ||
| 421 | 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 | 545 | pic->data[i]=NULL; |
| 426 | 546 | // pic->base[i]=NULL; |
| 427 | 547 | } |
| @@ -436,6 +556,8 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ · 8 unmodified lines | ||
| 436 | 556 | AVFrame temp_pic; |
| 437 | 557 | int i; |
| 438 | 558 | |
| 559 | + assert(s->codec_type == AVMEDIA_TYPE_VIDEO); | |
| 560 | + | |
| 439 | 561 | /* If no picture return a new buffer */ |
| 440 | 562 | if(pic->data[0] == NULL) { |
| 441 | 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 | 577 | * Not internal type and reget_buffer not overridden, emulate cr buffer |
| 456 | 578 | */ |
| 457 | 579 | temp_pic = *pic; |
| 458 | − for(i = 0; i < 4; i++) | |
| 580 | + for(i = 0; i < AV_NUM_DATA_POINTERS; i++) | |
| 459 | 581 | pic->data[i] = pic->base[i] = NULL; |
| 460 | 582 | pic->opaque = NULL; |
| 461 | 583 | /* Allocate new frame */ |
| @@ -862,36 +984,73 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi · 400 unmodified lines | ||
| 862 | 984 | return ret; |
| 863 | 985 | } |
| 864 | 986 | |
| 987 | +#if FF_API_OLD_DECODE_AUDIO | |
| 865 | 988 | int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, |
| 866 | 989 | int *frame_size_ptr, |
| 867 | 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 | + | |
| 1032 | +int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, | |
| 1033 | + AVFrame *frame, | |
| 1034 | + int *got_frame_ptr, | |
| 1035 | + AVPacket *avpkt) | |
| 1036 | +{ | |
| 1037 | + int ret = 0; | |
| 1038 | + | |
| 1039 | + *got_frame_ptr = 0; | |
| 870 | 1040 | |
| 871 | 1041 | if (!avpkt->data && avpkt->size) { |
| 872 | 1042 | av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); |
| 873 | 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 | 1047 | av_packet_split_side_data(avpkt); |
| 878 | 1048 | avctx->pkt = avpkt; |
| 879 | − //FIXME remove the check below _after_ ensuring that all audio check that the available space is enough | |
| 880 | − if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){ | |
| 881 | − av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n"); | |
| 882 | − return -1; | |
| 883 | − } | |
| 884 | − if(*frame_size_ptr < FF_MIN_BUFFER_SIZE || | |
| 885 | − *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t)){ | |
| 886 | − av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr); | |
| 887 | − return -1; | |
| 1049 | + ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt); | |
| 1050 | + if (ret >= 0 && *got_frame_ptr) { | |
| 1051 | + avctx->frame_number++; | |
| 1052 | + frame->pkt_dts = avpkt->dts; | |
| 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 | 1055 | return ret; |
| 897 | 1056 | } |
| @@ -1230,7 +1389,8 @@ void avcodec_flush_buffers(AVCodecContext *avctx) · 332 unmodified lines | ||
| 1230 | 1389 | avctx->codec->flush(avctx); |
| 1231 | 1390 | } |
| 1232 | 1391 | |
| 1233 | −void avcodec_default_free_buffers(AVCodecContext *s){ | |
| 1392 | +static void video_free_buffers(AVCodecContext *s) | |
| 1393 | +{ | |
| 1234 | 1394 | AVCodecInternal *avci = s->internal; |
| 1235 | 1395 | int i, j; |
| 1236 | 1396 | |
| @@ -1252,6 +1412,37 @@ void avcodec_default_free_buffers(AVCodecContext *s){ · 15 unmodified lines | ||
| 1252 | 1412 | avci->buffer_count=0; |
| 1253 | 1413 | } |
| 1254 | 1414 | |
| 1415 | +static void audio_free_buffers(AVCodecContext *avctx) | |
| 1416 | +{ | |
| 1417 | + AVCodecInternal *avci = avctx->internal; | |
| 1418 | + InternalBuffer *buf; | |
| 1419 | + | |
| 1420 | + if (!avci->buffer) | |
| 1421 | + return; | |
| 1422 | + buf = avci->buffer; | |
| 1423 | + | |
| 1424 | + if (buf->extended_data) { | |
| 1425 | + av_free(buf->extended_data[0]); | |
| 1426 | + if (buf->extended_data != buf->data) | |
| 1427 | + av_free(buf->extended_data); | |
| 1428 | + } | |
| 1429 | + av_freep(&avci->buffer); | |
| 1430 | +} | |
| 1431 | + | |
| 1432 | +void avcodec_default_free_buffers(AVCodecContext *avctx) | |
| 1433 | +{ | |
| 1434 | + switch (avctx->codec_type) { | |
| 1435 | + case AVMEDIA_TYPE_VIDEO: | |
| 1436 | + video_free_buffers(avctx); | |
| 1437 | + break; | |
| 1438 | + case AVMEDIA_TYPE_AUDIO: | |
| 1439 | + audio_free_buffers(avctx); | |
| 1440 | + break; | |
| 1441 | + default: | |
| 1442 | + break; | |
| 1443 | + } | |
| 1444 | +} | |
| 1445 | + | |
| 1255 | 1446 | #if FF_API_OLD_FF_PICT_TYPES |
| 1256 | 1447 | char av_get_pict_type_char(int pict_type){ |
| 1257 | 1448 | return av_get_picture_type_char(pict_type); |
| @@ -21,8 +21,8 @@ · 20 unmodified lines | ||
| 21 | 21 | #define AVCODEC_VERSION_H |
| 22 | 22 | |
| 23 | 23 | #define LIBAVCODEC_VERSION_MAJOR 53 |
| 24 | −#define LIBAVCODEC_VERSION_MINOR 39 | |
| 25 | −#define LIBAVCODEC_VERSION_MICRO 1 | |
| 24 | +#define LIBAVCODEC_VERSION_MINOR 40 | |
| 25 | +#define LIBAVCODEC_VERSION_MICRO 0 | |
| 26 | 26 | |
| 27 | 27 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 28 | 28 | LIBAVCODEC_VERSION_MINOR, \ |
| @@ -110,6 +110,11 @@ · 81 unmodified lines | ||
| 110 | 110 | #ifndef FF_API_TIFFENC_COMPLEVEL |
| 111 | 111 | #define FF_API_TIFFENC_COMPLEVEL (LIBAVCODEC_VERSION_MAJOR < 54) |
| 112 | 112 | #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 | 120 | #endif /* AVCODEC_VERSION_H */ |
| @@ -466,6 +466,7 @@ static av_cold int vmdvideo_decode_end(AVCodecContext *avctx) · 465 unmodified lines | ||
| 466 | 466 | #define BLOCK_TYPE_SILENCE 3 |
| 467 | 467 | |
| 468 | 468 | typedef struct VmdAudioContext { |
| 469 | + AVFrame frame; | |
| 469 | 470 | int out_bps; |
| 470 | 471 | int chunk_size; |
| 471 | 472 | } VmdAudioContext; |
| @@ -507,6 +508,9 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx) · 35 unmodified lines | ||
| 507 | 508 | |
| 508 | 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 | 514 | av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, " |
| 511 | 515 | "block align = %d, sample rate = %d\n", |
| 512 | 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 | |
| 547 | −static int vmdaudio_decode_frame(AVCodecContext *avctx, | |
| 548 | − void *data, int *data_size, | |
| 549 | − AVPacket *avpkt) | |
| 551 | +static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data, | |
| 552 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 550 | 553 | { |
| 551 | 554 | const uint8_t *buf = avpkt->data; |
| 552 | 555 | const uint8_t *buf_end; |
| 553 | 556 | int buf_size = avpkt->size; |
| 554 | 557 | VmdAudioContext *s = avctx->priv_data; |
| 555 | 558 | int block_type, silent_chunks, audio_chunks; |
| 556 | − int nb_samples, out_size; | |
| 557 | − uint8_t *output_samples_u8 = data; | |
| 558 | − int16_t *output_samples_s16 = data; | |
| 559 | + int ret; | |
| 560 | + uint8_t *output_samples_u8; | |
| 561 | + int16_t *output_samples_s16; | |
| 559 | 562 | |
| 560 | 563 | if (buf_size < 16) { |
| 561 | 564 | av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n"); |
| 562 | − *data_size = 0; | |
| 565 | + *got_frame_ptr = 0; | |
| 563 | 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 | 594 | /* ensure output buffer is large enough */ |
| 592 | 595 | audio_chunks = buf_size / s->chunk_size; |
| 593 | − nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels; | |
| 594 | − out_size = nb_samples * avctx->channels * s->out_bps; | |
| 595 | − if (*data_size < out_size) | |
| 596 | − return -1; | |
| 596 | + | |
| 597 | + /* get output buffer */ | |
| 598 | + s->frame.nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels; | |
| 599 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 600 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 601 | + return ret; | |
| 602 | + } | |
| 603 | + output_samples_u8 = s->frame.data[0]; | |
| 604 | + output_samples_s16 = (int16_t *)s->frame.data[0]; | |
| 597 | 605 | |
| 598 | 606 | /* decode silent chunks */ |
| 599 | 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 | 637 | return avpkt->size; |
| 628 | 638 | } |
| 629 | 639 | |
| @@ -651,5 +661,6 @@ AVCodec ff_vmdaudio_decoder = { · 21 unmodified lines | ||
| 651 | 661 | .priv_data_size = sizeof(VmdAudioContext), |
| 652 | 662 | .init = vmdaudio_decode_init, |
| 653 | 663 | .decode = vmdaudio_decode_frame, |
| 664 | + .capabilities = CODEC_CAP_DR1, | |
| 654 | 665 | .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"), |
| 655 | 666 | }; |
| @@ -125,6 +125,7 @@ typedef struct { · 124 unmodified lines | ||
| 125 | 125 | |
| 126 | 126 | typedef struct vorbis_context_s { |
| 127 | 127 | AVCodecContext *avccontext; |
| 128 | + AVFrame frame; | |
| 128 | 129 | GetBitContext gb; |
| 129 | 130 | DSPContext dsp; |
| 130 | 131 | FmtConvertContext fmt_conv; |
| @@ -1037,6 +1038,9 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext) · 906 unmodified lines | ||
| 1037 | 1038 | avccontext->sample_rate = vc->audio_samplerate; |
| 1038 | 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 | 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 | 1614 | // Return the decoded audio packet through the standard api |
| 1611 | 1615 | |
| 1612 | −static int vorbis_decode_frame(AVCodecContext *avccontext, | |
| 1613 | − void *data, int *data_size, | |
| 1614 | − AVPacket *avpkt) | |
| 1616 | +static int vorbis_decode_frame(AVCodecContext *avccontext, void *data, | |
| 1617 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1615 | 1618 | { |
| 1616 | 1619 | const uint8_t *buf = avpkt->data; |
| 1617 | 1620 | int buf_size = avpkt->size; |
| 1618 | 1621 | vorbis_context *vc = avccontext->priv_data; |
| 1619 | 1622 | GetBitContext *gb = &(vc->gb); |
| 1620 | 1623 | const float *channel_ptrs[255]; |
| 1621 | − int i, len, out_size; | |
| 1624 | + int i, len, ret; | |
| 1622 | 1625 | |
| 1623 | 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 | 1633 | if (!vc->first_frame) { |
| 1631 | 1634 | vc->first_frame = 1; |
| 1632 | − *data_size = 0; | |
| 1635 | + *got_frame_ptr = 0; | |
| 1633 | 1636 | return buf_size; |
| 1634 | 1637 | } |
| 1635 | 1638 | |
| 1636 | 1639 | av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", |
| 1637 | 1640 | get_bits_count(gb) / 8, get_bits_count(gb) % 8, len); |
| 1638 | 1641 | |
| 1639 | − out_size = len * vc->audio_channels * | |
| 1640 | − av_get_bytes_per_sample(avccontext->sample_fmt); | |
| 1641 | − if (*data_size < out_size) { | |
| 1642 | − av_log(avccontext, AV_LOG_ERROR, "output buffer is too small\n"); | |
| 1643 | − return AVERROR(EINVAL); | |
| 1642 | + /* get output buffer */ | |
| 1643 | + vc->frame.nb_samples = len; | |
| 1644 | + if ((ret = avccontext->get_buffer(avccontext, &vc->frame)) < 0) { | |
| 1645 | + av_log(avccontext, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 1646 | + return ret; | |
| 1644 | 1647 | } |
| 1645 | 1648 | |
| 1646 | 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 | 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 | 1661 | 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 | 1664 | vc->audio_channels); |
| 1660 | 1665 | |
| 1661 | − *data_size = out_size; | |
| 1666 | + *got_frame_ptr = 1; | |
| 1667 | + *(AVFrame *)data = vc->frame; | |
| 1662 | 1668 | |
| 1663 | 1669 | return buf_size; |
| 1664 | 1670 | } |
| @@ -1682,6 +1688,7 @@ AVCodec ff_vorbis_decoder = { · 17 unmodified lines | ||
| 1682 | 1688 | .init = vorbis_decode_init, |
| 1683 | 1689 | .close = vorbis_decode_close, |
| 1684 | 1690 | .decode = vorbis_decode_frame, |
| 1691 | + .capabilities = CODEC_CAP_DR1, | |
| 1685 | 1692 | .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), |
| 1686 | 1693 | .channel_layouts = ff_vorbis_channel_layouts, |
| 1687 | 1694 | .sample_fmts = (const enum AVSampleFormat[]) { |
| @@ -1335,8 +1335,8 @@ end: · 1334 unmodified lines | ||
| 1335 | 1335 | */ |
| 1336 | 1336 | static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y) |
| 1337 | 1337 | { |
| 1338 | − int h, cy; | |
| 1339 | − int offset[4]; | |
| 1338 | + int h, cy, i; | |
| 1339 | + int offset[AV_NUM_DATA_POINTERS]; | |
| 1340 | 1340 | |
| 1341 | 1341 | if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { |
| 1342 | 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 | 1362 | offset[0] = s->current_frame.linesize[0]*y; |
| 1363 | 1363 | offset[1] = s->current_frame.linesize[1]*cy; |
| 1364 | 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 | 1368 | emms_c(); |
| 1368 | 1369 | s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h); |
| @@ -51,8 +51,7 @@ static int vp8_alloc_frame(VP8Context *s, AVFrame *f) · 50 unmodified lines | ||
| 51 | 51 | int ret; |
| 52 | 52 | if ((ret = ff_thread_get_buffer(s->avctx, f)) < 0) |
| 53 | 53 | return ret; |
| 54 | − if (s->num_maps_to_be_freed) { | |
| 55 | − assert(!s->maps_are_invalid); | |
| 54 | + if (s->num_maps_to_be_freed && !s->maps_are_invalid) { | |
| 56 | 55 | f->ref_index[0] = s->segmentation_maps[--s->num_maps_to_be_freed]; |
| 57 | 56 | } else if (!(f->ref_index[0] = av_mallocz(s->mb_width * s->mb_height))) { |
| 58 | 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 | 1567 | VP8Context *s = avctx->priv_data; |
| 1569 | 1568 | int ret, mb_x, mb_y, i, y, referenced; |
| 1570 | 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 | 1572 | release_queued_segmaps(s, 0); |
| 1574 | 1573 | |
| 1575 | 1574 | if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0) |
| 1576 | 1575 | return ret; |
| 1577 | 1576 | |
| 1577 | + prev_frame = s->framep[VP56_FRAME_CURRENT]; | |
| 1578 | + | |
| 1578 | 1579 | referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT |
| 1579 | 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 | 1816 | if (s->macroblocks_base && |
| 1816 | 1817 | (s_src->mb_width != s->mb_width || s_src->mb_height != s->mb_height)) { |
| 1817 | 1818 | free_buffers(s); |
| 1819 | + s->maps_are_invalid = 1; | |
| 1818 | 1820 | } |
| 1819 | 1821 | |
| 1820 | 1822 | s->prob[0] = s_src->prob[!s_src->update_probabilities]; |
| @@ -115,8 +115,6 @@ typedef struct WavpackFrameContext { · 114 unmodified lines | ||
| 115 | 115 | int float_shift; |
| 116 | 116 | int float_max_exp; |
| 117 | 117 | WvChannel ch[2]; |
| 118 | − int samples_left; | |
| 119 | − int max_samples; | |
| 120 | 118 | int pos; |
| 121 | 119 | SavedContext sc, extra_sc; |
| 122 | 120 | } WavpackFrameContext; |
| @@ -125,6 +123,7 @@ typedef struct WavpackFrameContext { · 2 unmodified lines | ||
| 125 | 123 | |
| 126 | 124 | typedef struct WavpackContext { |
| 127 | 125 | AVCodecContext *avctx; |
| 126 | + AVFrame frame; | |
| 128 | 127 | |
| 129 | 128 | WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS]; |
| 130 | 129 | int fdec_num; |
| @@ -133,7 +132,6 @@ typedef struct WavpackContext { · 2 unmodified lines | ||
| 133 | 132 | int mkv_mode; |
| 134 | 133 | int block; |
| 135 | 134 | int samples; |
| 136 | − int samples_left; | |
| 137 | 135 | int ch_offset; |
| 138 | 136 | } WavpackContext; |
| 139 | 137 | |
| @@ -485,7 +483,6 @@ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) · 345 unmodified lines | ||
| 485 | 483 | static void wv_reset_saved_context(WavpackFrameContext *s) |
| 486 | 484 | { |
| 487 | 485 | s->pos = 0; |
| 488 | − s->samples_left = 0; | |
| 489 | 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 | 499 | float *dstfl = dst; |
| 503 | 500 | const int channel_pad = s->avctx->channels - 2; |
| 504 | 501 | |
| 505 | − if(s->samples_left == s->samples) | |
| 506 | − s->one = s->zero = s->zeroes = 0; | |
| 502 | + s->one = s->zero = s->zeroes = 0; | |
| 507 | 503 | do{ |
| 508 | 504 | L = wv_get_value(s, gb, 0, &last); |
| 509 | 505 | if(last) break; |
| @@ -594,13 +590,8 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo · 84 unmodified lines | ||
| 594 | 590 | dst16 += channel_pad; |
| 595 | 591 | } |
| 596 | 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 | 595 | wv_reset_saved_context(s); |
| 605 | 596 | if(crc != s->CRC){ |
| 606 | 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 | 601 | av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n"); |
| 611 | 602 | return -1; |
| 612 | 603 | } |
| 613 | − }else{ | |
| 614 | − s->pos = pos; | |
| 615 | − s->sc.crc = crc; | |
| 616 | − s->sc.bits_used = get_bits_count(&s->gb); | |
| 617 | − if(s->got_extra_bits){ | |
| 618 | − s->extra_sc.crc = crc_extra_bits; | |
| 619 | − s->extra_sc.bits_used = get_bits_count(&s->gb_extra_bits); | |
| 620 | − } | |
| 621 | − } | |
| 604 | + | |
| 622 | 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 | 618 | float *dstfl = dst; |
| 636 | 619 | const int channel_stride = s->avctx->channels; |
| 637 | 620 | |
| 638 | − if(s->samples_left == s->samples) | |
| 639 | − s->one = s->zero = s->zeroes = 0; | |
| 621 | + s->one = s->zero = s->zeroes = 0; | |
| 640 | 622 | do{ |
| 641 | 623 | T = wv_get_value(s, gb, 0, &last); |
| 642 | 624 | S = 0; |
| @@ -675,13 +657,8 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void · 32 unmodified lines | ||
| 675 | 657 | dst16 += channel_stride; |
| 676 | 658 | } |
| 677 | 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 | 662 | wv_reset_saved_context(s); |
| 686 | 663 | if(crc != s->CRC){ |
| 687 | 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 | 668 | av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n"); |
| 692 | 669 | return -1; |
| 693 | 670 | } |
| 694 | − }else{ | |
| 695 | − s->pos = pos; | |
| 696 | − s->sc.crc = crc; | |
| 697 | − s->sc.bits_used = get_bits_count(&s->gb); | |
| 698 | − if(s->got_extra_bits){ | |
| 699 | − s->extra_sc.crc = crc_extra_bits; | |
| 700 | − s->extra_sc.bits_used = get_bits_count(&s->gb_extra_bits); | |
| 701 | − } | |
| 702 | − } | |
| 671 | + | |
| 703 | 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 | 713 | s->fdec_num = 0; |
| 745 | 714 | |
| 715 | + avcodec_get_frame_defaults(&s->frame); | |
| 716 | + avctx->coded_frame = &s->frame; | |
| 717 | + | |
| 746 | 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 | |
| 761 | 733 | static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 762 | − void *data, int *data_size, | |
| 734 | + void *data, int *got_frame_ptr, | |
| 763 | 735 | const uint8_t *buf, int buf_size) |
| 764 | 736 | { |
| 765 | 737 | WavpackContext *wc = avctx->priv_data; |
| @@ -774,7 +746,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 8 unmodified lines | ||
| 774 | 746 | int bpp, chan, chmask; |
| 775 | 747 | |
| 776 | 748 | if (buf_size == 0){ |
| 777 | − *data_size = 0; | |
| 749 | + *got_frame_ptr = 0; | |
| 778 | 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 | 761 | return -1; |
| 790 | 762 | } |
| 791 | 763 | |
| 792 | − if(!s->samples_left){ | |
| 793 | 764 | memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr)); |
| 794 | 765 | memset(s->ch, 0, sizeof(s->ch)); |
| 795 | 766 | s->extra_bits = 0; |
| 796 | 767 | s->and = s->or = s->shift = 0; |
| 797 | 768 | s->got_extra_bits = 0; |
| 798 | − } | |
| 799 | 769 | |
| 800 | 770 | if(!wc->mkv_mode){ |
| 801 | 771 | s->samples = AV_RL32(buf); buf += 4; |
| 802 | 772 | if(!s->samples){ |
| 803 | − *data_size = 0; | |
| 773 | + *got_frame_ptr = 0; | |
| 804 | 774 | return 0; |
| 805 | 775 | } |
| 806 | 776 | }else{ |
| @@ -829,13 +799,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 22 unmodified lines | ||
| 829 | 799 | |
| 830 | 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 | 802 | // parse metadata blocks |
| 840 | 803 | while(buf < buf_end){ |
| 841 | 804 | id = *buf++; |
| @@ -1064,7 +1027,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 222 unmodified lines | ||
| 1064 | 1027 | } |
| 1065 | 1028 | if(id & WP_IDF_ODD) buf++; |
| 1066 | 1029 | } |
| 1067 | − if(!s->samples_left){ | |
| 1030 | + | |
| 1068 | 1031 | if(!got_terms){ |
| 1069 | 1032 | av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n"); |
| 1070 | 1033 | return -1; |
| @@ -1101,16 +1064,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 30 unmodified lines | ||
| 1101 | 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 | 1068 | if(s->stereo_in){ |
| 1116 | 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 | 1125 | return samplecount * bpp; |
| 1173 | 1126 | } |
| @@ -1181,23 +1134,40 @@ static void wavpack_decode_flush(AVCodecContext *avctx) · 7 unmodified lines | ||
| 1181 | 1134 | wv_reset_saved_context(s->fdec[i]); |
| 1182 | 1135 | } |
| 1183 | 1136 | |
| 1184 | −static int wavpack_decode_frame(AVCodecContext *avctx, | |
| 1185 | − void *data, int *data_size, | |
| 1186 | − AVPacket *avpkt) | |
| 1137 | +static int wavpack_decode_frame(AVCodecContext *avctx, void *data, | |
| 1138 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1187 | 1139 | { |
| 1188 | 1140 | WavpackContext *s = avctx->priv_data; |
| 1189 | 1141 | const uint8_t *buf = avpkt->data; |
| 1190 | 1142 | int buf_size = avpkt->size; |
| 1191 | − int frame_size; | |
| 1143 | + int frame_size, ret; | |
| 1192 | 1144 | int samplecount = 0; |
| 1193 | 1145 | |
| 1194 | 1146 | s->block = 0; |
| 1195 | − s->samples_left = 0; | |
| 1196 | 1147 | s->ch_offset = 0; |
| 1197 | 1148 | |
| 1149 | + /* determine number of samples */ | |
| 1198 | 1150 | if(s->mkv_mode){ |
| 1199 | 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 | 1171 | while(buf_size > 0){ |
| 1202 | 1172 | if(!s->multichannel){ |
| 1203 | 1173 | frame_size = buf_size; |
| @@ -1216,17 +1186,19 @@ static int wavpack_decode_frame(AVCodecContext *avctx, · 12 unmodified lines | ||
| 1216 | 1186 | wavpack_decode_flush(avctx); |
| 1217 | 1187 | return -1; |
| 1218 | 1188 | } |
| 1219 | − if((samplecount = wavpack_decode_block(avctx, s->block, data, | |
| 1220 | − data_size, buf, frame_size)) < 0) { | |
| 1189 | + if((samplecount = wavpack_decode_block(avctx, s->block, s->frame.data[0], | |
| 1190 | + got_frame_ptr, buf, frame_size)) < 0) { | |
| 1221 | 1191 | wavpack_decode_flush(avctx); |
| 1222 | 1192 | return -1; |
| 1223 | 1193 | } |
| 1224 | 1194 | s->block++; |
| 1225 | 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 | |
| 1232 | 1204 | AVCodec ff_wavpack_decoder = { |
| @@ -1238,6 +1210,6 @@ AVCodec ff_wavpack_decoder = { · 5 unmodified lines | ||
| 1238 | 1210 | .close = wavpack_decode_end, |
| 1239 | 1211 | .decode = wavpack_decode_frame, |
| 1240 | 1212 | .flush = wavpack_decode_flush, |
| 1241 | − .capabilities = CODEC_CAP_SUBFRAMES, | |
| 1213 | + .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, | |
| 1242 | 1214 | .long_name = NULL_IF_CONFIG_SMALL("WavPack"), |
| 1243 | 1215 | }; |
| @@ -65,6 +65,7 @@ typedef struct CoefVLCTable { · 64 unmodified lines | ||
| 65 | 65 | |
| 66 | 66 | typedef struct WMACodecContext { |
| 67 | 67 | AVCodecContext* avctx; |
| 68 | + AVFrame frame; | |
| 68 | 69 | GetBitContext gb; |
| 69 | 70 | PutBitContext pb; |
| 70 | 71 | int sample_rate; |
| @@ -136,6 +136,10 @@ static int wma_decode_init(AVCodecContext * avctx) · 135 unmodified lines | ||
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 139 | + | |
| 140 | + avcodec_get_frame_defaults(&s->frame); | |
| 141 | + avctx->coded_frame = &s->frame; | |
| 142 | + | |
| 139 | 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 | 818 | return 0; |
| 815 | 819 | } |
| 816 | 820 | |
| 817 | −static int wma_decode_superframe(AVCodecContext *avctx, | |
| 818 | − void *data, int *data_size, | |
| 819 | − AVPacket *avpkt) | |
| 821 | +static int wma_decode_superframe(AVCodecContext *avctx, void *data, | |
| 822 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 820 | 823 | { |
| 821 | 824 | const uint8_t *buf = avpkt->data; |
| 822 | 825 | int buf_size = avpkt->size; |
| 823 | 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 | 828 | uint8_t *q; |
| 826 | 829 | int16_t *samples; |
| 827 | 830 | |
| @@ -836,8 +839,6 @@ static int wma_decode_superframe(AVCodecContext *avctx, · 8 unmodified lines | ||
| 836 | 839 | if(s->block_align) |
| 837 | 840 | buf_size = s->block_align; |
| 838 | 841 | |
| 839 | − samples = data; | |
| 840 | − | |
| 841 | 842 | init_get_bits(&s->gb, buf, buf_size*8); |
| 842 | 843 | |
| 843 | 844 | if (s->use_bit_reservoir) { |
| @@ -848,12 +849,13 @@ static int wma_decode_superframe(AVCodecContext *avctx, · 4 unmodified lines | ||
| 848 | 849 | nb_frames = 1; |
| 849 | 850 | } |
| 850 | 851 | |
| 851 | − out_size = nb_frames * s->frame_len * s->nb_channels * | |
| 852 | − av_get_bytes_per_sample(avctx->sample_fmt); | |
| 853 | − if (*data_size < out_size) { | |
| 854 | − av_log(s->avctx, AV_LOG_ERROR, "Insufficient output space\n"); | |
| 855 | − goto fail; | |
| 852 | + /* get output buffer */ | |
| 853 | + s->frame.nb_samples = nb_frames * s->frame_len; | |
| 854 | + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { | |
| 855 | + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 856 | + return ret; | |
| 856 | 857 | } |
| 858 | + samples = (int16_t *)s->frame.data[0]; | |
| 857 | 859 | |
| 858 | 860 | if (s->use_bit_reservoir) { |
| 859 | 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 | 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 | 929 | return buf_size; |
| 925 | 930 | fail: |
| 926 | 931 | /* when error, we reset the bit reservoir */ |
| @@ -945,6 +950,7 @@ AVCodec ff_wmav1_decoder = { · 18 unmodified lines | ||
| 945 | 950 | .close = ff_wma_end, |
| 946 | 951 | .decode = wma_decode_superframe, |
| 947 | 952 | .flush = flush, |
| 953 | + .capabilities = CODEC_CAP_DR1, | |
| 948 | 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 | 963 | .close = ff_wma_end, |
| 958 | 964 | .decode = wma_decode_superframe, |
| 959 | 965 | .flush = flush, |
| 966 | + .capabilities = CODEC_CAP_DR1, | |
| 960 | 967 | .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), |
| 961 | 968 | }; |
| @@ -167,6 +167,7 @@ typedef struct { · 166 unmodified lines | ||
| 167 | 167 | typedef struct WMAProDecodeCtx { |
| 168 | 168 | /* generic decoder variables */ |
| 169 | 169 | AVCodecContext* avctx; ///< codec context for av_log |
| 170 | + AVFrame frame; ///< AVFrame for decoded output | |
| 170 | 171 | DSPContext dsp; ///< accelerated DSP functions |
| 171 | 172 | FmtConvertContext fmt_conv; |
| 172 | 173 | uint8_t frame_data[MAX_FRAMESIZE + |
| @@ -209,8 +210,6 @@ typedef struct WMAProDecodeCtx { · 36 unmodified lines | ||
| 209 | 210 | uint32_t frame_num; ///< current frame number (not used for decoding) |
| 210 | 211 | GetBitContext gb; ///< bitstream reader context |
| 211 | 212 | int buf_bit_size; ///< buffer size in bits |
| 212 | − float* samples; ///< current samplebuffer pointer | |
| 213 | − float* samples_end; ///< maximum samplebuffer pointer | |
| 214 | 213 | uint8_t drc_gain; ///< gain for the DRC tool |
| 215 | 214 | int8_t skip_frame; ///< skip output step |
| 216 | 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 | 452 | dump_context(s); |
| 454 | 453 | |
| 455 | 454 | avctx->channel_layout = channel_mask; |
| 455 | + | |
| 456 | + avcodec_get_frame_defaults(&s->frame); | |
| 457 | + avctx->coded_frame = &s->frame; | |
| 458 | + | |
| 456 | 459 | return 0; |
| 457 | 460 | } |
| 458 | 461 | |
| @@ -1279,22 +1282,15 @@ static int decode_subframe(WMAProDecodeCtx *s) · 820 unmodified lines | ||
| 1279 | 1282 | *@return 0 if the trailer bit indicates that this is the last frame, |
| 1280 | 1283 | * 1 if there are additional frames |
| 1281 | 1284 | */ |
| 1282 | −static int decode_frame(WMAProDecodeCtx *s) | |
| 1285 | +static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr) | |
| 1283 | 1286 | { |
| 1287 | + AVCodecContext *avctx = s->avctx; | |
| 1284 | 1288 | GetBitContext* gb = &s->gb; |
| 1285 | 1289 | int more_frames = 0; |
| 1286 | 1290 | int len = 0; |
| 1287 | − int i; | |
| 1291 | + int i, ret; | |
| 1288 | 1292 | const float *out_ptr[WMAPRO_MAX_CHANNELS]; |
| 1289 | − | |
| 1290 | − /** check for potential output buffer overflow */ | |
| 1291 | − if (s->num_channels * s->samples_per_frame > s->samples_end - s->samples) { | |
| 1292 | − /** return an error if no frame could be decoded at all */ | |
| 1293 | − av_log(s->avctx, AV_LOG_ERROR, | |
| 1294 | − "not enough space for the output samples\n"); | |
| 1295 | − s->packet_loss = 1; | |
| 1296 | − return 0; | |
| 1297 | − } | |
| 1293 | + float *samples; | |
| 1298 | 1294 | |
| 1299 | 1295 | /** get frame length */ |
| 1300 | 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 | 1368 | /** interleave samples and write them to the output buffer */ |
| 1364 | 1369 | for (i = 0; i < s->num_channels; i++) |
| 1365 | 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 | 1372 | s->num_channels); |
| 1368 | 1373 | |
| 1369 | 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 | 1381 | if (s->skip_frame) { |
| 1377 | 1382 | s->skip_frame = 0; |
| 1378 | − } else | |
| 1379 | − s->samples += s->num_channels * s->samples_per_frame; | |
| 1383 | + *got_frame_ptr = 0; | |
| 1384 | + } else { | |
| 1385 | + *got_frame_ptr = 1; | |
| 1386 | + } | |
| 1380 | 1387 | |
| 1381 | 1388 | if (s->len_prefix) { |
| 1382 | 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 | 1480 | *@param avpkt input packet |
| 1474 | 1481 | *@return number of bytes that were read from the input buffer |
| 1475 | 1482 | */ |
| 1476 | −static int decode_packet(AVCodecContext *avctx, | |
| 1477 | − void *data, int *data_size, AVPacket* avpkt) | |
| 1483 | +static int decode_packet(AVCodecContext *avctx, void *data, | |
| 1484 | + int *got_frame_ptr, AVPacket* avpkt) | |
| 1478 | 1485 | { |
| 1479 | 1486 | WMAProDecodeCtx *s = avctx->priv_data; |
| 1480 | 1487 | GetBitContext* gb = &s->pgb; |
| @@ -1483,9 +1490,7 @@ static int decode_packet(AVCodecContext *avctx, · 2 unmodified lines | ||
| 1483 | 1490 | int num_bits_prev_frame; |
| 1484 | 1491 | int packet_sequence_number; |
| 1485 | 1492 | |
| 1486 | − s->samples = data; | |
| 1487 | − s->samples_end = (float*)((int8_t*)data + *data_size); | |
| 1488 | − *data_size = 0; | |
| 1493 | + *got_frame_ptr = 0; | |
| 1489 | 1494 | |
| 1490 | 1495 | if (s->packet_done || s->packet_loss) { |
| 1491 | 1496 | s->packet_done = 0; |
| @@ -1532,7 +1537,7 @@ static int decode_packet(AVCodecContext *avctx, · 40 unmodified lines | ||
| 1532 | 1537 | |
| 1533 | 1538 | /** decode the cross packet frame if it is valid */ |
| 1534 | 1539 | if (!s->packet_loss) |
| 1535 | − decode_frame(s); | |
| 1540 | + decode_frame(s, got_frame_ptr); | |
| 1536 | 1541 | } else if (s->num_saved_bits - s->frame_offset) { |
| 1537 | 1542 | av_dlog(avctx, "ignoring %x previously saved bits\n", |
| 1538 | 1543 | s->num_saved_bits - s->frame_offset); |
| @@ -1555,7 +1560,7 @@ static int decode_packet(AVCodecContext *avctx, · 16 unmodified lines | ||
| 1555 | 1560 | (frame_size = show_bits(gb, s->log2_frame_size)) && |
| 1556 | 1561 | frame_size <= remaining_bits(s, gb)) { |
| 1557 | 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 | 1564 | } else if (!s->len_prefix |
| 1560 | 1565 | && s->num_saved_bits > get_bits_count(&s->gb)) { |
| 1561 | 1566 | /** 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 | 1570 | therefore we save the incoming packet first, then we append |
| 1566 | 1571 | the "previous frame" data from the next packet so that |
| 1567 | 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 | 1574 | } else |
| 1570 | 1575 | s->packet_done = 1; |
| 1571 | 1576 | } |
| @@ -1577,10 +1582,14 @@ static int decode_packet(AVCodecContext *avctx, · 5 unmodified lines | ||
| 1577 | 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 | 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 | 1620 | .init = decode_init, |
| 1612 | 1621 | .close = decode_end, |
| 1613 | 1622 | .decode = decode_packet, |
| 1614 | − .capabilities = CODEC_CAP_SUBFRAMES, | |
| 1623 | + .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, | |
| 1615 | 1624 | .flush= flush, |
| 1616 | 1625 | .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"), |
| 1617 | 1626 | }; |
| @@ -131,6 +131,7 @@ typedef struct { · 130 unmodified lines | ||
| 131 | 131 | * @name Global values specified in the stream header / extradata or used all over. |
| 132 | 132 | * @{ |
| 133 | 133 | */ |
| 134 | + AVFrame frame; | |
| 134 | 135 | GetBitContext gb; ///< packet bitreader. During decoder init, |
| 135 | 136 | ///< it contains the extradata from the |
| 136 | 137 | ///< demuxer. During decoding, it contains |
| @@ -438,6 +439,9 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) · 301 unmodified lines | ||
| 438 | 439 | |
| 439 | 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 | 445 | return 0; |
| 442 | 446 | } |
| 443 | 447 | |
| @@ -1725,17 +1729,17 @@ static int check_bits_for_superframe(GetBitContext *orig_gb, · 1281 unmodified lines | ||
| 1725 | 1729 | * @return 0 on success, <0 on error or 1 if there was not enough data to |
| 1726 | 1730 | * fully parse the superframe |
| 1727 | 1731 | */ |
| 1728 | −static int synth_superframe(AVCodecContext *ctx, | |
| 1729 | − float *samples, int *data_size) | |
| 1732 | +static int synth_superframe(AVCodecContext *ctx, int *got_frame_ptr) | |
| 1730 | 1733 | { |
| 1731 | 1734 | WMAVoiceContext *s = ctx->priv_data; |
| 1732 | 1735 | GetBitContext *gb = &s->gb, s_gb; |
| 1733 | − int n, res, out_size, n_samples = 480; | |
| 1736 | + int n, res, n_samples = 480; | |
| 1734 | 1737 | double lsps[MAX_FRAMES][MAX_LSPS]; |
| 1735 | 1738 | const double *mean_lsf = s->lsps == 16 ? |
| 1736 | 1739 | wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode]; |
| 1737 | 1740 | float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12]; |
| 1738 | 1741 | float synth[MAX_LSPS + MAX_SFRAMESIZE]; |
| 1742 | + float *samples; | |
| 1739 | 1743 | |
| 1740 | 1744 | memcpy(synth, s->synth_history, |
| 1741 | 1745 | s->lsps * sizeof(*synth)); |
| @@ -1749,7 +1753,7 @@ static int synth_superframe(AVCodecContext *ctx, · 7 unmodified lines | ||
| 1749 | 1753 | } |
| 1750 | 1754 | |
| 1751 | 1755 | if ((res = check_bits_for_superframe(gb, s)) == 1) { |
| 1752 | − *data_size = 0; | |
| 1756 | + *got_frame_ptr = 0; | |
| 1753 | 1757 | return 1; |
| 1754 | 1758 | } |
| 1755 | 1759 | |
| @@ -1792,13 +1796,14 @@ static int synth_superframe(AVCodecContext *ctx, · 36 unmodified lines | ||
| 1792 | 1796 | stabilize_lsps(lsps[n], s->lsps); |
| 1793 | 1797 | } |
| 1794 | 1798 | |
| 1795 | − out_size = n_samples * av_get_bytes_per_sample(ctx->sample_fmt); | |
| 1796 | − if (*data_size < out_size) { | |
| 1797 | − av_log(ctx, AV_LOG_ERROR, | |
| 1798 | − "Output buffer too small (%d given - %d needed)\n", | |
| 1799 | − *data_size, out_size); | |
| 1800 | − return -1; | |
| 1799 | + /* get output buffer */ | |
| 1800 | + s->frame.nb_samples = 480; | |
| 1801 | + if ((res = ctx->get_buffer(ctx, &s->frame)) < 0) { | |
| 1802 | + av_log(ctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
| 1803 | + return res; | |
| 1801 | 1804 | } |
| 1805 | + s->frame.nb_samples = n_samples; | |
| 1806 | + samples = (float *)s->frame.data[0]; | |
| 1802 | 1807 | |
| 1803 | 1808 | /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */ |
| 1804 | 1809 | for (n = 0; n < 3; n++) { |
| @@ -1820,7 +1825,7 @@ static int synth_superframe(AVCodecContext *ctx, · 15 unmodified lines | ||
| 1820 | 1825 | lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1], |
| 1821 | 1826 | &excitation[s->history_nsamples + n * MAX_FRAMESIZE], |
| 1822 | 1827 | &synth[s->lsps + n * MAX_FRAMESIZE]))) { |
| 1823 | − *data_size = 0; | |
| 1828 | + *got_frame_ptr = 0; | |
| 1824 | 1829 | return res; |
| 1825 | 1830 | } |
| 1826 | 1831 | } |
| @@ -1833,8 +1838,7 @@ static int synth_superframe(AVCodecContext *ctx, · 6 unmodified lines | ||
| 1833 | 1838 | skip_bits(gb, 10 * (res + 1)); |
| 1834 | 1839 | } |
| 1835 | 1840 | |
| 1836 | − /* Specify nr. of output samples */ | |
| 1837 | − *data_size = out_size; | |
| 1841 | + *got_frame_ptr = 1; | |
| 1838 | 1842 | |
| 1839 | 1843 | /* Update history */ |
| 1840 | 1844 | memcpy(s->prev_lsps, lsps[2], |
| @@ -1922,7 +1926,7 @@ static void copy_bits(PutBitContext *pb, · 81 unmodified lines | ||
| 1922 | 1926 | * For more information about frames, see #synth_superframe(). |
| 1923 | 1927 | */ |
| 1924 | 1928 | static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, |
| 1925 | − int *data_size, AVPacket *avpkt) | |
| 1929 | + int *got_frame_ptr, AVPacket *avpkt) | |
| 1926 | 1930 | { |
| 1927 | 1931 | WMAVoiceContext *s = ctx->priv_data; |
| 1928 | 1932 | GetBitContext *gb = &s->gb; |
| @@ -1935,7 +1939,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, · 6 unmodified lines | ||
| 1935 | 1939 | * capping the packet size at ctx->block_align. */ |
| 1936 | 1940 | for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align); |
| 1937 | 1941 | if (!size) { |
| 1938 | − *data_size = 0; | |
| 1942 | + *got_frame_ptr = 0; | |
| 1939 | 1943 | return 0; |
| 1940 | 1944 | } |
| 1941 | 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 | 1960 | copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits); |
| 1957 | 1961 | flush_put_bits(&s->pb); |
| 1958 | 1962 | s->sframe_cache_size += s->spillover_nbits; |
| 1959 | − if ((res = synth_superframe(ctx, data, data_size)) == 0 && | |
| 1960 | − *data_size > 0) { | |
| 1963 | + if ((res = synth_superframe(ctx, got_frame_ptr)) == 0 && | |
| 1964 | + *got_frame_ptr) { | |
| 1961 | 1965 | cnt += s->spillover_nbits; |
| 1962 | 1966 | s->skip_bits_next = cnt & 7; |
| 1967 | + *(AVFrame *)data = s->frame; | |
| 1963 | 1968 | return cnt >> 3; |
| 1964 | 1969 | } else |
| 1965 | 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 | 1979 | s->sframe_cache_size = 0; |
| 1975 | 1980 | s->skip_bits_next = 0; |
| 1976 | 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 | 1983 | return res; |
| 1979 | − } else if (*data_size > 0) { | |
| 1984 | + } else if (*got_frame_ptr) { | |
| 1980 | 1985 | int cnt = get_bits_count(gb); |
| 1981 | 1986 | s->skip_bits_next = cnt & 7; |
| 1987 | + *(AVFrame *)data = s->frame; | |
| 1982 | 1988 | return cnt >> 3; |
| 1983 | 1989 | } else if ((s->sframe_cache_size = pos) > 0) { |
| 1984 | 1990 | /* rewind bit reader to start of last (incomplete) superframe... */ |
| @@ -2046,7 +2052,7 @@ AVCodec ff_wmavoice_decoder = { · 61 unmodified lines | ||
| 2046 | 2052 | .init = wmavoice_decode_init, |
| 2047 | 2053 | .close = wmavoice_decode_end, |
| 2048 | 2054 | .decode = wmavoice_decode_packet, |
| 2049 | − .capabilities = CODEC_CAP_SUBFRAMES, | |
| 2055 | + .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, | |
| 2050 | 2056 | .flush = wmavoice_flush, |
| 2051 | 2057 | .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"), |
| 2052 | 2058 | }; |
| @@ -37,26 +37,37 @@ static const int8_t ws_adpcm_4bit[] = { · 36 unmodified lines | ||
| 37 | 37 | 0, 1, 2, 3, 4, 5, 6, 8 |
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | +typedef struct WSSndContext { | |
| 41 | + AVFrame frame; | |
| 42 | +} WSSndContext; | |
| 43 | + | |
| 40 | 44 | static av_cold int ws_snd_decode_init(AVCodecContext *avctx) |
| 41 | 45 | { |
| 46 | + WSSndContext *s = avctx->priv_data; | |
| 47 | + | |
| 42 | 48 | if (avctx->channels != 1) { |
| 43 | 49 | av_log_ask_for_sample(avctx, "unsupported number of channels\n"); |
| 44 | 50 | return AVERROR(EINVAL); |
| 45 | 51 | } |
| 46 | 52 | |
| 47 | 53 | avctx->sample_fmt = AV_SAMPLE_FMT_U8; |
| 54 | + | |
| 55 | + avcodec_get_frame_defaults(&s->frame); | |
| 56 | + avctx->coded_frame = &s->frame; | |
| 57 | + | |
| 48 | 58 | return 0; |
| 49 | 59 | } |
| 50 | 60 | |
| 51 | 61 | static 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 | 65 | const uint8_t *buf = avpkt->data; |
| 55 | 66 | int buf_size = avpkt->size; |
| 56 | 67 | |
| 57 | − int in_size, out_size; | |
| 68 | + int in_size, out_size, ret; | |
| 58 | 69 | int sample = 128; |
| 59 | − uint8_t *samples = data; | |
| 70 | + uint8_t *samples; | |
| 60 | 71 | uint8_t *samples_end; |
| 61 | 72 | |
| 62 | 73 | if (!buf_size) |
| @@ -71,19 +82,24 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, void *data, · 8 unmodified lines | ||
| 71 | 82 | in_size = AV_RL16(&buf[2]); |
| 72 | 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 | 85 | if (in_size > buf_size) { |
| 79 | 86 | av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n"); |
| 80 | 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 | 97 | samples_end = samples + out_size; |
| 83 | 98 | |
| 84 | 99 | if (in_size == out_size) { |
| 85 | 100 | memcpy(samples, buf, out_size); |
| 86 | − *data_size = out_size; | |
| 101 | + *got_frame_ptr = 1; | |
| 102 | + *(AVFrame *)data = s->frame; | |
| 87 | 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 | 182 | return buf_size; |
| 165 | 183 | } |
| @@ -168,7 +186,9 @@ AVCodec ff_ws_snd1_decoder = { · 2 unmodified lines | ||
| 168 | 186 | .name = "ws_snd1", |
| 169 | 187 | .type = AVMEDIA_TYPE_AUDIO, |
| 170 | 188 | .id = CODEC_ID_WESTWOOD_SND1, |
| 189 | + .priv_data_size = sizeof(WSSndContext), | |
| 171 | 190 | .init = ws_snd_decode_init, |
| 172 | 191 | .decode = ws_snd_decode_frame, |
| 192 | + .capabilities = CODEC_CAP_DR1, | |
| 173 | 193 | .long_name = NULL_IF_CONFIG_SMALL("Westwood Audio (SND1)"), |
| 174 | 194 | }; |
| @@ -37,7 +37,7 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf · 36 unmodified lines | ||
| 37 | 37 | int off; |
| 38 | 38 | |
| 39 | 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 | 41 | if (off < 0) |
| 42 | 42 | return off; |
| 43 | 43 | skip_bits_long(&gb, off); |
| @@ -1182,7 +1182,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, · 1181 unmodified lines | ||
| 1182 | 1182 | return AV_NOPTS_VALUE; |
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | − pts= pkt->dts; | |
| 1185 | + pts = pkt->dts; | |
| 1186 | 1186 | |
| 1187 | 1187 | av_free_packet(pkt); |
| 1188 | 1188 | if(pkt->flags&AV_PKT_FLAG_KEY){ |
| @@ -550,7 +550,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) · 549 unmodified lines | ||
| 550 | 550 | if (st->codec->codec_id == CODEC_ID_AAC) { |
| 551 | 551 | MPEG4AudioConfig cfg; |
| 552 | 552 | avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, |
| 553 | − st->codec->extradata_size); | |
| 553 | + st->codec->extradata_size * 8, 1); | |
| 554 | 554 | st->codec->channels = cfg.channels; |
| 555 | 555 | if (cfg.ext_sample_rate) |
| 556 | 556 | st->codec->sample_rate = cfg.ext_sample_rate; |
| @@ -438,7 +438,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext · 437 unmodified lines | ||
| 438 | 438 | if (st->codec->codec_id == CODEC_ID_AAC) { |
| 439 | 439 | MPEG4AudioConfig cfg; |
| 440 | 440 | avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, |
| 441 | − st->codec->extradata_size); | |
| 441 | + st->codec->extradata_size * 8, 1); | |
| 442 | 442 | st->codec->channels = cfg.channels; |
| 443 | 443 | if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4 |
| 444 | 444 | st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; |
| @@ -55,7 +55,7 @@ static int latm_decode_extradata(LATMContext *ctx, uint8_t *buf, int size) · 54 unmodified lines | ||
| 55 | 55 | MPEG4AudioConfig m4ac; |
| 56 | 56 | |
| 57 | 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 | 59 | if (ctx->off < 0) |
| 60 | 60 | return ctx->off; |
| 61 | 61 | skip_bits_long(&gb, ctx->off); |
| @@ -448,7 +448,8 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int · 447 unmodified lines | ||
| 448 | 448 | { |
| 449 | 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 | 453 | av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n"); |
| 453 | 454 | return; |
| 454 | 455 | } |
| @@ -32,5 +32,5 @@ AVOutputFormat ff_null_muxer = { · 31 unmodified lines | ||
| 32 | 32 | .audio_codec = AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE), |
| 33 | 33 | .video_codec = CODEC_ID_RAWVIDEO, |
| 34 | 34 | .write_packet = null_write_packet, |
| 35 | − .flags = AVFMT_NOFILE | AVFMT_NOTIMESTAMPS, | |
| 35 | + .flags = AVFMT_NOFILE | AVFMT_NOTIMESTAMPS | AVFMT_RAWPICTURE, | |
| 36 | 36 | }; |
| @@ -1934,6 +1934,7 @@ static int rtp_read_header(AVFormatContext *s, · 1933 unmodified lines | ||
| 1934 | 1934 | struct sockaddr_storage addr; |
| 1935 | 1935 | AVIOContext pb; |
| 1936 | 1936 | socklen_t addrlen = sizeof(addr); |
| 1937 | + RTSPState *rt = s->priv_data; | |
| 1937 | 1938 | |
| 1938 | 1939 | if (!ff_network_init()) |
| 1939 | 1940 | return AVERROR(EIO); |
| @@ -1997,6 +1998,8 @@ static int rtp_read_header(AVFormatContext *s, · 57 unmodified lines | ||
| 1997 | 1998 | /* sdp_read_header initializes this again */ |
| 1998 | 1999 | ff_network_close(); |
| 1999 | 2000 | |
| 2001 | + rt->media_type_mask = (1 << (AVMEDIA_TYPE_DATA+1)) - 1; | |
| 2002 | + | |
| 2000 | 2003 | ret = sdp_read_header(s, ap); |
| 2001 | 2004 | s->pb = NULL; |
| 2002 | 2005 | return ret; |