* 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
Merged-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -1267,7 +1267,8 @@ static void do_video_out(AVFormatContext *s, |
| 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) |
| 1528 | 1528 |
|
| 1529 | 1529 |
if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1) |
| 1530 | 1530 |
continue; |
| 1531 |
- if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE)) |
|
| 1531 |
+ if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == CODEC_ID_RAWVIDEO) |
|
| 1532 | 1532 |
continue; |
| 1533 | 1533 |
|
| 1534 | 1534 |
for(;;) {
|
| ... | ... |
@@ -22,6 +22,19 @@ API changes, most recent first: |
| 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. |
| 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) |
| 128 | 128 |
... |
| 129 | 129 |
@end example |
| 130 | 130 |
|
| 131 |
+@subsection C language features |
|
| 132 |
+ |
|
| 133 |
+FFmpeg is programmed in the ISO C90 language with a few additional |
|
| 134 |
+features from ISO C99, namely: |
|
| 135 |
+@itemize @bullet |
|
| 136 |
+@item |
|
| 137 |
+the @samp{inline} keyword;
|
|
| 138 |
+@item |
|
| 139 |
+@samp{//} comments;
|
|
| 140 |
+@item |
|
| 141 |
+designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
|
|
| 142 |
+@item |
|
| 143 |
+compound literals (@samp{x = (struct s) @{ 17, 23 @};})
|
|
| 144 |
+@end itemize |
|
| 145 |
+ |
|
| 146 |
+These features are supported by all compilers we care about, so we will not |
|
| 147 |
+accept patches to remove their use unless they absolutely do not impair |
|
| 148 |
+clarity and performance. |
|
| 149 |
+ |
|
| 150 |
+All code must compile with recent versions of GCC and a number of other |
|
| 151 |
+currently supported compilers. To ensure compatibility, please do not use |
|
| 152 |
+additional C99 features or GCC extensions. Especially watch out for: |
|
| 153 |
+@itemize @bullet |
|
| 154 |
+@item |
|
| 155 |
+mixing statements and declarations; |
|
| 156 |
+@item |
|
| 157 |
+@samp{long long} (use @samp{int64_t} instead);
|
|
| 158 |
+@item |
|
| 159 |
+@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
|
|
| 160 |
+@item |
|
| 161 |
+GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
|
|
| 162 |
+@end itemize |
|
| 163 |
+ |
|
| 164 |
+@subsection Naming conventions |
|
| 165 |
+All names are using underscores (_), not CamelCase. For example, @samp{avfilter_get_video_buffer} is
|
|
| 166 |
+a valid function name and @samp{AVFilterGetVideo} is not. The only exception from this are structure names;
|
|
| 167 |
+they should always be in the CamelCase |
|
| 168 |
+ |
|
| 169 |
+There are following conventions for naming variables and functions: |
|
| 170 |
+@itemize @bullet |
|
| 171 |
+@item |
|
| 172 |
+For local variables no prefix is required. |
|
| 173 |
+@item |
|
| 174 |
+For variables and functions declared as @code{static} no prefixes are required.
|
|
| 175 |
+@item |
|
| 176 |
+For variables and functions used internally by the library, @code{ff_} prefix should be used.
|
|
| 177 |
+For example, @samp{ff_w64_demuxer}.
|
|
| 178 |
+@item |
|
| 179 |
+For variables and functions used internally across multiple libraries, use @code{avpriv_}. For example,
|
|
| 180 |
+@samp{avpriv_aac_parse_header}.
|
|
| 181 |
+@item |
|
| 182 |
+For exported names, each library has its own prefixes. Just check the existing code and name accordingly. |
|
| 183 |
+@end itemize |
|
| 184 |
+ |
|
| 185 |
+@subsection Miscellanous conventions |
|
| 186 |
+@itemize @bullet |
|
| 187 |
+@item |
|
| 131 | 188 |
fprintf and printf are forbidden in libavformat and libavcodec, |
| 132 | 189 |
please use av_log() instead. |
| 133 |
- |
|
| 190 |
+@item |
|
| 134 | 191 |
Casts should be used only when necessary. Unneeded parentheses |
| 135 | 192 |
should also be avoided if they don't make the code easier to understand. |
| 193 |
+@end itemize |
|
| 136 | 194 |
|
| 137 | 195 |
@section Development Policy |
| 138 | 196 |
|
| ... | ... |
@@ -840,13 +840,22 @@ bash directly to work around this: |
| 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, |
| 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) |
| 1560 | 1560 |
|
| 1561 | 1561 |
if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1) |
| 1562 | 1562 |
continue; |
| 1563 |
- if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE)) |
|
| 1563 |
+ if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == CODEC_ID_RAWVIDEO) |
|
| 1564 | 1564 |
continue; |
| 1565 | 1565 |
|
| 1566 | 1566 |
for(;;) {
|
| ... | ... |
@@ -41,6 +41,7 @@ |
| 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, |
| 99 | 99 |
return dst-dst0; |
| 100 | 100 |
} |
| 101 | 101 |
|
| 102 |
-static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
|
| 103 |
- AVPacket *avpkt) |
|
| 102 |
+/** decode a frame */ |
|
| 103 |
+static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, |
|
| 104 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 104 | 105 |
{
|
| 105 | 106 |
EightSvxContext *esc = avctx->priv_data; |
| 106 |
- int out_data_size, n; |
|
| 107 |
+ int n, out_data_size, ret; |
|
| 108 |
+ uint8_t *out_date; |
|
| 107 | 109 |
uint8_t *src, *dst; |
| 108 | 110 |
|
| 109 | 111 |
/* decode and interleave the first packet */ |
| ... | ... |
@@ -145,19 +148,22 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_si |
| 145 | 145 |
memcpy(esc->samples, deinterleaved_samples, esc->samples_size); |
| 146 | 146 |
} |
| 147 | 147 |
|
| 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); |
|
| 148 |
+ /* get output buffer */ |
|
| 149 |
+ esc->frame.nb_samples = (FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx) +avctx->channels-1) / avctx->channels; |
|
| 150 |
+ if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) {
|
|
| 151 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 152 |
+ return ret; |
|
| 153 | 153 |
} |
| 154 | 154 |
|
| 155 |
- *data_size = out_data_size; |
|
| 156 |
- dst = data; |
|
| 155 |
+ *got_frame_ptr = 1; |
|
| 156 |
+ *(AVFrame *)data = esc->frame; |
|
| 157 |
+ |
|
| 158 |
+ dst = esc->frame.data[0]; |
|
| 157 | 159 |
src = esc->samples + esc->samples_idx; |
| 160 |
+ out_data_size = esc->frame.nb_samples * avctx->channels; |
|
| 158 | 161 |
for (n = out_data_size; n > 0; n--) |
| 159 | 162 |
*dst++ = *src++ + 128; |
| 160 |
- esc->samples_idx += *data_size; |
|
| 163 |
+ esc->samples_idx += out_data_size; |
|
| 161 | 164 |
|
| 162 | 165 |
return avctx->codec->id == CODEC_ID_8SVX_FIB || avctx->codec->id == CODEC_ID_8SVX_EXP ? |
| 163 | 166 |
(avctx->frame_number == 0)*2 + out_data_size / 2 : |
| ... | ... |
@@ -184,6 +190,9 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx) |
| 184 | 184 |
} |
| 185 | 185 |
avctx->sample_fmt = AV_SAMPLE_FMT_U8; |
| 186 | 186 |
|
| 187 |
+ avcodec_get_frame_defaults(&esc->frame); |
|
| 188 |
+ avctx->coded_frame = &esc->frame; |
|
| 189 |
+ |
|
| 187 | 190 |
return 0; |
| 188 | 191 |
} |
| 189 | 192 |
|
| ... | ... |
@@ -206,6 +215,7 @@ AVCodec ff_eightsvx_fib_decoder = {
|
| 206 | 206 |
.init = eightsvx_decode_init, |
| 207 | 207 |
.decode = eightsvx_decode_frame, |
| 208 | 208 |
.close = eightsvx_decode_close, |
| 209 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 209 | 210 |
.long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
|
| 210 | 211 |
}; |
| 211 | 212 |
|
| ... | ... |
@@ -217,6 +227,7 @@ AVCodec ff_eightsvx_exp_decoder = {
|
| 217 | 217 |
.init = eightsvx_decode_init, |
| 218 | 218 |
.decode = eightsvx_decode_frame, |
| 219 | 219 |
.close = eightsvx_decode_close, |
| 220 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 220 | 221 |
.long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),
|
| 221 | 222 |
}; |
| 222 | 223 |
|
| ... | ... |
@@ -228,5 +239,6 @@ AVCodec ff_pcm_s8_planar_decoder = {
|
| 228 | 228 |
.init = eightsvx_decode_init, |
| 229 | 229 |
.close = eightsvx_decode_close, |
| 230 | 230 |
.decode = eightsvx_decode_frame, |
| 231 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 231 | 232 |
.long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
|
| 232 | 233 |
}; |
| ... | ... |
@@ -471,15 +471,17 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, |
| 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, |
| 489 | 489 |
av_dlog(avctx, "%02x ", avctx->extradata[i]); |
| 490 | 490 |
av_dlog(avctx, "\n"); |
| 491 | 491 |
|
| 492 |
- init_get_bits(&gb, data, data_size * 8); |
|
| 492 |
+ init_get_bits(&gb, data, bit_size); |
|
| 493 | 493 |
|
| 494 |
- if ((i = avpriv_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0) |
|
| 494 |
+ if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, sync_extension)) < 0) |
|
| 495 | 495 |
return -1; |
| 496 | 496 |
if (m4ac->sampling_index > 12) {
|
| 497 | 497 |
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) |
| 591 | 591 |
if (avctx->extradata_size > 0) {
|
| 592 | 592 |
if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, |
| 593 | 593 |
avctx->extradata, |
| 594 |
- avctx->extradata_size, 8*avctx->extradata_size) < 0) |
|
| 594 |
+ avctx->extradata_size*8, 1) < 0) |
|
| 595 | 595 |
return -1; |
| 596 | 596 |
} else {
|
| 597 | 597 |
int sr, i; |
| ... | ... |
@@ -665,6 +667,9 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) |
| 665 | 665 |
|
| 666 | 666 |
cbrt_tableinit(); |
| 667 | 667 |
|
| 668 |
+ avcodec_get_frame_defaults(&ac->frame); |
|
| 669 |
+ avctx->coded_frame = &ac->frame; |
|
| 670 |
+ |
|
| 668 | 671 |
return 0; |
| 669 | 672 |
} |
| 670 | 673 |
|
| ... | ... |
@@ -2132,12 +2137,12 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) |
| 2132 | 2132 |
} |
| 2133 | 2133 |
|
| 2134 | 2134 |
static int aac_decode_frame_int(AVCodecContext *avctx, void *data, |
| 2135 |
- int *data_size, GetBitContext *gb) |
|
| 2135 |
+ int *got_frame_ptr, GetBitContext *gb) |
|
| 2136 | 2136 |
{
|
| 2137 | 2137 |
AACContext *ac = avctx->priv_data; |
| 2138 | 2138 |
ChannelElement *che = NULL, *che_prev = NULL; |
| 2139 | 2139 |
enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; |
| 2140 |
- int err, elem_id, data_size_tmp; |
|
| 2140 |
+ int err, elem_id; |
|
| 2141 | 2141 |
int samples = 0, multiplier, audio_found = 0; |
| 2142 | 2142 |
|
| 2143 | 2143 |
if (show_bits(gb, 12) == 0xfff) {
|
| ... | ... |
@@ -2250,24 +2255,26 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, |
| 2250 | 2250 |
avctx->frame_size = samples; |
| 2251 | 2251 |
} |
| 2252 | 2252 |
|
| 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 | 2253 |
if (samples) {
|
| 2254 |
+ /* get output buffer */ |
|
| 2255 |
+ ac->frame.nb_samples = samples; |
|
| 2256 |
+ if ((err = avctx->get_buffer(avctx, &ac->frame)) < 0) {
|
|
| 2257 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 2258 |
+ return err; |
|
| 2259 |
+ } |
|
| 2260 |
+ |
|
| 2264 | 2261 |
if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) |
| 2265 |
- ac->fmt_conv.float_interleave(data, (const float **)ac->output_data, |
|
| 2262 |
+ ac->fmt_conv.float_interleave((float *)ac->frame.data[0], |
|
| 2263 |
+ (const float **)ac->output_data, |
|
| 2266 | 2264 |
samples, avctx->channels); |
| 2267 | 2265 |
else |
| 2268 |
- ac->fmt_conv.float_to_int16_interleave(data, (const float **)ac->output_data, |
|
| 2266 |
+ ac->fmt_conv.float_to_int16_interleave((int16_t *)ac->frame.data[0], |
|
| 2267 |
+ (const float **)ac->output_data, |
|
| 2269 | 2268 |
samples, avctx->channels); |
| 2269 |
+ |
|
| 2270 |
+ *(AVFrame *)data = ac->frame; |
|
| 2270 | 2271 |
} |
| 2272 |
+ *got_frame_ptr = !!samples; |
|
| 2271 | 2273 |
|
| 2272 | 2274 |
if (ac->output_configured && audio_found) |
| 2273 | 2275 |
ac->output_configured = OC_LOCKED; |
| ... | ... |
@@ -2276,7 +2283,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, |
| 2276 | 2276 |
} |
| 2277 | 2277 |
|
| 2278 | 2278 |
static int aac_decode_frame(AVCodecContext *avctx, void *data, |
| 2279 |
- int *data_size, AVPacket *avpkt) |
|
| 2279 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 2280 | 2280 |
{
|
| 2281 | 2281 |
const uint8_t *buf = avpkt->data; |
| 2282 | 2282 |
int buf_size = avpkt->size; |
| ... | ... |
@@ -2287,7 +2294,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, |
| 2287 | 2287 |
|
| 2288 | 2288 |
init_get_bits(&gb, buf, buf_size * 8); |
| 2289 | 2289 |
|
| 2290 |
- if ((err = aac_decode_frame_int(avctx, data, data_size, &gb)) < 0) |
|
| 2290 |
+ if ((err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb)) < 0) |
|
| 2291 | 2291 |
return err; |
| 2292 | 2292 |
|
| 2293 | 2293 |
buf_consumed = (get_bits_count(&gb) + 7) >> 3; |
| ... | ... |
@@ -2340,30 +2347,40 @@ static inline uint32_t latm_get_value(GetBitContext *b) |
| 2340 | 2340 |
static int latm_decode_audio_specific_config(struct LATMContext *latmctx, |
| 2341 | 2341 |
GetBitContext *gb, int asclen) |
| 2342 | 2342 |
{
|
| 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; |
|
| 2343 |
+ AACContext *ac = &latmctx->aac_ctx; |
|
| 2344 |
+ AVCodecContext *avctx = ac->avctx; |
|
| 2345 |
+ MPEG4AudioConfig m4ac = {0};
|
|
| 2346 |
+ int config_start_bit = get_bits_count(gb); |
|
| 2347 |
+ int sync_extension = 0; |
|
| 2348 |
+ int bits_consumed, esize; |
|
| 2349 |
+ |
|
| 2350 |
+ if (asclen) {
|
|
| 2351 |
+ sync_extension = 1; |
|
| 2352 |
+ asclen = FFMIN(asclen, get_bits_left(gb)); |
|
| 2353 |
+ } else |
|
| 2354 |
+ asclen = get_bits_left(gb); |
|
| 2348 | 2355 |
|
| 2349 | 2356 |
if (config_start_bit % 8) {
|
| 2350 | 2357 |
av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific " |
| 2351 | 2358 |
"config not byte aligned.\n", 1); |
| 2352 | 2359 |
return AVERROR_INVALIDDATA; |
| 2353 |
- } else {
|
|
| 2354 |
- bits_consumed = |
|
| 2355 |
- decode_audio_specific_config(ac, avctx, &m4ac, |
|
| 2360 |
+ } |
|
| 2361 |
+ bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac, |
|
| 2356 | 2362 |
gb->buffer + (config_start_bit / 8), |
| 2357 |
- get_bits_left(gb) / 8, asclen); |
|
| 2363 |
+ asclen, sync_extension); |
|
| 2358 | 2364 |
|
| 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; |
|
| 2365 |
+ if (bits_consumed < 0) |
|
| 2366 |
+ return AVERROR_INVALIDDATA; |
|
| 2367 |
+ |
|
| 2368 |
+ if (ac->m4ac.sample_rate != m4ac.sample_rate || |
|
| 2369 |
+ ac->m4ac.chan_config != m4ac.chan_config) {
|
|
| 2370 |
+ |
|
| 2371 |
+ av_log(avctx, AV_LOG_INFO, "audio config changed\n"); |
|
| 2372 |
+ latmctx->initialized = 0; |
|
| 2363 | 2373 |
|
| 2364 | 2374 |
esize = (bits_consumed+7) / 8; |
| 2365 | 2375 |
|
| 2366 |
- if (avctx->extradata_size <= esize) {
|
|
| 2376 |
+ if (avctx->extradata_size < esize) {
|
|
| 2367 | 2377 |
av_free(avctx->extradata); |
| 2368 | 2378 |
avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE); |
| 2369 | 2379 |
if (!avctx->extradata) |
| ... | ... |
@@ -2373,9 +2390,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, |
| 2373 | 2373 |
avctx->extradata_size = esize; |
| 2374 | 2374 |
memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize); |
| 2375 | 2375 |
memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE); |
| 2376 |
- |
|
| 2377 |
- skip_bits_long(gb, bits_consumed); |
|
| 2378 | 2376 |
} |
| 2377 |
+ skip_bits_long(gb, bits_consumed); |
|
| 2379 | 2378 |
|
| 2380 | 2379 |
return bits_consumed; |
| 2381 | 2380 |
} |
| ... | ... |
@@ -2512,8 +2528,8 @@ static int read_audio_mux_element(struct LATMContext *latmctx, |
| 2512 | 2512 |
} |
| 2513 | 2513 |
|
| 2514 | 2514 |
|
| 2515 |
-static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, |
|
| 2516 |
- AVPacket *avpkt) |
|
| 2515 |
+static int latm_decode_frame(AVCodecContext *avctx, void *out, |
|
| 2516 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 2517 | 2517 |
{
|
| 2518 | 2518 |
struct LATMContext *latmctx = avctx->priv_data; |
| 2519 | 2519 |
int muxlength, err; |
| ... | ... |
@@ -2535,12 +2551,12 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, |
| 2535 | 2535 |
|
| 2536 | 2536 |
if (!latmctx->initialized) {
|
| 2537 | 2537 |
if (!avctx->extradata) {
|
| 2538 |
- *out_size = 0; |
|
| 2538 |
+ *got_frame_ptr = 0; |
|
| 2539 | 2539 |
return avpkt->size; |
| 2540 | 2540 |
} else {
|
| 2541 | 2541 |
if ((err = decode_audio_specific_config( |
| 2542 | 2542 |
&latmctx->aac_ctx, avctx, &latmctx->aac_ctx.m4ac, |
| 2543 |
- avctx->extradata, avctx->extradata_size, 8*avctx->extradata_size)) < 0) |
|
| 2543 |
+ avctx->extradata, avctx->extradata_size*8, 1)) < 0) |
|
| 2544 | 2544 |
return err; |
| 2545 | 2545 |
latmctx->initialized = 1; |
| 2546 | 2546 |
} |
| ... | ... |
@@ -2553,7 +2569,7 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, |
| 2553 | 2553 |
return AVERROR_INVALIDDATA; |
| 2554 | 2554 |
} |
| 2555 | 2555 |
|
| 2556 |
- if ((err = aac_decode_frame_int(avctx, out, out_size, &gb)) < 0) |
|
| 2556 |
+ if ((err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb)) < 0) |
|
| 2557 | 2557 |
return err; |
| 2558 | 2558 |
|
| 2559 | 2559 |
return muxlength; |
| ... | ... |
@@ -2583,7 +2599,7 @@ AVCodec ff_aac_decoder = {
|
| 2583 | 2583 |
.sample_fmts = (const enum AVSampleFormat[]) {
|
| 2584 | 2584 |
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
| 2585 | 2585 |
}, |
| 2586 |
- .capabilities = CODEC_CAP_CHANNEL_CONF, |
|
| 2586 |
+ .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, |
|
| 2587 | 2587 |
.channel_layouts = aac_channel_layout, |
| 2588 | 2588 |
}; |
| 2589 | 2589 |
|
| ... | ... |
@@ -2604,7 +2620,7 @@ AVCodec ff_aac_latm_decoder = {
|
| 2604 | 2604 |
.sample_fmts = (const enum AVSampleFormat[]) {
|
| 2605 | 2605 |
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
| 2606 | 2606 |
}, |
| 2607 |
- .capabilities = CODEC_CAP_CHANNEL_CONF, |
|
| 2607 |
+ .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, |
|
| 2608 | 2608 |
.channel_layouts = aac_channel_layout, |
| 2609 | 2609 |
.flush = flush, |
| 2610 | 2610 |
}; |
| ... | ... |
@@ -208,6 +208,9 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) |
| 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) |
| 1296 | 1296 |
/** |
| 1297 | 1297 |
* Decode a single AC-3 frame. |
| 1298 | 1298 |
*/ |
| 1299 |
-static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
|
| 1300 |
- AVPacket *avpkt) |
|
| 1299 |
+static int ac3_decode_frame(AVCodecContext * avctx, void *data, |
|
| 1300 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1301 | 1301 |
{
|
| 1302 | 1302 |
const uint8_t *buf = avpkt->data; |
| 1303 | 1303 |
int buf_size = avpkt->size; |
| 1304 | 1304 |
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; |
|
| 1305 |
+ float *out_samples_flt; |
|
| 1306 |
+ int16_t *out_samples_s16; |
|
| 1307 |
+ int blk, ch, err, ret; |
|
| 1309 | 1308 |
const uint8_t *channel_map; |
| 1310 | 1309 |
const float *output[AC3_MAX_CHANNELS]; |
| 1311 | 1310 |
|
| ... | ... |
@@ -1322,8 +1324,6 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
| 1322 | 1322 |
init_get_bits(&s->gbc, buf, buf_size * 8); |
| 1323 | 1323 |
|
| 1324 | 1324 |
/* parse the syncinfo */ |
| 1325 |
- data_size_orig = *data_size; |
|
| 1326 |
- *data_size = 0; |
|
| 1327 | 1325 |
err = parse_frame_header(s); |
| 1328 | 1326 |
|
| 1329 | 1327 |
if (err) {
|
| ... | ... |
@@ -1345,6 +1345,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
| 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, |
| 1406 | 1406 |
if (s->bitstream_mode == 0x7 && s->channels > 1) |
| 1407 | 1407 |
avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE; |
| 1408 | 1408 |
|
| 1409 |
+ /* get output buffer */ |
|
| 1410 |
+ s->frame.nb_samples = s->num_blocks * 256; |
|
| 1411 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 1412 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1413 |
+ return ret; |
|
| 1414 |
+ } |
|
| 1415 |
+ out_samples_flt = (float *)s->frame.data[0]; |
|
| 1416 |
+ out_samples_s16 = (int16_t *)s->frame.data[0]; |
|
| 1417 |
+ |
|
| 1409 | 1418 |
/* decode the audio blocks */ |
| 1410 | 1419 |
channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on]; |
| 1411 | 1420 |
for (ch = 0; ch < s->out_channels; ch++) |
| 1412 | 1421 |
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 | 1422 |
for (blk = 0; blk < s->num_blocks; blk++) {
|
| 1419 | 1423 |
if (!err && decode_audio_block(s, blk)) {
|
| 1420 | 1424 |
av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n"); |
| 1421 | 1425 |
err = 1; |
| 1422 | 1426 |
} |
| 1423 |
- |
|
| 1424 | 1427 |
if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
|
| 1425 | 1428 |
s->fmt_conv.float_interleave(out_samples_flt, output, 256, |
| 1426 | 1429 |
s->out_channels); |
| ... | ... |
@@ -1431,8 +1435,10 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
| 1431 | 1431 |
out_samples_s16 += 256 * s->out_channels; |
| 1432 | 1432 |
} |
| 1433 | 1433 |
} |
| 1434 |
- *data_size = s->num_blocks * 256 * avctx->channels * |
|
| 1435 |
- av_get_bytes_per_sample(avctx->sample_fmt); |
|
| 1434 |
+ |
|
| 1435 |
+ *got_frame_ptr = 1; |
|
| 1436 |
+ *(AVFrame *)data = s->frame; |
|
| 1437 |
+ |
|
| 1436 | 1438 |
return FFMIN(buf_size, s->frame_size); |
| 1437 | 1439 |
} |
| 1438 | 1440 |
|
| ... | ... |
@@ -1477,6 +1483,7 @@ AVCodec ff_ac3_decoder = {
|
| 1477 | 1477 |
.init = ac3_decode_init, |
| 1478 | 1478 |
.close = ac3_decode_end, |
| 1479 | 1479 |
.decode = ac3_decode_frame, |
| 1480 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1480 | 1481 |
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
|
| 1481 | 1482 |
.sample_fmts = (const enum AVSampleFormat[]) {
|
| 1482 | 1483 |
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
| ... | ... |
@@ -1499,6 +1506,7 @@ AVCodec ff_eac3_decoder = {
|
| 1499 | 1499 |
.init = ac3_decode_init, |
| 1500 | 1500 |
.close = ac3_decode_end, |
| 1501 | 1501 |
.decode = ac3_decode_frame, |
| 1502 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1502 | 1503 |
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
|
| 1503 | 1504 |
.sample_fmts = (const enum AVSampleFormat[]) {
|
| 1504 | 1505 |
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
| ... | ... |
@@ -84,6 +84,7 @@ static const int swf_index_tables[4][16] = {
|
| 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) |
| 124 | 124 |
break; |
| 125 | 125 |
} |
| 126 | 126 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 127 |
+ |
|
| 128 |
+ avcodec_get_frame_defaults(&c->frame); |
|
| 129 |
+ avctx->coded_frame = &c->frame; |
|
| 130 |
+ |
|
| 127 | 131 |
return 0; |
| 128 | 132 |
} |
| 129 | 133 |
|
| ... | ... |
@@ -501,9 +506,8 @@ static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf, |
| 501 | 501 |
decode_top_nibble_next = 1; \ |
| 502 | 502 |
} |
| 503 | 503 |
|
| 504 |
-static int adpcm_decode_frame(AVCodecContext *avctx, |
|
| 505 |
- void *data, int *data_size, |
|
| 506 |
- AVPacket *avpkt) |
|
| 504 |
+static int adpcm_decode_frame(AVCodecContext *avctx, void *data, |
|
| 505 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 507 | 506 |
{
|
| 508 | 507 |
const uint8_t *buf = avpkt->data; |
| 509 | 508 |
int buf_size = avpkt->size; |
| ... | ... |
@@ -514,7 +518,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, |
| 514 | 514 |
const uint8_t *src; |
| 515 | 515 |
int st; /* stereo */ |
| 516 | 516 |
int count1, count2; |
| 517 |
- int nb_samples, coded_samples, out_bps, out_size; |
|
| 517 |
+ int nb_samples, coded_samples, ret; |
|
| 518 | 518 |
|
| 519 | 519 |
nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples); |
| 520 | 520 |
if (nb_samples <= 0) {
|
| ... | ... |
@@ -522,22 +526,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx, |
| 522 | 522 |
return AVERROR_INVALIDDATA; |
| 523 | 523 |
} |
| 524 | 524 |
|
| 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); |
|
| 525 |
+ /* get output buffer */ |
|
| 526 |
+ c->frame.nb_samples = nb_samples; |
|
| 527 |
+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
|
| 528 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 529 |
+ return ret; |
|
| 530 | 530 |
} |
| 531 |
+ samples = (short *)c->frame.data[0]; |
|
| 532 |
+ |
|
| 531 | 533 |
/* use coded_samples when applicable */ |
| 532 | 534 |
/* it is always <= nb_samples, so the output buffer will be large enough */ |
| 533 | 535 |
if (coded_samples) {
|
| 534 | 536 |
if (coded_samples != nb_samples) |
| 535 | 537 |
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; |
|
| 538 |
+ c->frame.nb_samples = nb_samples = coded_samples; |
|
| 538 | 539 |
} |
| 539 | 540 |
|
| 540 |
- samples = data; |
|
| 541 | 541 |
src = buf; |
| 542 | 542 |
|
| 543 | 543 |
st = avctx->channels == 2 ? 1 : 0; |
| ... | ... |
@@ -576,7 +580,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, |
| 576 | 576 |
cs->step_index = 88; |
| 577 | 577 |
} |
| 578 | 578 |
|
| 579 |
- samples = (short*)data + channel; |
|
| 579 |
+ samples = (short *)c->frame.data[0] + channel; |
|
| 580 | 580 |
|
| 581 | 581 |
for (m = 0; m < 32; m++) {
|
| 582 | 582 |
*samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3); |
| ... | ... |
@@ -628,7 +632,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, |
| 628 | 628 |
} |
| 629 | 629 |
|
| 630 | 630 |
for (i = 0; i < avctx->channels; i++) {
|
| 631 |
- samples = (short*)data + i; |
|
| 631 |
+ samples = (short *)c->frame.data[0] + i; |
|
| 632 | 632 |
cs = &c->status[i]; |
| 633 | 633 |
for (n = nb_samples >> 1; n > 0; n--, src++) {
|
| 634 | 634 |
uint8_t v = *src; |
| ... | ... |
@@ -965,7 +969,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, |
| 965 | 965 |
} |
| 966 | 966 |
} |
| 967 | 967 |
|
| 968 |
- out_size = count * 28 * avctx->channels * out_bps; |
|
| 968 |
+ c->frame.nb_samples = count * 28; |
|
| 969 | 969 |
src = src_end; |
| 970 | 970 |
break; |
| 971 | 971 |
} |
| ... | ... |
@@ -1144,7 +1148,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, |
| 1144 | 1144 |
prev[0][i] = (int16_t)bytestream_get_be16(&src); |
| 1145 | 1145 |
|
| 1146 | 1146 |
for (ch = 0; ch <= st; ch++) {
|
| 1147 |
- samples = (unsigned short *) data + ch; |
|
| 1147 |
+ samples = (short *)c->frame.data[0] + ch; |
|
| 1148 | 1148 |
|
| 1149 | 1149 |
/* Read in every sample for this channel. */ |
| 1150 | 1150 |
for (i = 0; i < nb_samples / 14; i++) {
|
| ... | ... |
@@ -1177,7 +1181,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx, |
| 1177 | 1177 |
default: |
| 1178 | 1178 |
return -1; |
| 1179 | 1179 |
} |
| 1180 |
- *data_size = out_size; |
|
| 1180 |
+ |
|
| 1181 |
+ *got_frame_ptr = 1; |
|
| 1182 |
+ *(AVFrame *)data = c->frame; |
|
| 1183 |
+ |
|
| 1181 | 1184 |
return src - buf; |
| 1182 | 1185 |
} |
| 1183 | 1186 |
|
| ... | ... |
@@ -1190,6 +1197,7 @@ AVCodec ff_ ## name_ ## _decoder = { \
|
| 1190 | 1190 |
.priv_data_size = sizeof(ADPCMDecodeContext), \ |
| 1191 | 1191 |
.init = adpcm_decode_init, \ |
| 1192 | 1192 |
.decode = adpcm_decode_frame, \ |
| 1193 |
+ .capabilities = CODEC_CAP_DR1, \ |
|
| 1193 | 1194 |
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ |
| 1194 | 1195 |
} |
| 1195 | 1196 |
|
| ... | ... |
@@ -50,6 +50,10 @@ static av_cold int adx_decode_init(AVCodecContext *avctx) |
| 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) |
| 89 | 89 |
return 0; |
| 90 | 90 |
} |
| 91 | 91 |
|
| 92 |
-static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
|
| 93 |
- AVPacket *avpkt) |
|
| 92 |
+static int adx_decode_frame(AVCodecContext *avctx, void *data, |
|
| 93 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 94 | 94 |
{
|
| 95 | 95 |
int buf_size = avpkt->size; |
| 96 | 96 |
ADXContext *c = avctx->priv_data; |
| 97 |
- int16_t *samples = data; |
|
| 97 |
+ int16_t *samples; |
|
| 98 | 98 |
const uint8_t *buf = avpkt->data; |
| 99 |
- int num_blocks, ch; |
|
| 99 |
+ int num_blocks, ch, ret; |
|
| 100 | 100 |
|
| 101 | 101 |
if (c->eof) {
|
| 102 |
- *data_size = 0; |
|
| 102 |
+ *got_frame_ptr = 0; |
|
| 103 | 103 |
return buf_size; |
| 104 | 104 |
} |
| 105 | 105 |
|
| 106 |
- /* 18 bytes of data are expanded into 32*2 bytes of audio, |
|
| 107 |
- so guard against buffer overflows */ |
|
| 106 |
+ /* calculate number of blocks in the packet */ |
|
| 108 | 107 |
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)) {
|
|
| 108 |
+ |
|
| 109 |
+ /* if the packet is not an even multiple of BLOCK_SIZE, check for an EOF |
|
| 110 |
+ packet */ |
|
| 111 |
+ if (!num_blocks || buf_size % (BLOCK_SIZE * avctx->channels)) {
|
|
| 114 | 112 |
if (buf_size >= 4 && (AV_RB16(buf) & 0x8000)) {
|
| 115 | 113 |
c->eof = 1; |
| 116 |
- *data_size = 0; |
|
| 114 |
+ *got_frame_ptr = 0; |
|
| 117 | 115 |
return avpkt->size; |
| 118 | 116 |
} |
| 119 | 117 |
return AVERROR_INVALIDDATA; |
| 120 | 118 |
} |
| 121 | 119 |
|
| 120 |
+ /* get output buffer */ |
|
| 121 |
+ c->frame.nb_samples = num_blocks * BLOCK_SAMPLES; |
|
| 122 |
+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
|
| 123 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 124 |
+ return ret; |
|
| 125 |
+ } |
|
| 126 |
+ samples = (int16_t *)c->frame.data[0]; |
|
| 127 |
+ |
|
| 122 | 128 |
while (num_blocks--) {
|
| 123 | 129 |
for (ch = 0; ch < c->channels; ch++) {
|
| 124 | 130 |
if (adx_decode(c, samples + ch, buf, ch)) {
|
| ... | ... |
@@ -132,7 +142,9 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 132 | 132 |
samples += BLOCK_SAMPLES * c->channels; |
| 133 | 133 |
} |
| 134 | 134 |
|
| 135 |
- *data_size = (uint8_t*)samples - (uint8_t*)data; |
|
| 135 |
+ *got_frame_ptr = 1; |
|
| 136 |
+ *(AVFrame *)data = c->frame; |
|
| 137 |
+ |
|
| 136 | 138 |
return buf - avpkt->data; |
| 137 | 139 |
} |
| 138 | 140 |
|
| ... | ... |
@@ -143,5 +155,6 @@ AVCodec ff_adpcm_adx_decoder = {
|
| 143 | 143 |
.priv_data_size = sizeof(ADXContext), |
| 144 | 144 |
.init = adx_decode_init, |
| 145 | 145 |
.decode = adx_decode_frame, |
| 146 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 146 | 147 |
.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
|
| 147 | 148 |
}; |
| ... | ... |
@@ -62,10 +62,10 @@ |
| 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], |
| 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, |
| 366 | 366 |
int isnotcompressed; |
| 367 | 367 |
uint8_t interlacing_shift; |
| 368 | 368 |
uint8_t interlacing_leftweight; |
| 369 |
- int i, ch; |
|
| 369 |
+ int i, ch, ret; |
|
| 370 | 370 |
|
| 371 | 371 |
init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8); |
| 372 | 372 |
|
| ... | ... |
@@ -401,14 +400,17 @@ static int alac_decode_frame(AVCodecContext *avctx, |
| 401 | 401 |
} else |
| 402 | 402 |
outputsamples = alac->setinfo_max_samples_per_frame; |
| 403 | 403 |
|
| 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; |
|
| 404 |
+ /* get output buffer */ |
|
| 405 |
+ if (outputsamples > INT32_MAX) {
|
|
| 406 |
+ av_log(avctx, AV_LOG_ERROR, "unsupported block size: %u\n", outputsamples); |
|
| 407 |
+ return AVERROR_INVALIDDATA; |
|
| 408 |
+ } |
|
| 409 |
+ alac->frame.nb_samples = outputsamples; |
|
| 410 |
+ if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) {
|
|
| 411 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 412 |
+ return ret; |
|
| 409 | 413 |
} |
| 410 | 414 |
|
| 411 |
- *outputsize = outputsamples * alac->bytespersample; |
|
| 412 | 415 |
readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1; |
| 413 | 416 |
if (readsamplesize > MIN_CACHE_BITS) {
|
| 414 | 417 |
av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize); |
| ... | ... |
@@ -501,21 +503,23 @@ static int alac_decode_frame(AVCodecContext *avctx, |
| 501 | 501 |
switch(alac->setinfo_sample_size) {
|
| 502 | 502 |
case 16: |
| 503 | 503 |
if (channels == 2) {
|
| 504 |
- interleave_stereo_16(alac->outputsamples_buffer, outbuffer, |
|
| 505 |
- outputsamples); |
|
| 504 |
+ interleave_stereo_16(alac->outputsamples_buffer, |
|
| 505 |
+ (int16_t *)alac->frame.data[0], outputsamples); |
|
| 506 | 506 |
} else {
|
| 507 |
+ int16_t *outbuffer = (int16_t *)alac->frame.data[0]; |
|
| 507 | 508 |
for (i = 0; i < outputsamples; i++) {
|
| 508 |
- ((int16_t*)outbuffer)[i] = alac->outputsamples_buffer[0][i]; |
|
| 509 |
+ outbuffer[i] = alac->outputsamples_buffer[0][i]; |
|
| 509 | 510 |
} |
| 510 | 511 |
} |
| 511 | 512 |
break; |
| 512 | 513 |
case 24: |
| 513 | 514 |
if (channels == 2) {
|
| 514 |
- interleave_stereo_24(alac->outputsamples_buffer, outbuffer, |
|
| 515 |
- outputsamples); |
|
| 515 |
+ interleave_stereo_24(alac->outputsamples_buffer, |
|
| 516 |
+ (int32_t *)alac->frame.data[0], outputsamples); |
|
| 516 | 517 |
} else {
|
| 518 |
+ int32_t *outbuffer = (int32_t *)alac->frame.data[0]; |
|
| 517 | 519 |
for (i = 0; i < outputsamples; i++) |
| 518 |
- ((int32_t *)outbuffer)[i] = alac->outputsamples_buffer[0][i] << 8; |
|
| 520 |
+ outbuffer[i] = alac->outputsamples_buffer[0][i] << 8; |
|
| 519 | 521 |
} |
| 520 | 522 |
break; |
| 521 | 523 |
} |
| ... | ... |
@@ -523,6 +527,9 @@ static int alac_decode_frame(AVCodecContext *avctx, |
| 523 | 523 |
if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8) |
| 524 | 524 |
av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb)); |
| 525 | 525 |
|
| 526 |
+ *got_frame_ptr = 1; |
|
| 527 |
+ *(AVFrame *)data = alac->frame; |
|
| 528 |
+ |
|
| 526 | 529 |
return input_buffer_size; |
| 527 | 530 |
} |
| 528 | 531 |
|
| ... | ... |
@@ -637,6 +644,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx) |
| 637 | 637 |
return ret; |
| 638 | 638 |
} |
| 639 | 639 |
|
| 640 |
+ avcodec_get_frame_defaults(&alac->frame); |
|
| 641 |
+ avctx->coded_frame = &alac->frame; |
|
| 642 |
+ |
|
| 640 | 643 |
return 0; |
| 641 | 644 |
} |
| 642 | 645 |
|
| ... | ... |
@@ -648,5 +658,6 @@ AVCodec ff_alac_decoder = {
|
| 648 | 648 |
.init = alac_decode_init, |
| 649 | 649 |
.close = alac_decode_close, |
| 650 | 650 |
.decode = alac_decode_frame, |
| 651 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 651 | 652 |
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
|
| 652 | 653 |
}; |
| ... | ... |
@@ -75,20 +75,22 @@ typedef struct AlacEncodeContext {
|
| 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 |
| 97 | 97 |
q = x / divisor; |
| 98 | 98 |
r = x % divisor; |
| 99 | 99 |
|
| 100 |
- if(q > 8) {
|
|
| 100 |
+ if (q > 8) {
|
|
| 101 | 101 |
// write escape code and sample value directly |
| 102 | 102 |
put_bits(&s->pbctx, 9, ALAC_ESCAPE_CODE); |
| 103 | 103 |
put_bits(&s->pbctx, write_sample_size, x); |
| 104 | 104 |
} else {
|
| 105 |
- if(q) |
|
| 105 |
+ if (q) |
|
| 106 | 106 |
put_bits(&s->pbctx, q, (1<<q) - 1); |
| 107 | 107 |
put_bits(&s->pbctx, 1, 0); |
| 108 | 108 |
|
| 109 |
- if(k != 1) {
|
|
| 110 |
- if(r > 0) |
|
| 109 |
+ if (k != 1) {
|
|
| 110 |
+ if (r > 0) |
|
| 111 | 111 |
put_bits(&s->pbctx, k, r+1); |
| 112 | 112 |
else |
| 113 | 113 |
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) |
| 164 | 164 |
|
| 165 | 165 |
/* calculate sum of 2nd order residual for each channel */ |
| 166 | 166 |
sum[0] = sum[1] = sum[2] = sum[3] = 0; |
| 167 |
- for(i=2; i<n; i++) {
|
|
| 167 |
+ for (i = 2; i < n; i++) {
|
|
| 168 | 168 |
lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2]; |
| 169 | 169 |
rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2]; |
| 170 | 170 |
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) |
| 181 | 181 |
|
| 182 | 182 |
/* return mode with lowest score */ |
| 183 | 183 |
best = 0; |
| 184 |
- for(i=1; i<4; i++) {
|
|
| 185 |
- if(score[i] < score[best]) {
|
|
| 184 |
+ for (i = 1; i < 4; i++) {
|
|
| 185 |
+ if (score[i] < score[best]) {
|
|
| 186 | 186 |
best = i; |
| 187 | 187 |
} |
| 188 | 188 |
} |
| ... | ... |
@@ -205,7 +207,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) |
| 205 | 205 |
break; |
| 206 | 206 |
|
| 207 | 207 |
case ALAC_CHMODE_LEFT_SIDE: |
| 208 |
- for(i=0; i<n; i++) {
|
|
| 208 |
+ for (i = 0; i < n; i++) {
|
|
| 209 | 209 |
right[i] = left[i] - right[i]; |
| 210 | 210 |
} |
| 211 | 211 |
s->interlacing_leftweight = 1; |
| ... | ... |
@@ -213,7 +215,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) |
| 213 | 213 |
break; |
| 214 | 214 |
|
| 215 | 215 |
case ALAC_CHMODE_RIGHT_SIDE: |
| 216 |
- for(i=0; i<n; i++) {
|
|
| 216 |
+ for (i = 0; i < n; i++) {
|
|
| 217 | 217 |
tmp = right[i]; |
| 218 | 218 |
right[i] = left[i] - right[i]; |
| 219 | 219 |
left[i] = tmp + (right[i] >> 31); |
| ... | ... |
@@ -223,7 +225,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s) |
| 223 | 223 |
break; |
| 224 | 224 |
|
| 225 | 225 |
default: |
| 226 |
- for(i=0; i<n; i++) {
|
|
| 226 |
+ for (i = 0; i < n; i++) {
|
|
| 227 | 227 |
tmp = left[i]; |
| 228 | 228 |
left[i] = (tmp + right[i]) >> 1; |
| 229 | 229 |
right[i] = tmp - right[i]; |
| ... | ... |
@@ -239,10 +241,10 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) |
| 239 | 239 |
int i; |
| 240 | 240 |
AlacLPCContext lpc = s->lpc[ch]; |
| 241 | 241 |
|
| 242 |
- if(lpc.lpc_order == 31) {
|
|
| 242 |
+ if (lpc.lpc_order == 31) {
|
|
| 243 | 243 |
s->predictor_buf[0] = s->sample_buf[ch][0]; |
| 244 | 244 |
|
| 245 |
- for(i=1; i<s->avctx->frame_size; i++) |
|
| 245 |
+ for (i = 1; i < s->avctx->frame_size; i++) |
|
| 246 | 246 |
s->predictor_buf[i] = s->sample_buf[ch][i] - s->sample_buf[ch][i-1]; |
| 247 | 247 |
|
| 248 | 248 |
return; |
| ... | ... |
@@ -250,17 +252,17 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) |
| 250 | 250 |
|
| 251 | 251 |
// generalised linear predictor |
| 252 | 252 |
|
| 253 |
- if(lpc.lpc_order > 0) {
|
|
| 253 |
+ if (lpc.lpc_order > 0) {
|
|
| 254 | 254 |
int32_t *samples = s->sample_buf[ch]; |
| 255 | 255 |
int32_t *residual = s->predictor_buf; |
| 256 | 256 |
|
| 257 | 257 |
// generate warm-up samples |
| 258 | 258 |
residual[0] = samples[0]; |
| 259 |
- for(i=1;i<=lpc.lpc_order;i++) |
|
| 259 |
+ for (i = 1; i <= lpc.lpc_order; i++) |
|
| 260 | 260 |
residual[i] = samples[i] - samples[i-1]; |
| 261 | 261 |
|
| 262 | 262 |
// perform lpc on remaining samples |
| 263 |
- for(i = lpc.lpc_order + 1; i < s->avctx->frame_size; i++) {
|
|
| 263 |
+ for (i = lpc.lpc_order + 1; i < s->avctx->frame_size; i++) {
|
|
| 264 | 264 |
int sum = 1 << (lpc.lpc_quant - 1), res_val, j; |
| 265 | 265 |
|
| 266 | 266 |
for (j = 0; j < lpc.lpc_order; j++) {
|
| ... | ... |
@@ -303,7 +305,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) |
| 303 | 303 |
int sign_modifier = 0, i, k; |
| 304 | 304 |
int32_t *samples = s->predictor_buf; |
| 305 | 305 |
|
| 306 |
- for(i=0;i < s->avctx->frame_size;) {
|
|
| 306 |
+ for (i = 0; i < s->avctx->frame_size;) {
|
|
| 307 | 307 |
int x; |
| 308 | 308 |
|
| 309 | 309 |
k = av_log2((history >> 9) + 3); |
| ... | ... |
@@ -320,15 +322,15 @@ static void alac_entropy_coder(AlacEncodeContext *s) |
| 320 | 320 |
- ((history * s->rc.history_mult) >> 9); |
| 321 | 321 |
|
| 322 | 322 |
sign_modifier = 0; |
| 323 |
- if(x > 0xFFFF) |
|
| 323 |
+ if (x > 0xFFFF) |
|
| 324 | 324 |
history = 0xFFFF; |
| 325 | 325 |
|
| 326 |
- if((history < 128) && (i < s->avctx->frame_size)) {
|
|
| 326 |
+ if (history < 128 && i < s->avctx->frame_size) {
|
|
| 327 | 327 |
unsigned int block_size = 0; |
| 328 | 328 |
|
| 329 | 329 |
k = 7 - av_log2(history) + ((history + 16) >> 6); |
| 330 | 330 |
|
| 331 |
- while((*samples == 0) && (i < s->avctx->frame_size)) {
|
|
| 331 |
+ while (*samples == 0 && i < s->avctx->frame_size) {
|
|
| 332 | 332 |
samples++; |
| 333 | 333 |
i++; |
| 334 | 334 |
block_size++; |
| ... | ... |
@@ -347,12 +349,12 @@ static void write_compressed_frame(AlacEncodeContext *s) |
| 347 | 347 |
{
|
| 348 | 348 |
int i, j; |
| 349 | 349 |
|
| 350 |
- if(s->avctx->channels == 2) |
|
| 350 |
+ if (s->avctx->channels == 2) |
|
| 351 | 351 |
alac_stereo_decorrelation(s); |
| 352 | 352 |
put_bits(&s->pbctx, 8, s->interlacing_shift); |
| 353 | 353 |
put_bits(&s->pbctx, 8, s->interlacing_leftweight); |
| 354 | 354 |
|
| 355 |
- for(i=0;i<s->avctx->channels;i++) {
|
|
| 355 |
+ for (i = 0; i < s->avctx->channels; i++) {
|
|
| 356 | 356 |
|
| 357 | 357 |
calc_predictor_params(s, i); |
| 358 | 358 |
|
| ... | ... |
@@ -362,14 +364,14 @@ static void write_compressed_frame(AlacEncodeContext *s) |
| 362 | 362 |
put_bits(&s->pbctx, 3, s->rc.rice_modifier); |
| 363 | 363 |
put_bits(&s->pbctx, 5, s->lpc[i].lpc_order); |
| 364 | 364 |
// predictor coeff. table |
| 365 |
- for(j=0;j<s->lpc[i].lpc_order;j++) {
|
|
| 365 |
+ for (j = 0; j < s->lpc[i].lpc_order; j++) {
|
|
| 366 | 366 |
put_sbits(&s->pbctx, 16, s->lpc[i].lpc_coeff[j]); |
| 367 | 367 |
} |
| 368 | 368 |
} |
| 369 | 369 |
|
| 370 | 370 |
// apply lpc and entropy coding to audio samples |
| 371 | 371 |
|
| 372 |
- for(i=0;i<s->avctx->channels;i++) {
|
|
| 372 |
+ for (i = 0; i < s->avctx->channels; i++) {
|
|
| 373 | 373 |
alac_linear_predictor(s, i); |
| 374 | 374 |
alac_entropy_coder(s); |
| 375 | 375 |
} |
| ... | ... |
@@ -384,7 +386,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) |
| 384 | 384 |
avctx->frame_size = DEFAULT_FRAME_SIZE; |
| 385 | 385 |
avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE; |
| 386 | 386 |
|
| 387 |
- if(avctx->sample_fmt != AV_SAMPLE_FMT_S16) {
|
|
| 387 |
+ if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) {
|
|
| 388 | 388 |
av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n"); |
| 389 | 389 |
return -1; |
| 390 | 390 |
} |
| ... | ... |
@@ -395,7 +397,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) |
| 395 | 395 |
} |
| 396 | 396 |
|
| 397 | 397 |
// Set default compression level |
| 398 |
- if(avctx->compression_level == FF_COMPRESSION_DEFAULT) |
|
| 398 |
+ if (avctx->compression_level == FF_COMPRESSION_DEFAULT) |
|
| 399 | 399 |
s->compression_level = 2; |
| 400 | 400 |
else |
| 401 | 401 |
s->compression_level = av_clip(avctx->compression_level, 0, 2); |
| ... | ... |
@@ -416,21 +418,23 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) |
| 416 | 416 |
AV_WB8 (alac_extradata+17, avctx->bits_per_coded_sample); |
| 417 | 417 |
AV_WB8 (alac_extradata+21, avctx->channels); |
| 418 | 418 |
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 |
|
| 419 |
+ AV_WB32(alac_extradata+28, |
|
| 420 |
+ avctx->sample_rate * avctx->channels * avctx->bits_per_coded_sample); // average bitrate |
|
| 420 | 421 |
AV_WB32(alac_extradata+32, avctx->sample_rate); |
| 421 | 422 |
|
| 422 | 423 |
// Set relevant extradata fields |
| 423 |
- if(s->compression_level > 0) {
|
|
| 424 |
+ if (s->compression_level > 0) {
|
|
| 424 | 425 |
AV_WB8(alac_extradata+18, s->rc.history_mult); |
| 425 | 426 |
AV_WB8(alac_extradata+19, s->rc.initial_history); |
| 426 | 427 |
AV_WB8(alac_extradata+20, s->rc.k_modifier); |
| 427 | 428 |
} |
| 428 | 429 |
|
| 429 | 430 |
s->min_prediction_order = DEFAULT_MIN_PRED_ORDER; |
| 430 |
- if(avctx->min_prediction_order >= 0) {
|
|
| 431 |
- if(avctx->min_prediction_order < MIN_LPC_ORDER || |
|
| 431 |
+ if (avctx->min_prediction_order >= 0) {
|
|
| 432 |
+ if (avctx->min_prediction_order < MIN_LPC_ORDER || |
|
| 432 | 433 |
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); |
|
| 434 |
+ av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", |
|
| 435 |
+ avctx->min_prediction_order); |
|
| 434 | 436 |
return -1; |
| 435 | 437 |
} |
| 436 | 438 |
|
| ... | ... |
@@ -438,18 +442,20 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) |
| 438 | 438 |
} |
| 439 | 439 |
|
| 440 | 440 |
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); |
|
| 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", |
|
| 445 |
+ avctx->max_prediction_order); |
|
| 445 | 446 |
return -1; |
| 446 | 447 |
} |
| 447 | 448 |
|
| 448 | 449 |
s->max_prediction_order = avctx->max_prediction_order; |
| 449 | 450 |
} |
| 450 | 451 |
|
| 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", |
|
| 452 |
+ if (s->max_prediction_order < s->min_prediction_order) {
|
|
| 453 |
+ av_log(avctx, AV_LOG_ERROR, |
|
| 454 |
+ "invalid prediction orders: min=%d max=%d\n", |
|
| 453 | 455 |
s->min_prediction_order, s->max_prediction_order); |
| 454 | 456 |
return -1; |
| 455 | 457 |
} |
| ... | ... |
@@ -474,12 +480,12 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame, |
| 474 | 474 |
PutBitContext *pb = &s->pbctx; |
| 475 | 475 |
int i, out_bytes, verbatim_flag = 0; |
| 476 | 476 |
|
| 477 |
- if(avctx->frame_size > DEFAULT_FRAME_SIZE) {
|
|
| 477 |
+ if (avctx->frame_size > DEFAULT_FRAME_SIZE) {
|
|
| 478 | 478 |
av_log(avctx, AV_LOG_ERROR, "input frame size exceeded\n"); |
| 479 | 479 |
return -1; |
| 480 | 480 |
} |
| 481 | 481 |
|
| 482 |
- if(buf_size < 2*s->max_coded_frame_size) {
|
|
| 482 |
+ if (buf_size < 2 * s->max_coded_frame_size) {
|
|
| 483 | 483 |
av_log(avctx, AV_LOG_ERROR, "buffer size is too small\n"); |
| 484 | 484 |
return -1; |
| 485 | 485 |
} |
| ... | ... |
@@ -487,11 +493,11 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame, |
| 487 | 487 |
verbatim: |
| 488 | 488 |
init_put_bits(pb, frame, buf_size); |
| 489 | 489 |
|
| 490 |
- if((s->compression_level == 0) || verbatim_flag) {
|
|
| 490 |
+ if (s->compression_level == 0 || verbatim_flag) {
|
|
| 491 | 491 |
// Verbatim mode |
| 492 | 492 |
const int16_t *samples = data; |
| 493 | 493 |
write_frame_header(s, 1); |
| 494 |
- for(i=0; i<avctx->frame_size*avctx->channels; i++) {
|
|
| 494 |
+ for (i = 0; i < avctx->frame_size * avctx->channels; i++) {
|
|
| 495 | 495 |
put_sbits(pb, 16, *samples++); |
| 496 | 496 |
} |
| 497 | 497 |
} else {
|
| ... | ... |
@@ -504,9 +510,9 @@ verbatim: |
| 504 | 504 |
flush_put_bits(pb); |
| 505 | 505 |
out_bytes = put_bits_count(pb) >> 3; |
| 506 | 506 |
|
| 507 |
- if(out_bytes > s->max_coded_frame_size) {
|
|
| 507 |
+ if (out_bytes > s->max_coded_frame_size) {
|
|
| 508 | 508 |
/* frame too large. use verbatim mode */ |
| 509 |
- if(verbatim_flag || (s->compression_level == 0)) {
|
|
| 509 |
+ if (verbatim_flag || s->compression_level == 0) {
|
|
| 510 | 510 |
/* still too large. must be an error. */ |
| 511 | 511 |
av_log(avctx, AV_LOG_ERROR, "error encoding frame\n"); |
| 512 | 512 |
return -1; |
| ... | ... |
@@ -537,6 +543,7 @@ AVCodec ff_alac_encoder = {
|
| 537 | 537 |
.encode = alac_encode_frame, |
| 538 | 538 |
.close = alac_encode_close, |
| 539 | 539 |
.capabilities = CODEC_CAP_SMALL_LAST_FRAME, |
| 540 |
- .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE},
|
|
| 540 |
+ .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
|
|
| 541 |
+ AV_SAMPLE_FMT_NONE }, |
|
| 541 | 542 |
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
|
| 542 | 543 |
}; |
| ... | ... |
@@ -191,6 +191,7 @@ typedef struct {
|
| 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) |
| 290 | 290 |
init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8); |
| 291 | 291 |
|
| 292 | 292 |
config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata, |
| 293 |
- avctx->extradata_size); |
|
| 293 |
+ avctx->extradata_size * 8, 1); |
|
| 294 | 294 |
|
| 295 | 295 |
if (config_offset < 0) |
| 296 | 296 |
return -1; |
| ... | ... |
@@ -1415,15 +1416,14 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) |
| 1415 | 1415 |
|
| 1416 | 1416 |
/** Decode an ALS frame. |
| 1417 | 1417 |
*/ |
| 1418 |
-static int decode_frame(AVCodecContext *avctx, |
|
| 1419 |
- void *data, int *data_size, |
|
| 1418 |
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, |
|
| 1420 | 1419 |
AVPacket *avpkt) |
| 1421 | 1420 |
{
|
| 1422 | 1421 |
ALSDecContext *ctx = avctx->priv_data; |
| 1423 | 1422 |
ALSSpecificConfig *sconf = &ctx->sconf; |
| 1424 | 1423 |
const uint8_t *buffer = avpkt->data; |
| 1425 | 1424 |
int buffer_size = avpkt->size; |
| 1426 |
- int invalid_frame, size; |
|
| 1425 |
+ int invalid_frame, ret; |
|
| 1427 | 1426 |
unsigned int c, sample, ra_frame, bytes_read, shift; |
| 1428 | 1427 |
|
| 1429 | 1428 |
init_get_bits(&ctx->gb, buffer, buffer_size * 8); |
| ... | ... |
@@ -1448,21 +1448,17 @@ static int decode_frame(AVCodecContext *avctx, |
| 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, |
| 1480 | 1480 |
int swap = HAVE_BIGENDIAN != sconf->msb_first; |
| 1481 | 1481 |
|
| 1482 | 1482 |
if (ctx->avctx->bits_per_raw_sample == 24) {
|
| 1483 |
- int32_t *src = data; |
|
| 1483 |
+ int32_t *src = (int32_t *)ctx->frame.data[0]; |
|
| 1484 | 1484 |
|
| 1485 | 1485 |
for (sample = 0; |
| 1486 | 1486 |
sample < ctx->cur_frame_length * avctx->channels; |
| ... | ... |
@@ -1501,22 +1497,25 @@ static int decode_frame(AVCodecContext *avctx, |
| 1501 | 1501 |
|
| 1502 | 1502 |
if (swap) {
|
| 1503 | 1503 |
if (ctx->avctx->bits_per_raw_sample <= 16) {
|
| 1504 |
- int16_t *src = (int16_t*) data; |
|
| 1504 |
+ int16_t *src = (int16_t*) ctx->frame.data[0]; |
|
| 1505 | 1505 |
int16_t *dest = (int16_t*) ctx->crc_buffer; |
| 1506 | 1506 |
for (sample = 0; |
| 1507 | 1507 |
sample < ctx->cur_frame_length * avctx->channels; |
| 1508 | 1508 |
sample++) |
| 1509 | 1509 |
*dest++ = av_bswap16(src[sample]); |
| 1510 | 1510 |
} else {
|
| 1511 |
- ctx->dsp.bswap_buf((uint32_t*)ctx->crc_buffer, data, |
|
| 1511 |
+ ctx->dsp.bswap_buf((uint32_t*)ctx->crc_buffer, |
|
| 1512 |
+ (uint32_t *)ctx->frame.data[0], |
|
| 1512 | 1513 |
ctx->cur_frame_length * avctx->channels); |
| 1513 | 1514 |
} |
| 1514 | 1515 |
crc_source = ctx->crc_buffer; |
| 1515 | 1516 |
} else {
|
| 1516 |
- crc_source = data; |
|
| 1517 |
+ crc_source = ctx->frame.data[0]; |
|
| 1517 | 1518 |
} |
| 1518 | 1519 |
|
| 1519 |
- ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source, size); |
|
| 1520 |
+ ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source, |
|
| 1521 |
+ ctx->cur_frame_length * avctx->channels * |
|
| 1522 |
+ av_get_bytes_per_sample(avctx->sample_fmt)); |
|
| 1520 | 1523 |
} |
| 1521 | 1524 |
|
| 1522 | 1525 |
|
| ... | ... |
@@ -1527,6 +1526,9 @@ static int decode_frame(AVCodecContext *avctx, |
| 1527 | 1527 |
} |
| 1528 | 1528 |
} |
| 1529 | 1529 |
|
| 1530 |
+ *got_frame_ptr = 1; |
|
| 1531 |
+ *(AVFrame *)data = ctx->frame; |
|
| 1532 |
+ |
|
| 1530 | 1533 |
|
| 1531 | 1534 |
bytes_read = invalid_frame ? buffer_size : |
| 1532 | 1535 |
(get_bits_count(&ctx->gb) + 7) >> 3; |
| ... | ... |
@@ -1724,6 +1726,9 @@ static av_cold int decode_init(AVCodecContext *avctx) |
| 1724 | 1724 |
|
| 1725 | 1725 |
dsputil_init(&ctx->dsp, avctx); |
| 1726 | 1726 |
|
| 1727 |
+ avcodec_get_frame_defaults(&ctx->frame); |
|
| 1728 |
+ avctx->coded_frame = &ctx->frame; |
|
| 1729 |
+ |
|
| 1727 | 1730 |
return 0; |
| 1728 | 1731 |
} |
| 1729 | 1732 |
|
| ... | ... |
@@ -1747,7 +1752,7 @@ AVCodec ff_als_decoder = {
|
| 1747 | 1747 |
.close = decode_end, |
| 1748 | 1748 |
.decode = decode_frame, |
| 1749 | 1749 |
.flush = flush, |
| 1750 |
- .capabilities = CODEC_CAP_SUBFRAMES, |
|
| 1750 |
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, |
|
| 1751 | 1751 |
.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"),
|
| 1752 | 1752 |
}; |
| 1753 | 1753 |
|
| ... | ... |
@@ -95,6 +95,7 @@ |
| 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) |
| 167 | 167 |
for (i = 0; i < 4; i++) |
| 168 | 168 |
p->prediction_error[i] = MIN_ENERGY; |
| 169 | 169 |
|
| 170 |
+ avcodec_get_frame_defaults(&p->avframe); |
|
| 171 |
+ avctx->coded_frame = &p->avframe; |
|
| 172 |
+ |
|
| 170 | 173 |
return 0; |
| 171 | 174 |
} |
| 172 | 175 |
|
| ... | ... |
@@ -919,21 +923,29 @@ static void postfilter(AMRContext *p, float *lpc, float *buf_out) |
| 919 | 919 |
|
| 920 | 920 |
/// @} |
| 921 | 921 |
|
| 922 |
-static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
|
| 923 |
- AVPacket *avpkt) |
|
| 922 |
+static int amrnb_decode_frame(AVCodecContext *avctx, void *data, |
|
| 923 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 924 | 924 |
{
|
| 925 | 925 |
|
| 926 | 926 |
AMRContext *p = avctx->priv_data; // pointer to private data |
| 927 | 927 |
const uint8_t *buf = avpkt->data; |
| 928 | 928 |
int buf_size = avpkt->size; |
| 929 |
- float *buf_out = data; // pointer to the output data buffer |
|
| 930 |
- int i, subframe; |
|
| 929 |
+ float *buf_out; // pointer to the output data buffer |
|
| 930 |
+ int i, subframe, ret; |
|
| 931 | 931 |
float fixed_gain_factor; |
| 932 | 932 |
AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing
|
| 933 | 933 |
float spare_vector[AMR_SUBFRAME_SIZE]; // extra stack space to hold result from anti-sparseness processing |
| 934 | 934 |
float synth_fixed_gain; // the fixed gain that synthesis should use |
| 935 | 935 |
const float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use |
| 936 | 936 |
|
| 937 |
+ /* get output buffer */ |
|
| 938 |
+ p->avframe.nb_samples = AMR_BLOCK_SIZE; |
|
| 939 |
+ if ((ret = avctx->get_buffer(avctx, &p->avframe)) < 0) {
|
|
| 940 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 941 |
+ return ret; |
|
| 942 |
+ } |
|
| 943 |
+ buf_out = (float *)p->avframe.data[0]; |
|
| 944 |
+ |
|
| 937 | 945 |
p->cur_frame_mode = unpack_bitstream(p, buf, buf_size); |
| 938 | 946 |
if (p->cur_frame_mode == MODE_DTX) {
|
| 939 | 947 |
av_log_missing_feature(avctx, "dtx mode", 0); |
| ... | ... |
@@ -1029,8 +1041,8 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 1029 | 1029 |
ff_weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3], |
| 1030 | 1030 |
0.84, 0.16, LP_FILTER_ORDER); |
| 1031 | 1031 |
|
| 1032 |
- /* report how many samples we got */ |
|
| 1033 |
- *data_size = AMR_BLOCK_SIZE * sizeof(float); |
|
| 1032 |
+ *got_frame_ptr = 1; |
|
| 1033 |
+ *(AVFrame *)data = p->avframe; |
|
| 1034 | 1034 |
|
| 1035 | 1035 |
/* return the amount of bytes consumed if everything was OK */ |
| 1036 | 1036 |
return frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC |
| ... | ... |
@@ -1044,6 +1056,7 @@ AVCodec ff_amrnb_decoder = {
|
| 1044 | 1044 |
.priv_data_size = sizeof(AMRContext), |
| 1045 | 1045 |
.init = amrnb_decode_init, |
| 1046 | 1046 |
.decode = amrnb_decode_frame, |
| 1047 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1047 | 1048 |
.long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate NarrowBand"),
|
| 1048 | 1049 |
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
|
| 1049 | 1050 |
}; |
| ... | ... |
@@ -41,6 +41,7 @@ |
| 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) |
| 102 | 102 |
for (i = 0; i < 4; i++) |
| 103 | 103 |
ctx->prediction_error[i] = MIN_ENERGY; |
| 104 | 104 |
|
| 105 |
+ avcodec_get_frame_defaults(&ctx->avframe); |
|
| 106 |
+ avctx->coded_frame = &ctx->avframe; |
|
| 107 |
+ |
|
| 105 | 108 |
return 0; |
| 106 | 109 |
} |
| 107 | 110 |
|
| ... | ... |
@@ -1062,15 +1066,15 @@ static void update_sub_state(AMRWBContext *ctx) |
| 1062 | 1062 |
LP_ORDER_16k * sizeof(float)); |
| 1063 | 1063 |
} |
| 1064 | 1064 |
|
| 1065 |
-static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
|
| 1066 |
- AVPacket *avpkt) |
|
| 1065 |
+static int amrwb_decode_frame(AVCodecContext *avctx, void *data, |
|
| 1066 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1067 | 1067 |
{
|
| 1068 | 1068 |
AMRWBContext *ctx = avctx->priv_data; |
| 1069 | 1069 |
AMRWBFrame *cf = &ctx->frame; |
| 1070 | 1070 |
const uint8_t *buf = avpkt->data; |
| 1071 | 1071 |
int buf_size = avpkt->size; |
| 1072 | 1072 |
int expected_fr_size, header_size; |
| 1073 |
- float *buf_out = data; |
|
| 1073 |
+ float *buf_out; |
|
| 1074 | 1074 |
float spare_vector[AMRWB_SFR_SIZE]; // extra stack space to hold result from anti-sparseness processing |
| 1075 | 1075 |
float fixed_gain_factor; // fixed gain correction factor (gamma) |
| 1076 | 1076 |
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, |
| 1080 | 1080 |
float hb_exc[AMRWB_SFR_SIZE_16k]; // excitation for the high frequency band |
| 1081 | 1081 |
float hb_samples[AMRWB_SFR_SIZE_16k]; // filtered high-band samples from synthesis |
| 1082 | 1082 |
float hb_gain; |
| 1083 |
- int sub, i; |
|
| 1083 |
+ int sub, i, ret; |
|
| 1084 |
+ |
|
| 1085 |
+ /* get output buffer */ |
|
| 1086 |
+ ctx->avframe.nb_samples = 4 * AMRWB_SFR_SIZE_16k; |
|
| 1087 |
+ if ((ret = avctx->get_buffer(avctx, &ctx->avframe)) < 0) {
|
|
| 1088 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1089 |
+ return ret; |
|
| 1090 |
+ } |
|
| 1091 |
+ buf_out = (float *)ctx->avframe.data[0]; |
|
| 1084 | 1092 |
|
| 1085 | 1093 |
header_size = decode_mime_header(ctx, buf); |
| 1086 | 1094 |
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, |
| 1088 | 1088 |
if (buf_size < expected_fr_size) {
|
| 1089 | 1089 |
av_log(avctx, AV_LOG_ERROR, |
| 1090 | 1090 |
"Frame too small (%d bytes). Truncated file?\n", buf_size); |
| 1091 |
- *data_size = 0; |
|
| 1091 |
+ *got_frame_ptr = 0; |
|
| 1092 | 1092 |
return buf_size; |
| 1093 | 1093 |
} |
| 1094 | 1094 |
|
| ... | ... |
@@ -1219,8 +1231,8 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 1219 | 1219 |
memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0])); |
| 1220 | 1220 |
memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float)); |
| 1221 | 1221 |
|
| 1222 |
- /* report how many samples we got */ |
|
| 1223 |
- *data_size = 4 * AMRWB_SFR_SIZE_16k * sizeof(float); |
|
| 1222 |
+ *got_frame_ptr = 1; |
|
| 1223 |
+ *(AVFrame *)data = ctx->avframe; |
|
| 1224 | 1224 |
|
| 1225 | 1225 |
return expected_fr_size; |
| 1226 | 1226 |
} |
| ... | ... |
@@ -1232,6 +1244,7 @@ AVCodec ff_amrwb_decoder = {
|
| 1232 | 1232 |
.priv_data_size = sizeof(AMRWBContext), |
| 1233 | 1233 |
.init = amrwb_decode_init, |
| 1234 | 1234 |
.decode = amrwb_decode_frame, |
| 1235 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1235 | 1236 |
.long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"),
|
| 1236 | 1237 |
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
|
| 1237 | 1238 |
}; |
| ... | ... |
@@ -129,6 +129,7 @@ typedef struct APEPredictor {
|
| 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) |
| 215 | 215 |
dsputil_init(&s->dsp, avctx); |
| 216 | 216 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 217 | 217 |
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; |
| 218 |
+ |
|
| 219 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 220 |
+ avctx->coded_frame = &s->frame; |
|
| 221 |
+ |
|
| 218 | 222 |
return 0; |
| 219 | 223 |
filter_alloc_fail: |
| 220 | 224 |
ape_decode_close(avctx); |
| ... | ... |
@@ -805,16 +810,15 @@ static void ape_unpack_stereo(APEContext *ctx, int count) |
| 805 | 805 |
} |
| 806 | 806 |
} |
| 807 | 807 |
|
| 808 |
-static int ape_decode_frame(AVCodecContext *avctx, |
|
| 809 |
- void *data, int *data_size, |
|
| 810 |
- AVPacket *avpkt) |
|
| 808 |
+static int ape_decode_frame(AVCodecContext *avctx, void *data, |
|
| 809 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 811 | 810 |
{
|
| 812 | 811 |
const uint8_t *buf = avpkt->data; |
| 813 | 812 |
int buf_size = avpkt->size; |
| 814 | 813 |
APEContext *s = avctx->priv_data; |
| 815 |
- int16_t *samples = data; |
|
| 816 |
- int i; |
|
| 817 |
- int blockstodecode, out_size; |
|
| 814 |
+ int16_t *samples; |
|
| 815 |
+ int i, ret; |
|
| 816 |
+ int blockstodecode; |
|
| 818 | 817 |
int bytes_used = 0; |
| 819 | 818 |
|
| 820 | 819 |
/* 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, |
| 826 | 826 |
void *tmp_data; |
| 827 | 827 |
|
| 828 | 828 |
if (!buf_size) {
|
| 829 |
- *data_size = 0; |
|
| 829 |
+ *got_frame_ptr = 0; |
|
| 830 | 830 |
return 0; |
| 831 | 831 |
} |
| 832 | 832 |
if (buf_size < 8) {
|
| ... | ... |
@@ -874,18 +878,19 @@ static int ape_decode_frame(AVCodecContext *avctx, |
| 874 | 874 |
} |
| 875 | 875 |
|
| 876 | 876 |
if (!s->data) {
|
| 877 |
- *data_size = 0; |
|
| 877 |
+ *got_frame_ptr = 0; |
|
| 878 | 878 |
return buf_size; |
| 879 | 879 |
} |
| 880 | 880 |
|
| 881 | 881 |
blockstodecode = FFMIN(BLOCKS_PER_LOOP, s->samples); |
| 882 | 882 |
|
| 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); |
|
| 883 |
+ /* get output buffer */ |
|
| 884 |
+ s->frame.nb_samples = blockstodecode; |
|
| 885 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 886 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 887 |
+ return ret; |
|
| 888 | 888 |
} |
| 889 |
+ samples = (int16_t *)s->frame.data[0]; |
|
| 889 | 890 |
|
| 890 | 891 |
s->error=0; |
| 891 | 892 |
|
| ... | ... |
@@ -909,7 +914,9 @@ static int ape_decode_frame(AVCodecContext *avctx, |
| 909 | 909 |
|
| 910 | 910 |
s->samples -= blockstodecode; |
| 911 | 911 |
|
| 912 |
- *data_size = out_size; |
|
| 912 |
+ *got_frame_ptr = 1; |
|
| 913 |
+ *(AVFrame *)data = s->frame; |
|
| 914 |
+ |
|
| 913 | 915 |
return bytes_used; |
| 914 | 916 |
} |
| 915 | 917 |
|
| ... | ... |
@@ -927,7 +934,7 @@ AVCodec ff_ape_decoder = {
|
| 927 | 927 |
.init = ape_decode_init, |
| 928 | 928 |
.close = ape_decode_close, |
| 929 | 929 |
.decode = ape_decode_frame, |
| 930 |
- .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY, |
|
| 930 |
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1, |
|
| 931 | 931 |
.flush = ape_flush, |
| 932 | 932 |
.long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
|
| 933 | 933 |
}; |
| ... | ... |
@@ -19,55 +19,16 @@ |
| 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 |
| 75 | 75 |
T mul r7, r4, r5 |
| 76 | 76 |
T cmp r7, #0 |
| 77 | 77 |
rsb r6, r7, r5, lsl #3 |
| 78 |
- rsb ip, r7, r4, lsl #3 |
|
| 78 |
+ rsb r12, r7, r4, lsl #3 |
|
| 79 | 79 |
sub r4, r7, r4, lsl #3 |
| 80 | 80 |
sub r4, r4, r5, lsl #3 |
| 81 | 81 |
add r4, r4, #64 |
| ... | ... |
@@ -86,10 +47,10 @@ T cmp r7, #0 |
| 86 | 86 |
|
| 87 | 87 |
vdup.8 d0, r4 |
| 88 | 88 |
lsl r4, r2, #1 |
| 89 |
- vdup.8 d1, ip |
|
| 90 |
- vld1.64 {d4, d5}, [r1], r4
|
|
| 89 |
+ vdup.8 d1, r12 |
|
| 90 |
+ vld1.8 {d4, d5}, [r1], r4
|
|
| 91 | 91 |
vdup.8 d2, r6 |
| 92 |
- vld1.64 {d6, d7}, [r5], r4
|
|
| 92 |
+ vld1.8 {d6, d7}, [r5], r4
|
|
| 93 | 93 |
vdup.8 d3, r7 |
| 94 | 94 |
|
| 95 | 95 |
vext.8 d5, d4, d5, #1 |
| ... | ... |
@@ -98,7 +59,7 @@ T cmp r7, #0 |
| 98 | 98 |
1: pld [r5] |
| 99 | 99 |
vmull.u8 q8, d4, d0 |
| 100 | 100 |
vmlal.u8 q8, d5, d1 |
| 101 |
- vld1.64 {d4, d5}, [r1], r4
|
|
| 101 |
+ vld1.8 {d4, d5}, [r1], r4
|
|
| 102 | 102 |
vmlal.u8 q8, d6, d2 |
| 103 | 103 |
vext.8 d5, d4, d5, #1 |
| 104 | 104 |
vmlal.u8 q8, d7, d3 |
| ... | ... |
@@ -108,57 +69,57 @@ T cmp r7, #0 |
| 108 | 108 |
vmlal.u8 q9, d4, d2 |
| 109 | 109 |
vmlal.u8 q9, d5, d3 |
| 110 | 110 |
vrshrn.u16 d16, q8, #6 |
| 111 |
- vld1.64 {d6, d7}, [r5], r4
|
|
| 111 |
+ vld1.8 {d6, d7}, [r5], r4
|
|
| 112 | 112 |
pld [r1] |
| 113 | 113 |
vrshrn.u16 d17, q9, #6 |
| 114 |
-.ifc \type,avg |
|
| 115 |
- vld1.64 {d20}, [lr,:64], r2
|
|
| 116 |
- vld1.64 {d21}, [lr,:64], r2
|
|
| 114 |
+ .ifc \type,avg |
|
| 115 |
+ vld1.8 {d20}, [lr,:64], r2
|
|
| 116 |
+ vld1.8 {d21}, [lr,:64], r2
|
|
| 117 | 117 |
vrhadd.u8 q8, q8, q10 |
| 118 |
-.endif |
|
| 118 |
+ .endif |
|
| 119 | 119 |
vext.8 d7, d6, d7, #1 |
| 120 |
- vst1.64 {d16}, [r0,:64], r2
|
|
| 121 |
- vst1.64 {d17}, [r0,:64], r2
|
|
| 120 |
+ vst1.8 {d16}, [r0,:64], r2
|
|
| 121 |
+ vst1.8 {d17}, [r0,:64], r2
|
|
| 122 | 122 |
bgt 1b |
| 123 | 123 |
|
| 124 | 124 |
pop {r4-r7, pc}
|
| 125 | 125 |
|
| 126 | 126 |
2: tst r6, r6 |
| 127 |
- add ip, ip, r6 |
|
| 127 |
+ add r12, r12, r6 |
|
| 128 | 128 |
vdup.8 d0, r4 |
| 129 |
- vdup.8 d1, ip |
|
| 129 |
+ vdup.8 d1, r12 |
|
| 130 | 130 |
|
| 131 | 131 |
beq 4f |
| 132 | 132 |
|
| 133 | 133 |
add r5, r1, r2 |
| 134 | 134 |
lsl r4, r2, #1 |
| 135 |
- vld1.64 {d4}, [r1], r4
|
|
| 136 |
- vld1.64 {d6}, [r5], r4
|
|
| 135 |
+ vld1.8 {d4}, [r1], r4
|
|
| 136 |
+ vld1.8 {d6}, [r5], r4
|
|
| 137 | 137 |
|
| 138 | 138 |
3: pld [r5] |
| 139 | 139 |
vmull.u8 q8, d4, d0 |
| 140 | 140 |
vmlal.u8 q8, d6, d1 |
| 141 |
- vld1.64 {d4}, [r1], r4
|
|
| 141 |
+ vld1.8 {d4}, [r1], r4
|
|
| 142 | 142 |
vmull.u8 q9, d6, d0 |
| 143 | 143 |
vmlal.u8 q9, d4, d1 |
| 144 |
- vld1.64 {d6}, [r5], r4
|
|
| 144 |
+ vld1.8 {d6}, [r5], r4
|
|
| 145 | 145 |
vrshrn.u16 d16, q8, #6 |
| 146 | 146 |
vrshrn.u16 d17, q9, #6 |
| 147 |
-.ifc \type,avg |
|
| 148 |
- vld1.64 {d20}, [lr,:64], r2
|
|
| 149 |
- vld1.64 {d21}, [lr,:64], r2
|
|
| 147 |
+ .ifc \type,avg |
|
| 148 |
+ vld1.8 {d20}, [lr,:64], r2
|
|
| 149 |
+ vld1.8 {d21}, [lr,:64], r2
|
|
| 150 | 150 |
vrhadd.u8 q8, q8, q10 |
| 151 |
-.endif |
|
| 151 |
+ .endif |
|
| 152 | 152 |
subs r3, r3, #2 |
| 153 | 153 |
pld [r1] |
| 154 |
- vst1.64 {d16}, [r0,:64], r2
|
|
| 155 |
- vst1.64 {d17}, [r0,:64], r2
|
|
| 154 |
+ vst1.8 {d16}, [r0,:64], r2
|
|
| 155 |
+ vst1.8 {d17}, [r0,:64], r2
|
|
| 156 | 156 |
bgt 3b |
| 157 | 157 |
|
| 158 | 158 |
pop {r4-r7, pc}
|
| 159 | 159 |
|
| 160 |
-4: vld1.64 {d4, d5}, [r1], r2
|
|
| 161 |
- vld1.64 {d6, d7}, [r1], r2
|
|
| 160 |
+4: vld1.8 {d4, d5}, [r1], r2
|
|
| 161 |
+ vld1.8 {d6, d7}, [r1], r2
|
|
| 162 | 162 |
vext.8 d5, d4, d5, #1 |
| 163 | 163 |
vext.8 d7, d6, d7, #1 |
| 164 | 164 |
|
| ... | ... |
@@ -166,36 +127,36 @@ T cmp r7, #0 |
| 166 | 166 |
subs r3, r3, #2 |
| 167 | 167 |
vmull.u8 q8, d4, d0 |
| 168 | 168 |
vmlal.u8 q8, d5, d1 |
| 169 |
- vld1.64 {d4, d5}, [r1], r2
|
|
| 169 |
+ vld1.8 {d4, d5}, [r1], r2
|
|
| 170 | 170 |
vmull.u8 q9, d6, d0 |
| 171 | 171 |
vmlal.u8 q9, d7, d1 |
| 172 | 172 |
pld [r1] |
| 173 | 173 |
vext.8 d5, d4, d5, #1 |
| 174 | 174 |
vrshrn.u16 d16, q8, #6 |
| 175 | 175 |
vrshrn.u16 d17, q9, #6 |
| 176 |
-.ifc \type,avg |
|
| 177 |
- vld1.64 {d20}, [lr,:64], r2
|
|
| 178 |
- vld1.64 {d21}, [lr,:64], r2
|
|
| 176 |
+ .ifc \type,avg |
|
| 177 |
+ vld1.8 {d20}, [lr,:64], r2
|
|
| 178 |
+ vld1.8 {d21}, [lr,:64], r2
|
|
| 179 | 179 |
vrhadd.u8 q8, q8, q10 |
| 180 |
-.endif |
|
| 181 |
- vld1.64 {d6, d7}, [r1], r2
|
|
| 180 |
+ .endif |
|
| 181 |
+ vld1.8 {d6, d7}, [r1], r2
|
|
| 182 | 182 |
vext.8 d7, d6, d7, #1 |
| 183 |
- vst1.64 {d16}, [r0,:64], r2
|
|
| 184 |
- vst1.64 {d17}, [r0,:64], r2
|
|
| 183 |
+ vst1.8 {d16}, [r0,:64], r2
|
|
| 184 |
+ vst1.8 {d17}, [r0,:64], r2
|
|
| 185 | 185 |
bgt 5b |
| 186 | 186 |
|
| 187 | 187 |
pop {r4-r7, pc}
|
| 188 | 188 |
endfunc |
| 189 |
- .endm |
|
| 189 |
+.endm |
|
| 190 | 190 |
|
| 191 | 191 |
/* chroma_mc4(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */ |
| 192 |
- .macro h264_chroma_mc4 type |
|
| 192 |
+.macro h264_chroma_mc4 type |
|
| 193 | 193 |
function ff_\type\()_h264_chroma_mc4_neon, export=1 |
| 194 | 194 |
push {r4-r7, lr}
|
| 195 | 195 |
ldrd r4, [sp, #20] |
| 196 |
-.ifc \type,avg |
|
| 196 |
+ .ifc \type,avg |
|
| 197 | 197 |
mov lr, r0 |
| 198 |
-.endif |
|
| 198 |
+ .endif |
|
| 199 | 199 |
pld [r1] |
| 200 | 200 |
pld [r1, r2] |
| 201 | 201 |
|
| ... | ... |
@@ -203,7 +164,7 @@ A muls r7, r4, r5 |
| 203 | 203 |
T mul r7, r4, r5 |
| 204 | 204 |
T cmp r7, #0 |
| 205 | 205 |
rsb r6, r7, r5, lsl #3 |
| 206 |
- rsb ip, r7, r4, lsl #3 |
|
| 206 |
+ rsb r12, r7, r4, lsl #3 |
|
| 207 | 207 |
sub r4, r7, r4, lsl #3 |
| 208 | 208 |
sub r4, r4, r5, lsl #3 |
| 209 | 209 |
add r4, r4, #64 |
| ... | ... |
@@ -214,10 +175,10 @@ T cmp r7, #0 |
| 214 | 214 |
|
| 215 | 215 |
vdup.8 d0, r4 |
| 216 | 216 |
lsl r4, r2, #1 |
| 217 |
- vdup.8 d1, ip |
|
| 218 |
- vld1.64 {d4}, [r1], r4
|
|
| 217 |
+ vdup.8 d1, r12 |
|
| 218 |
+ vld1.8 {d4}, [r1], r4
|
|
| 219 | 219 |
vdup.8 d2, r6 |
| 220 |
- vld1.64 {d6}, [r5], r4
|
|
| 220 |
+ vld1.8 {d6}, [r5], r4
|
|
| 221 | 221 |
vdup.8 d3, r7 |
| 222 | 222 |
|
| 223 | 223 |
vext.8 d5, d4, d5, #1 |
| ... | ... |
@@ -231,22 +192,22 @@ T cmp r7, #0 |
| 231 | 231 |
1: pld [r5] |
| 232 | 232 |
vmull.u8 q8, d4, d0 |
| 233 | 233 |
vmlal.u8 q8, d6, d2 |
| 234 |
- vld1.64 {d4}, [r1], r4
|
|
| 234 |
+ vld1.8 {d4}, [r1], r4
|
|
| 235 | 235 |
vext.8 d5, d4, d5, #1 |
| 236 | 236 |
vtrn.32 d4, d5 |
| 237 | 237 |
vmull.u8 q9, d6, d0 |
| 238 | 238 |
vmlal.u8 q9, d4, d2 |
| 239 |
- vld1.64 {d6}, [r5], r4
|
|
| 239 |
+ vld1.8 {d6}, [r5], r4
|
|
| 240 | 240 |
vadd.i16 d16, d16, d17 |
| 241 | 241 |
vadd.i16 d17, d18, d19 |
| 242 | 242 |
vrshrn.u16 d16, q8, #6 |
| 243 | 243 |
subs r3, r3, #2 |
| 244 | 244 |
pld [r1] |
| 245 |
-.ifc \type,avg |
|
| 245 |
+ .ifc \type,avg |
|
| 246 | 246 |
vld1.32 {d20[0]}, [lr,:32], r2
|
| 247 | 247 |
vld1.32 {d20[1]}, [lr,:32], r2
|
| 248 | 248 |
vrhadd.u8 d16, d16, d20 |
| 249 |
-.endif |
|
| 249 |
+ .endif |
|
| 250 | 250 |
vext.8 d7, d6, d7, #1 |
| 251 | 251 |
vtrn.32 d6, d7 |
| 252 | 252 |
vst1.32 {d16[0]}, [r0,:32], r2
|
| ... | ... |
@@ -256,9 +217,9 @@ T cmp r7, #0 |
| 256 | 256 |
pop {r4-r7, pc}
|
| 257 | 257 |
|
| 258 | 258 |
2: tst r6, r6 |
| 259 |
- add ip, ip, r6 |
|
| 259 |
+ add r12, r12, r6 |
|
| 260 | 260 |
vdup.8 d0, r4 |
| 261 |
- vdup.8 d1, ip |
|
| 261 |
+ vdup.8 d1, r12 |
|
| 262 | 262 |
vtrn.32 d0, d1 |
| 263 | 263 |
|
| 264 | 264 |
beq 4f |
| ... | ... |
@@ -277,11 +238,11 @@ T cmp r7, #0 |
| 277 | 277 |
vadd.i16 d16, d16, d17 |
| 278 | 278 |
vadd.i16 d17, d18, d19 |
| 279 | 279 |
vrshrn.u16 d16, q8, #6 |
| 280 |
-.ifc \type,avg |
|
| 280 |
+ .ifc \type,avg |
|
| 281 | 281 |
vld1.32 {d20[0]}, [lr,:32], r2
|
| 282 | 282 |
vld1.32 {d20[1]}, [lr,:32], r2
|
| 283 | 283 |
vrhadd.u8 d16, d16, d20 |
| 284 |
-.endif |
|
| 284 |
+ .endif |
|
| 285 | 285 |
subs r3, r3, #2 |
| 286 | 286 |
pld [r1] |
| 287 | 287 |
vst1.32 {d16[0]}, [r0,:32], r2
|
| ... | ... |
@@ -290,8 +251,8 @@ T cmp r7, #0 |
| 290 | 290 |
|
| 291 | 291 |
pop {r4-r7, pc}
|
| 292 | 292 |
|
| 293 |
-4: vld1.64 {d4}, [r1], r2
|
|
| 294 |
- vld1.64 {d6}, [r1], r2
|
|
| 293 |
+4: vld1.8 {d4}, [r1], r2
|
|
| 294 |
+ vld1.8 {d6}, [r1], r2
|
|
| 295 | 295 |
vext.8 d5, d4, d5, #1 |
| 296 | 296 |
vext.8 d7, d6, d7, #1 |
| 297 | 297 |
vtrn.32 d4, d5 |
| ... | ... |
@@ -300,19 +261,19 @@ T cmp r7, #0 |
| 300 | 300 |
5: vmull.u8 q8, d4, d0 |
| 301 | 301 |
vmull.u8 q9, d6, d0 |
| 302 | 302 |
subs r3, r3, #2 |
| 303 |
- vld1.64 {d4}, [r1], r2
|
|
| 303 |
+ vld1.8 {d4}, [r1], r2
|
|
| 304 | 304 |
vext.8 d5, d4, d5, #1 |
| 305 | 305 |
vtrn.32 d4, d5 |
| 306 | 306 |
vadd.i16 d16, d16, d17 |
| 307 | 307 |
vadd.i16 d17, d18, d19 |
| 308 | 308 |
pld [r1] |
| 309 | 309 |
vrshrn.u16 d16, q8, #6 |
| 310 |
-.ifc \type,avg |
|
| 310 |
+ .ifc \type,avg |
|
| 311 | 311 |
vld1.32 {d20[0]}, [lr,:32], r2
|
| 312 | 312 |
vld1.32 {d20[1]}, [lr,:32], r2
|
| 313 | 313 |
vrhadd.u8 d16, d16, d20 |
| 314 |
-.endif |
|
| 315 |
- vld1.64 {d6}, [r1], r2
|
|
| 314 |
+ .endif |
|
| 315 |
+ vld1.8 {d6}, [r1], r2
|
|
| 316 | 316 |
vext.8 d7, d6, d7, #1 |
| 317 | 317 |
vtrn.32 d6, d7 |
| 318 | 318 |
pld [r1] |
| ... | ... |
@@ -322,9 +283,9 @@ T cmp r7, #0 |
| 322 | 322 |
|
| 323 | 323 |
pop {r4-r7, pc}
|
| 324 | 324 |
endfunc |
| 325 |
- .endm |
|
| 325 |
+.endm |
|
| 326 | 326 |
|
| 327 |
- .macro h264_chroma_mc2 type |
|
| 327 |
+.macro h264_chroma_mc2 type |
|
| 328 | 328 |
function ff_\type\()_h264_chroma_mc2_neon, export=1 |
| 329 | 329 |
push {r4-r6, lr}
|
| 330 | 330 |
ldr r4, [sp, #16] |
| ... | ... |
@@ -354,29 +315,29 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 |
| 354 | 354 |
vtrn.16 q2, q3 |
| 355 | 355 |
vmull.u8 q8, d4, d0 |
| 356 | 356 |
vmlal.u8 q8, d5, d1 |
| 357 |
-.ifc \type,avg |
|
| 357 |
+ .ifc \type,avg |
|
| 358 | 358 |
vld1.16 {d18[0]}, [r0,:16], r2
|
| 359 | 359 |
vld1.16 {d18[1]}, [r0,:16]
|
| 360 | 360 |
sub r0, r0, r2 |
| 361 |
-.endif |
|
| 361 |
+ .endif |
|
| 362 | 362 |
vtrn.32 d16, d17 |
| 363 | 363 |
vadd.i16 d16, d16, d17 |
| 364 | 364 |
vrshrn.u16 d16, q8, #6 |
| 365 |
-.ifc \type,avg |
|
| 365 |
+ .ifc \type,avg |
|
| 366 | 366 |
vrhadd.u8 d16, d16, d18 |
| 367 |
-.endif |
|
| 367 |
+ .endif |
|
| 368 | 368 |
vst1.16 {d16[0]}, [r0,:16], r2
|
| 369 | 369 |
vst1.16 {d16[1]}, [r0,:16], r2
|
| 370 | 370 |
subs r3, r3, #2 |
| 371 | 371 |
bgt 1b |
| 372 | 372 |
pop {r4-r6, pc}
|
| 373 | 373 |
2: |
| 374 |
-.ifc \type,put |
|
| 374 |
+ .ifc \type,put |
|
| 375 | 375 |
ldrh_post r5, r1, r2 |
| 376 | 376 |
strh_post r5, r0, r2 |
| 377 | 377 |
ldrh_post r6, r1, r2 |
| 378 | 378 |
strh_post r6, r0, r2 |
| 379 |
-.else |
|
| 379 |
+ .else |
|
| 380 | 380 |
vld1.16 {d16[0]}, [r1], r2
|
| 381 | 381 |
vld1.16 {d16[1]}, [r1], r2
|
| 382 | 382 |
vld1.16 {d18[0]}, [r0,:16], r2
|
| ... | ... |
@@ -385,7 +346,7 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 |
| 385 | 385 |
vrhadd.u8 d16, d16, d18 |
| 386 | 386 |
vst1.16 {d16[0]}, [r0,:16], r2
|
| 387 | 387 |
vst1.16 {d16[1]}, [r0,:16], r2
|
| 388 |
-.endif |
|
| 388 |
+ .endif |
|
| 389 | 389 |
subs r3, r3, #2 |
| 390 | 390 |
bgt 2b |
| 391 | 391 |
pop {r4-r6, pc}
|
| ... | ... |
@@ -401,22 +362,22 @@ endfunc |
| 401 | 401 |
|
| 402 | 402 |
/* H.264 loop filter */ |
| 403 | 403 |
|
| 404 |
- .macro h264_loop_filter_start |
|
| 405 |
- ldr ip, [sp] |
|
| 404 |
+.macro h264_loop_filter_start |
|
| 405 |
+ ldr r12, [sp] |
|
| 406 | 406 |
tst r2, r2 |
| 407 |
- ldr ip, [ip] |
|
| 407 |
+ ldr r12, [r12] |
|
| 408 | 408 |
it ne |
| 409 | 409 |
tstne r3, r3 |
| 410 |
- vmov.32 d24[0], ip |
|
| 411 |
- and ip, ip, ip, lsl #16 |
|
| 410 |
+ vmov.32 d24[0], r12 |
|
| 411 |
+ and r12, r12, r12, lsl #16 |
|
| 412 | 412 |
it eq |
| 413 | 413 |
bxeq lr |
| 414 |
- ands ip, ip, ip, lsl #8 |
|
| 414 |
+ ands r12, r12, r12, lsl #8 |
|
| 415 | 415 |
it lt |
| 416 | 416 |
bxlt lr |
| 417 |
- .endm |
|
| 417 |
+.endm |
|
| 418 | 418 |
|
| 419 |
- .macro h264_loop_filter_luma |
|
| 419 |
+.macro h264_loop_filter_luma |
|
| 420 | 420 |
vdup.8 q11, r2 @ alpha |
| 421 | 421 |
vmovl.u8 q12, d24 |
| 422 | 422 |
vabd.u8 q6, q8, q0 @ abs(p0 - q0) |
| ... | ... |
@@ -482,29 +443,29 @@ endfunc |
| 482 | 482 |
vqmovun.s16 d17, q6 |
| 483 | 483 |
vqmovun.s16 d0, q11 |
| 484 | 484 |
vqmovun.s16 d1, q12 |
| 485 |
- .endm |
|
| 485 |
+.endm |
|
| 486 | 486 |
|
| 487 | 487 |
function ff_h264_v_loop_filter_luma_neon, export=1 |
| 488 | 488 |
h264_loop_filter_start |
| 489 | 489 |
|
| 490 |
- vld1.64 {d0, d1}, [r0,:128], r1
|
|
| 491 |
- vld1.64 {d2, d3}, [r0,:128], r1
|
|
| 492 |
- vld1.64 {d4, d5}, [r0,:128], r1
|
|
| 490 |
+ vld1.8 {d0, d1}, [r0,:128], r1
|
|
| 491 |
+ vld1.8 {d2, d3}, [r0,:128], r1
|
|
| 492 |
+ vld1.8 {d4, d5}, [r0,:128], r1
|
|
| 493 | 493 |
sub r0, r0, r1, lsl #2 |
| 494 | 494 |
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
|
|
| 495 |
+ vld1.8 {d20,d21}, [r0,:128], r1
|
|
| 496 |
+ vld1.8 {d18,d19}, [r0,:128], r1
|
|
| 497 |
+ vld1.8 {d16,d17}, [r0,:128], r1
|
|
| 498 | 498 |
|
| 499 | 499 |
vpush {d8-d15}
|
| 500 | 500 |
|
| 501 | 501 |
h264_loop_filter_luma |
| 502 | 502 |
|
| 503 | 503 |
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]
|
|
| 504 |
+ vst1.8 {d8, d9}, [r0,:128], r1
|
|
| 505 |
+ vst1.8 {d16,d17}, [r0,:128], r1
|
|
| 506 |
+ vst1.8 {d0, d1}, [r0,:128], r1
|
|
| 507 |
+ vst1.8 {d10,d11}, [r0,:128]
|
|
| 508 | 508 |
|
| 509 | 509 |
vpop {d8-d15}
|
| 510 | 510 |
bx lr |
| ... | ... |
@@ -514,22 +475,22 @@ function ff_h264_h_loop_filter_luma_neon, export=1 |
| 514 | 514 |
h264_loop_filter_start |
| 515 | 515 |
|
| 516 | 516 |
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
|
|
| 517 |
+ vld1.8 {d6}, [r0], r1
|
|
| 518 |
+ vld1.8 {d20}, [r0], r1
|
|
| 519 |
+ vld1.8 {d18}, [r0], r1
|
|
| 520 |
+ vld1.8 {d16}, [r0], r1
|
|
| 521 |
+ vld1.8 {d0}, [r0], r1
|
|
| 522 |
+ vld1.8 {d2}, [r0], r1
|
|
| 523 |
+ vld1.8 {d4}, [r0], r1
|
|
| 524 |
+ vld1.8 {d26}, [r0], r1
|
|
| 525 |
+ vld1.8 {d7}, [r0], r1
|
|
| 526 |
+ vld1.8 {d21}, [r0], r1
|
|
| 527 |
+ vld1.8 {d19}, [r0], r1
|
|
| 528 |
+ vld1.8 {d17}, [r0], r1
|
|
| 529 |
+ vld1.8 {d1}, [r0], r1
|
|
| 530 |
+ vld1.8 {d3}, [r0], r1
|
|
| 531 |
+ vld1.8 {d5}, [r0], r1
|
|
| 532 |
+ vld1.8 {d27}, [r0], r1
|
|
| 533 | 533 |
|
| 534 | 534 |
transpose_8x8 q3, q10, q9, q8, q0, q1, q2, q13 |
| 535 | 535 |
|
| ... | ... |
@@ -562,7 +523,7 @@ function ff_h264_h_loop_filter_luma_neon, export=1 |
| 562 | 562 |
bx lr |
| 563 | 563 |
endfunc |
| 564 | 564 |
|
| 565 |
- .macro h264_loop_filter_chroma |
|
| 565 |
+.macro h264_loop_filter_chroma |
|
| 566 | 566 |
vdup.8 d22, r2 @ alpha |
| 567 | 567 |
vmovl.u8 q12, d24 |
| 568 | 568 |
vabd.u8 d26, d16, d0 @ abs(p0 - q0) |
| ... | ... |
@@ -591,22 +552,22 @@ endfunc |
| 591 | 591 |
vsubw.s8 q11, q11, d4 |
| 592 | 592 |
vqmovun.s16 d16, q14 |
| 593 | 593 |
vqmovun.s16 d0, q11 |
| 594 |
- .endm |
|
| 594 |
+.endm |
|
| 595 | 595 |
|
| 596 | 596 |
function ff_h264_v_loop_filter_chroma_neon, export=1 |
| 597 | 597 |
h264_loop_filter_start |
| 598 | 598 |
|
| 599 | 599 |
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]
|
|
| 600 |
+ vld1.8 {d18}, [r0,:64], r1
|
|
| 601 |
+ vld1.8 {d16}, [r0,:64], r1
|
|
| 602 |
+ vld1.8 {d0}, [r0,:64], r1
|
|
| 603 |
+ vld1.8 {d2}, [r0,:64]
|
|
| 604 | 604 |
|
| 605 | 605 |
h264_loop_filter_chroma |
| 606 | 606 |
|
| 607 | 607 |
sub r0, r0, r1, lsl #1 |
| 608 |
- vst1.64 {d16}, [r0,:64], r1
|
|
| 609 |
- vst1.64 {d0}, [r0,:64], r1
|
|
| 608 |
+ vst1.8 {d16}, [r0,:64], r1
|
|
| 609 |
+ vst1.8 {d0}, [r0,:64], r1
|
|
| 610 | 610 |
|
| 611 | 611 |
bx lr |
| 612 | 612 |
endfunc |
| ... | ... |
@@ -651,20 +612,20 @@ endfunc |
| 651 | 651 |
|
| 652 | 652 |
/* H.264 qpel MC */ |
| 653 | 653 |
|
| 654 |
- .macro lowpass_const r |
|
| 654 |
+.macro lowpass_const r |
|
| 655 | 655 |
movw \r, #5 |
| 656 | 656 |
movt \r, #20 |
| 657 | 657 |
vmov.32 d6[0], \r |
| 658 |
- .endm |
|
| 658 |
+.endm |
|
| 659 | 659 |
|
| 660 |
- .macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1 |
|
| 661 |
-.if \narrow |
|
| 660 |
+.macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1 |
|
| 661 |
+ .if \narrow |
|
| 662 | 662 |
t0 .req q0 |
| 663 | 663 |
t1 .req q8 |
| 664 |
-.else |
|
| 664 |
+ .else |
|
| 665 | 665 |
t0 .req \d0 |
| 666 | 666 |
t1 .req \d1 |
| 667 |
-.endif |
|
| 667 |
+ .endif |
|
| 668 | 668 |
vext.8 d2, \r0, \r1, #2 |
| 669 | 669 |
vext.8 d3, \r0, \r1, #3 |
| 670 | 670 |
vaddl.u8 q1, d2, d3 |
| ... | ... |
@@ -685,20 +646,20 @@ endfunc |
| 685 | 685 |
vaddl.u8 t1, \r2, d31 |
| 686 | 686 |
vmla.i16 t1, q9, d6[1] |
| 687 | 687 |
vmls.i16 t1, q10, d6[0] |
| 688 |
-.if \narrow |
|
| 688 |
+ .if \narrow |
|
| 689 | 689 |
vqrshrun.s16 \d0, t0, #5 |
| 690 | 690 |
vqrshrun.s16 \d1, t1, #5 |
| 691 |
-.endif |
|
| 691 |
+ .endif |
|
| 692 | 692 |
.unreq t0 |
| 693 | 693 |
.unreq t1 |
| 694 |
- .endm |
|
| 694 |
+.endm |
|
| 695 | 695 |
|
| 696 |
- .macro lowpass_8_1 r0, r1, d0, narrow=1 |
|
| 697 |
-.if \narrow |
|
| 696 |
+.macro lowpass_8_1 r0, r1, d0, narrow=1 |
|
| 697 |
+ .if \narrow |
|
| 698 | 698 |
t0 .req q0 |
| 699 |
-.else |
|
| 699 |
+ .else |
|
| 700 | 700 |
t0 .req \d0 |
| 701 |
-.endif |
|
| 701 |
+ .endif |
|
| 702 | 702 |
vext.8 d2, \r0, \r1, #2 |
| 703 | 703 |
vext.8 d3, \r0, \r1, #3 |
| 704 | 704 |
vaddl.u8 q1, d2, d3 |
| ... | ... |
@@ -709,13 +670,13 @@ endfunc |
| 709 | 709 |
vaddl.u8 t0, \r0, d30 |
| 710 | 710 |
vmla.i16 t0, q1, d6[1] |
| 711 | 711 |
vmls.i16 t0, q2, d6[0] |
| 712 |
-.if \narrow |
|
| 712 |
+ .if \narrow |
|
| 713 | 713 |
vqrshrun.s16 \d0, t0, #5 |
| 714 |
-.endif |
|
| 714 |
+ .endif |
|
| 715 | 715 |
.unreq t0 |
| 716 |
- .endm |
|
| 716 |
+.endm |
|
| 717 | 717 |
|
| 718 |
- .macro lowpass_8.16 r0, r1, l0, h0, l1, h1, d |
|
| 718 |
+.macro lowpass_8.16 r0, r1, l0, h0, l1, h1, d |
|
| 719 | 719 |
vext.16 q1, \r0, \r1, #2 |
| 720 | 720 |
vext.16 q0, \r0, \r1, #3 |
| 721 | 721 |
vaddl.s16 q9, d2, d0 |
| ... | ... |
@@ -750,59 +711,59 @@ endfunc |
| 750 | 750 |
vrshrn.s32 d19, q1, #10 |
| 751 | 751 |
|
| 752 | 752 |
vqmovun.s16 \d, q9 |
| 753 |
- .endm |
|
| 753 |
+.endm |
|
| 754 | 754 |
|
| 755 | 755 |
function put_h264_qpel16_h_lowpass_neon_packed |
| 756 | 756 |
mov r4, lr |
| 757 |
- mov ip, #16 |
|
| 757 |
+ mov r12, #16 |
|
| 758 | 758 |
mov r3, #8 |
| 759 | 759 |
bl put_h264_qpel8_h_lowpass_neon |
| 760 | 760 |
sub r1, r1, r2, lsl #4 |
| 761 | 761 |
add r1, r1, #8 |
| 762 |
- mov ip, #16 |
|
| 762 |
+ mov r12, #16 |
|
| 763 | 763 |
mov lr, r4 |
| 764 | 764 |
b put_h264_qpel8_h_lowpass_neon |
| 765 | 765 |
endfunc |
| 766 | 766 |
|
| 767 |
- .macro h264_qpel_h_lowpass type |
|
| 767 |
+.macro h264_qpel_h_lowpass type |
|
| 768 | 768 |
function \type\()_h264_qpel16_h_lowpass_neon |
| 769 | 769 |
push {lr}
|
| 770 |
- mov ip, #16 |
|
| 770 |
+ mov r12, #16 |
|
| 771 | 771 |
bl \type\()_h264_qpel8_h_lowpass_neon |
| 772 | 772 |
sub r0, r0, r3, lsl #4 |
| 773 | 773 |
sub r1, r1, r2, lsl #4 |
| 774 | 774 |
add r0, r0, #8 |
| 775 | 775 |
add r1, r1, #8 |
| 776 |
- mov ip, #16 |
|
| 776 |
+ mov r12, #16 |
|
| 777 | 777 |
pop {lr}
|
| 778 | 778 |
endfunc |
| 779 | 779 |
|
| 780 | 780 |
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 |
|
| 781 |
+1: vld1.8 {d0, d1}, [r1], r2
|
|
| 782 |
+ vld1.8 {d16,d17}, [r1], r2
|
|
| 783 |
+ subs r12, r12, #2 |
|
| 784 | 784 |
lowpass_8 d0, d1, d16, d17, d0, d16 |
| 785 |
-.ifc \type,avg |
|
| 785 |
+ .ifc \type,avg |
|
| 786 | 786 |
vld1.8 {d2}, [r0,:64], r3
|
| 787 | 787 |
vrhadd.u8 d0, d0, d2 |
| 788 | 788 |
vld1.8 {d3}, [r0,:64]
|
| 789 | 789 |
vrhadd.u8 d16, d16, d3 |
| 790 | 790 |
sub r0, r0, r3 |
| 791 |
-.endif |
|
| 792 |
- vst1.64 {d0}, [r0,:64], r3
|
|
| 793 |
- vst1.64 {d16}, [r0,:64], r3
|
|
| 791 |
+ .endif |
|
| 792 |
+ vst1.8 {d0}, [r0,:64], r3
|
|
| 793 |
+ vst1.8 {d16}, [r0,:64], r3
|
|
| 794 | 794 |
bne 1b |
| 795 | 795 |
bx lr |
| 796 | 796 |
endfunc |
| 797 |
- .endm |
|
| 797 |
+.endm |
|
| 798 | 798 |
|
| 799 | 799 |
h264_qpel_h_lowpass put |
| 800 | 800 |
h264_qpel_h_lowpass avg |
| 801 | 801 |
|
| 802 |
- .macro h264_qpel_h_lowpass_l2 type |
|
| 802 |
+.macro h264_qpel_h_lowpass_l2 type |
|
| 803 | 803 |
function \type\()_h264_qpel16_h_lowpass_l2_neon |
| 804 | 804 |
push {lr}
|
| 805 |
- mov ip, #16 |
|
| 805 |
+ mov r12, #16 |
|
| 806 | 806 |
bl \type\()_h264_qpel8_h_lowpass_l2_neon |
| 807 | 807 |
sub r0, r0, r2, lsl #4 |
| 808 | 808 |
sub r1, r1, r2, lsl #4 |
| ... | ... |
@@ -810,31 +771,31 @@ function \type\()_h264_qpel16_h_lowpass_l2_neon |
| 810 | 810 |
add r0, r0, #8 |
| 811 | 811 |
add r1, r1, #8 |
| 812 | 812 |
add r3, r3, #8 |
| 813 |
- mov ip, #16 |
|
| 813 |
+ mov r12, #16 |
|
| 814 | 814 |
pop {lr}
|
| 815 | 815 |
endfunc |
| 816 | 816 |
|
| 817 | 817 |
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 |
|
| 818 |
+1: vld1.8 {d0, d1}, [r1], r2
|
|
| 819 |
+ vld1.8 {d16,d17}, [r1], r2
|
|
| 820 |
+ vld1.8 {d28}, [r3], r2
|
|
| 821 |
+ vld1.8 {d29}, [r3], r2
|
|
| 822 |
+ subs r12, r12, #2 |
|
| 823 | 823 |
lowpass_8 d0, d1, d16, d17, d0, d1 |
| 824 | 824 |
vrhadd.u8 q0, q0, q14 |
| 825 |
-.ifc \type,avg |
|
| 825 |
+ .ifc \type,avg |
|
| 826 | 826 |
vld1.8 {d2}, [r0,:64], r2
|
| 827 | 827 |
vrhadd.u8 d0, d0, d2 |
| 828 | 828 |
vld1.8 {d3}, [r0,:64]
|
| 829 | 829 |
vrhadd.u8 d1, d1, d3 |
| 830 | 830 |
sub r0, r0, r2 |
| 831 |
-.endif |
|
| 832 |
- vst1.64 {d0}, [r0,:64], r2
|
|
| 833 |
- vst1.64 {d1}, [r0,:64], r2
|
|
| 831 |
+ .endif |
|
| 832 |
+ vst1.8 {d0}, [r0,:64], r2
|
|
| 833 |
+ vst1.8 {d1}, [r0,:64], r2
|
|
| 834 | 834 |
bne 1b |
| 835 | 835 |
bx lr |
| 836 | 836 |
endfunc |
| 837 |
- .endm |
|
| 837 |
+.endm |
|
| 838 | 838 |
|
| 839 | 839 |
h264_qpel_h_lowpass_l2 put |
| 840 | 840 |
h264_qpel_h_lowpass_l2 avg |
| ... | ... |
@@ -854,7 +815,7 @@ function put_h264_qpel16_v_lowpass_neon_packed |
| 854 | 854 |
b put_h264_qpel8_v_lowpass_neon |
| 855 | 855 |
endfunc |
| 856 | 856 |
|
| 857 |
- .macro h264_qpel_v_lowpass type |
|
| 857 |
+.macro h264_qpel_v_lowpass type |
|
| 858 | 858 |
function \type\()_h264_qpel16_v_lowpass_neon |
| 859 | 859 |
mov r4, lr |
| 860 | 860 |
bl \type\()_h264_qpel8_v_lowpass_neon |
| ... | ... |
@@ -871,19 +832,19 @@ function \type\()_h264_qpel16_v_lowpass_neon |
| 871 | 871 |
endfunc |
| 872 | 872 |
|
| 873 | 873 |
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]
|
|
| 874 |
+ vld1.8 {d8}, [r1], r3
|
|
| 875 |
+ vld1.8 {d10}, [r1], r3
|
|
| 876 |
+ vld1.8 {d12}, [r1], r3
|
|
| 877 |
+ vld1.8 {d14}, [r1], r3
|
|
| 878 |
+ vld1.8 {d22}, [r1], r3
|
|
| 879 |
+ vld1.8 {d24}, [r1], r3
|
|
| 880 |
+ vld1.8 {d26}, [r1], r3
|
|
| 881 |
+ vld1.8 {d28}, [r1], r3
|
|
| 882 |
+ vld1.8 {d9}, [r1], r3
|
|
| 883 |
+ vld1.8 {d11}, [r1], r3
|
|
| 884 |
+ vld1.8 {d13}, [r1], r3
|
|
| 885 |
+ vld1.8 {d15}, [r1], r3
|
|
| 886 |
+ vld1.8 {d23}, [r1]
|
|
| 887 | 887 |
|
| 888 | 888 |
transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14 |
| 889 | 889 |
lowpass_8 d8, d9, d10, d11, d8, d10 |
| ... | ... |
@@ -892,7 +853,7 @@ function \type\()_h264_qpel8_v_lowpass_neon |
| 892 | 892 |
lowpass_8 d26, d27, d28, d29, d26, d28 |
| 893 | 893 |
transpose_8x8 d8, d10, d12, d14, d22, d24, d26, d28 |
| 894 | 894 |
|
| 895 |
-.ifc \type,avg |
|
| 895 |
+ .ifc \type,avg |
|
| 896 | 896 |
vld1.8 {d9}, [r0,:64], r2
|
| 897 | 897 |
vrhadd.u8 d8, d8, d9 |
| 898 | 898 |
vld1.8 {d11}, [r0,:64], r2
|
| ... | ... |
@@ -910,34 +871,34 @@ function \type\()_h264_qpel8_v_lowpass_neon |
| 910 | 910 |
vld1.8 {d29}, [r0,:64], r2
|
| 911 | 911 |
vrhadd.u8 d28, d28, d29 |
| 912 | 912 |
sub r0, r0, r2, lsl #3 |
| 913 |
-.endif |
|
| 913 |
+ .endif |
|
| 914 | 914 |
|
| 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
|
|
| 915 |
+ vst1.8 {d8}, [r0,:64], r2
|
|
| 916 |
+ vst1.8 {d10}, [r0,:64], r2
|
|
| 917 |
+ vst1.8 {d12}, [r0,:64], r2
|
|
| 918 |
+ vst1.8 {d14}, [r0,:64], r2
|
|
| 919 |
+ vst1.8 {d22}, [r0,:64], r2
|
|
| 920 |
+ vst1.8 {d24}, [r0,:64], r2
|
|
| 921 |
+ vst1.8 {d26}, [r0,:64], r2
|
|
| 922 |
+ vst1.8 {d28}, [r0,:64], r2
|
|
| 923 | 923 |
|
| 924 | 924 |
bx lr |
| 925 | 925 |
endfunc |
| 926 |
- .endm |
|
| 926 |
+.endm |
|
| 927 | 927 |
|
| 928 | 928 |
h264_qpel_v_lowpass put |
| 929 | 929 |
h264_qpel_v_lowpass avg |
| 930 | 930 |
|
| 931 |
- .macro h264_qpel_v_lowpass_l2 type |
|
| 931 |
+.macro h264_qpel_v_lowpass_l2 type |
|
| 932 | 932 |
function \type\()_h264_qpel16_v_lowpass_l2_neon |
| 933 | 933 |
mov r4, lr |
| 934 | 934 |
bl \type\()_h264_qpel8_v_lowpass_l2_neon |
| 935 | 935 |
sub r1, r1, r3, lsl #2 |
| 936 | 936 |
bl \type\()_h264_qpel8_v_lowpass_l2_neon |
| 937 | 937 |
sub r0, r0, r3, lsl #4 |
| 938 |
- sub ip, ip, r2, lsl #4 |
|
| 938 |
+ sub r12, r12, r2, lsl #4 |
|
| 939 | 939 |
add r0, r0, #8 |
| 940 |
- add ip, ip, #8 |
|
| 940 |
+ add r12, r12, #8 |
|
| 941 | 941 |
sub r1, r1, r3, lsl #4 |
| 942 | 942 |
sub r1, r1, r3, lsl #2 |
| 943 | 943 |
add r1, r1, #8 |
| ... | ... |
@@ -947,19 +908,19 @@ function \type\()_h264_qpel16_v_lowpass_l2_neon |
| 947 | 947 |
endfunc |
| 948 | 948 |
|
| 949 | 949 |
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]
|
|
| 950 |
+ vld1.8 {d8}, [r1], r3
|
|
| 951 |
+ vld1.8 {d10}, [r1], r3
|
|
| 952 |
+ vld1.8 {d12}, [r1], r3
|
|
| 953 |
+ vld1.8 {d14}, [r1], r3
|
|
| 954 |
+ vld1.8 {d22}, [r1], r3
|
|
| 955 |
+ vld1.8 {d24}, [r1], r3
|
|
| 956 |
+ vld1.8 {d26}, [r1], r3
|
|
| 957 |
+ vld1.8 {d28}, [r1], r3
|
|
| 958 |
+ vld1.8 {d9}, [r1], r3
|
|
| 959 |
+ vld1.8 {d11}, [r1], r3
|
|
| 960 |
+ vld1.8 {d13}, [r1], r3
|
|
| 961 |
+ vld1.8 {d15}, [r1], r3
|
|
| 962 |
+ vld1.8 {d23}, [r1]
|
|
| 963 | 963 |
|
| 964 | 964 |
transpose_8x8 q4, q5, q6, q7, q11, q12, q13, q14 |
| 965 | 965 |
lowpass_8 d8, d9, d10, d11, d8, d9 |
| ... | ... |
@@ -968,20 +929,20 @@ function \type\()_h264_qpel8_v_lowpass_l2_neon |
| 968 | 968 |
lowpass_8 d26, d27, d28, d29, d26, d27 |
| 969 | 969 |
transpose_8x8 d8, d9, d12, d13, d22, d23, d26, d27 |
| 970 | 970 |
|
| 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
|
|
| 971 |
+ vld1.8 {d0}, [r12], r2
|
|
| 972 |
+ vld1.8 {d1}, [r12], r2
|
|
| 973 |
+ vld1.8 {d2}, [r12], r2
|
|
| 974 |
+ vld1.8 {d3}, [r12], r2
|
|
| 975 |
+ vld1.8 {d4}, [r12], r2
|
|
| 976 | 976 |
vrhadd.u8 q0, q0, q4 |
| 977 |
- vld1.64 {d5}, [ip], r2
|
|
| 977 |
+ vld1.8 {d5}, [r12], r2
|
|
| 978 | 978 |
vrhadd.u8 q1, q1, q6 |
| 979 |
- vld1.64 {d10}, [ip], r2
|
|
| 979 |
+ vld1.8 {d10}, [r12], r2
|
|
| 980 | 980 |
vrhadd.u8 q2, q2, q11 |
| 981 |
- vld1.64 {d11}, [ip], r2
|
|
| 981 |
+ vld1.8 {d11}, [r12], r2
|
|
| 982 | 982 |
vrhadd.u8 q5, q5, q13 |
| 983 | 983 |
|
| 984 |
-.ifc \type,avg |
|
| 984 |
+ .ifc \type,avg |
|
| 985 | 985 |
vld1.8 {d16}, [r0,:64], r3
|
| 986 | 986 |
vrhadd.u8 d0, d0, d16 |
| 987 | 987 |
vld1.8 {d17}, [r0,:64], r3
|
| ... | ... |
@@ -999,51 +960,51 @@ function \type\()_h264_qpel8_v_lowpass_l2_neon |
| 999 | 999 |
vld1.8 {d17}, [r0,:64], r3
|
| 1000 | 1000 |
vrhadd.u8 d11, d11, d17 |
| 1001 | 1001 |
sub r0, r0, r3, lsl #3 |
| 1002 |
-.endif |
|
| 1002 |
+ .endif |
|
| 1003 | 1003 |
|
| 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
|
|
| 1004 |
+ vst1.8 {d0}, [r0,:64], r3
|
|
| 1005 |
+ vst1.8 {d1}, [r0,:64], r3
|
|
| 1006 |
+ vst1.8 {d2}, [r0,:64], r3
|
|
| 1007 |
+ vst1.8 {d3}, [r0,:64], r3
|
|
| 1008 |
+ vst1.8 {d4}, [r0,:64], r3
|
|
| 1009 |
+ vst1.8 {d5}, [r0,:64], r3
|
|
| 1010 |
+ vst1.8 {d10}, [r0,:64], r3
|
|
| 1011 |
+ vst1.8 {d11}, [r0,:64], r3
|
|
| 1012 | 1012 |
|
| 1013 | 1013 |
bx lr |
| 1014 | 1014 |
endfunc |
| 1015 |
- .endm |
|
| 1015 |
+.endm |
|
| 1016 | 1016 |
|
| 1017 | 1017 |
h264_qpel_v_lowpass_l2 put |
| 1018 | 1018 |
h264_qpel_v_lowpass_l2 avg |
| 1019 | 1019 |
|
| 1020 | 1020 |
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 |
|
| 1021 |
+ lowpass_const r12 |
|
| 1022 |
+ mov r12, #12 |
|
| 1023 |
+1: vld1.8 {d0, d1}, [r1], r3
|
|
| 1024 |
+ vld1.8 {d16,d17}, [r1], r3
|
|
| 1025 |
+ subs r12, r12, #2 |
|
| 1026 | 1026 |
lowpass_8 d0, d1, d16, d17, q11, q12, narrow=0 |
| 1027 |
- vst1.64 {d22-d25}, [r4,:128]!
|
|
| 1027 |
+ vst1.8 {d22-d25}, [r4,:128]!
|
|
| 1028 | 1028 |
bne 1b |
| 1029 | 1029 |
|
| 1030 |
- vld1.64 {d0, d1}, [r1]
|
|
| 1030 |
+ vld1.8 {d0, d1}, [r1]
|
|
| 1031 | 1031 |
lowpass_8_1 d0, d1, q12, narrow=0 |
| 1032 | 1032 |
|
| 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]
|
|
| 1033 |
+ mov r12, #-16 |
|
| 1034 |
+ add r4, r4, r12 |
|
| 1035 |
+ vld1.8 {d30,d31}, [r4,:128], r12
|
|
| 1036 |
+ vld1.8 {d20,d21}, [r4,:128], r12
|
|
| 1037 |
+ vld1.8 {d18,d19}, [r4,:128], r12
|
|
| 1038 |
+ vld1.8 {d16,d17}, [r4,:128], r12
|
|
| 1039 |
+ vld1.8 {d14,d15}, [r4,:128], r12
|
|
| 1040 |
+ vld1.8 {d12,d13}, [r4,:128], r12
|
|
| 1041 |
+ vld1.8 {d10,d11}, [r4,:128], r12
|
|
| 1042 |
+ vld1.8 {d8, d9}, [r4,:128], r12
|
|
| 1043 |
+ vld1.8 {d6, d7}, [r4,:128], r12
|
|
| 1044 |
+ vld1.8 {d4, d5}, [r4,:128], r12
|
|
| 1045 |
+ vld1.8 {d2, d3}, [r4,:128], r12
|
|
| 1046 |
+ vld1.8 {d0, d1}, [r4,:128]
|
|
| 1047 | 1047 |
|
| 1048 | 1048 |
swap4 d1, d3, d5, d7, d8, d10, d12, d14 |
| 1049 | 1049 |
transpose16_4x4 q0, q1, q2, q3, q4, q5, q6, q7 |
| ... | ... |
@@ -1051,31 +1012,31 @@ function put_h264_qpel8_hv_lowpass_neon_top |
| 1051 | 1051 |
swap4 d17, d19, d21, d31, d24, d26, d28, d22 |
| 1052 | 1052 |
transpose16_4x4 q8, q9, q10, q15, q12, q13, q14, q11 |
| 1053 | 1053 |
|
| 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]
|
|
| 1054 |
+ vst1.8 {d30,d31}, [r4,:128]!
|
|
| 1055 |
+ vst1.8 {d6, d7}, [r4,:128]!
|
|
| 1056 |
+ vst1.8 {d20,d21}, [r4,:128]!
|
|
| 1057 |
+ vst1.8 {d4, d5}, [r4,:128]!
|
|
| 1058 |
+ vst1.8 {d18,d19}, [r4,:128]!
|
|
| 1059 |
+ vst1.8 {d2, d3}, [r4,:128]!
|
|
| 1060 |
+ vst1.8 {d16,d17}, [r4,:128]!
|
|
| 1061 |
+ vst1.8 {d0, d1}, [r4,:128]
|
|
| 1062 | 1062 |
|
| 1063 | 1063 |
lowpass_8.16 q4, q12, d8, d9, d24, d25, d8 |
| 1064 | 1064 |
lowpass_8.16 q5, q13, d10, d11, d26, d27, d9 |
| 1065 | 1065 |
lowpass_8.16 q6, q14, d12, d13, d28, d29, d10 |
| 1066 | 1066 |
lowpass_8.16 q7, q11, d14, d15, d22, d23, d11 |
| 1067 | 1067 |
|
| 1068 |
- vld1.64 {d16,d17}, [r4,:128], ip
|
|
| 1069 |
- vld1.64 {d30,d31}, [r4,:128], ip
|
|
| 1068 |
+ vld1.8 {d16,d17}, [r4,:128], r12
|
|
| 1069 |
+ vld1.8 {d30,d31}, [r4,:128], r12
|
|
| 1070 | 1070 |
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
|
|
| 1071 |
+ vld1.8 {d16,d17}, [r4,:128], r12
|
|
| 1072 |
+ vld1.8 {d30,d31}, [r4,:128], r12
|
|
| 1073 | 1073 |
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
|
|
| 1074 |
+ vld1.8 {d16,d17}, [r4,:128], r12
|
|
| 1075 |
+ vld1.8 {d30,d31}, [r4,:128], r12
|
|
| 1076 | 1076 |
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]
|
|
| 1077 |
+ vld1.8 {d16,d17}, [r4,:128], r12
|
|
| 1078 |
+ vld1.8 {d30,d31}, [r4,:128]
|
|
| 1079 | 1079 |
lowpass_8.16 q8, q15, d16, d17, d30, d31, d15 |
| 1080 | 1080 |
|
| 1081 | 1081 |
transpose_8x8 d12, d13, d14, d15, d8, d9, d10, d11 |
| ... | ... |
@@ -1083,11 +1044,11 @@ function put_h264_qpel8_hv_lowpass_neon_top |
| 1083 | 1083 |
bx lr |
| 1084 | 1084 |
endfunc |
| 1085 | 1085 |
|
| 1086 |
- .macro h264_qpel8_hv_lowpass type |
|
| 1086 |
+.macro h264_qpel8_hv_lowpass type |
|
| 1087 | 1087 |
function \type\()_h264_qpel8_hv_lowpass_neon |
| 1088 | 1088 |
mov r10, lr |
| 1089 | 1089 |
bl put_h264_qpel8_hv_lowpass_neon_top |
| 1090 |
-.ifc \type,avg |
|
| 1090 |
+ .ifc \type,avg |
|
| 1091 | 1091 |
vld1.8 {d0}, [r0,:64], r2
|
| 1092 | 1092 |
vrhadd.u8 d12, d12, d0 |
| 1093 | 1093 |
vld1.8 {d1}, [r0,:64], r2
|
| ... | ... |
@@ -1105,39 +1066,39 @@ function \type\()_h264_qpel8_hv_lowpass_neon |
| 1105 | 1105 |
vld1.8 {d7}, [r0,:64], r2
|
| 1106 | 1106 |
vrhadd.u8 d11, d11, d7 |
| 1107 | 1107 |
sub r0, r0, r2, lsl #3 |
| 1108 |
-.endif |
|
| 1108 |
+ .endif |
|
| 1109 | 1109 |
|
| 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
|
|
| 1110 |
+ vst1.8 {d12}, [r0,:64], r2
|
|
| 1111 |
+ vst1.8 {d13}, [r0,:64], r2
|
|
| 1112 |
+ vst1.8 {d14}, [r0,:64], r2
|
|
| 1113 |
+ vst1.8 {d15}, [r0,:64], r2
|
|
| 1114 |
+ vst1.8 {d8}, [r0,:64], r2
|
|
| 1115 |
+ vst1.8 {d9}, [r0,:64], r2
|
|
| 1116 |
+ vst1.8 {d10}, [r0,:64], r2
|
|
| 1117 |
+ vst1.8 {d11}, [r0,:64], r2
|
|
| 1118 | 1118 |
|
| 1119 | 1119 |
mov lr, r10 |
| 1120 | 1120 |
bx lr |
| 1121 | 1121 |
endfunc |
| 1122 |
- .endm |
|
| 1122 |
+.endm |
|
| 1123 | 1123 |
|
| 1124 | 1124 |
h264_qpel8_hv_lowpass put |
| 1125 | 1125 |
h264_qpel8_hv_lowpass avg |
| 1126 | 1126 |
|
| 1127 |
- .macro h264_qpel8_hv_lowpass_l2 type |
|
| 1127 |
+.macro h264_qpel8_hv_lowpass_l2 type |
|
| 1128 | 1128 |
function \type\()_h264_qpel8_hv_lowpass_l2_neon |
| 1129 | 1129 |
mov r10, lr |
| 1130 | 1130 |
bl put_h264_qpel8_hv_lowpass_neon_top |
| 1131 | 1131 |
|
| 1132 |
- vld1.64 {d0, d1}, [r2,:128]!
|
|
| 1133 |
- vld1.64 {d2, d3}, [r2,:128]!
|
|
| 1132 |
+ vld1.8 {d0, d1}, [r2,:128]!
|
|
| 1133 |
+ vld1.8 {d2, d3}, [r2,:128]!
|
|
| 1134 | 1134 |
vrhadd.u8 q0, q0, q6 |
| 1135 |
- vld1.64 {d4, d5}, [r2,:128]!
|
|
| 1135 |
+ vld1.8 {d4, d5}, [r2,:128]!
|
|
| 1136 | 1136 |
vrhadd.u8 q1, q1, q7 |
| 1137 |
- vld1.64 {d6, d7}, [r2,:128]!
|
|
| 1137 |
+ vld1.8 {d6, d7}, [r2,:128]!
|
|
| 1138 | 1138 |
vrhadd.u8 q2, q2, q4 |
| 1139 | 1139 |
vrhadd.u8 q3, q3, q5 |
| 1140 |
-.ifc \type,avg |
|
| 1140 |
+ .ifc \type,avg |
|
| 1141 | 1141 |
vld1.8 {d16}, [r0,:64], r3
|
| 1142 | 1142 |
vrhadd.u8 d0, d0, d16 |
| 1143 | 1143 |
vld1.8 {d17}, [r0,:64], r3
|
| ... | ... |
@@ -1155,25 +1116,25 @@ function \type\()_h264_qpel8_hv_lowpass_l2_neon |
| 1155 | 1155 |
vld1.8 {d23}, [r0,:64], r3
|
| 1156 | 1156 |
vrhadd.u8 d7, d7, d23 |
| 1157 | 1157 |
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
|
|
| 1158 |
+ .endif |
|
| 1159 |
+ vst1.8 {d0}, [r0,:64], r3
|
|
| 1160 |
+ vst1.8 {d1}, [r0,:64], r3
|
|
| 1161 |
+ vst1.8 {d2}, [r0,:64], r3
|
|
| 1162 |
+ vst1.8 {d3}, [r0,:64], r3
|
|
| 1163 |
+ vst1.8 {d4}, [r0,:64], r3
|
|
| 1164 |
+ vst1.8 {d5}, [r0,:64], r3
|
|
| 1165 |
+ vst1.8 {d6}, [r0,:64], r3
|
|
| 1166 |
+ vst1.8 {d7}, [r0,:64], r3
|
|
| 1167 | 1167 |
|
| 1168 | 1168 |
mov lr, r10 |
| 1169 | 1169 |
bx lr |
| 1170 | 1170 |
endfunc |
| 1171 |
- .endm |
|
| 1171 |
+.endm |
|
| 1172 | 1172 |
|
| 1173 | 1173 |
h264_qpel8_hv_lowpass_l2 put |
| 1174 | 1174 |
h264_qpel8_hv_lowpass_l2 avg |
| 1175 | 1175 |
|
| 1176 |
- .macro h264_qpel16_hv type |
|
| 1176 |
+.macro h264_qpel16_hv type |
|
| 1177 | 1177 |
function \type\()_h264_qpel16_hv_lowpass_neon |
| 1178 | 1178 |
mov r9, lr |
| 1179 | 1179 |
bl \type\()_h264_qpel8_hv_lowpass_neon |
| ... | ... |
@@ -1206,17 +1167,17 @@ function \type\()_h264_qpel16_hv_lowpass_l2_neon |
| 1206 | 1206 |
mov lr, r9 |
| 1207 | 1207 |
b \type\()_h264_qpel8_hv_lowpass_l2_neon |
| 1208 | 1208 |
endfunc |
| 1209 |
- .endm |
|
| 1209 |
+.endm |
|
| 1210 | 1210 |
|
| 1211 | 1211 |
h264_qpel16_hv put |
| 1212 | 1212 |
h264_qpel16_hv avg |
| 1213 | 1213 |
|
| 1214 |
- .macro h264_qpel8 type |
|
| 1214 |
+.macro h264_qpel8 type |
|
| 1215 | 1215 |
function ff_\type\()_h264_qpel8_mc10_neon, export=1 |
| 1216 | 1216 |
lowpass_const r3 |
| 1217 | 1217 |
mov r3, r1 |
| 1218 | 1218 |
sub r1, r1, #2 |
| 1219 |
- mov ip, #8 |
|
| 1219 |
+ mov r12, #8 |
|
| 1220 | 1220 |
b \type\()_h264_qpel8_h_lowpass_l2_neon |
| 1221 | 1221 |
endfunc |
| 1222 | 1222 |
|
| ... | ... |
@@ -1224,7 +1185,7 @@ function ff_\type\()_h264_qpel8_mc20_neon, export=1 |
| 1224 | 1224 |
lowpass_const r3 |
| 1225 | 1225 |
sub r1, r1, #2 |
| 1226 | 1226 |
mov r3, r2 |
| 1227 |
- mov ip, #8 |
|
| 1227 |
+ mov r12, #8 |
|
| 1228 | 1228 |
b \type\()_h264_qpel8_h_lowpass_neon |
| 1229 | 1229 |
endfunc |
| 1230 | 1230 |
|
| ... | ... |
@@ -1232,13 +1193,13 @@ function ff_\type\()_h264_qpel8_mc30_neon, export=1 |
| 1232 | 1232 |
lowpass_const r3 |
| 1233 | 1233 |
add r3, r1, #1 |
| 1234 | 1234 |
sub r1, r1, #2 |
| 1235 |
- mov ip, #8 |
|
| 1235 |
+ mov r12, #8 |
|
| 1236 | 1236 |
b \type\()_h264_qpel8_h_lowpass_l2_neon |
| 1237 | 1237 |
endfunc |
| 1238 | 1238 |
|
| 1239 | 1239 |
function ff_\type\()_h264_qpel8_mc01_neon, export=1 |
| 1240 | 1240 |
push {lr}
|
| 1241 |
- mov ip, r1 |
|
| 1241 |
+ mov r12, r1 |
|
| 1242 | 1242 |
\type\()_h264_qpel8_mc01: |
| 1243 | 1243 |
lowpass_const r3 |
| 1244 | 1244 |
mov r3, r2 |
| ... | ... |
@@ -1261,12 +1222,12 @@ T mov sp, r0 |
| 1261 | 1261 |
mov r0, sp |
| 1262 | 1262 |
sub r1, r1, #2 |
| 1263 | 1263 |
mov r3, #8 |
| 1264 |
- mov ip, #8 |
|
| 1264 |
+ mov r12, #8 |
|
| 1265 | 1265 |
vpush {d8-d15}
|
| 1266 | 1266 |
bl put_h264_qpel8_h_lowpass_neon |
| 1267 | 1267 |
ldrd r0, [r11], #8 |
| 1268 | 1268 |
mov r3, r2 |
| 1269 |
- add ip, sp, #64 |
|
| 1269 |
+ add r12, sp, #64 |
|
| 1270 | 1270 |
sub r1, r1, r2, lsl #1 |
| 1271 | 1271 |
mov r2, #8 |
| 1272 | 1272 |
bl \type\()_h264_qpel8_v_lowpass_l2_neon |
| ... | ... |
@@ -1287,7 +1248,7 @@ T mov sp, r0 |
| 1287 | 1287 |
sub r1, r1, #2 |
| 1288 | 1288 |
mov r3, #8 |
| 1289 | 1289 |
mov r0, sp |
| 1290 |
- mov ip, #8 |
|
| 1290 |
+ mov r12, #8 |
|
| 1291 | 1291 |
vpush {d8-d15}
|
| 1292 | 1292 |
bl put_h264_qpel8_h_lowpass_neon |
| 1293 | 1293 |
mov r4, r0 |
| ... | ... |
@@ -1372,7 +1333,7 @@ endfunc |
| 1372 | 1372 |
|
| 1373 | 1373 |
function ff_\type\()_h264_qpel8_mc03_neon, export=1 |
| 1374 | 1374 |
push {lr}
|
| 1375 |
- add ip, r1, r2 |
|
| 1375 |
+ add r12, r1, r2 |
|
| 1376 | 1376 |
b \type\()_h264_qpel8_mc01 |
| 1377 | 1377 |
endfunc |
| 1378 | 1378 |
|
| ... | ... |
@@ -1395,12 +1356,12 @@ function ff_\type\()_h264_qpel8_mc33_neon, export=1 |
| 1395 | 1395 |
sub r1, r1, #1 |
| 1396 | 1396 |
b \type\()_h264_qpel8_mc11 |
| 1397 | 1397 |
endfunc |
| 1398 |
- .endm |
|
| 1398 |
+.endm |
|
| 1399 | 1399 |
|
| 1400 | 1400 |
h264_qpel8 put |
| 1401 | 1401 |
h264_qpel8 avg |
| 1402 | 1402 |
|
| 1403 |
- .macro h264_qpel16 type |
|
| 1403 |
+.macro h264_qpel16 type |
|
| 1404 | 1404 |
function ff_\type\()_h264_qpel16_mc10_neon, export=1 |
| 1405 | 1405 |
lowpass_const r3 |
| 1406 | 1406 |
mov r3, r1 |
| ... | ... |
@@ -1424,7 +1385,7 @@ endfunc |
| 1424 | 1424 |
|
| 1425 | 1425 |
function ff_\type\()_h264_qpel16_mc01_neon, export=1 |
| 1426 | 1426 |
push {r4, lr}
|
| 1427 |
- mov ip, r1 |
|
| 1427 |
+ mov r12, r1 |
|
| 1428 | 1428 |
\type\()_h264_qpel16_mc01: |
| 1429 | 1429 |
lowpass_const r3 |
| 1430 | 1430 |
mov r3, r2 |
| ... | ... |
@@ -1451,7 +1412,7 @@ T mov sp, r0 |
| 1451 | 1451 |
bl put_h264_qpel16_h_lowpass_neon |
| 1452 | 1452 |
ldrd r0, [r11], #8 |
| 1453 | 1453 |
mov r3, r2 |
| 1454 |
- add ip, sp, #64 |
|
| 1454 |
+ add r12, sp, #64 |
|
| 1455 | 1455 |
sub r1, r1, r2, lsl #1 |
| 1456 | 1456 |
mov r2, #16 |
| 1457 | 1457 |
bl \type\()_h264_qpel16_v_lowpass_l2_neon |
| ... | ... |
@@ -1554,7 +1515,7 @@ endfunc |
| 1554 | 1554 |
|
| 1555 | 1555 |
function ff_\type\()_h264_qpel16_mc03_neon, export=1 |
| 1556 | 1556 |
push {r4, lr}
|
| 1557 |
- add ip, r1, r2 |
|
| 1557 |
+ add r12, r1, r2 |
|
| 1558 | 1558 |
b \type\()_h264_qpel16_mc01 |
| 1559 | 1559 |
endfunc |
| 1560 | 1560 |
|
| ... | ... |
@@ -1577,14 +1538,14 @@ function ff_\type\()_h264_qpel16_mc33_neon, export=1 |
| 1577 | 1577 |
sub r1, r1, #1 |
| 1578 | 1578 |
b \type\()_h264_qpel16_mc11 |
| 1579 | 1579 |
endfunc |
| 1580 |
- .endm |
|
| 1580 |
+.endm |
|
| 1581 | 1581 |
|
| 1582 | 1582 |
h264_qpel16 put |
| 1583 | 1583 |
h264_qpel16 avg |
| 1584 | 1584 |
|
| 1585 | 1585 |
@ Biweighted prediction |
| 1586 | 1586 |
|
| 1587 |
- .macro biweight_16 macs, macd |
|
| 1587 |
+.macro biweight_16 macs, macd |
|
| 1588 | 1588 |
vdup.8 d0, r4 |
| 1589 | 1589 |
vdup.8 d1, r5 |
| 1590 | 1590 |
vmov q2, q8 |
| ... | ... |
@@ -1622,9 +1583,9 @@ endfunc |
| 1622 | 1622 |
vst1.8 {d24-d25},[r6,:128], r2
|
| 1623 | 1623 |
bne 1b |
| 1624 | 1624 |
pop {r4-r6, pc}
|
| 1625 |
- .endm |
|
| 1625 |
+.endm |
|
| 1626 | 1626 |
|
| 1627 |
- .macro biweight_8 macs, macd |
|
| 1627 |
+.macro biweight_8 macs, macd |
|
| 1628 | 1628 |
vdup.8 d0, r4 |
| 1629 | 1629 |
vdup.8 d1, r5 |
| 1630 | 1630 |
vmov q1, q8 |
| ... | ... |
@@ -1652,9 +1613,9 @@ endfunc |
| 1652 | 1652 |
vst1.8 {d4},[r6,:64], r2
|
| 1653 | 1653 |
bne 1b |
| 1654 | 1654 |
pop {r4-r6, pc}
|
| 1655 |
- .endm |
|
| 1655 |
+.endm |
|
| 1656 | 1656 |
|
| 1657 |
- .macro biweight_4 macs, macd |
|
| 1657 |
+.macro biweight_4 macs, macd |
|
| 1658 | 1658 |
vdup.8 d0, r4 |
| 1659 | 1659 |
vdup.8 d1, r5 |
| 1660 | 1660 |
vmov q1, q8 |
| ... | ... |
@@ -1694,9 +1655,9 @@ endfunc |
| 1694 | 1694 |
vst1.32 {d2[0]},[r6,:32], r2
|
| 1695 | 1695 |
vst1.32 {d2[1]},[r6,:32], r2
|
| 1696 | 1696 |
pop {r4-r6, pc}
|
| 1697 |
- .endm |
|
| 1697 |
+.endm |
|
| 1698 | 1698 |
|
| 1699 |
- .macro biweight_func w |
|
| 1699 |
+.macro biweight_func w |
|
| 1700 | 1700 |
function ff_biweight_h264_pixels_\w\()_neon, export=1 |
| 1701 | 1701 |
push {r4-r6, lr}
|
| 1702 | 1702 |
ldr r12, [sp, #16] |
| ... | ... |
@@ -1726,7 +1687,7 @@ function ff_biweight_h264_pixels_\w\()_neon, export=1 |
| 1726 | 1726 |
40: rsb r5, r5, #0 |
| 1727 | 1727 |
biweight_\w vmlsl.u8, vmlal.u8 |
| 1728 | 1728 |
endfunc |
| 1729 |
- .endm |
|
| 1729 |
+.endm |
|
| 1730 | 1730 |
|
| 1731 | 1731 |
biweight_func 16 |
| 1732 | 1732 |
biweight_func 8 |
| ... | ... |
@@ -1734,7 +1695,7 @@ endfunc |
| 1734 | 1734 |
|
| 1735 | 1735 |
@ Weighted prediction |
| 1736 | 1736 |
|
| 1737 |
- .macro weight_16 add |
|
| 1737 |
+.macro weight_16 add |
|
| 1738 | 1738 |
vdup.8 d0, r12 |
| 1739 | 1739 |
1: subs r2, r2, #2 |
| 1740 | 1740 |
vld1.8 {d20-d21},[r0,:128], r1
|
| ... | ... |
@@ -1761,9 +1722,9 @@ endfunc |
| 1761 | 1761 |
vst1.8 {d24-d25},[r4,:128], r1
|
| 1762 | 1762 |
bne 1b |
| 1763 | 1763 |
pop {r4, pc}
|
| 1764 |
- .endm |
|
| 1764 |
+.endm |
|
| 1765 | 1765 |
|
| 1766 |
- .macro weight_8 add |
|
| 1766 |
+.macro weight_8 add |
|
| 1767 | 1767 |
vdup.8 d0, r12 |
| 1768 | 1768 |
1: subs r2, r2, #2 |
| 1769 | 1769 |
vld1.8 {d4},[r0,:64], r1
|
| ... | ... |
@@ -1782,9 +1743,9 @@ endfunc |
| 1782 | 1782 |
vst1.8 {d4},[r4,:64], r1
|
| 1783 | 1783 |
bne 1b |
| 1784 | 1784 |
pop {r4, pc}
|
| 1785 |
- .endm |
|
| 1785 |
+.endm |
|
| 1786 | 1786 |
|
| 1787 |
- .macro weight_4 add |
|
| 1787 |
+.macro weight_4 add |
|
| 1788 | 1788 |
vdup.8 d0, r12 |
| 1789 | 1789 |
vmov q1, q8 |
| 1790 | 1790 |
vmov q10, q8 |
| ... | ... |
@@ -1818,9 +1779,9 @@ endfunc |
| 1818 | 1818 |
vst1.32 {d2[0]},[r4,:32], r1
|
| 1819 | 1819 |
vst1.32 {d2[1]},[r4,:32], r1
|
| 1820 | 1820 |
pop {r4, pc}
|
| 1821 |
- .endm |
|
| 1821 |
+.endm |
|
| 1822 | 1822 |
|
| 1823 |
- .macro weight_func w |
|
| 1823 |
+.macro weight_func w |
|
| 1824 | 1824 |
function ff_weight_h264_pixels_\w\()_neon, export=1 |
| 1825 | 1825 |
push {r4, lr}
|
| 1826 | 1826 |
ldr r12, [sp, #8] |
| ... | ... |
@@ -1845,7 +1806,7 @@ function ff_weight_h264_pixels_\w\()_neon, export=1 |
| 1845 | 1845 |
10: rsb r12, r12, #0 |
| 1846 | 1846 |
weight_\w vsub.s16 |
| 1847 | 1847 |
endfunc |
| 1848 |
- .endm |
|
| 1848 |
+.endm |
|
| 1849 | 1849 |
|
| 1850 | 1850 |
weight_func 16 |
| 1851 | 1851 |
weight_func 8 |
| 1852 | 1852 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,59 @@ |
| 0 |
+/* |
|
| 1 |
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> |
|
| 2 |
+ * |
|
| 3 |
+ * This file is part of Libav. |
|
| 4 |
+ * |
|
| 5 |
+ * Libav is free software; you can redistribute it and/or |
|
| 6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
| 7 |
+ * License as published by the Free Software Foundation; either |
|
| 8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
| 9 |
+ * |
|
| 10 |
+ * Libav is distributed in the hope that it will be useful, |
|
| 11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 13 |
+ * Lesser General Public License for more details. |
|
| 14 |
+ * |
|
| 15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
| 16 |
+ * License along with Libav; if not, write to the Free Software |
|
| 17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 18 |
+ */ |
|
| 19 |
+ |
|
| 20 |
+.macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7 |
|
| 21 |
+ vtrn.32 \r0, \r4 |
|
| 22 |
+ vtrn.32 \r1, \r5 |
|
| 23 |
+ vtrn.32 \r2, \r6 |
|
| 24 |
+ vtrn.32 \r3, \r7 |
|
| 25 |
+ vtrn.16 \r0, \r2 |
|
| 26 |
+ vtrn.16 \r1, \r3 |
|
| 27 |
+ vtrn.16 \r4, \r6 |
|
| 28 |
+ vtrn.16 \r5, \r7 |
|
| 29 |
+ vtrn.8 \r0, \r1 |
|
| 30 |
+ vtrn.8 \r2, \r3 |
|
| 31 |
+ vtrn.8 \r4, \r5 |
|
| 32 |
+ vtrn.8 \r6, \r7 |
|
| 33 |
+.endm |
|
| 34 |
+ |
|
| 35 |
+.macro transpose_4x4 r0, r1, r2, r3 |
|
| 36 |
+ vtrn.16 \r0, \r2 |
|
| 37 |
+ vtrn.16 \r1, \r3 |
|
| 38 |
+ vtrn.8 \r0, \r1 |
|
| 39 |
+ vtrn.8 \r2, \r3 |
|
| 40 |
+.endm |
|
| 41 |
+ |
|
| 42 |
+.macro swap4 r0, r1, r2, r3, r4, r5, r6, r7 |
|
| 43 |
+ vswp \r0, \r4 |
|
| 44 |
+ vswp \r1, \r5 |
|
| 45 |
+ vswp \r2, \r6 |
|
| 46 |
+ vswp \r3, \r7 |
|
| 47 |
+.endm |
|
| 48 |
+ |
|
| 49 |
+.macro transpose16_4x4 r0, r1, r2, r3, r4, r5, r6, r7 |
|
| 50 |
+ vtrn.32 \r0, \r2 |
|
| 51 |
+ vtrn.32 \r1, \r3 |
|
| 52 |
+ vtrn.32 \r4, \r6 |
|
| 53 |
+ vtrn.32 \r5, \r7 |
|
| 54 |
+ vtrn.16 \r0, \r1 |
|
| 55 |
+ vtrn.16 \r2, \r3 |
|
| 56 |
+ vtrn.16 \r4, \r5 |
|
| 57 |
+ vtrn.16 \r6, \r7 |
|
| 58 |
+.endm |
| ... | ... |
@@ -22,6 +22,7 @@ |
| 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 |
| 442 | 442 |
.endif |
| 443 | 443 |
.endm |
| 444 | 444 |
|
| 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 | 445 |
.macro vp8_v_loop_filter16 name, inner=0, simple=0 |
| 463 | 446 |
function ff_vp8_v_loop_filter16\name\()_neon, export=1 |
| 464 | 447 |
vpush {q4-q7}
|
| ... | ... |
@@ -593,7 +577,7 @@ function ff_vp8_h_loop_filter16\name\()_neon, export=1 |
| 593 | 593 |
vld1.8 {d13}, [r0], r1
|
| 594 | 594 |
vld1.8 {d15}, [r0], r1
|
| 595 | 595 |
|
| 596 |
- transpose8x16matrix |
|
| 596 |
+ transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7 |
|
| 597 | 597 |
|
| 598 | 598 |
vdup.8 q14, r2 @ flim_E |
| 599 | 599 |
.if !\simple |
| ... | ... |
@@ -604,7 +588,7 @@ function ff_vp8_h_loop_filter16\name\()_neon, export=1 |
| 604 | 604 |
|
| 605 | 605 |
sub r0, r0, r1, lsl #4 @ backup 16 rows |
| 606 | 606 |
|
| 607 |
- transpose8x16matrix |
|
| 607 |
+ transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7 |
|
| 608 | 608 |
|
| 609 | 609 |
@ Store pixels: |
| 610 | 610 |
vst1.8 {d0}, [r0], r1
|
| ... | ... |
@@ -658,7 +642,7 @@ function ff_vp8_h_loop_filter8uv\name\()_neon, export=1 |
| 658 | 658 |
vld1.8 {d14}, [r0], r2
|
| 659 | 659 |
vld1.8 {d15}, [r1], r2
|
| 660 | 660 |
|
| 661 |
- transpose8x16matrix |
|
| 661 |
+ transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7 |
|
| 662 | 662 |
|
| 663 | 663 |
vdup.8 q14, r3 @ flim_E |
| 664 | 664 |
vdup.8 q15, r12 @ flim_I |
| ... | ... |
@@ -669,7 +653,7 @@ function ff_vp8_h_loop_filter8uv\name\()_neon, export=1 |
| 669 | 669 |
sub r0, r0, r2, lsl #3 @ backup u 8 rows |
| 670 | 670 |
sub r1, r1, r2, lsl #3 @ backup v 8 rows |
| 671 | 671 |
|
| 672 |
- transpose8x16matrix |
|
| 672 |
+ transpose_8x8 q0, q1, q2, q3, q4, q5, q6, q7 |
|
| 673 | 673 |
|
| 674 | 674 |
@ Store pixels: |
| 675 | 675 |
vst1.8 {d0}, [r0], r2
|
| ... | ... |
@@ -72,6 +72,7 @@ typedef struct {
|
| 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) |
| 273 | 273 |
|
| 274 | 274 |
|
| 275 | 275 |
static int atrac1_decode_frame(AVCodecContext *avctx, void *data, |
| 276 |
- int *data_size, AVPacket *avpkt) |
|
| 276 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 277 | 277 |
{
|
| 278 | 278 |
const uint8_t *buf = avpkt->data; |
| 279 | 279 |
int buf_size = avpkt->size; |
| 280 | 280 |
AT1Ctx *q = avctx->priv_data; |
| 281 |
- int ch, ret, out_size; |
|
| 281 |
+ int ch, ret; |
|
| 282 | 282 |
GetBitContext gb; |
| 283 |
- float* samples = data; |
|
| 283 |
+ float *samples; |
|
| 284 | 284 |
|
| 285 | 285 |
|
| 286 | 286 |
if (buf_size < 212 * q->channels) {
|
| ... | ... |
@@ -288,12 +289,13 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data, |
| 288 | 288 |
return AVERROR_INVALIDDATA; |
| 289 | 289 |
} |
| 290 | 290 |
|
| 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); |
|
| 291 |
+ /* get output buffer */ |
|
| 292 |
+ q->frame.nb_samples = AT1_SU_SAMPLES; |
|
| 293 |
+ if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
|
|
| 294 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 295 |
+ return ret; |
|
| 296 | 296 |
} |
| 297 |
+ samples = (float *)q->frame.data[0]; |
|
| 297 | 298 |
|
| 298 | 299 |
for (ch = 0; ch < q->channels; ch++) {
|
| 299 | 300 |
AT1SUCtx* su = &q->SUs[ch]; |
| ... | ... |
@@ -321,7 +323,9 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data, |
| 321 | 321 |
AT1_SU_SAMPLES, 2); |
| 322 | 322 |
} |
| 323 | 323 |
|
| 324 |
- *data_size = out_size; |
|
| 324 |
+ *got_frame_ptr = 1; |
|
| 325 |
+ *(AVFrame *)data = q->frame; |
|
| 326 |
+ |
|
| 325 | 327 |
return avctx->block_align; |
| 326 | 328 |
} |
| 327 | 329 |
|
| ... | ... |
@@ -389,6 +393,9 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) |
| 389 | 389 |
q->SUs[1].spectrum[0] = q->SUs[1].spec1; |
| 390 | 390 |
q->SUs[1].spectrum[1] = q->SUs[1].spec2; |
| 391 | 391 |
|
| 392 |
+ avcodec_get_frame_defaults(&q->frame); |
|
| 393 |
+ avctx->coded_frame = &q->frame; |
|
| 394 |
+ |
|
| 392 | 395 |
return 0; |
| 393 | 396 |
} |
| 394 | 397 |
|
| ... | ... |
@@ -401,5 +408,6 @@ AVCodec ff_atrac1_decoder = {
|
| 401 | 401 |
.init = atrac1_decode_init, |
| 402 | 402 |
.close = atrac1_decode_end, |
| 403 | 403 |
.decode = atrac1_decode_frame, |
| 404 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 404 | 405 |
.long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Coding)"),
|
| 405 | 406 |
}; |
| ... | ... |
@@ -86,6 +86,7 @@ typedef struct {
|
| 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, |
| 823 | 823 |
* @param avctx pointer to the AVCodecContext |
| 824 | 824 |
*/ |
| 825 | 825 |
|
| 826 |
-static int atrac3_decode_frame(AVCodecContext *avctx, |
|
| 827 |
- void *data, int *data_size, |
|
| 828 |
- AVPacket *avpkt) {
|
|
| 826 |
+static int atrac3_decode_frame(AVCodecContext *avctx, void *data, |
|
| 827 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 828 |
+{
|
|
| 829 | 829 |
const uint8_t *buf = avpkt->data; |
| 830 | 830 |
int buf_size = avpkt->size; |
| 831 | 831 |
ATRAC3Context *q = avctx->priv_data; |
| 832 |
- int result = 0, out_size; |
|
| 832 |
+ int result; |
|
| 833 | 833 |
const uint8_t* databuf; |
| 834 |
- float *samples_flt = data; |
|
| 835 |
- int16_t *samples_s16 = data; |
|
| 834 |
+ float *samples_flt; |
|
| 835 |
+ int16_t *samples_s16; |
|
| 836 | 836 |
|
| 837 | 837 |
if (buf_size < avctx->block_align) {
|
| 838 | 838 |
av_log(avctx, AV_LOG_ERROR, |
| ... | ... |
@@ -840,12 +841,14 @@ static int atrac3_decode_frame(AVCodecContext *avctx, |
| 840 | 840 |
return AVERROR_INVALIDDATA; |
| 841 | 841 |
} |
| 842 | 842 |
|
| 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); |
|
| 843 |
+ /* get output buffer */ |
|
| 844 |
+ q->frame.nb_samples = SAMPLES_PER_FRAME; |
|
| 845 |
+ if ((result = avctx->get_buffer(avctx, &q->frame)) < 0) {
|
|
| 846 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 847 |
+ return result; |
|
| 848 | 848 |
} |
| 849 |
+ samples_flt = (float *)q->frame.data[0]; |
|
| 850 |
+ samples_s16 = (int16_t *)q->frame.data[0]; |
|
| 849 | 851 |
|
| 850 | 852 |
/* Check if we need to descramble and what buffer to pass on. */ |
| 851 | 853 |
if (q->scrambled_stream) {
|
| ... | ... |
@@ -875,7 +878,9 @@ static int atrac3_decode_frame(AVCodecContext *avctx, |
| 875 | 875 |
(const float **)q->outSamples, |
| 876 | 876 |
SAMPLES_PER_FRAME, q->channels); |
| 877 | 877 |
} |
| 878 |
- *data_size = out_size; |
|
| 878 |
+ |
|
| 879 |
+ *got_frame_ptr = 1; |
|
| 880 |
+ *(AVFrame *)data = q->frame; |
|
| 879 | 881 |
|
| 880 | 882 |
return avctx->block_align; |
| 881 | 883 |
} |
| ... | ... |
@@ -1047,6 +1052,9 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) |
| 1047 | 1047 |
} |
| 1048 | 1048 |
} |
| 1049 | 1049 |
|
| 1050 |
+ avcodec_get_frame_defaults(&q->frame); |
|
| 1051 |
+ avctx->coded_frame = &q->frame; |
|
| 1052 |
+ |
|
| 1050 | 1053 |
return 0; |
| 1051 | 1054 |
} |
| 1052 | 1055 |
|
| ... | ... |
@@ -1060,6 +1068,6 @@ AVCodec ff_atrac3_decoder = |
| 1060 | 1060 |
.init = atrac3_decode_init, |
| 1061 | 1061 |
.close = atrac3_decode_close, |
| 1062 | 1062 |
.decode = atrac3_decode_frame, |
| 1063 |
- .capabilities = CODEC_CAP_SUBFRAMES, |
|
| 1063 |
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, |
|
| 1064 | 1064 |
.long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),
|
| 1065 | 1065 |
}; |
| ... | ... |
@@ -491,8 +491,10 @@ enum CodecID {
|
| 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 {
|
| 947 | 947 |
* sizeof(AVFrame) must not be used outside libav*. |
| 948 | 948 |
*/ |
| 949 | 949 |
typedef struct AVFrame {
|
| 950 |
+#if FF_API_DATA_POINTERS |
|
| 951 |
+#define AV_NUM_DATA_POINTERS 4 |
|
| 952 |
+#else |
|
| 953 |
+#define AV_NUM_DATA_POINTERS 8 |
|
| 954 |
+#endif |
|
| 950 | 955 |
/** |
| 951 |
- * pointer to the picture planes. |
|
| 956 |
+ * pointer to the picture/channel planes. |
|
| 952 | 957 |
* This might be different from the first allocated byte |
| 953 |
- * - encoding: |
|
| 954 |
- * - decoding: |
|
| 958 |
+ * - encoding: Set by user |
|
| 959 |
+ * - decoding: set by AVCodecContext.get_buffer() |
|
| 960 |
+ */ |
|
| 961 |
+ uint8_t *data[AV_NUM_DATA_POINTERS]; |
|
| 962 |
+ |
|
| 963 |
+ /** |
|
| 964 |
+ * Size, in bytes, of the data for each picture/channel plane. |
|
| 965 |
+ * |
|
| 966 |
+ * For audio, only linesize[0] may be set. For planar audio, each channel |
|
| 967 |
+ * plane must be the same size. |
|
| 968 |
+ * |
|
| 969 |
+ * - encoding: Set by user (video only) |
|
| 970 |
+ * - decoding: set by AVCodecContext.get_buffer() |
|
| 955 | 971 |
*/ |
| 956 |
- uint8_t *data[4]; |
|
| 957 |
- int linesize[4]; |
|
| 972 |
+ int linesize[AV_NUM_DATA_POINTERS]; |
|
| 973 |
+ |
|
| 958 | 974 |
/** |
| 959 | 975 |
* pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer. |
| 960 | 976 |
* This isn't used by libavcodec unless the default get/release_buffer() is used. |
| 961 | 977 |
* - encoding: |
| 962 | 978 |
* - decoding: |
| 963 | 979 |
*/ |
| 964 |
- uint8_t *base[4]; |
|
| 980 |
+ uint8_t *base[AV_NUM_DATA_POINTERS]; |
|
| 965 | 981 |
/** |
| 966 | 982 |
* 1 -> keyframe, 0-> not |
| 967 | 983 |
* - encoding: Set by libavcodec. |
| ... | ... |
@@ -1008,7 +1026,7 @@ typedef struct AVFrame {
|
| 1008 | 1008 |
* buffer age (1->was last buffer and dint change, 2->..., ...). |
| 1009 | 1009 |
* Set to INT_MAX if the buffer has not been used yet. |
| 1010 | 1010 |
* - encoding: unused |
| 1011 |
- * - decoding: MUST be set by get_buffer(). |
|
| 1011 |
+ * - decoding: MUST be set by get_buffer() for video. |
|
| 1012 | 1012 |
*/ |
| 1013 | 1013 |
int age; |
| 1014 | 1014 |
|
| ... | ... |
@@ -1085,7 +1103,7 @@ typedef struct AVFrame {
|
| 1085 | 1085 |
* - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR. |
| 1086 | 1086 |
* - decoding: unused |
| 1087 | 1087 |
*/ |
| 1088 |
- uint64_t error[4]; |
|
| 1088 |
+ uint64_t error[AV_NUM_DATA_POINTERS]; |
|
| 1089 | 1089 |
|
| 1090 | 1090 |
/** |
| 1091 | 1091 |
* type of the buffer (to keep track of who has to deallocate data[*]) |
| ... | ... |
@@ -1207,6 +1225,33 @@ typedef struct AVFrame {
|
| 1207 | 1207 |
void *thread_opaque; |
| 1208 | 1208 |
|
| 1209 | 1209 |
/** |
| 1210 |
+ * number of audio samples (per channel) described by this frame |
|
| 1211 |
+ * - encoding: unused |
|
| 1212 |
+ * - decoding: Set by libavcodec |
|
| 1213 |
+ */ |
|
| 1214 |
+ int nb_samples; |
|
| 1215 |
+ |
|
| 1216 |
+ /** |
|
| 1217 |
+ * pointers to the data planes/channels. |
|
| 1218 |
+ * |
|
| 1219 |
+ * For video, this should simply point to data[]. |
|
| 1220 |
+ * |
|
| 1221 |
+ * For planar audio, each channel has a separate data pointer, and |
|
| 1222 |
+ * linesize[0] contains the size of each channel buffer. |
|
| 1223 |
+ * For packed audio, there is just one data pointer, and linesize[0] |
|
| 1224 |
+ * contains the total size of the buffer for all channels. |
|
| 1225 |
+ * |
|
| 1226 |
+ * Note: Both data and extended_data will always be set by get_buffer(), |
|
| 1227 |
+ * but for planar audio with more channels that can fit in data, |
|
| 1228 |
+ * extended_data must be used by the decoder in order to access all |
|
| 1229 |
+ * channels. |
|
| 1230 |
+ * |
|
| 1231 |
+ * encoding: unused |
|
| 1232 |
+ * decoding: set by AVCodecContext.get_buffer() |
|
| 1233 |
+ */ |
|
| 1234 |
+ uint8_t **extended_data; |
|
| 1235 |
+ |
|
| 1236 |
+ /** |
|
| 1210 | 1237 |
* frame timestamp estimated using various heuristics, in stream time base |
| 1211 | 1238 |
* - encoding: unused |
| 1212 | 1239 |
* - decoding: set by libavcodec, read by user. |
| ... | ... |
@@ -1379,7 +1424,7 @@ typedef struct AVCodecContext {
|
| 1379 | 1379 |
* @param offset offset into the AVFrame.data from which the slice should be read |
| 1380 | 1380 |
*/ |
| 1381 | 1381 |
void (*draw_horiz_band)(struct AVCodecContext *s, |
| 1382 |
- const AVFrame *src, int offset[4], |
|
| 1382 |
+ const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], |
|
| 1383 | 1383 |
int y, int type, int height); |
| 1384 | 1384 |
|
| 1385 | 1385 |
/* audio only */ |
| ... | ... |
@@ -1602,15 +1647,56 @@ typedef struct AVCodecContext {
|
| 1602 | 1602 |
|
| 1603 | 1603 |
/** |
| 1604 | 1604 |
* 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. |
|
| 1605 |
+ * |
|
| 1606 |
+ * The function will set AVFrame.data[], AVFrame.linesize[]. |
|
| 1607 |
+ * AVFrame.extended_data[] must also be set, but it should be the same as |
|
| 1608 |
+ * AVFrame.data[] except for planar audio with more channels than can fit |
|
| 1609 |
+ * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as |
|
| 1610 |
+ * many data pointers as it can hold. |
|
| 1611 |
+ * |
|
| 1608 | 1612 |
* if CODEC_CAP_DR1 is not set then get_buffer() must call |
| 1609 | 1613 |
* avcodec_default_get_buffer() instead of providing buffers allocated by |
| 1610 | 1614 |
* some other means. |
| 1615 |
+ * |
|
| 1616 |
+ * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't |
|
| 1617 |
+ * need it. avcodec_default_get_buffer() aligns the output buffer properly, |
|
| 1618 |
+ * but if get_buffer() is overridden then alignment considerations should |
|
| 1619 |
+ * be taken into account. |
|
| 1620 |
+ * |
|
| 1621 |
+ * @see avcodec_default_get_buffer() |
|
| 1622 |
+ * |
|
| 1623 |
+ * Video: |
|
| 1624 |
+ * |
|
| 1625 |
+ * If pic.reference is set then the frame will be read later by libavcodec. |
|
| 1626 |
+ * avcodec_align_dimensions2() should be used to find the required width and |
|
| 1627 |
+ * height, as they normally need to be rounded up to the next multiple of 16. |
|
| 1628 |
+ * |
|
| 1611 | 1629 |
* 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. |
|
| 1630 |
+ * it may be called from a different thread, but not from more than one at |
|
| 1631 |
+ * once. Does not need to be reentrant. |
|
| 1632 |
+ * |
|
| 1633 |
+ * @see release_buffer(), reget_buffer() |
|
| 1634 |
+ * @see avcodec_align_dimensions2() |
|
| 1635 |
+ * |
|
| 1636 |
+ * Audio: |
|
| 1637 |
+ * |
|
| 1638 |
+ * Decoders request a buffer of a particular size by setting |
|
| 1639 |
+ * AVFrame.nb_samples prior to calling get_buffer(). The decoder may, |
|
| 1640 |
+ * however, utilize only part of the buffer by setting AVFrame.nb_samples |
|
| 1641 |
+ * to a smaller value in the output frame. |
|
| 1642 |
+ * |
|
| 1643 |
+ * Decoders cannot use the buffer after returning from |
|
| 1644 |
+ * avcodec_decode_audio4(), so they will not call release_buffer(), as it |
|
| 1645 |
+ * is assumed to be released immediately upon return. |
|
| 1646 |
+ * |
|
| 1647 |
+ * As a convenience, av_samples_get_buffer_size() and |
|
| 1648 |
+ * av_samples_fill_arrays() in libavutil may be used by custom get_buffer() |
|
| 1649 |
+ * functions to find the required data size and to fill data pointers and |
|
| 1650 |
+ * linesize. In AVFrame.linesize, only linesize[0] may be set for audio |
|
| 1651 |
+ * since all planes must be the same size. |
|
| 1652 |
+ * |
|
| 1653 |
+ * @see av_samples_get_buffer_size(), av_samples_fill_arrays() |
|
| 1654 |
+ * |
|
| 1614 | 1655 |
* - encoding: unused |
| 1615 | 1656 |
* - decoding: Set by libavcodec, user can override. |
| 1616 | 1657 |
*/ |
| ... | ... |
@@ -1929,7 +2015,7 @@ typedef struct AVCodecContext {
|
| 1929 | 1929 |
* - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. |
| 1930 | 1930 |
* - decoding: unused |
| 1931 | 1931 |
*/ |
| 1932 |
- uint64_t error[4]; |
|
| 1932 |
+ uint64_t error[AV_NUM_DATA_POINTERS]; |
|
| 1933 | 1933 |
|
| 1934 | 1934 |
/** |
| 1935 | 1935 |
* motion estimation comparison function |
| ... | ... |
@@ -3253,8 +3339,8 @@ typedef struct AVHWAccel {
|
| 3253 | 3253 |
* the last component is alpha |
| 3254 | 3254 |
*/ |
| 3255 | 3255 |
typedef struct AVPicture {
|
| 3256 |
- uint8_t *data[4]; |
|
| 3257 |
- int linesize[4]; ///< number of bytes per line |
|
| 3256 |
+ uint8_t *data[AV_NUM_DATA_POINTERS]; |
|
| 3257 |
+ int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line |
|
| 3258 | 3258 |
} AVPicture; |
| 3259 | 3259 |
|
| 3260 | 3260 |
#define AVPALETTE_SIZE 1024 |
| ... | ... |
@@ -3922,7 +4008,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); |
| 3922 | 3922 |
* according to avcodec_get_edge_width() before. |
| 3923 | 3923 |
*/ |
| 3924 | 3924 |
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, |
| 3925 |
- int linesize_align[4]); |
|
| 3925 |
+ int linesize_align[AV_NUM_DATA_POINTERS]); |
|
| 3926 | 3926 |
|
| 3927 | 3927 |
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); |
| 3928 | 3928 |
|
| ... | ... |
@@ -4005,7 +4091,12 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec); |
| 4005 | 4005 |
*/ |
| 4006 | 4006 |
int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options); |
| 4007 | 4007 |
|
| 4008 |
+#if FF_API_OLD_DECODE_AUDIO |
|
| 4008 | 4009 |
/** |
| 4010 |
+ * Wrapper function which calls avcodec_decode_audio4. |
|
| 4011 |
+ * |
|
| 4012 |
+ * @deprecated Use avcodec_decode_audio4 instead. |
|
| 4013 |
+ * |
|
| 4009 | 4014 |
* Decode the audio frame of size avpkt->size from avpkt->data into samples. |
| 4010 | 4015 |
* Some decoders may support multiple frames in a single AVPacket, such |
| 4011 | 4016 |
* decoders would then just decode the first frame. In this case, |
| ... | ... |
@@ -4040,6 +4131,8 @@ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) |
| 4040 | 4040 |
* |
| 4041 | 4041 |
* @param avctx the codec context |
| 4042 | 4042 |
* @param[out] samples the output buffer, sample type in avctx->sample_fmt |
| 4043 |
+ * If the sample format is planar, each channel plane will |
|
| 4044 |
+ * be the same size, with no padding between channels. |
|
| 4043 | 4045 |
* @param[in,out] frame_size_ptr the output buffer size in bytes |
| 4044 | 4046 |
* @param[in] avpkt The input AVPacket containing the input buffer. |
| 4045 | 4047 |
* 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) |
| 4048 | 4048 |
* @return On error a negative value is returned, otherwise the number of bytes |
| 4049 | 4049 |
* used or zero if no frame data was decompressed (used) from the input AVPacket. |
| 4050 | 4050 |
*/ |
| 4051 |
-int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, |
|
| 4051 |
+attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, |
|
| 4052 | 4052 |
int *frame_size_ptr, |
| 4053 | 4053 |
AVPacket *avpkt); |
| 4054 |
+#endif |
|
| 4055 |
+ |
|
| 4056 |
+/** |
|
| 4057 |
+ * Decode the audio frame of size avpkt->size from avpkt->data into frame. |
|
| 4058 |
+ * |
|
| 4059 |
+ * Some decoders may support multiple frames in a single AVPacket. Such |
|
| 4060 |
+ * decoders would then just decode the first frame. In this case, |
|
| 4061 |
+ * avcodec_decode_audio4 has to be called again with an AVPacket containing |
|
| 4062 |
+ * the remaining data in order to decode the second frame, etc... |
|
| 4063 |
+ * Even if no frames are returned, the packet needs to be fed to the decoder |
|
| 4064 |
+ * with remaining data until it is completely consumed or an error occurs. |
|
| 4065 |
+ * |
|
| 4066 |
+ * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE |
|
| 4067 |
+ * larger than the actual read bytes because some optimized bitstream |
|
| 4068 |
+ * readers read 32 or 64 bits at once and could read over the end. |
|
| 4069 |
+ * |
|
| 4070 |
+ * @note You might have to align the input buffer. The alignment requirements |
|
| 4071 |
+ * depend on the CPU and the decoder. |
|
| 4072 |
+ * |
|
| 4073 |
+ * @param avctx the codec context |
|
| 4074 |
+ * @param[out] frame The AVFrame in which to store decoded audio samples. |
|
| 4075 |
+ * Decoders request a buffer of a particular size by setting |
|
| 4076 |
+ * AVFrame.nb_samples prior to calling get_buffer(). The |
|
| 4077 |
+ * decoder may, however, only utilize part of the buffer by |
|
| 4078 |
+ * setting AVFrame.nb_samples to a smaller value in the |
|
| 4079 |
+ * output frame. |
|
| 4080 |
+ * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is |
|
| 4081 |
+ * non-zero. |
|
| 4082 |
+ * @param[in] avpkt The input AVPacket containing the input buffer. |
|
| 4083 |
+ * At least avpkt->data and avpkt->size should be set. Some |
|
| 4084 |
+ * decoders might also require additional fields to be set. |
|
| 4085 |
+ * @return A negative error code is returned if an error occurred during |
|
| 4086 |
+ * decoding, otherwise the number of bytes consumed from the input |
|
| 4087 |
+ * AVPacket is returned. |
|
| 4088 |
+ */ |
|
| 4089 |
+int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, |
|
| 4090 |
+ int *got_frame_ptr, AVPacket *avpkt); |
|
| 4054 | 4091 |
|
| 4055 | 4092 |
/** |
| 4056 | 4093 |
* Decode the video frame of size avpkt->size from avpkt->data into picture. |
| ... | ... |
@@ -45,6 +45,7 @@ static float quant_table[96]; |
| 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) |
| 147 | 147 |
else |
| 148 | 148 |
return -1; |
| 149 | 149 |
|
| 150 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 151 |
+ avctx->coded_frame = &s->frame; |
|
| 152 |
+ |
|
| 150 | 153 |
return 0; |
| 151 | 154 |
} |
| 152 | 155 |
|
| ... | ... |
@@ -293,6 +297,7 @@ static av_cold int decode_end(AVCodecContext *avctx) |
| 293 | 293 |
ff_rdft_end(&s->trans.rdft); |
| 294 | 294 |
else if (CONFIG_BINKAUDIO_DCT_DECODER) |
| 295 | 295 |
ff_dct_end(&s->trans.dct); |
| 296 |
+ |
|
| 296 | 297 |
return 0; |
| 297 | 298 |
} |
| 298 | 299 |
|
| ... | ... |
@@ -302,20 +307,19 @@ static void get_bits_align32(GetBitContext *s) |
| 302 | 302 |
if (n) skip_bits(s, n); |
| 303 | 303 |
} |
| 304 | 304 |
|
| 305 |
-static int decode_frame(AVCodecContext *avctx, |
|
| 306 |
- void *data, int *data_size, |
|
| 307 |
- AVPacket *avpkt) |
|
| 305 |
+static int decode_frame(AVCodecContext *avctx, void *data, |
|
| 306 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 308 | 307 |
{
|
| 309 | 308 |
BinkAudioContext *s = avctx->priv_data; |
| 310 |
- int16_t *samples = data; |
|
| 309 |
+ int16_t *samples; |
|
| 311 | 310 |
GetBitContext *gb = &s->gb; |
| 312 |
- int out_size, consumed = 0; |
|
| 311 |
+ int ret, consumed = 0; |
|
| 313 | 312 |
|
| 314 | 313 |
if (!get_bits_left(gb)) {
|
| 315 | 314 |
uint8_t *buf; |
| 316 | 315 |
/* handle end-of-stream */ |
| 317 | 316 |
if (!avpkt->size) {
|
| 318 |
- *data_size = 0; |
|
| 317 |
+ *got_frame_ptr = 0; |
|
| 319 | 318 |
return 0; |
| 320 | 319 |
} |
| 321 | 320 |
if (avpkt->size < 4) {
|
| ... | ... |
@@ -334,11 +338,13 @@ static int decode_frame(AVCodecContext *avctx, |
| 334 | 334 |
skip_bits_long(gb, 32); |
| 335 | 335 |
} |
| 336 | 336 |
|
| 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); |
|
| 337 |
+ /* get output buffer */ |
|
| 338 |
+ s->frame.nb_samples = s->block_size / avctx->channels; |
|
| 339 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 340 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 341 |
+ return ret; |
|
| 341 | 342 |
} |
| 343 |
+ samples = (int16_t *)s->frame.data[0]; |
|
| 342 | 344 |
|
| 343 | 345 |
if (decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT)) {
|
| 344 | 346 |
av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n"); |
| ... | ... |
@@ -346,7 +352,9 @@ static int decode_frame(AVCodecContext *avctx, |
| 346 | 346 |
} |
| 347 | 347 |
get_bits_align32(gb); |
| 348 | 348 |
|
| 349 |
- *data_size = out_size; |
|
| 349 |
+ *got_frame_ptr = 1; |
|
| 350 |
+ *(AVFrame *)data = s->frame; |
|
| 351 |
+ |
|
| 350 | 352 |
return consumed; |
| 351 | 353 |
} |
| 352 | 354 |
|
| ... | ... |
@@ -358,7 +366,7 @@ AVCodec ff_binkaudio_rdft_decoder = {
|
| 358 | 358 |
.init = decode_init, |
| 359 | 359 |
.close = decode_end, |
| 360 | 360 |
.decode = decode_frame, |
| 361 |
- .capabilities = CODEC_CAP_DELAY, |
|
| 361 |
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, |
|
| 362 | 362 |
.long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)")
|
| 363 | 363 |
}; |
| 364 | 364 |
|
| ... | ... |
@@ -370,6 +378,6 @@ AVCodec ff_binkaudio_dct_decoder = {
|
| 370 | 370 |
.init = decode_init, |
| 371 | 371 |
.close = decode_end, |
| 372 | 372 |
.decode = decode_frame, |
| 373 |
- .capabilities = CODEC_CAP_DELAY, |
|
| 373 |
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, |
|
| 374 | 374 |
.long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)")
|
| 375 | 375 |
}; |
| ... | ... |
@@ -122,6 +122,7 @@ typedef struct cook {
|
| 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 {
|
| 131 | 131 |
int samples_per_channel; |
| 132 | 132 |
/* states */ |
| 133 | 133 |
AVLFG random_state; |
| 134 |
+ int discarded_packets; |
|
| 134 | 135 |
|
| 135 | 136 |
/* transform data */ |
| 136 | 137 |
FFTContext mdct_ctx; |
| ... | ... |
@@ -896,7 +898,8 @@ mlt_compensate_output(COOKContext *q, float *decode_buffer, |
| 896 | 896 |
float *out, int chan) |
| 897 | 897 |
{
|
| 898 | 898 |
imlt_gain(q, decode_buffer, gains_ptr, previous_buffer); |
| 899 |
- q->saturate_output (q, chan, out); |
|
| 899 |
+ if (out) |
|
| 900 |
+ q->saturate_output(q, chan, out); |
|
| 900 | 901 |
} |
| 901 | 902 |
|
| 902 | 903 |
|
| ... | ... |
@@ -953,24 +956,28 @@ static void decode_subpacket(COOKContext *q, COOKSubpacket *p, |
| 953 | 953 |
* @param avctx pointer to the AVCodecContext |
| 954 | 954 |
*/ |
| 955 | 955 |
|
| 956 |
-static int cook_decode_frame(AVCodecContext *avctx, |
|
| 957 |
- void *data, int *data_size, |
|
| 958 |
- AVPacket *avpkt) {
|
|
| 956 |
+static int cook_decode_frame(AVCodecContext *avctx, void *data, |
|
| 957 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 958 |
+{
|
|
| 959 | 959 |
const uint8_t *buf = avpkt->data; |
| 960 | 960 |
int buf_size = avpkt->size; |
| 961 | 961 |
COOKContext *q = avctx->priv_data; |
| 962 |
- int i, out_size; |
|
| 962 |
+ float *samples = NULL; |
|
| 963 |
+ int i, ret; |
|
| 963 | 964 |
int offset = 0; |
| 964 | 965 |
int chidx = 0; |
| 965 | 966 |
|
| 966 | 967 |
if (buf_size < avctx->block_align) |
| 967 | 968 |
return buf_size; |
| 968 | 969 |
|
| 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); |
|
| 970 |
+ /* get output buffer */ |
|
| 971 |
+ if (q->discarded_packets >= 2) {
|
|
| 972 |
+ q->frame.nb_samples = q->samples_per_channel; |
|
| 973 |
+ if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
|
|
| 974 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 975 |
+ return ret; |
|
| 976 |
+ } |
|
| 977 |
+ samples = (float *)q->frame.data[0]; |
|
| 974 | 978 |
} |
| 975 | 979 |
|
| 976 | 980 |
/* estimate subpacket sizes */ |
| ... | ... |
@@ -990,15 +997,21 @@ static int cook_decode_frame(AVCodecContext *avctx, |
| 990 | 990 |
q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv; |
| 991 | 991 |
q->subpacket[i].ch_idx = chidx; |
| 992 | 992 |
av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align); |
| 993 |
- decode_subpacket(q, &q->subpacket[i], buf + offset, data); |
|
| 993 |
+ decode_subpacket(q, &q->subpacket[i], buf + offset, samples); |
|
| 994 | 994 |
offset += q->subpacket[i].size; |
| 995 | 995 |
chidx += q->subpacket[i].num_channels; |
| 996 | 996 |
av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb)); |
| 997 | 997 |
} |
| 998 |
- *data_size = out_size; |
|
| 999 | 998 |
|
| 1000 | 999 |
/* Discard the first two frames: no valid audio. */ |
| 1001 |
- if (avctx->frame_number < 2) *data_size = 0; |
|
| 1000 |
+ if (q->discarded_packets < 2) {
|
|
| 1001 |
+ q->discarded_packets++; |
|
| 1002 |
+ *got_frame_ptr = 0; |
|
| 1003 |
+ return avctx->block_align; |
|
| 1004 |
+ } |
|
| 1005 |
+ |
|
| 1006 |
+ *got_frame_ptr = 1; |
|
| 1007 |
+ *(AVFrame *)data = q->frame; |
|
| 1002 | 1008 |
|
| 1003 | 1009 |
return avctx->block_align; |
| 1004 | 1010 |
} |
| ... | ... |
@@ -1246,6 +1259,9 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) |
| 1246 | 1246 |
else |
| 1247 | 1247 |
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; |
| 1248 | 1248 |
|
| 1249 |
+ avcodec_get_frame_defaults(&q->frame); |
|
| 1250 |
+ avctx->coded_frame = &q->frame; |
|
| 1251 |
+ |
|
| 1249 | 1252 |
#ifdef DEBUG |
| 1250 | 1253 |
dump_cook_context(q); |
| 1251 | 1254 |
#endif |
| ... | ... |
@@ -1262,5 +1278,6 @@ AVCodec ff_cook_decoder = |
| 1262 | 1262 |
.init = cook_decode_init, |
| 1263 | 1263 |
.close = cook_decode_close, |
| 1264 | 1264 |
.decode = cook_decode_frame, |
| 1265 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1265 | 1266 |
.long_name = NULL_IF_CONFIG_SMALL("COOK"),
|
| 1266 | 1267 |
}; |
| ... | ... |
@@ -261,6 +261,7 @@ static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int id |
| 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) |
| 1634 | 1634 |
* Main frame decoding function |
| 1635 | 1635 |
* FIXME add arguments |
| 1636 | 1636 |
*/ |
| 1637 |
-static int dca_decode_frame(AVCodecContext * avctx, |
|
| 1638 |
- void *data, int *data_size, |
|
| 1639 |
- AVPacket *avpkt) |
|
| 1637 |
+static int dca_decode_frame(AVCodecContext *avctx, void *data, |
|
| 1638 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1640 | 1639 |
{
|
| 1641 | 1640 |
const uint8_t *buf = avpkt->data; |
| 1642 | 1641 |
int buf_size = avpkt->size; |
| ... | ... |
@@ -1644,9 +1644,8 @@ static int dca_decode_frame(AVCodecContext * avctx, |
| 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, |
| 1832 | 1832 |
avctx->channels = channels; |
| 1833 | 1833 |
} |
| 1834 | 1834 |
|
| 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; |
|
| 1835 |
+ /* get output buffer */ |
|
| 1836 |
+ s->frame.nb_samples = 256 * (s->sample_blocks / 8); |
|
| 1837 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 1838 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1839 |
+ return ret; |
|
| 1840 |
+ } |
|
| 1841 |
+ samples_flt = (float *)s->frame.data[0]; |
|
| 1842 |
+ samples_s16 = (int16_t *)s->frame.data[0]; |
|
| 1840 | 1843 |
|
| 1841 | 1844 |
/* filter to get final output */ |
| 1842 | 1845 |
for (i = 0; i < (s->sample_blocks / 8); i++) {
|
| ... | ... |
@@ -1870,6 +1872,9 @@ static int dca_decode_frame(AVCodecContext * avctx, |
| 1870 | 1870 |
s->lfe_data[i] = s->lfe_data[i + lfe_samples]; |
| 1871 | 1871 |
} |
| 1872 | 1872 |
|
| 1873 |
+ *got_frame_ptr = 1; |
|
| 1874 |
+ *(AVFrame *)data = s->frame; |
|
| 1875 |
+ |
|
| 1873 | 1876 |
return buf_size; |
| 1874 | 1877 |
} |
| 1875 | 1878 |
|
| ... | ... |
@@ -1912,6 +1917,9 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) |
| 1912 | 1912 |
avctx->channels = avctx->request_channels; |
| 1913 | 1913 |
} |
| 1914 | 1914 |
|
| 1915 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 1916 |
+ avctx->coded_frame = &s->frame; |
|
| 1917 |
+ |
|
| 1915 | 1918 |
return 0; |
| 1916 | 1919 |
} |
| 1917 | 1920 |
|
| ... | ... |
@@ -1940,7 +1948,7 @@ AVCodec ff_dca_decoder = {
|
| 1940 | 1940 |
.decode = dca_decode_frame, |
| 1941 | 1941 |
.close = dca_decode_end, |
| 1942 | 1942 |
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
|
| 1943 |
- .capabilities = CODEC_CAP_CHANNEL_CONF, |
|
| 1943 |
+ .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, |
|
| 1944 | 1944 |
.sample_fmts = (const enum AVSampleFormat[]) {
|
| 1945 | 1945 |
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
| 1946 | 1946 |
}, |
| ... | ... |
@@ -42,6 +42,7 @@ |
| 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) |
| 162 | 162 |
else |
| 163 | 163 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 164 | 164 |
|
| 165 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 166 |
+ avctx->coded_frame = &s->frame; |
|
| 167 |
+ |
|
| 165 | 168 |
return 0; |
| 166 | 169 |
} |
| 167 | 170 |
|
| 168 | 171 |
|
| 169 |
-static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
|
| 170 |
- AVPacket *avpkt) |
|
| 172 |
+static int dpcm_decode_frame(AVCodecContext *avctx, void *data, |
|
| 173 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 171 | 174 |
{
|
| 172 | 175 |
const uint8_t *buf = avpkt->data; |
| 173 | 176 |
int buf_size = avpkt->size; |
| 174 | 177 |
const uint8_t *buf_end = buf + buf_size; |
| 175 | 178 |
DPCMContext *s = avctx->priv_data; |
| 176 |
- int out = 0; |
|
| 179 |
+ int out = 0, ret; |
|
| 177 | 180 |
int predictor[2]; |
| 178 | 181 |
int ch = 0; |
| 179 | 182 |
int stereo = s->channels - 1; |
| 180 |
- int16_t *output_samples = data; |
|
| 183 |
+ int16_t *output_samples; |
|
| 181 | 184 |
|
| 182 | 185 |
/* calculate output size */ |
| 183 | 186 |
switch(avctx->codec->id) {
|
| ... | ... |
@@ -197,15 +201,18 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 197 | 197 |
out = buf_size; |
| 198 | 198 |
break; |
| 199 | 199 |
} |
| 200 |
- out *= av_get_bytes_per_sample(avctx->sample_fmt); |
|
| 201 | 200 |
if (out <= 0) {
|
| 202 | 201 |
av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); |
| 203 | 202 |
return AVERROR(EINVAL); |
| 204 | 203 |
} |
| 205 |
- if (*data_size < out) {
|
|
| 206 |
- av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); |
|
| 207 |
- return AVERROR(EINVAL); |
|
| 204 |
+ |
|
| 205 |
+ /* get output buffer */ |
|
| 206 |
+ s->frame.nb_samples = out / s->channels; |
|
| 207 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 208 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 209 |
+ return ret; |
|
| 208 | 210 |
} |
| 211 |
+ output_samples = (int16_t *)s->frame.data[0]; |
|
| 209 | 212 |
|
| 210 | 213 |
switch(avctx->codec->id) {
|
| 211 | 214 |
|
| ... | ... |
@@ -307,7 +314,9 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 307 | 307 |
break; |
| 308 | 308 |
} |
| 309 | 309 |
|
| 310 |
- *data_size = out; |
|
| 310 |
+ *got_frame_ptr = 1; |
|
| 311 |
+ *(AVFrame *)data = s->frame; |
|
| 312 |
+ |
|
| 311 | 313 |
return buf_size; |
| 312 | 314 |
} |
| 313 | 315 |
|
| ... | ... |
@@ -319,6 +328,7 @@ AVCodec ff_ ## name_ ## _decoder = { \
|
| 319 | 319 |
.priv_data_size = sizeof(DPCMContext), \ |
| 320 | 320 |
.init = dpcm_decode_init, \ |
| 321 | 321 |
.decode = dpcm_decode_frame, \ |
| 322 |
+ .capabilities = CODEC_CAP_DR1, \ |
|
| 322 | 323 |
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ |
| 323 | 324 |
} |
| 324 | 325 |
|
| ... | ... |
@@ -44,6 +44,7 @@ typedef struct CinVideoContext {
|
| 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) |
| 318 | 318 |
cin->delta = 0; |
| 319 | 319 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 320 | 320 |
|
| 321 |
+ avcodec_get_frame_defaults(&cin->frame); |
|
| 322 |
+ avctx->coded_frame = &cin->frame; |
|
| 323 |
+ |
|
| 321 | 324 |
return 0; |
| 322 | 325 |
} |
| 323 | 326 |
|
| 324 |
-static int cinaudio_decode_frame(AVCodecContext *avctx, |
|
| 325 |
- void *data, int *data_size, |
|
| 326 |
- AVPacket *avpkt) |
|
| 327 |
+static int cinaudio_decode_frame(AVCodecContext *avctx, void *data, |
|
| 328 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 327 | 329 |
{
|
| 328 | 330 |
const uint8_t *buf = avpkt->data; |
| 329 | 331 |
CinAudioContext *cin = avctx->priv_data; |
| 330 | 332 |
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); |
|
| 333 |
+ int16_t *samples; |
|
| 334 |
+ int delta, ret; |
|
| 335 |
+ |
|
| 336 |
+ /* get output buffer */ |
|
| 337 |
+ cin->frame.nb_samples = avpkt->size - cin->initial_decode_frame; |
|
| 338 |
+ if ((ret = avctx->get_buffer(avctx, &cin->frame)) < 0) {
|
|
| 339 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 340 |
+ return ret; |
|
| 339 | 341 |
} |
| 342 |
+ samples = (int16_t *)cin->frame.data[0]; |
|
| 340 | 343 |
|
| 341 | 344 |
delta = cin->delta; |
| 342 | 345 |
if (cin->initial_decode_frame) {
|
| ... | ... |
@@ -352,7 +356,8 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, |
| 352 | 352 |
} |
| 353 | 353 |
cin->delta = delta; |
| 354 | 354 |
|
| 355 |
- *data_size = out_size; |
|
| 355 |
+ *got_frame_ptr = 1; |
|
| 356 |
+ *(AVFrame *)data = cin->frame; |
|
| 356 | 357 |
|
| 357 | 358 |
return avpkt->size; |
| 358 | 359 |
} |
| ... | ... |
@@ -377,5 +382,6 @@ AVCodec ff_dsicinaudio_decoder = {
|
| 377 | 377 |
.priv_data_size = sizeof(CinAudioContext), |
| 378 | 378 |
.init = cinaudio_decode_init, |
| 379 | 379 |
.decode = cinaudio_decode_frame, |
| 380 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 380 | 381 |
.long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"),
|
| 381 | 382 |
}; |
| ... | ... |
@@ -49,6 +49,7 @@ typedef struct FLACContext {
|
| 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) |
| 116 | 116 |
allocate_buffers(s); |
| 117 | 117 |
s->got_streaminfo = 1; |
| 118 | 118 |
|
| 119 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 120 |
+ avctx->coded_frame = &s->frame; |
|
| 121 |
+ |
|
| 119 | 122 |
return 0; |
| 120 | 123 |
} |
| 121 | 124 |
|
| ... | ... |
@@ -542,20 +546,18 @@ static int decode_frame(FLACContext *s) |
| 542 | 542 |
return 0; |
| 543 | 543 |
} |
| 544 | 544 |
|
| 545 |
-static int flac_decode_frame(AVCodecContext *avctx, |
|
| 546 |
- void *data, int *data_size, |
|
| 547 |
- AVPacket *avpkt) |
|
| 545 |
+static int flac_decode_frame(AVCodecContext *avctx, void *data, |
|
| 546 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 548 | 547 |
{
|
| 549 | 548 |
const uint8_t *buf = avpkt->data; |
| 550 | 549 |
int buf_size = avpkt->size; |
| 551 | 550 |
FLACContext *s = avctx->priv_data; |
| 552 | 551 |
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; |
|
| 552 |
+ int16_t *samples_16; |
|
| 553 |
+ int32_t *samples_32; |
|
| 554 |
+ int ret; |
|
| 557 | 555 |
|
| 558 |
- *data_size=0; |
|
| 556 |
+ *got_frame_ptr = 0; |
|
| 559 | 557 |
|
| 560 | 558 |
if (s->max_framesize == 0) {
|
| 561 | 559 |
s->max_framesize = |
| ... | ... |
@@ -586,15 +588,14 @@ static int flac_decode_frame(AVCodecContext *avctx, |
| 586 | 586 |
} |
| 587 | 587 |
bytes_read = (get_bits_count(&s->gb)+7)/8; |
| 588 | 588 |
|
| 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; |
|
| 589 |
+ /* get output buffer */ |
|
| 590 |
+ s->frame.nb_samples = s->blocksize; |
|
| 591 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 592 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 593 |
+ return ret; |
|
| 596 | 594 |
} |
| 597 |
- *data_size = output_size; |
|
| 595 |
+ samples_16 = (int16_t *)s->frame.data[0]; |
|
| 596 |
+ samples_32 = (int32_t *)s->frame.data[0]; |
|
| 598 | 597 |
|
| 599 | 598 |
#define DECORRELATE(left, right)\ |
| 600 | 599 |
assert(s->channels == 2);\ |
| ... | ... |
@@ -639,6 +640,9 @@ static int flac_decode_frame(AVCodecContext *avctx, |
| 639 | 639 |
buf_size - bytes_read, buf_size); |
| 640 | 640 |
} |
| 641 | 641 |
|
| 642 |
+ *got_frame_ptr = 1; |
|
| 643 |
+ *(AVFrame *)data = s->frame; |
|
| 644 |
+ |
|
| 642 | 645 |
return bytes_read; |
| 643 | 646 |
} |
| 644 | 647 |
|
| ... | ... |
@@ -662,5 +666,6 @@ AVCodec ff_flac_decoder = {
|
| 662 | 662 |
.init = flac_decode_init, |
| 663 | 663 |
.close = flac_decode_close, |
| 664 | 664 |
.decode = flac_decode_frame, |
| 665 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 665 | 666 |
.long_name= NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
|
| 666 | 667 |
}; |
| ... | ... |
@@ -26,10 +26,12 @@ |
| 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) |
| 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,
|
| 81 | 81 |
ff_g722_low_inv_quant4 }; |
| 82 | 82 |
|
| 83 | 83 |
static int g722_decode_frame(AVCodecContext *avctx, void *data, |
| 84 |
- int *data_size, AVPacket *avpkt) |
|
| 84 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 85 | 85 |
{
|
| 86 | 86 |
G722Context *c = avctx->priv_data; |
| 87 |
- int16_t *out_buf = data; |
|
| 88 |
- int j, out_len; |
|
| 87 |
+ int16_t *out_buf; |
|
| 88 |
+ int j, ret; |
|
| 89 | 89 |
const int skip = 8 - avctx->bits_per_coded_sample; |
| 90 | 90 |
const int16_t *quantizer_table = low_inv_quants[skip]; |
| 91 | 91 |
GetBitContext gb; |
| 92 | 92 |
|
| 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); |
|
| 93 |
+ /* get output buffer */ |
|
| 94 |
+ c->frame.nb_samples = avpkt->size * 2; |
|
| 95 |
+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
|
| 96 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 97 |
+ return ret; |
|
| 97 | 98 |
} |
| 99 |
+ out_buf = (int16_t *)c->frame.data[0]; |
|
| 98 | 100 |
|
| 99 | 101 |
init_get_bits(&gb, avpkt->data, avpkt->size * 8); |
| 100 | 102 |
|
| ... | ... |
@@ -128,7 +133,10 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data, |
| 128 | 128 |
c->prev_samples_pos = 22; |
| 129 | 129 |
} |
| 130 | 130 |
} |
| 131 |
- *data_size = out_len; |
|
| 131 |
+ |
|
| 132 |
+ *got_frame_ptr = 1; |
|
| 133 |
+ *(AVFrame *)data = c->frame; |
|
| 134 |
+ |
|
| 132 | 135 |
return avpkt->size; |
| 133 | 136 |
} |
| 134 | 137 |
|
| ... | ... |
@@ -139,5 +147,6 @@ AVCodec ff_adpcm_g722_decoder = {
|
| 139 | 139 |
.priv_data_size = sizeof(G722Context), |
| 140 | 140 |
.init = g722_decode_init, |
| 141 | 141 |
.decode = g722_decode_frame, |
| 142 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 142 | 143 |
.long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
|
| 143 | 144 |
}; |
| ... | ... |
@@ -75,6 +75,7 @@ typedef struct G726Tables {
|
| 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) |
| 427 | 427 |
|
| 428 | 428 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 429 | 429 |
|
| 430 |
+ avcodec_get_frame_defaults(&c->frame); |
|
| 431 |
+ avctx->coded_frame = &c->frame; |
|
| 432 |
+ |
|
| 430 | 433 |
return 0; |
| 431 | 434 |
} |
| 432 | 435 |
|
| 433 |
-static int g726_decode_frame(AVCodecContext *avctx, |
|
| 434 |
- void *data, int *data_size, |
|
| 435 |
- AVPacket *avpkt) |
|
| 436 |
+static int g726_decode_frame(AVCodecContext *avctx, void *data, |
|
| 437 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 436 | 438 |
{
|
| 437 | 439 |
const uint8_t *buf = avpkt->data; |
| 438 | 440 |
int buf_size = avpkt->size; |
| 439 | 441 |
G726Context *c = avctx->priv_data; |
| 440 |
- int16_t *samples = data; |
|
| 442 |
+ int16_t *samples; |
|
| 441 | 443 |
GetBitContext gb; |
| 442 |
- int out_samples, out_size; |
|
| 444 |
+ int out_samples, ret; |
|
| 443 | 445 |
|
| 444 | 446 |
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); |
|
| 447 |
+ |
|
| 448 |
+ /* get output buffer */ |
|
| 449 |
+ c->frame.nb_samples = out_samples; |
|
| 450 |
+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
|
| 451 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 452 |
+ return ret; |
|
| 449 | 453 |
} |
| 454 |
+ samples = (int16_t *)c->frame.data[0]; |
|
| 450 | 455 |
|
| 451 | 456 |
init_get_bits(&gb, buf, buf_size * 8); |
| 452 | 457 |
|
| ... | ... |
@@ -456,7 +462,9 @@ static int g726_decode_frame(AVCodecContext *avctx, |
| 456 | 456 |
if (get_bits_left(&gb) > 0) |
| 457 | 457 |
av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n"); |
| 458 | 458 |
|
| 459 |
- *data_size = out_size; |
|
| 459 |
+ *got_frame_ptr = 1; |
|
| 460 |
+ *(AVFrame *)data = c->frame; |
|
| 461 |
+ |
|
| 460 | 462 |
return buf_size; |
| 461 | 463 |
} |
| 462 | 464 |
|
| ... | ... |
@@ -474,6 +482,7 @@ AVCodec ff_adpcm_g726_decoder = {
|
| 474 | 474 |
.init = g726_decode_init, |
| 475 | 475 |
.decode = g726_decode_frame, |
| 476 | 476 |
.flush = g726_decode_flush, |
| 477 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 477 | 478 |
.long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"),
|
| 478 | 479 |
}; |
| 479 | 480 |
#endif |
| ... | ... |
@@ -32,6 +32,8 @@ |
| 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) |
| 47 | 47 |
avctx->block_align = GSM_MS_BLOCK_SIZE; |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 51 |
+ avctx->coded_frame = &s->frame; |
|
| 52 |
+ |
|
| 50 | 53 |
return 0; |
| 51 | 54 |
} |
| 52 | 55 |
|
| 53 | 56 |
static int gsm_decode_frame(AVCodecContext *avctx, void *data, |
| 54 |
- int *data_size, AVPacket *avpkt) |
|
| 57 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 55 | 58 |
{
|
| 59 |
+ GSMContext *s = avctx->priv_data; |
|
| 56 | 60 |
int res; |
| 57 | 61 |
GetBitContext gb; |
| 58 | 62 |
const uint8_t *buf = avpkt->data; |
| 59 | 63 |
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 |
- } |
|
| 64 |
+ int16_t *samples; |
|
| 68 | 65 |
|
| 69 | 66 |
if (buf_size < avctx->block_align) {
|
| 70 | 67 |
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); |
| 71 | 68 |
return AVERROR_INVALIDDATA; |
| 72 | 69 |
} |
| 73 | 70 |
|
| 71 |
+ /* get output buffer */ |
|
| 72 |
+ s->frame.nb_samples = avctx->frame_size; |
|
| 73 |
+ if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 74 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 75 |
+ return res; |
|
| 76 |
+ } |
|
| 77 |
+ samples = (int16_t *)s->frame.data[0]; |
|
| 78 |
+ |
|
| 74 | 79 |
switch (avctx->codec_id) {
|
| 75 | 80 |
case CODEC_ID_GSM: |
| 76 | 81 |
init_get_bits(&gb, buf, buf_size * 8); |
| ... | ... |
@@ -85,7 +92,10 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data, |
| 85 | 85 |
if (res < 0) |
| 86 | 86 |
return res; |
| 87 | 87 |
} |
| 88 |
- *data_size = frame_bytes; |
|
| 88 |
+ |
|
| 89 |
+ *got_frame_ptr = 1; |
|
| 90 |
+ *(AVFrame *)data = s->frame; |
|
| 91 |
+ |
|
| 89 | 92 |
return avctx->block_align; |
| 90 | 93 |
} |
| 91 | 94 |
|
| ... | ... |
@@ -103,6 +113,7 @@ AVCodec ff_gsm_decoder = {
|
| 103 | 103 |
.init = gsm_init, |
| 104 | 104 |
.decode = gsm_decode_frame, |
| 105 | 105 |
.flush = gsm_flush, |
| 106 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 106 | 107 |
.long_name = NULL_IF_CONFIG_SMALL("GSM"),
|
| 107 | 108 |
}; |
| 108 | 109 |
|
| ... | ... |
@@ -114,5 +125,6 @@ AVCodec ff_gsm_ms_decoder = {
|
| 114 | 114 |
.init = gsm_init, |
| 115 | 115 |
.decode = gsm_decode_frame, |
| 116 | 116 |
.flush = gsm_flush, |
| 117 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 117 | 118 |
.long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"),
|
| 118 | 119 |
}; |
| ... | ... |
@@ -23,6 +23,7 @@ |
| 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 @@ |
| 30 | 30 |
#define GSM_FRAME_SIZE 160 |
| 31 | 31 |
|
| 32 | 32 |
typedef struct {
|
| 33 |
+ AVFrame frame; |
|
| 33 | 34 |
// Contains first 120 elements from the previous frame |
| 34 | 35 |
// (used by long_term_synth according to the "lag"), |
| 35 | 36 |
// then in the following 160 elements the current |
| ... | ... |
@@ -956,8 +956,8 @@ static inline int encode_bgra_bitstream(HYuvContext *s, int count, int planes){
|
| 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){
|
| 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 @@ |
| 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) |
| 168 | 168 |
dsputil_init(&q->dsp, avctx); |
| 169 | 169 |
avctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
| 170 | 170 |
avctx->channel_layout = AV_CH_LAYOUT_MONO; |
| 171 |
+ |
|
| 172 |
+ avcodec_get_frame_defaults(&q->frame); |
|
| 173 |
+ avctx->coded_frame = &q->frame; |
|
| 174 |
+ |
|
| 171 | 175 |
return 0; |
| 172 | 176 |
} |
| 173 | 177 |
|
| ... | ... |
@@ -649,9 +655,8 @@ static int imc_get_coeffs (IMCContext* q) {
|
| 649 | 649 |
return 0; |
| 650 | 650 |
} |
| 651 | 651 |
|
| 652 |
-static int imc_decode_frame(AVCodecContext * avctx, |
|
| 653 |
- void *data, int *data_size, |
|
| 654 |
- AVPacket *avpkt) |
|
| 652 |
+static int imc_decode_frame(AVCodecContext * avctx, void *data, |
|
| 653 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 655 | 654 |
{
|
| 656 | 655 |
const uint8_t *buf = avpkt->data; |
| 657 | 656 |
int buf_size = avpkt->size; |
| ... | ... |
@@ -659,7 +664,7 @@ static int imc_decode_frame(AVCodecContext * avctx, |
| 659 | 659 |
IMCContext *q = avctx->priv_data; |
| 660 | 660 |
|
| 661 | 661 |
int stream_format_code; |
| 662 |
- int imc_hdr, i, j, out_size, ret; |
|
| 662 |
+ int imc_hdr, i, j, ret; |
|
| 663 | 663 |
int flag; |
| 664 | 664 |
int bits, summer; |
| 665 | 665 |
int counter, bitscount; |
| ... | ... |
@@ -670,15 +675,16 @@ static int imc_decode_frame(AVCodecContext * avctx, |
| 670 | 670 |
return AVERROR_INVALIDDATA; |
| 671 | 671 |
} |
| 672 | 672 |
|
| 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); |
|
| 673 |
+ /* get output buffer */ |
|
| 674 |
+ q->frame.nb_samples = COEFFS; |
|
| 675 |
+ if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
|
|
| 676 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 677 |
+ return ret; |
|
| 677 | 678 |
} |
| 679 |
+ q->out_samples = (float *)q->frame.data[0]; |
|
| 678 | 680 |
|
| 679 | 681 |
q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2); |
| 680 | 682 |
|
| 681 |
- q->out_samples = data; |
|
| 682 | 683 |
init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); |
| 683 | 684 |
|
| 684 | 685 |
/* Check the frame header */ |
| ... | ... |
@@ -823,7 +829,8 @@ static int imc_decode_frame(AVCodecContext * avctx, |
| 823 | 823 |
|
| 824 | 824 |
imc_imdct256(q); |
| 825 | 825 |
|
| 826 |
- *data_size = out_size; |
|
| 826 |
+ *got_frame_ptr = 1; |
|
| 827 |
+ *(AVFrame *)data = q->frame; |
|
| 827 | 828 |
|
| 828 | 829 |
return IMC_BLOCK_SIZE; |
| 829 | 830 |
} |
| ... | ... |
@@ -834,6 +841,7 @@ static av_cold int imc_decode_close(AVCodecContext * avctx) |
| 834 | 834 |
IMCContext *q = avctx->priv_data; |
| 835 | 835 |
|
| 836 | 836 |
ff_fft_end(&q->fft); |
| 837 |
+ |
|
| 837 | 838 |
return 0; |
| 838 | 839 |
} |
| 839 | 840 |
|
| ... | ... |
@@ -846,5 +854,6 @@ AVCodec ff_imc_decoder = {
|
| 846 | 846 |
.init = imc_decode_init, |
| 847 | 847 |
.close = imc_decode_close, |
| 848 | 848 |
.decode = imc_decode_frame, |
| 849 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 849 | 850 |
.long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"),
|
| 850 | 851 |
}; |
| ... | ... |
@@ -31,12 +31,15 @@ |
| 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 = {
|
| 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) {
|
| 139 | 139 |
|
| 140 | 140 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 141 | 141 |
|
| 142 |
- avctx->priv_data = gsm_create(); |
|
| 142 |
+ s->state = gsm_create(); |
|
| 143 | 143 |
|
| 144 | 144 |
switch(avctx->codec_id) {
|
| 145 | 145 |
case CODEC_ID_GSM: |
| ... | ... |
@@ -154,59 +161,72 @@ static av_cold int libgsm_decode_init(AVCodecContext *avctx) {
|
| 154 | 154 |
} |
| 155 | 155 |
} |
| 156 | 156 |
|
| 157 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 158 |
+ avctx->coded_frame = &s->frame; |
|
| 159 |
+ |
|
| 157 | 160 |
return 0; |
| 158 | 161 |
} |
| 159 | 162 |
|
| 160 | 163 |
static av_cold int libgsm_decode_close(AVCodecContext *avctx) {
|
| 161 |
- gsm_destroy(avctx->priv_data); |
|
| 162 |
- avctx->priv_data = NULL; |
|
| 164 |
+ LibGSMDecodeContext *s = avctx->priv_data; |
|
| 165 |
+ |
|
| 166 |
+ gsm_destroy(s->state); |
|
| 167 |
+ s->state = NULL; |
|
| 163 | 168 |
return 0; |
| 164 | 169 |
} |
| 165 | 170 |
|
| 166 |
-static int libgsm_decode_frame(AVCodecContext *avctx, |
|
| 167 |
- void *data, int *data_size, |
|
| 168 |
- AVPacket *avpkt) {
|
|
| 171 |
+static int libgsm_decode_frame(AVCodecContext *avctx, void *data, |
|
| 172 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 173 |
+{
|
|
| 169 | 174 |
int i, ret; |
| 170 |
- struct gsm_state *s = avctx->priv_data; |
|
| 175 |
+ LibGSMDecodeContext *s = avctx->priv_data; |
|
| 171 | 176 |
uint8_t *buf = avpkt->data; |
| 172 | 177 |
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 |
- } |
|
| 178 |
+ int16_t *samples; |
|
| 180 | 179 |
|
| 181 | 180 |
if (buf_size < avctx->block_align) {
|
| 182 | 181 |
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); |
| 183 | 182 |
return AVERROR_INVALIDDATA; |
| 184 | 183 |
} |
| 185 | 184 |
|
| 185 |
+ /* get output buffer */ |
|
| 186 |
+ s->frame.nb_samples = avctx->frame_size; |
|
| 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 = (int16_t *)s->frame.data[0]; |
|
| 192 |
+ |
|
| 186 | 193 |
for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) {
|
| 187 |
- if ((ret = gsm_decode(s, buf, samples)) < 0) |
|
| 194 |
+ if ((ret = gsm_decode(s->state, buf, samples)) < 0) |
|
| 188 | 195 |
return -1; |
| 189 | 196 |
buf += GSM_BLOCK_SIZE; |
| 190 | 197 |
samples += GSM_FRAME_SIZE; |
| 191 | 198 |
} |
| 192 | 199 |
|
| 193 |
- *data_size = out_size; |
|
| 200 |
+ *got_frame_ptr = 1; |
|
| 201 |
+ *(AVFrame *)data = s->frame; |
|
| 202 |
+ |
|
| 194 | 203 |
return avctx->block_align; |
| 195 | 204 |
} |
| 196 | 205 |
|
| 197 | 206 |
static void libgsm_flush(AVCodecContext *avctx) {
|
| 198 |
- gsm_destroy(avctx->priv_data); |
|
| 199 |
- avctx->priv_data = gsm_create(); |
|
| 207 |
+ LibGSMDecodeContext *s = avctx->priv_data; |
|
| 208 |
+ |
|
| 209 |
+ gsm_destroy(s->state); |
|
| 210 |
+ s->state = gsm_create(); |
|
| 200 | 211 |
} |
| 201 | 212 |
|
| 202 | 213 |
AVCodec ff_libgsm_decoder = {
|
| 203 | 214 |
.name = "libgsm", |
| 204 | 215 |
.type = AVMEDIA_TYPE_AUDIO, |
| 205 | 216 |
.id = CODEC_ID_GSM, |
| 217 |
+ .priv_data_size = sizeof(LibGSMDecodeContext), |
|
| 206 | 218 |
.init = libgsm_decode_init, |
| 207 | 219 |
.close = libgsm_decode_close, |
| 208 | 220 |
.decode = libgsm_decode_frame, |
| 209 | 221 |
.flush = libgsm_flush, |
| 222 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 210 | 223 |
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
|
| 211 | 224 |
}; |
| 212 | 225 |
|
| ... | ... |
@@ -214,9 +234,11 @@ AVCodec ff_libgsm_ms_decoder = {
|
| 214 | 214 |
.name = "libgsm_ms", |
| 215 | 215 |
.type = AVMEDIA_TYPE_AUDIO, |
| 216 | 216 |
.id = CODEC_ID_GSM_MS, |
| 217 |
+ .priv_data_size = sizeof(LibGSMDecodeContext), |
|
| 217 | 218 |
.init = libgsm_decode_init, |
| 218 | 219 |
.close = libgsm_decode_close, |
| 219 | 220 |
.decode = libgsm_decode_frame, |
| 220 | 221 |
.flush = libgsm_flush, |
| 222 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 221 | 223 |
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
|
| 222 | 224 |
}; |
| ... | ... |
@@ -79,6 +79,7 @@ static int get_bitrate_mode(int bitrate, void *log_ctx) |
| 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) |
| 112 | 112 |
return AVERROR(ENOSYS); |
| 113 | 113 |
} |
| 114 | 114 |
|
| 115 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 116 |
+ avctx->coded_frame = &s->frame; |
|
| 117 |
+ |
|
| 115 | 118 |
return 0; |
| 116 | 119 |
} |
| 117 | 120 |
|
| ... | ... |
@@ -120,26 +124,28 @@ static av_cold int amr_nb_decode_close(AVCodecContext *avctx) |
| 120 | 120 |
AMRContext *s = avctx->priv_data; |
| 121 | 121 |
|
| 122 | 122 |
Decoder_Interface_exit(s->dec_state); |
| 123 |
+ |
|
| 123 | 124 |
return 0; |
| 124 | 125 |
} |
| 125 | 126 |
|
| 126 | 127 |
static int amr_nb_decode_frame(AVCodecContext *avctx, void *data, |
| 127 |
- int *data_size, AVPacket *avpkt) |
|
| 128 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 128 | 129 |
{
|
| 129 | 130 |
const uint8_t *buf = avpkt->data; |
| 130 | 131 |
int buf_size = avpkt->size; |
| 131 | 132 |
AMRContext *s = avctx->priv_data; |
| 132 | 133 |
static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
|
| 133 | 134 |
enum Mode dec_mode; |
| 134 |
- int packet_size, out_size; |
|
| 135 |
+ int packet_size, ret; |
|
| 135 | 136 |
|
| 136 | 137 |
av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n", |
| 137 | 138 |
buf, buf_size, avctx->frame_number); |
| 138 | 139 |
|
| 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); |
|
| 140 |
+ /* get output buffer */ |
|
| 141 |
+ s->frame.nb_samples = 160; |
|
| 142 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 143 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 144 |
+ return ret; |
|
| 143 | 145 |
} |
| 144 | 146 |
|
| 145 | 147 |
dec_mode = (buf[0] >> 3) & 0x000F; |
| ... | ... |
@@ -154,8 +160,10 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data, |
| 154 | 154 |
av_dlog(avctx, "packet_size=%d buf= 0x%X %X %X %X\n", |
| 155 | 155 |
packet_size, buf[0], buf[1], buf[2], buf[3]); |
| 156 | 156 |
/* call decoder */ |
| 157 |
- Decoder_Interface_Decode(s->dec_state, buf, data, 0); |
|
| 158 |
- *data_size = out_size; |
|
| 157 |
+ Decoder_Interface_Decode(s->dec_state, buf, (short *)s->frame.data[0], 0); |
|
| 158 |
+ |
|
| 159 |
+ *got_frame_ptr = 1; |
|
| 160 |
+ *(AVFrame *)data = s->frame; |
|
| 159 | 161 |
|
| 160 | 162 |
return packet_size; |
| 161 | 163 |
} |
| ... | ... |
@@ -168,6 +176,7 @@ AVCodec ff_libopencore_amrnb_decoder = {
|
| 168 | 168 |
.init = amr_nb_decode_init, |
| 169 | 169 |
.close = amr_nb_decode_close, |
| 170 | 170 |
.decode = amr_nb_decode_frame, |
| 171 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 171 | 172 |
.long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),
|
| 172 | 173 |
}; |
| 173 | 174 |
|
| ... | ... |
@@ -251,6 +260,7 @@ AVCodec ff_libopencore_amrnb_encoder = {
|
| 251 | 251 |
#include <opencore-amrwb/if_rom.h> |
| 252 | 252 |
|
| 253 | 253 |
typedef struct AMRWBContext {
|
| 254 |
+ AVFrame frame; |
|
| 254 | 255 |
void *state; |
| 255 | 256 |
} AMRWBContext; |
| 256 | 257 |
|
| ... | ... |
@@ -267,23 +277,27 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx) |
| 267 | 267 |
return AVERROR(ENOSYS); |
| 268 | 268 |
} |
| 269 | 269 |
|
| 270 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 271 |
+ avctx->coded_frame = &s->frame; |
|
| 272 |
+ |
|
| 270 | 273 |
return 0; |
| 271 | 274 |
} |
| 272 | 275 |
|
| 273 | 276 |
static int amr_wb_decode_frame(AVCodecContext *avctx, void *data, |
| 274 |
- int *data_size, AVPacket *avpkt) |
|
| 277 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 275 | 278 |
{
|
| 276 | 279 |
const uint8_t *buf = avpkt->data; |
| 277 | 280 |
int buf_size = avpkt->size; |
| 278 | 281 |
AMRWBContext *s = avctx->priv_data; |
| 279 |
- int mode; |
|
| 280 |
- int packet_size, out_size; |
|
| 282 |
+ int mode, ret; |
|
| 283 |
+ int packet_size; |
|
| 281 | 284 |
static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
|
| 282 | 285 |
|
| 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); |
|
| 286 |
+ /* get output buffer */ |
|
| 287 |
+ s->frame.nb_samples = 320; |
|
| 288 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 289 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 290 |
+ return ret; |
|
| 287 | 291 |
} |
| 288 | 292 |
|
| 289 | 293 |
mode = (buf[0] >> 3) & 0x000F; |
| ... | ... |
@@ -295,8 +309,11 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data, |
| 295 | 295 |
return AVERROR_INVALIDDATA; |
| 296 | 296 |
} |
| 297 | 297 |
|
| 298 |
- D_IF_decode(s->state, buf, data, _good_frame); |
|
| 299 |
- *data_size = out_size; |
|
| 298 |
+ D_IF_decode(s->state, buf, (short *)s->frame.data[0], _good_frame); |
|
| 299 |
+ |
|
| 300 |
+ *got_frame_ptr = 1; |
|
| 301 |
+ *(AVFrame *)data = s->frame; |
|
| 302 |
+ |
|
| 300 | 303 |
return packet_size; |
| 301 | 304 |
} |
| 302 | 305 |
|
| ... | ... |
@@ -316,6 +333,7 @@ AVCodec ff_libopencore_amrwb_decoder = {
|
| 316 | 316 |
.init = amr_wb_decode_init, |
| 317 | 317 |
.close = amr_wb_decode_close, |
| 318 | 318 |
.decode = amr_wb_decode_frame, |
| 319 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 319 | 320 |
.long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"),
|
| 320 | 321 |
}; |
| 321 | 322 |
|
| ... | ... |
@@ -25,6 +25,7 @@ |
| 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) |
| 89 | 89 |
s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT; |
| 90 | 90 |
speex_decoder_ctl(s->dec_state, SPEEX_SET_HANDLER, &callback); |
| 91 | 91 |
} |
| 92 |
+ |
|
| 93 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 94 |
+ avctx->coded_frame = &s->frame; |
|
| 95 |
+ |
|
| 92 | 96 |
return 0; |
| 93 | 97 |
} |
| 94 | 98 |
|
| 95 |
-static int libspeex_decode_frame(AVCodecContext *avctx, |
|
| 96 |
- void *data, int *data_size, |
|
| 97 |
- AVPacket *avpkt) |
|
| 99 |
+static int libspeex_decode_frame(AVCodecContext *avctx, void *data, |
|
| 100 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 98 | 101 |
{
|
| 99 | 102 |
uint8_t *buf = avpkt->data; |
| 100 | 103 |
int buf_size = avpkt->size; |
| 101 | 104 |
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); |
|
| 105 |
+ int16_t *output; |
|
| 106 |
+ int ret, consumed = 0; |
|
| 107 |
+ |
|
| 108 |
+ /* get output buffer */ |
|
| 109 |
+ s->frame.nb_samples = s->frame_size; |
|
| 110 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 111 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 112 |
+ return ret; |
|
| 111 | 113 |
} |
| 114 |
+ output = (int16_t *)s->frame.data[0]; |
|
| 112 | 115 |
|
| 113 | 116 |
/* if there is not enough data left for the smallest possible frame, |
| 114 | 117 |
reset the libspeex buffer using the current packet, otherwise ignore |
| ... | ... |
@@ -116,7 +120,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx, |
| 116 | 116 |
if (speex_bits_remaining(&s->bits) < 43) {
|
| 117 | 117 |
/* check for flush packet */ |
| 118 | 118 |
if (!buf || !buf_size) {
|
| 119 |
- *data_size = 0; |
|
| 119 |
+ *got_frame_ptr = 0; |
|
| 120 | 120 |
return buf_size; |
| 121 | 121 |
} |
| 122 | 122 |
/* set new buffer */ |
| ... | ... |
@@ -133,7 +137,9 @@ static int libspeex_decode_frame(AVCodecContext *avctx, |
| 133 | 133 |
if (avctx->channels == 2) |
| 134 | 134 |
speex_decode_stereo_int(output, s->frame_size, &s->stereo); |
| 135 | 135 |
|
| 136 |
- *data_size = out_size; |
|
| 136 |
+ *got_frame_ptr = 1; |
|
| 137 |
+ *(AVFrame *)data = s->frame; |
|
| 138 |
+ |
|
| 137 | 139 |
return consumed; |
| 138 | 140 |
} |
| 139 | 141 |
|
| ... | ... |
@@ -163,6 +169,6 @@ AVCodec ff_libspeex_decoder = {
|
| 163 | 163 |
.close = libspeex_decode_close, |
| 164 | 164 |
.decode = libspeex_decode_frame, |
| 165 | 165 |
.flush = libspeex_decode_flush, |
| 166 |
- .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY, |
|
| 166 |
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1, |
|
| 167 | 167 |
.long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"),
|
| 168 | 168 |
}; |
| ... | ... |
@@ -153,6 +153,7 @@ typedef struct ChannelData {
|
| 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, |
| 228 | 228 |
|
| 229 | 229 |
static av_cold int mace_decode_init(AVCodecContext * avctx) |
| 230 | 230 |
{
|
| 231 |
+ MACEContext *ctx = avctx->priv_data; |
|
| 232 |
+ |
|
| 231 | 233 |
if (avctx->channels > 2) |
| 232 | 234 |
return -1; |
| 233 | 235 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 236 |
+ |
|
| 237 |
+ avcodec_get_frame_defaults(&ctx->frame); |
|
| 238 |
+ avctx->coded_frame = &ctx->frame; |
|
| 239 |
+ |
|
| 234 | 240 |
return 0; |
| 235 | 241 |
} |
| 236 | 242 |
|
| 237 |
-static int mace_decode_frame(AVCodecContext *avctx, |
|
| 238 |
- void *data, int *data_size, |
|
| 239 |
- AVPacket *avpkt) |
|
| 243 |
+static int mace_decode_frame(AVCodecContext *avctx, void *data, |
|
| 244 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 240 | 245 |
{
|
| 241 | 246 |
const uint8_t *buf = avpkt->data; |
| 242 | 247 |
int buf_size = avpkt->size; |
| 243 |
- int16_t *samples = data; |
|
| 248 |
+ int16_t *samples; |
|
| 244 | 249 |
MACEContext *ctx = avctx->priv_data; |
| 245 |
- int i, j, k, l; |
|
| 246 |
- int out_size; |
|
| 250 |
+ int i, j, k, l, ret; |
|
| 247 | 251 |
int is_mace3 = (avctx->codec_id == CODEC_ID_MACE3); |
| 248 | 252 |
|
| 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); |
|
| 253 |
+ /* get output buffer */ |
|
| 254 |
+ ctx->frame.nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels; |
|
| 255 |
+ if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
|
|
| 256 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 257 |
+ return ret; |
|
| 254 | 258 |
} |
| 259 |
+ samples = (int16_t *)ctx->frame.data[0]; |
|
| 255 | 260 |
|
| 256 | 261 |
for(i = 0; i < avctx->channels; i++) {
|
| 257 | 262 |
int16_t *output = samples + i; |
| ... | ... |
@@ -277,7 +283,8 @@ static int mace_decode_frame(AVCodecContext *avctx, |
| 277 | 277 |
} |
| 278 | 278 |
} |
| 279 | 279 |
|
| 280 |
- *data_size = out_size; |
|
| 280 |
+ *got_frame_ptr = 1; |
|
| 281 |
+ *(AVFrame *)data = ctx->frame; |
|
| 281 | 282 |
|
| 282 | 283 |
return buf_size; |
| 283 | 284 |
} |
| ... | ... |
@@ -289,6 +296,7 @@ AVCodec ff_mace3_decoder = {
|
| 289 | 289 |
.priv_data_size = sizeof(MACEContext), |
| 290 | 290 |
.init = mace_decode_init, |
| 291 | 291 |
.decode = mace_decode_frame, |
| 292 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 292 | 293 |
.long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),
|
| 293 | 294 |
}; |
| 294 | 295 |
|
| ... | ... |
@@ -299,6 +307,7 @@ AVCodec ff_mace6_decoder = {
|
| 299 | 299 |
.priv_data_size = sizeof(MACEContext), |
| 300 | 300 |
.init = mace_decode_init, |
| 301 | 301 |
.decode = mace_decode_frame, |
| 302 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 302 | 303 |
.long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"),
|
| 303 | 304 |
}; |
| 304 | 305 |
|
| ... | ... |
@@ -120,6 +120,7 @@ typedef struct SubStream {
|
| 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) |
| 242 | 242 |
m->substream[substr].lossless_check_data = 0xffffffff; |
| 243 | 243 |
dsputil_init(&m->dsp, avctx); |
| 244 | 244 |
|
| 245 |
+ avcodec_get_frame_defaults(&m->frame); |
|
| 246 |
+ avctx->coded_frame = &m->frame; |
|
| 247 |
+ |
|
| 245 | 248 |
return 0; |
| 246 | 249 |
} |
| 247 | 250 |
|
| ... | ... |
@@ -946,13 +950,14 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) |
| 946 | 946 |
/** Write the audio data into the output buffer. */ |
| 947 | 947 |
|
| 948 | 948 |
static int output_data(MLPDecodeContext *m, unsigned int substr, |
| 949 |
- uint8_t *data, unsigned int *data_size) |
|
| 949 |
+ void *data, int *got_frame_ptr) |
|
| 950 | 950 |
{
|
| 951 |
+ AVCodecContext *avctx = m->avctx; |
|
| 951 | 952 |
SubStream *s = &m->substream[substr]; |
| 952 | 953 |
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; |
|
| 954 |
+ int32_t *data_32; |
|
| 955 |
+ int16_t *data_16; |
|
| 956 |
+ int ret; |
|
| 956 | 957 |
int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); |
| 957 | 958 |
|
| 958 | 959 |
if (m->avctx->channels != s->max_matrix_channel + 1) {
|
| ... | ... |
@@ -960,11 +965,14 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, |
| 960 | 960 |
return AVERROR_INVALIDDATA; |
| 961 | 961 |
} |
| 962 | 962 |
|
| 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); |
|
| 963 |
+ /* get output buffer */ |
|
| 964 |
+ m->frame.nb_samples = s->blockpos; |
|
| 965 |
+ if ((ret = avctx->get_buffer(avctx, &m->frame)) < 0) {
|
|
| 966 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 967 |
+ return ret; |
|
| 968 |
+ } |
|
| 969 |
+ data_32 = (int32_t *)m->frame.data[0]; |
|
| 970 |
+ data_16 = (int16_t *)m->frame.data[0]; |
|
| 968 | 971 |
|
| 969 | 972 |
for (i = 0; i < s->blockpos; i++) {
|
| 970 | 973 |
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, |
| 977 | 977 |
} |
| 978 | 978 |
} |
| 979 | 979 |
|
| 980 |
- *data_size = out_size; |
|
| 980 |
+ *got_frame_ptr = 1; |
|
| 981 |
+ *(AVFrame *)data = m->frame; |
|
| 981 | 982 |
|
| 982 | 983 |
return 0; |
| 983 | 984 |
} |
| ... | ... |
@@ -986,8 +995,8 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, |
| 986 | 986 |
* @return negative on error, 0 if not enough data is present in the input stream, |
| 987 | 987 |
* otherwise the number of bytes consumed. */ |
| 988 | 988 |
|
| 989 |
-static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size, |
|
| 990 |
- AVPacket *avpkt) |
|
| 989 |
+static int read_access_unit(AVCodecContext *avctx, void* data, |
|
| 990 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 991 | 991 |
{
|
| 992 | 992 |
const uint8_t *buf = avpkt->data; |
| 993 | 993 |
int buf_size = avpkt->size; |
| ... | ... |
@@ -1023,7 +1032,7 @@ static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size, |
| 1023 | 1023 |
if (!m->params_valid) {
|
| 1024 | 1024 |
av_log(m->avctx, AV_LOG_WARNING, |
| 1025 | 1025 |
"Stream parameters not seen; skipping frame.\n"); |
| 1026 |
- *data_size = 0; |
|
| 1026 |
+ *got_frame_ptr = 0; |
|
| 1027 | 1027 |
return length; |
| 1028 | 1028 |
} |
| 1029 | 1029 |
|
| ... | ... |
@@ -1168,7 +1177,7 @@ next_substr: |
| 1168 | 1168 |
|
| 1169 | 1169 |
rematrix_channels(m, m->max_decoded_substream); |
| 1170 | 1170 |
|
| 1171 |
- if ((ret = output_data(m, m->max_decoded_substream, data, data_size)) < 0) |
|
| 1171 |
+ if ((ret = output_data(m, m->max_decoded_substream, data, got_frame_ptr)) < 0) |
|
| 1172 | 1172 |
return ret; |
| 1173 | 1173 |
|
| 1174 | 1174 |
return length; |
| ... | ... |
@@ -1189,6 +1198,7 @@ AVCodec ff_mlp_decoder = {
|
| 1189 | 1189 |
.priv_data_size = sizeof(MLPDecodeContext), |
| 1190 | 1190 |
.init = mlp_decode_init, |
| 1191 | 1191 |
.decode = read_access_unit, |
| 1192 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1192 | 1193 |
.long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),
|
| 1193 | 1194 |
}; |
| 1194 | 1195 |
|
| ... | ... |
@@ -1200,6 +1210,7 @@ AVCodec ff_truehd_decoder = {
|
| 1200 | 1200 |
.priv_data_size = sizeof(MLPDecodeContext), |
| 1201 | 1201 |
.init = mlp_decode_init, |
| 1202 | 1202 |
.decode = read_access_unit, |
| 1203 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1203 | 1204 |
.long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
|
| 1204 | 1205 |
}; |
| 1205 | 1206 |
#endif /* CONFIG_TRUEHD_DECODER */ |
| ... | ... |
@@ -136,6 +136,10 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) |
| 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) |
| 192 | 192 |
return ref + t; |
| 193 | 193 |
} |
| 194 | 194 |
|
| 195 |
-static int mpc7_decode_frame(AVCodecContext * avctx, |
|
| 196 |
- void *data, int *data_size, |
|
| 197 |
- AVPacket *avpkt) |
|
| 195 |
+static int mpc7_decode_frame(AVCodecContext * avctx, void *data, |
|
| 196 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 198 | 197 |
{
|
| 199 | 198 |
const uint8_t *buf = avpkt->data; |
| 200 | 199 |
int buf_size = avpkt->size; |
| ... | ... |
@@ -204,7 +207,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, |
| 204 | 204 |
int i, ch; |
| 205 | 205 |
int mb = -1; |
| 206 | 206 |
Band *bands = c->bands; |
| 207 |
- int off, out_size; |
|
| 207 |
+ int off, ret; |
|
| 208 | 208 |
int bits_used, bits_avail; |
| 209 | 209 |
|
| 210 | 210 |
memset(bands, 0, sizeof(*bands) * (c->maxbands + 1)); |
| ... | ... |
@@ -213,10 +216,11 @@ static int mpc7_decode_frame(AVCodecContext * avctx, |
| 213 | 213 |
return AVERROR(EINVAL); |
| 214 | 214 |
} |
| 215 | 215 |
|
| 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); |
|
| 216 |
+ /* get output buffer */ |
|
| 217 |
+ c->frame.nb_samples = buf[1] ? c->lastframelen : MPC_FRAME_SIZE; |
|
| 218 |
+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
|
| 219 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 220 |
+ return ret; |
|
| 220 | 221 |
} |
| 221 | 222 |
|
| 222 | 223 |
bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE); |
| ... | ... |
@@ -276,7 +280,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, |
| 276 | 276 |
for(ch = 0; ch < 2; ch++) |
| 277 | 277 |
idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off); |
| 278 | 278 |
|
| 279 |
- ff_mpc_dequantize_and_synth(c, mb, data, 2); |
|
| 279 |
+ ff_mpc_dequantize_and_synth(c, mb, c->frame.data[0], 2); |
|
| 280 | 280 |
|
| 281 | 281 |
av_free(bits); |
| 282 | 282 |
|
| ... | ... |
@@ -288,10 +292,12 @@ static int mpc7_decode_frame(AVCodecContext * avctx, |
| 288 | 288 |
} |
| 289 | 289 |
if(c->frames_to_skip){
|
| 290 | 290 |
c->frames_to_skip--; |
| 291 |
- *data_size = 0; |
|
| 291 |
+ *got_frame_ptr = 0; |
|
| 292 | 292 |
return buf_size; |
| 293 | 293 |
} |
| 294 |
- *data_size = out_size; |
|
| 294 |
+ |
|
| 295 |
+ *got_frame_ptr = 1; |
|
| 296 |
+ *(AVFrame *)data = c->frame; |
|
| 295 | 297 |
|
| 296 | 298 |
return buf_size; |
| 297 | 299 |
} |
| ... | ... |
@@ -312,5 +318,6 @@ AVCodec ff_mpc7_decoder = {
|
| 312 | 312 |
.init = mpc7_decode_init, |
| 313 | 313 |
.decode = mpc7_decode_frame, |
| 314 | 314 |
.flush = mpc7_decode_flush, |
| 315 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 315 | 316 |
.long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"),
|
| 316 | 317 |
}; |
| ... | ... |
@@ -230,12 +230,15 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) |
| 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, |
| 243 | 243 |
GetBitContext gb2, *gb = &gb2; |
| 244 | 244 |
int i, j, k, ch, cnt, res, t; |
| 245 | 245 |
Band *bands = c->bands; |
| 246 |
- int off, out_size; |
|
| 246 |
+ int off; |
|
| 247 | 247 |
int maxband, keyframe; |
| 248 | 248 |
int last[2]; |
| 249 | 249 |
|
| 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); |
|
| 250 |
+ /* get output buffer */ |
|
| 251 |
+ c->frame.nb_samples = MPC_FRAME_SIZE; |
|
| 252 |
+ if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
|
| 253 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 254 |
+ return res; |
|
| 254 | 255 |
} |
| 255 | 256 |
|
| 256 | 257 |
keyframe = c->cur_frame == 0; |
| ... | ... |
@@ -403,14 +407,16 @@ static int mpc8_decode_frame(AVCodecContext * avctx, |
| 403 | 403 |
} |
| 404 | 404 |
} |
| 405 | 405 |
|
| 406 |
- ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels); |
|
| 406 |
+ ff_mpc_dequantize_and_synth(c, maxband, c->frame.data[0], avctx->channels); |
|
| 407 | 407 |
|
| 408 | 408 |
c->cur_frame++; |
| 409 | 409 |
|
| 410 | 410 |
c->last_bits_used = get_bits_count(gb); |
| 411 | 411 |
if(c->cur_frame >= c->frames) |
| 412 | 412 |
c->cur_frame = 0; |
| 413 |
- *data_size = out_size; |
|
| 413 |
+ |
|
| 414 |
+ *got_frame_ptr = 1; |
|
| 415 |
+ *(AVFrame *)data = c->frame; |
|
| 414 | 416 |
|
| 415 | 417 |
return c->cur_frame ? c->last_bits_used >> 3 : buf_size; |
| 416 | 418 |
} |
| ... | ... |
@@ -422,5 +428,6 @@ AVCodec ff_mpc8_decoder = {
|
| 422 | 422 |
.priv_data_size = sizeof(MPCContext), |
| 423 | 423 |
.init = mpc8_decode_init, |
| 424 | 424 |
.decode = mpc8_decode_frame, |
| 425 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 425 | 426 |
.long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"),
|
| 426 | 427 |
}; |
| ... | ... |
@@ -76,12 +76,13 @@ static inline int get_sample_rate(GetBitContext *gb, int *index) |
| 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 |
| 117 | 117 |
return -1; |
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 |
- if (c->ext_object_type != AOT_SBR) {
|
|
| 120 |
+ if (c->ext_object_type != AOT_SBR && sync_extension) {
|
|
| 121 | 121 |
while (get_bits_left(&gb) > 15) {
|
| 122 | 122 |
if (show_bits(&gb, 11) == 0x2b7) { // sync extension
|
| 123 | 123 |
get_bits(&gb, 11); |
| ... | ... |
@@ -42,14 +42,17 @@ typedef struct {
|
| 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 {
|
| 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) |
| 479 | 479 |
|
| 480 | 480 |
if (avctx->codec_id == CODEC_ID_MP3ADU) |
| 481 | 481 |
s->adu_mode = 1; |
| 482 |
+ |
|
| 483 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 484 |
+ avctx->coded_frame = &s->frame; |
|
| 485 |
+ |
|
| 482 | 486 |
return 0; |
| 483 | 487 |
} |
| 484 | 488 |
|
| ... | ... |
@@ -1581,7 +1586,7 @@ static int mp_decode_layer3(MPADecodeContext *s) |
| 1581 | 1581 |
static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples, |
| 1582 | 1582 |
const uint8_t *buf, int buf_size) |
| 1583 | 1583 |
{
|
| 1584 |
- int i, nb_frames, ch; |
|
| 1584 |
+ int i, nb_frames, ch, ret; |
|
| 1585 | 1585 |
OUT_INT *samples_ptr; |
| 1586 | 1586 |
|
| 1587 | 1587 |
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, |
| 1629 | 1629 |
assert(i <= buf_size - HEADER_SIZE && i >= 0); |
| 1630 | 1630 |
memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i); |
| 1631 | 1631 |
s->last_buf_size += i; |
| 1632 |
+ } |
|
| 1632 | 1633 |
|
| 1633 |
- break; |
|
| 1634 |
+ /* get output buffer */ |
|
| 1635 |
+ if (!samples) {
|
|
| 1636 |
+ s->frame.nb_samples = s->avctx->frame_size; |
|
| 1637 |
+ if ((ret = s->avctx->get_buffer(s->avctx, &s->frame)) < 0) {
|
|
| 1638 |
+ av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1639 |
+ return ret; |
|
| 1640 |
+ } |
|
| 1641 |
+ samples = (OUT_INT *)s->frame.data[0]; |
|
| 1634 | 1642 |
} |
| 1635 | 1643 |
|
| 1636 | 1644 |
/* apply the synthesis filter */ |
| ... | ... |
@@ -1650,7 +1663,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples, |
| 1650 | 1650 |
return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; |
| 1651 | 1651 |
} |
| 1652 | 1652 |
|
| 1653 |
-static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
|
| 1653 |
+static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, |
|
| 1654 | 1654 |
AVPacket *avpkt) |
| 1655 | 1655 |
{
|
| 1656 | 1656 |
const uint8_t *buf = avpkt->data; |
| ... | ... |
@@ -1658,7 +1671,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
| 1658 | 1658 |
MPADecodeContext *s = avctx->priv_data; |
| 1659 | 1659 |
uint32_t header; |
| 1660 | 1660 |
int out_size; |
| 1661 |
- OUT_INT *out_samples = data; |
|
| 1662 | 1661 |
|
| 1663 | 1662 |
if (buf_size < HEADER_SIZE) |
| 1664 | 1663 |
return AVERROR_INVALIDDATA; |
| ... | ... |
@@ -1681,10 +1693,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
| 1681 | 1681 |
avctx->bit_rate = s->bit_rate; |
| 1682 | 1682 |
avctx->sub_id = s->layer; |
| 1683 | 1683 |
|
| 1684 |
- if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT)) |
|
| 1685 |
- return AVERROR(EINVAL); |
|
| 1686 |
- *data_size = 0; |
|
| 1687 |
- |
|
| 1688 | 1684 |
if (s->frame_size <= 0 || s->frame_size > buf_size) {
|
| 1689 | 1685 |
av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); |
| 1690 | 1686 |
return AVERROR_INVALIDDATA; |
| ... | ... |
@@ -1693,9 +1701,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
| 1693 | 1693 |
buf_size= s->frame_size; |
| 1694 | 1694 |
} |
| 1695 | 1695 |
|
| 1696 |
- out_size = mp_decode_frame(s, out_samples, buf, buf_size); |
|
| 1696 |
+ out_size = mp_decode_frame(s, NULL, buf, buf_size); |
|
| 1697 | 1697 |
if (out_size >= 0) {
|
| 1698 |
- *data_size = out_size; |
|
| 1698 |
+ *got_frame_ptr = 1; |
|
| 1699 |
+ *(AVFrame *)data = s->frame; |
|
| 1699 | 1700 |
avctx->sample_rate = s->sample_rate; |
| 1700 | 1701 |
//FIXME maybe move the other codec info stuff from above here too |
| 1701 | 1702 |
} else {
|
| ... | ... |
@@ -1704,6 +1713,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
| 1704 | 1704 |
If there is more data in the packet, just consume the bad frame |
| 1705 | 1705 |
instead of returning an error, which would discard the whole |
| 1706 | 1706 |
packet. */ |
| 1707 |
+ *got_frame_ptr = 0; |
|
| 1707 | 1708 |
if (buf_size == avpkt->size) |
| 1708 | 1709 |
return out_size; |
| 1709 | 1710 |
} |
| ... | ... |
@@ -1719,15 +1729,14 @@ static void flush(AVCodecContext *avctx) |
| 1719 | 1719 |
} |
| 1720 | 1720 |
|
| 1721 | 1721 |
#if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER |
| 1722 |
-static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, |
|
| 1723 |
- AVPacket *avpkt) |
|
| 1722 |
+static int decode_frame_adu(AVCodecContext *avctx, void *data, |
|
| 1723 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1724 | 1724 |
{
|
| 1725 | 1725 |
const uint8_t *buf = avpkt->data; |
| 1726 | 1726 |
int buf_size = avpkt->size; |
| 1727 | 1727 |
MPADecodeContext *s = avctx->priv_data; |
| 1728 | 1728 |
uint32_t header; |
| 1729 | 1729 |
int len, out_size; |
| 1730 |
- OUT_INT *out_samples = data; |
|
| 1731 | 1730 |
|
| 1732 | 1731 |
len = buf_size; |
| 1733 | 1732 |
|
| ... | ... |
@@ -1757,9 +1766,6 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, |
| 1757 | 1757 |
avctx->bit_rate = s->bit_rate; |
| 1758 | 1758 |
avctx->sub_id = s->layer; |
| 1759 | 1759 |
|
| 1760 |
- if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT)) |
|
| 1761 |
- return AVERROR(EINVAL); |
|
| 1762 |
- |
|
| 1763 | 1760 |
s->frame_size = len; |
| 1764 | 1761 |
|
| 1765 | 1762 |
#if FF_API_PARSE_FRAME |
| ... | ... |
@@ -1767,9 +1773,11 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, |
| 1767 | 1767 |
out_size = buf_size; |
| 1768 | 1768 |
else |
| 1769 | 1769 |
#endif |
| 1770 |
- out_size = mp_decode_frame(s, out_samples, buf, buf_size); |
|
| 1770 |
+ out_size = mp_decode_frame(s, NULL, buf, buf_size); |
|
| 1771 |
+ |
|
| 1772 |
+ *got_frame_ptr = 1; |
|
| 1773 |
+ *(AVFrame *)data = s->frame; |
|
| 1771 | 1774 |
|
| 1772 |
- *data_size = out_size; |
|
| 1773 | 1775 |
return buf_size; |
| 1774 | 1776 |
} |
| 1775 | 1777 |
#endif /* CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER */ |
| ... | ... |
@@ -1780,6 +1788,7 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, |
| 1780 | 1780 |
* Context for MP3On4 decoder |
| 1781 | 1781 |
*/ |
| 1782 | 1782 |
typedef struct MP3On4DecodeContext {
|
| 1783 |
+ AVFrame *frame; |
|
| 1783 | 1784 |
int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) |
| 1784 | 1785 |
int syncword; ///< syncword patch |
| 1785 | 1786 |
const uint8_t *coff; ///< channel offsets in output buffer |
| ... | ... |
@@ -1843,7 +1852,8 @@ static int decode_init_mp3on4(AVCodecContext * avctx) |
| 1843 | 1843 |
return AVERROR_INVALIDDATA; |
| 1844 | 1844 |
} |
| 1845 | 1845 |
|
| 1846 |
- avpriv_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size); |
|
| 1846 |
+ avpriv_mpeg4audio_get_config(&cfg, avctx->extradata, |
|
| 1847 |
+ avctx->extradata_size * 8, 1); |
|
| 1847 | 1848 |
if (!cfg.chan_config || cfg.chan_config > 7) {
|
| 1848 | 1849 |
av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n"); |
| 1849 | 1850 |
return AVERROR_INVALIDDATA; |
| ... | ... |
@@ -1870,6 +1880,7 @@ static int decode_init_mp3on4(AVCodecContext * avctx) |
| 1870 | 1870 |
// Put decoder context in place to make init_decode() happy |
| 1871 | 1871 |
avctx->priv_data = s->mp3decctx[0]; |
| 1872 | 1872 |
decode_init(avctx); |
| 1873 |
+ s->frame = avctx->coded_frame; |
|
| 1873 | 1874 |
// Restore mp3on4 context pointer |
| 1874 | 1875 |
avctx->priv_data = s; |
| 1875 | 1876 |
s->mp3decctx[0]->adu_mode = 1; // Set adu mode |
| ... | ... |
@@ -1914,9 +1925,8 @@ static void flush_mp3on4(AVCodecContext *avctx) |
| 1914 | 1914 |
} |
| 1915 | 1915 |
|
| 1916 | 1916 |
|
| 1917 |
-static int decode_frame_mp3on4(AVCodecContext * avctx, |
|
| 1918 |
- void *data, int *data_size, |
|
| 1919 |
- AVPacket *avpkt) |
|
| 1917 |
+static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, |
|
| 1918 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1920 | 1919 |
{
|
| 1921 | 1920 |
const uint8_t *buf = avpkt->data; |
| 1922 | 1921 |
int buf_size = avpkt->size; |
| ... | ... |
@@ -1924,14 +1934,17 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, |
| 1924 | 1924 |
MPADecodeContext *m; |
| 1925 | 1925 |
int fsize, len = buf_size, out_size = 0; |
| 1926 | 1926 |
uint32_t header; |
| 1927 |
- OUT_INT *out_samples = data; |
|
| 1927 |
+ OUT_INT *out_samples; |
|
| 1928 | 1928 |
OUT_INT *outptr, *bp; |
| 1929 |
- int fr, j, n, ch; |
|
| 1929 |
+ int fr, j, n, ch, ret; |
|
| 1930 | 1930 |
|
| 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); |
|
| 1931 |
+ /* get output buffer */ |
|
| 1932 |
+ s->frame->nb_samples = MPA_FRAME_SIZE; |
|
| 1933 |
+ if ((ret = avctx->get_buffer(avctx, s->frame)) < 0) {
|
|
| 1934 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1935 |
+ return ret; |
|
| 1934 | 1936 |
} |
| 1937 |
+ out_samples = (OUT_INT *)s->frame->data[0]; |
|
| 1935 | 1938 |
|
| 1936 | 1939 |
// Discard too short frames |
| 1937 | 1940 |
if (buf_size < HEADER_SIZE) |
| ... | ... |
@@ -1990,7 +2003,10 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, |
| 1990 | 1990 |
/* update codec info */ |
| 1991 | 1991 |
avctx->sample_rate = s->mp3decctx[0]->sample_rate; |
| 1992 | 1992 |
|
| 1993 |
- *data_size = out_size; |
|
| 1993 |
+ s->frame->nb_samples = out_size / (avctx->channels * sizeof(OUT_INT)); |
|
| 1994 |
+ *got_frame_ptr = 1; |
|
| 1995 |
+ *(AVFrame *)data = *s->frame; |
|
| 1996 |
+ |
|
| 1994 | 1997 |
return buf_size; |
| 1995 | 1998 |
} |
| 1996 | 1999 |
#endif /* CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER */ |
| ... | ... |
@@ -2005,7 +2021,9 @@ AVCodec ff_mp1_decoder = {
|
| 2005 | 2005 |
.init = decode_init, |
| 2006 | 2006 |
.decode = decode_frame, |
| 2007 | 2007 |
#if FF_API_PARSE_FRAME |
| 2008 |
- .capabilities = CODEC_CAP_PARSE_ONLY, |
|
| 2008 |
+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, |
|
| 2009 |
+#else |
|
| 2010 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 2009 | 2011 |
#endif |
| 2010 | 2012 |
.flush = flush, |
| 2011 | 2013 |
.long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
|
| ... | ... |
@@ -2020,7 +2038,9 @@ AVCodec ff_mp2_decoder = {
|
| 2020 | 2020 |
.init = decode_init, |
| 2021 | 2021 |
.decode = decode_frame, |
| 2022 | 2022 |
#if FF_API_PARSE_FRAME |
| 2023 |
- .capabilities = CODEC_CAP_PARSE_ONLY, |
|
| 2023 |
+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, |
|
| 2024 |
+#else |
|
| 2025 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 2024 | 2026 |
#endif |
| 2025 | 2027 |
.flush = flush, |
| 2026 | 2028 |
.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
|
| ... | ... |
@@ -2035,7 +2055,9 @@ AVCodec ff_mp3_decoder = {
|
| 2035 | 2035 |
.init = decode_init, |
| 2036 | 2036 |
.decode = decode_frame, |
| 2037 | 2037 |
#if FF_API_PARSE_FRAME |
| 2038 |
- .capabilities = CODEC_CAP_PARSE_ONLY, |
|
| 2038 |
+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, |
|
| 2039 |
+#else |
|
| 2040 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 2039 | 2041 |
#endif |
| 2040 | 2042 |
.flush = flush, |
| 2041 | 2043 |
.long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
|
| ... | ... |
@@ -2050,7 +2072,9 @@ AVCodec ff_mp3adu_decoder = {
|
| 2050 | 2050 |
.init = decode_init, |
| 2051 | 2051 |
.decode = decode_frame_adu, |
| 2052 | 2052 |
#if FF_API_PARSE_FRAME |
| 2053 |
- .capabilities = CODEC_CAP_PARSE_ONLY, |
|
| 2053 |
+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, |
|
| 2054 |
+#else |
|
| 2055 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 2054 | 2056 |
#endif |
| 2055 | 2057 |
.flush = flush, |
| 2056 | 2058 |
.long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
|
| ... | ... |
@@ -2065,6 +2089,7 @@ AVCodec ff_mp3on4_decoder = {
|
| 2065 | 2065 |
.init = decode_init_mp3on4, |
| 2066 | 2066 |
.close = decode_close_mp3on4, |
| 2067 | 2067 |
.decode = decode_frame_mp3on4, |
| 2068 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 2068 | 2069 |
.flush = flush_mp3on4, |
| 2069 | 2070 |
.long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
|
| 2070 | 2071 |
}; |
| ... | ... |
@@ -31,7 +31,9 @@ AVCodec ff_mp1float_decoder = {
|
| 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 = {
|
| 46 | 46 |
.init = decode_init, |
| 47 | 47 |
.decode = decode_frame, |
| 48 | 48 |
#if FF_API_PARSE_FRAME |
| 49 |
- .capabilities = CODEC_CAP_PARSE_ONLY, |
|
| 49 |
+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, |
|
| 50 |
+#else |
|
| 51 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 50 | 52 |
#endif |
| 51 | 53 |
.flush = flush, |
| 52 | 54 |
.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
|
| ... | ... |
@@ -61,7 +65,9 @@ AVCodec ff_mp3float_decoder = {
|
| 61 | 61 |
.init = decode_init, |
| 62 | 62 |
.decode = decode_frame, |
| 63 | 63 |
#if FF_API_PARSE_FRAME |
| 64 |
- .capabilities = CODEC_CAP_PARSE_ONLY, |
|
| 64 |
+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, |
|
| 65 |
+#else |
|
| 66 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 65 | 67 |
#endif |
| 66 | 68 |
.flush = flush, |
| 67 | 69 |
.long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
|
| ... | ... |
@@ -76,7 +82,9 @@ AVCodec ff_mp3adufloat_decoder = {
|
| 76 | 76 |
.init = decode_init, |
| 77 | 77 |
.decode = decode_frame_adu, |
| 78 | 78 |
#if FF_API_PARSE_FRAME |
| 79 |
- .capabilities = CODEC_CAP_PARSE_ONLY, |
|
| 79 |
+ .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, |
|
| 80 |
+#else |
|
| 81 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 80 | 82 |
#endif |
| 81 | 83 |
.flush = flush, |
| 82 | 84 |
.long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
|
| ... | ... |
@@ -91,6 +99,7 @@ AVCodec ff_mp3on4float_decoder = {
|
| 91 | 91 |
.init = decode_init_mp3on4, |
| 92 | 92 |
.close = decode_close_mp3on4, |
| 93 | 93 |
.decode = decode_frame_mp3on4, |
| 94 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 94 | 95 |
.flush = flush_mp3on4, |
| 95 | 96 |
.long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
|
| 96 | 97 |
}; |
| ... | ... |
@@ -2351,7 +2351,8 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
|
| 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){
|
| 2361 | 2361 |
return; |
| 2362 | 2362 |
|
| 2363 | 2363 |
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; |
|
| 2364 |
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) |
|
| 2365 |
+ offset[i] = 0; |
|
| 2368 | 2366 |
}else{
|
| 2369 | 2367 |
offset[0]= y * s->linesize; |
| 2370 | 2368 |
offset[1]= |
| 2371 | 2369 |
offset[2]= (y >> s->chroma_y_shift) * s->uvlinesize; |
| 2372 |
- offset[3]= 0; |
|
| 2370 |
+ for (i = 3; i < AV_NUM_DATA_POINTERS; i++) |
|
| 2371 |
+ offset[i] = 0; |
|
| 2373 | 2372 |
} |
| 2374 | 2373 |
|
| 2375 | 2374 |
emms_c(); |
| ... | ... |
@@ -47,6 +47,7 @@ |
| 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) {
|
| 142 | 142 |
ff_init_ff_sine_windows(7); |
| 143 | 143 |
|
| 144 | 144 |
avctx->channel_layout = AV_CH_LAYOUT_MONO; |
| 145 |
+ |
|
| 146 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 147 |
+ avctx->coded_frame = &s->frame; |
|
| 148 |
+ |
|
| 145 | 149 |
return 0; |
| 146 | 150 |
} |
| 147 | 151 |
|
| 148 |
-static int decode_tag(AVCodecContext * avctx, |
|
| 149 |
- void *data, int *data_size, |
|
| 150 |
- AVPacket *avpkt) {
|
|
| 152 |
+static int decode_tag(AVCodecContext *avctx, void *data, |
|
| 153 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 154 |
+{
|
|
| 151 | 155 |
const uint8_t *buf = avpkt->data; |
| 152 | 156 |
const uint8_t *side=av_packet_get_side_data(avpkt, 'F', NULL); |
| 153 | 157 |
int buf_size = avpkt->size; |
| 154 | 158 |
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; |
|
| 159 |
+ int blocks, i, ret; |
|
| 160 |
+ int16_t *samples_s16; |
|
| 161 |
+ float *samples_flt; |
|
| 160 | 162 |
|
| 161 |
- block_size = NELLY_SAMPLES * av_get_bytes_per_sample(avctx->sample_fmt); |
|
| 162 | 163 |
blocks = buf_size / NELLY_BLOCK_LEN; |
| 163 | 164 |
|
| 164 | 165 |
if (blocks <= 0) {
|
| 165 | 166 |
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); |
| 166 | 167 |
return AVERROR_INVALIDDATA; |
| 167 | 168 |
} |
| 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 |
- } |
|
| 169 |
+ |
|
| 172 | 170 |
if (buf_size % NELLY_BLOCK_LEN) {
|
| 173 | 171 |
av_log(avctx, AV_LOG_WARNING, "Leftover bytes: %d.\n", |
| 174 | 172 |
buf_size % NELLY_BLOCK_LEN); |
| ... | ... |
@@ -183,6 +182,15 @@ static int decode_tag(AVCodecContext * avctx, |
| 183 | 183 |
if(side && blocks>1 && avctx->sample_rate%11025==0 && (1<<((side[0]>>2)&3)) == blocks) |
| 184 | 184 |
avctx->sample_rate= 11025*(blocks/2); |
| 185 | 185 |
|
| 186 |
+ /* get output buffer */ |
|
| 187 |
+ s->frame.nb_samples = NELLY_SAMPLES * blocks; |
|
| 188 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 189 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 190 |
+ return ret; |
|
| 191 |
+ } |
|
| 192 |
+ samples_s16 = (int16_t *)s->frame.data[0]; |
|
| 193 |
+ samples_flt = (float *)s->frame.data[0]; |
|
| 194 |
+ |
|
| 186 | 195 |
for (i=0 ; i<blocks ; i++) {
|
| 187 | 196 |
if (avctx->sample_fmt == SAMPLE_FMT_FLT) {
|
| 188 | 197 |
nelly_decode_block(s, buf, samples_flt); |
| ... | ... |
@@ -194,7 +202,9 @@ static int decode_tag(AVCodecContext * avctx, |
| 194 | 194 |
} |
| 195 | 195 |
buf += NELLY_BLOCK_LEN; |
| 196 | 196 |
} |
| 197 |
- *data_size = blocks * block_size; |
|
| 197 |
+ |
|
| 198 |
+ *got_frame_ptr = 1; |
|
| 199 |
+ *(AVFrame *)data = s->frame; |
|
| 198 | 200 |
|
| 199 | 201 |
return buf_size; |
| 200 | 202 |
} |
| ... | ... |
@@ -204,6 +214,7 @@ static av_cold int decode_end(AVCodecContext * avctx) {
|
| 204 | 204 |
|
| 205 | 205 |
av_freep(&s->float_buf); |
| 206 | 206 |
ff_mdct_end(&s->imdct_ctx); |
| 207 |
+ |
|
| 207 | 208 |
return 0; |
| 208 | 209 |
} |
| 209 | 210 |
|
| ... | ... |
@@ -215,6 +226,7 @@ AVCodec ff_nellymoser_decoder = {
|
| 215 | 215 |
.init = decode_init, |
| 216 | 216 |
.close = decode_end, |
| 217 | 217 |
.decode = decode_tag, |
| 218 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 218 | 219 |
.long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
|
| 219 | 220 |
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
|
| 220 | 221 |
AV_SAMPLE_FMT_S16, |
| ... | ... |
@@ -192,6 +192,7 @@ static int pcm_encode_frame(AVCodecContext *avctx, |
| 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) |
| 223 | 223 |
if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) |
| 224 | 224 |
avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec->id); |
| 225 | 225 |
|
| 226 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 227 |
+ avctx->coded_frame = &s->frame; |
|
| 228 |
+ |
|
| 226 | 229 |
return 0; |
| 227 | 230 |
} |
| 228 | 231 |
|
| ... | ... |
@@ -243,22 +247,20 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx) |
| 243 | 243 |
dst += size / 8; \ |
| 244 | 244 |
} |
| 245 | 245 |
|
| 246 |
-static int pcm_decode_frame(AVCodecContext *avctx, |
|
| 247 |
- void *data, int *data_size, |
|
| 248 |
- AVPacket *avpkt) |
|
| 246 |
+static int pcm_decode_frame(AVCodecContext *avctx, void *data, |
|
| 247 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 249 | 248 |
{
|
| 250 | 249 |
const uint8_t *src = avpkt->data; |
| 251 | 250 |
int buf_size = avpkt->size; |
| 252 | 251 |
PCMDecode *s = avctx->priv_data; |
| 253 |
- int sample_size, c, n, out_size; |
|
| 252 |
+ int sample_size, c, n, ret, samples_per_block; |
|
| 254 | 253 |
uint8_t *samples; |
| 255 | 254 |
int32_t *dst_int32_t; |
| 256 | 255 |
|
| 257 |
- samples = data; |
|
| 258 |
- |
|
| 259 | 256 |
sample_size = av_get_bits_per_sample(avctx->codec_id)/8; |
| 260 | 257 |
|
| 261 | 258 |
/* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */ |
| 259 |
+ samples_per_block = 1; |
|
| 262 | 260 |
if (CODEC_ID_PCM_DVD == avctx->codec_id) {
|
| 263 | 261 |
if (avctx->bits_per_coded_sample != 20 && |
| 264 | 262 |
avctx->bits_per_coded_sample != 24) {
|
| ... | ... |
@@ -268,10 +270,13 @@ static int pcm_decode_frame(AVCodecContext *avctx, |
| 268 | 268 |
return AVERROR(EINVAL); |
| 269 | 269 |
} |
| 270 | 270 |
/* 2 samples are interleaved per block in PCM_DVD */ |
| 271 |
+ samples_per_block = 2; |
|
| 271 | 272 |
sample_size = avctx->bits_per_coded_sample * 2 / 8; |
| 272 |
- } else if (avctx->codec_id == CODEC_ID_PCM_LXF) |
|
| 273 |
+ } else if (avctx->codec_id == CODEC_ID_PCM_LXF) {
|
|
| 273 | 274 |
/* we process 40-bit blocks per channel for LXF */ |
| 275 |
+ samples_per_block = 2; |
|
| 274 | 276 |
sample_size = 5; |
| 277 |
+ } |
|
| 275 | 278 |
|
| 276 | 279 |
if (sample_size == 0) {
|
| 277 | 280 |
av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n"); |
| ... | ... |
@@ -290,14 +295,13 @@ static int pcm_decode_frame(AVCodecContext *avctx, |
| 290 | 290 |
|
| 291 | 291 |
n = buf_size/sample_size; |
| 292 | 292 |
|
| 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); |
|
| 293 |
+ /* get output buffer */ |
|
| 294 |
+ s->frame.nb_samples = n * samples_per_block / avctx->channels; |
|
| 295 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 296 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 297 |
+ return ret; |
|
| 300 | 298 |
} |
| 299 |
+ samples = s->frame.data[0]; |
|
| 301 | 300 |
|
| 302 | 301 |
switch(avctx->codec->id) {
|
| 303 | 302 |
case CODEC_ID_PCM_U32LE: |
| ... | ... |
@@ -403,7 +407,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, |
| 403 | 403 |
case CODEC_ID_PCM_DVD: |
| 404 | 404 |
{
|
| 405 | 405 |
const uint8_t *src8; |
| 406 |
- dst_int32_t = data; |
|
| 406 |
+ dst_int32_t = (int32_t *)s->frame.data[0]; |
|
| 407 | 407 |
n /= avctx->channels; |
| 408 | 408 |
switch (avctx->bits_per_coded_sample) {
|
| 409 | 409 |
case 20: |
| ... | ... |
@@ -435,7 +439,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, |
| 435 | 435 |
{
|
| 436 | 436 |
int i; |
| 437 | 437 |
const uint8_t *src8; |
| 438 |
- dst_int32_t = data; |
|
| 438 |
+ dst_int32_t = (int32_t *)s->frame.data[0]; |
|
| 439 | 439 |
n /= avctx->channels; |
| 440 | 440 |
//unpack and de-planerize |
| 441 | 441 |
for (i = 0; i < n; i++) {
|
| ... | ... |
@@ -456,7 +460,10 @@ static int pcm_decode_frame(AVCodecContext *avctx, |
| 456 | 456 |
default: |
| 457 | 457 |
return -1; |
| 458 | 458 |
} |
| 459 |
- *data_size = out_size; |
|
| 459 |
+ |
|
| 460 |
+ *got_frame_ptr = 1; |
|
| 461 |
+ *(AVFrame *)data = s->frame; |
|
| 462 |
+ |
|
| 460 | 463 |
return buf_size; |
| 461 | 464 |
} |
| 462 | 465 |
|
| ... | ... |
@@ -485,6 +492,7 @@ AVCodec ff_ ## name_ ## _decoder = { \
|
| 485 | 485 |
.priv_data_size = sizeof(PCMDecode), \ |
| 486 | 486 |
.init = pcm_decode_init, \ |
| 487 | 487 |
.decode = pcm_decode_frame, \ |
| 488 |
+ .capabilities = CODEC_CAP_DR1, \ |
|
| 488 | 489 |
.sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
|
| 489 | 490 |
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ |
| 490 | 491 |
} |
| ... | ... |
@@ -56,6 +56,7 @@ typedef enum |
| 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) |
| 97 | 97 |
for(i=0; i<10; i++) |
| 98 | 98 |
q->prev_lspf[i] = (i+1)/11.; |
| 99 | 99 |
|
| 100 |
+ avcodec_get_frame_defaults(&q->avframe); |
|
| 101 |
+ avctx->coded_frame = &q->avframe; |
|
| 102 |
+ |
|
| 100 | 103 |
return 0; |
| 101 | 104 |
} |
| 102 | 105 |
|
| ... | ... |
@@ -682,23 +686,25 @@ static void postfilter(QCELPContext *q, float *samples, float *lpc) |
| 682 | 682 |
160, 0.9375, &q->postfilter_agc_mem); |
| 683 | 683 |
} |
| 684 | 684 |
|
| 685 |
-static int qcelp_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
|
| 686 |
- AVPacket *avpkt) |
|
| 685 |
+static int qcelp_decode_frame(AVCodecContext *avctx, void *data, |
|
| 686 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 687 | 687 |
{
|
| 688 | 688 |
const uint8_t *buf = avpkt->data; |
| 689 | 689 |
int buf_size = avpkt->size; |
| 690 | 690 |
QCELPContext *q = avctx->priv_data; |
| 691 |
- float *outbuffer = data; |
|
| 692 |
- int i, out_size; |
|
| 691 |
+ float *outbuffer; |
|
| 692 |
+ int i, ret; |
|
| 693 | 693 |
float quantized_lspf[10], lpc[10]; |
| 694 | 694 |
float gain[16]; |
| 695 | 695 |
float *formant_mem; |
| 696 | 696 |
|
| 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); |
|
| 697 |
+ /* get output buffer */ |
|
| 698 |
+ q->avframe.nb_samples = 160; |
|
| 699 |
+ if ((ret = avctx->get_buffer(avctx, &q->avframe)) < 0) {
|
|
| 700 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 701 |
+ return ret; |
|
| 701 | 702 |
} |
| 703 |
+ outbuffer = (float *)q->avframe.data[0]; |
|
| 702 | 704 |
|
| 703 | 705 |
if ((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) {
|
| 704 | 706 |
warn_insufficient_frame_quality(avctx, "bitrate cannot be determined."); |
| ... | ... |
@@ -783,7 +789,8 @@ erasure: |
| 783 | 783 |
memcpy(q->prev_lspf, quantized_lspf, sizeof(q->prev_lspf)); |
| 784 | 784 |
q->prev_bitrate = q->bitrate; |
| 785 | 785 |
|
| 786 |
- *data_size = out_size; |
|
| 786 |
+ *got_frame_ptr = 1; |
|
| 787 |
+ *(AVFrame *)data = q->avframe; |
|
| 787 | 788 |
|
| 788 | 789 |
return buf_size; |
| 789 | 790 |
} |
| ... | ... |
@@ -795,6 +802,7 @@ AVCodec ff_qcelp_decoder = |
| 795 | 795 |
.id = CODEC_ID_QCELP, |
| 796 | 796 |
.init = qcelp_decode_init, |
| 797 | 797 |
.decode = qcelp_decode_frame, |
| 798 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 798 | 799 |
.priv_data_size = sizeof(QCELPContext), |
| 799 | 800 |
.long_name = NULL_IF_CONFIG_SMALL("QCELP / PureVoice"),
|
| 800 | 801 |
}; |
| ... | ... |
@@ -130,6 +130,8 @@ typedef struct {
|
| 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) |
| 1876 | 1876 |
|
| 1877 | 1877 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 1878 | 1878 |
|
| 1879 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 1880 |
+ avctx->coded_frame = &s->frame; |
|
| 1881 |
+ |
|
| 1879 | 1882 |
// dump_context(s); |
| 1880 | 1883 |
return 0; |
| 1881 | 1884 |
} |
| ... | ... |
@@ -1956,30 +1961,27 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) |
| 1956 | 1956 |
} |
| 1957 | 1957 |
|
| 1958 | 1958 |
|
| 1959 |
-static int qdm2_decode_frame(AVCodecContext *avctx, |
|
| 1960 |
- void *data, int *data_size, |
|
| 1961 |
- AVPacket *avpkt) |
|
| 1959 |
+static int qdm2_decode_frame(AVCodecContext *avctx, void *data, |
|
| 1960 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1962 | 1961 |
{
|
| 1963 | 1962 |
const uint8_t *buf = avpkt->data; |
| 1964 | 1963 |
int buf_size = avpkt->size; |
| 1965 | 1964 |
QDM2Context *s = avctx->priv_data; |
| 1966 |
- int16_t *out = data; |
|
| 1967 |
- int i, out_size; |
|
| 1965 |
+ int16_t *out; |
|
| 1966 |
+ int i, ret; |
|
| 1968 | 1967 |
|
| 1969 | 1968 |
if(!buf) |
| 1970 | 1969 |
return 0; |
| 1971 | 1970 |
if(buf_size < s->checksum_size) |
| 1972 | 1971 |
return -1; |
| 1973 | 1972 |
|
| 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); |
|
| 1973 |
+ /* get output buffer */ |
|
| 1974 |
+ s->frame.nb_samples = 16 * s->frame_size; |
|
| 1975 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 1976 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1977 |
+ return ret; |
|
| 1979 | 1978 |
} |
| 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); |
|
| 1979 |
+ out = (int16_t *)s->frame.data[0]; |
|
| 1983 | 1980 |
|
| 1984 | 1981 |
for (i = 0; i < 16; i++) {
|
| 1985 | 1982 |
if (qdm2_decode(s, buf, out) < 0) |
| ... | ... |
@@ -1987,7 +1989,8 @@ static int qdm2_decode_frame(AVCodecContext *avctx, |
| 1987 | 1987 |
out += s->channels * s->frame_size; |
| 1988 | 1988 |
} |
| 1989 | 1989 |
|
| 1990 |
- *data_size = out_size; |
|
| 1990 |
+ *got_frame_ptr = 1; |
|
| 1991 |
+ *(AVFrame *)data = s->frame; |
|
| 1991 | 1992 |
|
| 1992 | 1993 |
return s->checksum_size; |
| 1993 | 1994 |
} |
| ... | ... |
@@ -2001,5 +2004,6 @@ AVCodec ff_qdm2_decoder = |
| 2001 | 2001 |
.init = qdm2_decode_init, |
| 2002 | 2002 |
.close = qdm2_decode_close, |
| 2003 | 2003 |
.decode = qdm2_decode_frame, |
| 2004 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 2004 | 2005 |
.long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),
|
| 2005 | 2006 |
}; |
| ... | ... |
@@ -38,6 +38,10 @@ static av_cold int ra144_decode_init(AVCodecContext * avctx) |
| 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, |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 | 56 |
/** Uncompress one block (20 bytes -> 160*2 bytes). */ |
| 57 |
-static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, |
|
| 58 |
- int *data_size, AVPacket *avpkt) |
|
| 57 |
+static int ra144_decode_frame(AVCodecContext * avctx, void *data, |
|
| 58 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 59 | 59 |
{
|
| 60 | 60 |
const uint8_t *buf = avpkt->data; |
| 61 | 61 |
int buf_size = avpkt->size; |
| ... | ... |
@@ -64,23 +68,25 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, |
| 64 | 64 |
uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block |
| 65 | 65 |
unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame |
| 66 | 66 |
int i, j; |
| 67 |
- int out_size; |
|
| 68 |
- int16_t *data = vdata; |
|
| 67 |
+ int ret; |
|
| 68 |
+ int16_t *samples; |
|
| 69 | 69 |
unsigned int energy; |
| 70 | 70 |
|
| 71 | 71 |
RA144Context *ractx = avctx->priv_data; |
| 72 | 72 |
GetBitContext gb; |
| 73 | 73 |
|
| 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); |
|
| 74 |
+ /* get output buffer */ |
|
| 75 |
+ ractx->frame.nb_samples = NBLOCKS * BLOCKSIZE; |
|
| 76 |
+ if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) {
|
|
| 77 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 78 |
+ return ret; |
|
| 78 | 79 |
} |
| 80 |
+ samples = (int16_t *)ractx->frame.data[0]; |
|
| 79 | 81 |
|
| 80 | 82 |
if(buf_size < FRAMESIZE) {
|
| 81 | 83 |
av_log(avctx, AV_LOG_ERROR, |
| 82 | 84 |
"Frame too small (%d bytes). Truncated file?\n", buf_size); |
| 83 |
- *data_size = 0; |
|
| 85 |
+ *got_frame_ptr = 0; |
|
| 84 | 86 |
return buf_size; |
| 85 | 87 |
} |
| 86 | 88 |
init_get_bits(&gb, buf, FRAMESIZE * 8); |
| ... | ... |
@@ -106,7 +112,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, |
| 106 | 106 |
do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb); |
| 107 | 107 |
|
| 108 | 108 |
for (j=0; j < BLOCKSIZE; j++) |
| 109 |
- *data++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2); |
|
| 109 |
+ *samples++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2); |
|
| 110 | 110 |
} |
| 111 | 111 |
|
| 112 | 112 |
ractx->old_energy = energy; |
| ... | ... |
@@ -114,7 +120,9 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, |
| 114 | 114 |
|
| 115 | 115 |
FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); |
| 116 | 116 |
|
| 117 |
- *data_size = out_size; |
|
| 117 |
+ *got_frame_ptr = 1; |
|
| 118 |
+ *(AVFrame *)data = ractx->frame; |
|
| 119 |
+ |
|
| 118 | 120 |
return FRAMESIZE; |
| 119 | 121 |
} |
| 120 | 122 |
|
| ... | ... |
@@ -125,5 +133,6 @@ AVCodec ff_ra_144_decoder = {
|
| 125 | 125 |
.priv_data_size = sizeof(RA144Context), |
| 126 | 126 |
.init = ra144_decode_init, |
| 127 | 127 |
.decode = ra144_decode_frame, |
| 128 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 128 | 129 |
.long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
|
| 129 | 130 |
}; |
| ... | ... |
@@ -36,6 +36,7 @@ |
| 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) |
| 62 | 62 |
RA288Context *ractx = avctx->priv_data; |
| 63 | 63 |
avctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
| 64 | 64 |
dsputil_init(&ractx->dsp, avctx); |
| 65 |
+ |
|
| 66 |
+ avcodec_get_frame_defaults(&ractx->frame); |
|
| 67 |
+ avctx->coded_frame = &ractx->frame; |
|
| 68 |
+ |
|
| 65 | 69 |
return 0; |
| 66 | 70 |
} |
| 67 | 71 |
|
| ... | ... |
@@ -165,12 +170,12 @@ static void backward_filter(RA288Context *ractx, |
| 165 | 165 |
} |
| 166 | 166 |
|
| 167 | 167 |
static int ra288_decode_frame(AVCodecContext * avctx, void *data, |
| 168 |
- int *data_size, AVPacket *avpkt) |
|
| 168 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 169 | 169 |
{
|
| 170 | 170 |
const uint8_t *buf = avpkt->data; |
| 171 | 171 |
int buf_size = avpkt->size; |
| 172 |
- float *out = data; |
|
| 173 |
- int i, out_size; |
|
| 172 |
+ float *out; |
|
| 173 |
+ int i, ret; |
|
| 174 | 174 |
RA288Context *ractx = avctx->priv_data; |
| 175 | 175 |
GetBitContext gb; |
| 176 | 176 |
|
| ... | ... |
@@ -181,12 +186,13 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, |
| 181 | 181 |
return AVERROR_INVALIDDATA; |
| 182 | 182 |
} |
| 183 | 183 |
|
| 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); |
|
| 184 |
+ /* get output buffer */ |
|
| 185 |
+ ractx->frame.nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME; |
|
| 186 |
+ if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) {
|
|
| 187 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 188 |
+ return ret; |
|
| 189 | 189 |
} |
| 190 |
+ out = (float *)ractx->frame.data[0]; |
|
| 190 | 191 |
|
| 191 | 192 |
init_get_bits(&gb, buf, avctx->block_align * 8); |
| 192 | 193 |
|
| ... | ... |
@@ -208,7 +214,9 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, |
| 208 | 208 |
} |
| 209 | 209 |
} |
| 210 | 210 |
|
| 211 |
- *data_size = out_size; |
|
| 211 |
+ *got_frame_ptr = 1; |
|
| 212 |
+ *(AVFrame *)data = ractx->frame; |
|
| 213 |
+ |
|
| 212 | 214 |
return avctx->block_align; |
| 213 | 215 |
} |
| 214 | 216 |
|
| ... | ... |
@@ -219,5 +227,6 @@ AVCodec ff_ra_288_decoder = {
|
| 219 | 219 |
.priv_data_size = sizeof(RA288Context), |
| 220 | 220 |
.init = ra288_decode_init, |
| 221 | 221 |
.decode = ra288_decode_frame, |
| 222 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 222 | 223 |
.long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"),
|
| 223 | 224 |
}; |
| ... | ... |
@@ -25,6 +25,10 @@ |
| 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, |
| 83 | 83 |
} |
| 84 | 84 |
|
| 85 | 85 |
static int s302m_decode_frame(AVCodecContext *avctx, void *data, |
| 86 |
- int *data_size, AVPacket *avpkt) |
|
| 86 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 87 | 87 |
{
|
| 88 |
+ S302MDecodeContext *s = avctx->priv_data; |
|
| 88 | 89 |
const uint8_t *buf = avpkt->data; |
| 89 | 90 |
int buf_size = avpkt->size; |
| 91 |
+ int block_size, ret; |
|
| 90 | 92 |
|
| 91 | 93 |
int frame_size = s302m_parse_frame_header(avctx, buf, buf_size); |
| 92 | 94 |
if (frame_size < 0) |
| ... | ... |
@@ -95,11 +101,18 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, |
| 95 | 95 |
buf_size -= AES3_HEADER_LEN; |
| 96 | 96 |
buf += AES3_HEADER_LEN; |
| 97 | 97 |
|
| 98 |
- if (*data_size < 4 * buf_size * 8 / (avctx->bits_per_coded_sample + 4)) |
|
| 99 |
- return -1; |
|
| 98 |
+ /* get output buffer */ |
|
| 99 |
+ block_size = (avctx->bits_per_coded_sample + 4) / 4; |
|
| 100 |
+ s->frame.nb_samples = 2 * (buf_size / block_size) / avctx->channels; |
|
| 101 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 102 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 103 |
+ return ret; |
|
| 104 |
+ } |
|
| 105 |
+ |
|
| 106 |
+ buf_size = (s->frame.nb_samples * avctx->channels / 2) * block_size; |
|
| 100 | 107 |
|
| 101 | 108 |
if (avctx->bits_per_coded_sample == 24) {
|
| 102 |
- uint32_t *o = data; |
|
| 109 |
+ uint32_t *o = (uint32_t *)s->frame.data[0]; |
|
| 103 | 110 |
for (; buf_size > 6; buf_size -= 7) {
|
| 104 | 111 |
*o++ = (av_reverse[buf[2]] << 24) | |
| 105 | 112 |
(av_reverse[buf[1]] << 16) | |
| ... | ... |
@@ -110,9 +123,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, |
| 110 | 110 |
(av_reverse[buf[3] & 0x0f] << 4); |
| 111 | 111 |
buf += 7; |
| 112 | 112 |
} |
| 113 |
- *data_size = (uint8_t*) o - (uint8_t*) data; |
|
| 114 | 113 |
} else if (avctx->bits_per_coded_sample == 20) {
|
| 115 |
- uint32_t *o = data; |
|
| 114 |
+ uint32_t *o = (uint32_t *)s->frame.data[0]; |
|
| 116 | 115 |
for (; buf_size > 5; buf_size -= 6) {
|
| 117 | 116 |
*o++ = (av_reverse[buf[2] & 0xf0] << 28) | |
| 118 | 117 |
(av_reverse[buf[1]] << 20) | |
| ... | ... |
@@ -122,9 +134,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, |
| 122 | 122 |
(av_reverse[buf[3]] << 12); |
| 123 | 123 |
buf += 6; |
| 124 | 124 |
} |
| 125 |
- *data_size = (uint8_t*) o - (uint8_t*) data; |
|
| 126 | 125 |
} else {
|
| 127 |
- uint16_t *o = data; |
|
| 126 |
+ uint16_t *o = (uint16_t *)s->frame.data[0]; |
|
| 128 | 127 |
for (; buf_size > 4; buf_size -= 5) {
|
| 129 | 128 |
*o++ = (av_reverse[buf[1]] << 8) | |
| 130 | 129 |
av_reverse[buf[0]]; |
| ... | ... |
@@ -133,10 +144,22 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, |
| 133 | 133 |
(av_reverse[buf[2]] >> 4); |
| 134 | 134 |
buf += 5; |
| 135 | 135 |
} |
| 136 |
- *data_size = (uint8_t*) o - (uint8_t*) data; |
|
| 137 | 136 |
} |
| 138 | 137 |
|
| 139 |
- return buf - avpkt->data; |
|
| 138 |
+ *got_frame_ptr = 1; |
|
| 139 |
+ *(AVFrame *)data = s->frame; |
|
| 140 |
+ |
|
| 141 |
+ return avpkt->size; |
|
| 142 |
+} |
|
| 143 |
+ |
|
| 144 |
+static int s302m_decode_init(AVCodecContext *avctx) |
|
| 145 |
+{
|
|
| 146 |
+ S302MDecodeContext *s = avctx->priv_data; |
|
| 147 |
+ |
|
| 148 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 149 |
+ avctx->coded_frame = &s->frame; |
|
| 150 |
+ |
|
| 151 |
+ return 0; |
|
| 140 | 152 |
} |
| 141 | 153 |
|
| 142 | 154 |
|
| ... | ... |
@@ -144,6 +167,9 @@ AVCodec ff_s302m_decoder = {
|
| 144 | 144 |
.name = "s302m", |
| 145 | 145 |
.type = AVMEDIA_TYPE_AUDIO, |
| 146 | 146 |
.id = CODEC_ID_S302M, |
| 147 |
+ .priv_data_size = sizeof(S302MDecodeContext), |
|
| 148 |
+ .init = s302m_decode_init, |
|
| 147 | 149 |
.decode = s302m_decode_frame, |
| 150 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 148 | 151 |
.long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"),
|
| 149 | 152 |
}; |
| ... | ... |
@@ -79,6 +79,7 @@ static const uint8_t is_audio_command[10] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0 };
|
| 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) |
| 112 | 112 |
s->avctx = avctx; |
| 113 | 113 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| 114 | 114 |
|
| 115 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 116 |
+ avctx->coded_frame = &s->frame; |
|
| 117 |
+ |
|
| 115 | 118 |
return 0; |
| 116 | 119 |
} |
| 117 | 120 |
|
| ... | ... |
@@ -394,15 +398,13 @@ static int read_header(ShortenContext *s) |
| 394 | 394 |
return 0; |
| 395 | 395 |
} |
| 396 | 396 |
|
| 397 |
-static int shorten_decode_frame(AVCodecContext *avctx, |
|
| 398 |
- void *data, int *data_size, |
|
| 399 |
- AVPacket *avpkt) |
|
| 397 |
+static int shorten_decode_frame(AVCodecContext *avctx, void *data, |
|
| 398 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 400 | 399 |
{
|
| 401 | 400 |
const uint8_t *buf = avpkt->data; |
| 402 | 401 |
int buf_size = avpkt->size; |
| 403 | 402 |
ShortenContext *s = avctx->priv_data; |
| 404 | 403 |
int i, input_buf_size = 0; |
| 405 |
- int16_t *samples = data; |
|
| 406 | 404 |
int ret; |
| 407 | 405 |
|
| 408 | 406 |
/* allocate internal bitstream buffer */ |
| ... | ... |
@@ -436,7 +438,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, |
| 436 | 436 |
/* do not decode until buffer has at least max_framesize bytes or |
| 437 | 437 |
the end of the file has been reached */ |
| 438 | 438 |
if (buf_size < s->max_framesize && avpkt->data) {
|
| 439 |
- *data_size = 0; |
|
| 439 |
+ *got_frame_ptr = 0; |
|
| 440 | 440 |
return input_buf_size; |
| 441 | 441 |
} |
| 442 | 442 |
} |
| ... | ... |
@@ -448,13 +450,13 @@ static int shorten_decode_frame(AVCodecContext *avctx, |
| 448 | 448 |
if (!s->got_header) {
|
| 449 | 449 |
if ((ret = read_header(s)) < 0) |
| 450 | 450 |
return ret; |
| 451 |
- *data_size = 0; |
|
| 451 |
+ *got_frame_ptr = 0; |
|
| 452 | 452 |
goto finish_frame; |
| 453 | 453 |
} |
| 454 | 454 |
|
| 455 | 455 |
/* if quit command was read previously, don't decode anything */ |
| 456 | 456 |
if (s->got_quit_command) {
|
| 457 |
- *data_size = 0; |
|
| 457 |
+ *got_frame_ptr = 0; |
|
| 458 | 458 |
return avpkt->size; |
| 459 | 459 |
} |
| 460 | 460 |
|
| ... | ... |
@@ -464,7 +466,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, |
| 464 | 464 |
int len; |
| 465 | 465 |
|
| 466 | 466 |
if (get_bits_left(&s->gb) < 3+FNSIZE) {
|
| 467 |
- *data_size = 0; |
|
| 467 |
+ *got_frame_ptr = 0; |
|
| 468 | 468 |
break; |
| 469 | 469 |
} |
| 470 | 470 |
|
| ... | ... |
@@ -472,7 +474,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, |
| 472 | 472 |
|
| 473 | 473 |
if (cmd > FN_VERBATIM) {
|
| 474 | 474 |
av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); |
| 475 |
- *data_size = 0; |
|
| 475 |
+ *got_frame_ptr = 0; |
|
| 476 | 476 |
break; |
| 477 | 477 |
} |
| 478 | 478 |
|
| ... | ... |
@@ -507,7 +509,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, |
| 507 | 507 |
break; |
| 508 | 508 |
} |
| 509 | 509 |
if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {
|
| 510 |
- *data_size = 0; |
|
| 510 |
+ *got_frame_ptr = 0; |
|
| 511 | 511 |
break; |
| 512 | 512 |
} |
| 513 | 513 |
} else {
|
| ... | ... |
@@ -571,19 +573,23 @@ static int shorten_decode_frame(AVCodecContext *avctx, |
| 571 | 571 |
/* if this is the last channel in the block, output the samples */ |
| 572 | 572 |
s->cur_chan++; |
| 573 | 573 |
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); |
|
| 574 |
+ /* get output buffer */ |
|
| 575 |
+ s->frame.nb_samples = s->blocksize; |
|
| 576 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 577 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 578 |
+ return ret; |
|
| 579 | 579 |
} |
| 580 |
- interleave_buffer(samples, s->channels, s->blocksize, s->decoded); |
|
| 581 |
- *data_size = out_size; |
|
| 580 |
+ /* interleave output */ |
|
| 581 |
+ interleave_buffer((int16_t *)s->frame.data[0], s->channels, |
|
| 582 |
+ s->blocksize, s->decoded); |
|
| 583 |
+ |
|
| 584 |
+ *got_frame_ptr = 1; |
|
| 585 |
+ *(AVFrame *)data = s->frame; |
|
| 582 | 586 |
} |
| 583 | 587 |
} |
| 584 | 588 |
} |
| 585 | 589 |
if (s->cur_chan < s->channels) |
| 586 |
- *data_size = 0; |
|
| 590 |
+ *got_frame_ptr = 0; |
|
| 587 | 591 |
|
| 588 | 592 |
finish_frame: |
| 589 | 593 |
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) |
| 614 | 614 |
} |
| 615 | 615 |
av_freep(&s->bitstream); |
| 616 | 616 |
av_freep(&s->coeffs); |
| 617 |
+ |
|
| 617 | 618 |
return 0; |
| 618 | 619 |
} |
| 619 | 620 |
|
| ... | ... |
@@ -625,6 +632,6 @@ AVCodec ff_shorten_decoder = {
|
| 625 | 625 |
.init = shorten_decode_init, |
| 626 | 626 |
.close = shorten_decode_close, |
| 627 | 627 |
.decode = shorten_decode_frame, |
| 628 |
- .capabilities = CODEC_CAP_DELAY, |
|
| 628 |
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, |
|
| 629 | 629 |
.long_name= NULL_IF_CONFIG_SMALL("Shorten"),
|
| 630 | 630 |
}; |
| ... | ... |
@@ -507,20 +507,23 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx) |
| 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, |
| 530 | 530 |
return -1; |
| 531 | 531 |
} |
| 532 | 532 |
|
| 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; |
|
| 533 |
+ /* get output buffer */ |
|
| 534 |
+ ctx->frame.nb_samples = mode_par->frames_per_packet * subframe_size * |
|
| 535 |
+ mode_par->subframe_count; |
|
| 536 |
+ if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
|
|
| 537 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 538 |
+ return ret; |
|
| 541 | 539 |
} |
| 540 |
+ samples = (float *)ctx->frame.data[0]; |
|
| 542 | 541 |
|
| 543 | 542 |
init_get_bits(&gb, buf, mode_par->bits_per_frame); |
| 544 | 543 |
|
| 545 | 544 |
for (i = 0; i < mode_par->frames_per_packet; i++) {
|
| 546 | 545 |
decode_parameters(&parm, &gb, mode_par); |
| 547 | 546 |
|
| 548 |
- ctx->decode_frame(ctx, &parm, data); |
|
| 547 |
+ ctx->decode_frame(ctx, &parm, samples); |
|
| 549 | 548 |
|
| 550 |
- data += subframe_size * mode_par->subframe_count; |
|
| 549 |
+ samples += subframe_size * mode_par->subframe_count; |
|
| 551 | 550 |
} |
| 552 | 551 |
|
| 553 |
- *data_size = out_size; |
|
| 552 |
+ *got_frame_ptr = 1; |
|
| 553 |
+ *(AVFrame *)data = ctx->frame; |
|
| 554 | 554 |
|
| 555 | 555 |
return mode_par->bits_per_frame >> 3; |
| 556 | 556 |
} |
| ... | ... |
@@ -562,5 +565,6 @@ AVCodec ff_sipr_decoder = {
|
| 562 | 562 |
.priv_data_size = sizeof(SiprContext), |
| 563 | 563 |
.init = sipr_decoder_init, |
| 564 | 564 |
.decode = sipr_decode_frame, |
| 565 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 565 | 566 |
.long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
|
| 566 | 567 |
}; |
| ... | ... |
@@ -559,31 +559,43 @@ static av_cold int decode_end(AVCodecContext *avctx) |
| 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, |
| 599 | 599 |
|
| 600 | 600 |
if(!get_bits1(&gb)){
|
| 601 | 601 |
av_log(avctx, AV_LOG_INFO, "Sound: no data\n"); |
| 602 |
- *data_size = 0; |
|
| 602 |
+ *got_frame_ptr = 0; |
|
| 603 | 603 |
return 1; |
| 604 | 604 |
} |
| 605 | 605 |
stereo = get_bits1(&gb); |
| 606 | 606 |
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 | 607 |
if (stereo ^ (avctx->channels != 1)) {
|
| 612 | 608 |
av_log(avctx, AV_LOG_ERROR, "channels mismatch\n"); |
| 613 | 609 |
return AVERROR(EINVAL); |
| ... | ... |
@@ -617,6 +625,15 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 617 | 617 |
return AVERROR(EINVAL); |
| 618 | 618 |
} |
| 619 | 619 |
|
| 620 |
+ /* get output buffer */ |
|
| 621 |
+ s->frame.nb_samples = unp_size / (avctx->channels * (bits + 1)); |
|
| 622 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 623 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 624 |
+ return ret; |
|
| 625 |
+ } |
|
| 626 |
+ samples = (int16_t *)s->frame.data[0]; |
|
| 627 |
+ samples8 = s->frame.data[0]; |
|
| 628 |
+ |
|
| 620 | 629 |
memset(vlc, 0, sizeof(VLC) * 4); |
| 621 | 630 |
memset(h, 0, sizeof(HuffContext) * 4); |
| 622 | 631 |
// Initialize |
| ... | ... |
@@ -706,7 +723,9 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 706 | 706 |
av_free(h[i].values); |
| 707 | 707 |
} |
| 708 | 708 |
|
| 709 |
- *data_size = unp_size; |
|
| 709 |
+ *got_frame_ptr = 1; |
|
| 710 |
+ *(AVFrame *)data = s->frame; |
|
| 711 |
+ |
|
| 710 | 712 |
return buf_size; |
| 711 | 713 |
} |
| 712 | 714 |
|
| ... | ... |
@@ -726,8 +745,10 @@ AVCodec ff_smackaud_decoder = {
|
| 726 | 726 |
.name = "smackaud", |
| 727 | 727 |
.type = AVMEDIA_TYPE_AUDIO, |
| 728 | 728 |
.id = CODEC_ID_SMACKAUDIO, |
| 729 |
+ .priv_data_size = sizeof(SmackerAudioContext), |
|
| 729 | 730 |
.init = smka_decode_init, |
| 730 | 731 |
.decode = smka_decode_frame, |
| 732 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 731 | 733 |
.long_name = NULL_IF_CONFIG_SMALL("Smacker audio"),
|
| 732 | 734 |
}; |
| 733 | 735 |
|
| ... | ... |
@@ -195,7 +195,8 @@ static const uint8_t string_table[256] = {
|
| 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 @@ |
| 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) |
| 69 | 69 |
|
| 70 | 70 |
dsputil_init(&c->dsp, avctx); |
| 71 | 71 |
|
| 72 |
+ avcodec_get_frame_defaults(&c->frame); |
|
| 73 |
+ avctx->coded_frame = &c->frame; |
|
| 74 |
+ |
|
| 72 | 75 |
return 0; |
| 73 | 76 |
} |
| 74 | 77 |
|
| ... | ... |
@@ -299,17 +303,16 @@ static void truespeech_save_prevvec(TSContext *c) |
| 299 | 299 |
c->prevfilt[i] = c->cvector[i]; |
| 300 | 300 |
} |
| 301 | 301 |
|
| 302 |
-static int truespeech_decode_frame(AVCodecContext *avctx, |
|
| 303 |
- void *data, int *data_size, |
|
| 304 |
- AVPacket *avpkt) |
|
| 302 |
+static int truespeech_decode_frame(AVCodecContext *avctx, void *data, |
|
| 303 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 305 | 304 |
{
|
| 306 | 305 |
const uint8_t *buf = avpkt->data; |
| 307 | 306 |
int buf_size = avpkt->size; |
| 308 | 307 |
TSContext *c = avctx->priv_data; |
| 309 | 308 |
|
| 310 | 309 |
int i, j; |
| 311 |
- short *samples = data; |
|
| 312 |
- int iterations, out_size; |
|
| 310 |
+ int16_t *samples; |
|
| 311 |
+ int iterations, ret; |
|
| 313 | 312 |
|
| 314 | 313 |
iterations = buf_size / 32; |
| 315 | 314 |
|
| ... | ... |
@@ -319,13 +322,15 @@ static int truespeech_decode_frame(AVCodecContext *avctx, |
| 319 | 319 |
return -1; |
| 320 | 320 |
} |
| 321 | 321 |
|
| 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); |
|
| 322 |
+ /* get output buffer */ |
|
| 323 |
+ c->frame.nb_samples = iterations * 240; |
|
| 324 |
+ if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
|
|
| 325 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 326 |
+ return ret; |
|
| 326 | 327 |
} |
| 328 |
+ samples = (int16_t *)c->frame.data[0]; |
|
| 327 | 329 |
|
| 328 |
- memset(samples, 0, out_size); |
|
| 330 |
+ memset(samples, 0, iterations * 240 * sizeof(*samples)); |
|
| 329 | 331 |
|
| 330 | 332 |
for(j = 0; j < iterations; j++) {
|
| 331 | 333 |
truespeech_read_frame(c, buf); |
| ... | ... |
@@ -345,7 +350,8 @@ static int truespeech_decode_frame(AVCodecContext *avctx, |
| 345 | 345 |
truespeech_save_prevvec(c); |
| 346 | 346 |
} |
| 347 | 347 |
|
| 348 |
- *data_size = out_size; |
|
| 348 |
+ *got_frame_ptr = 1; |
|
| 349 |
+ *(AVFrame *)data = c->frame; |
|
| 349 | 350 |
|
| 350 | 351 |
return buf_size; |
| 351 | 352 |
} |
| ... | ... |
@@ -357,5 +363,6 @@ AVCodec ff_truespeech_decoder = {
|
| 357 | 357 |
.priv_data_size = sizeof(TSContext), |
| 358 | 358 |
.init = truespeech_decode_init, |
| 359 | 359 |
.decode = truespeech_decode_frame, |
| 360 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 360 | 361 |
.long_name = NULL_IF_CONFIG_SMALL("DSP Group TrueSpeech"),
|
| 361 | 362 |
}; |
| ... | ... |
@@ -56,6 +56,7 @@ typedef struct TTAChannel {
|
| 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) |
| 288 | 288 |
return -1; |
| 289 | 289 |
} |
| 290 | 290 |
|
| 291 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 292 |
+ avctx->coded_frame = &s->frame; |
|
| 293 |
+ |
|
| 291 | 294 |
return 0; |
| 292 | 295 |
} |
| 293 | 296 |
|
| 294 |
-static int tta_decode_frame(AVCodecContext *avctx, |
|
| 295 |
- void *data, int *data_size, |
|
| 296 |
- AVPacket *avpkt) |
|
| 297 |
+static int tta_decode_frame(AVCodecContext *avctx, void *data, |
|
| 298 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 297 | 299 |
{
|
| 298 | 300 |
const uint8_t *buf = avpkt->data; |
| 299 | 301 |
int buf_size = avpkt->size; |
| 300 | 302 |
TTAContext *s = avctx->priv_data; |
| 301 |
- int i, out_size; |
|
| 303 |
+ int i, ret; |
|
| 302 | 304 |
int cur_chan = 0, framelen = s->frame_length; |
| 303 | 305 |
int32_t *p; |
| 304 | 306 |
|
| ... | ... |
@@ -309,10 +312,11 @@ static int tta_decode_frame(AVCodecContext *avctx, |
| 309 | 309 |
if (!s->total_frames && s->last_frame_length) |
| 310 | 310 |
framelen = s->last_frame_length; |
| 311 | 311 |
|
| 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; |
|
| 312 |
+ /* get output buffer */ |
|
| 313 |
+ s->frame.nb_samples = framelen; |
|
| 314 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 315 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 316 |
+ return ret; |
|
| 316 | 317 |
} |
| 317 | 318 |
|
| 318 | 319 |
// decode directly to output buffer for 24-bit sample format |
| ... | ... |
@@ -409,20 +413,20 @@ static int tta_decode_frame(AVCodecContext *avctx, |
| 409 | 409 |
// convert to output buffer |
| 410 | 410 |
switch(s->bps) {
|
| 411 | 411 |
case 1: {
|
| 412 |
- uint8_t *samples = data; |
|
| 412 |
+ uint8_t *samples = (int16_t *)s->frame.data[0]; |
|
| 413 | 413 |
for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) |
| 414 | 414 |
*samples++ = *p + 0x80; |
| 415 | 415 |
break; |
| 416 | 416 |
} |
| 417 | 417 |
case 2: {
|
| 418 |
- uint16_t *samples = data; |
|
| 418 |
+ uint16_t *samples = (int16_t *)s->frame.data[0]; |
|
| 419 | 419 |
for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) |
| 420 | 420 |
*samples++ = *p; |
| 421 | 421 |
break; |
| 422 | 422 |
} |
| 423 | 423 |
case 3: {
|
| 424 | 424 |
// shift samples for 24-bit sample format |
| 425 |
- int32_t *samples = data; |
|
| 425 |
+ int32_t *samples = (int16_t *)s->frame.data[0]; |
|
| 426 | 426 |
for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) |
| 427 | 427 |
*samples++ <<= 8; |
| 428 | 428 |
// reset decode buffer |
| ... | ... |
@@ -433,7 +437,8 @@ static int tta_decode_frame(AVCodecContext *avctx, |
| 433 | 433 |
av_log(s->avctx, AV_LOG_ERROR, "Error, only 16bit samples supported!\n"); |
| 434 | 434 |
} |
| 435 | 435 |
|
| 436 |
- *data_size = out_size; |
|
| 436 |
+ *got_frame_ptr = 1; |
|
| 437 |
+ *(AVFrame *)data = s->frame; |
|
| 437 | 438 |
|
| 438 | 439 |
return buf_size; |
| 439 | 440 |
} |
| ... | ... |
@@ -455,5 +460,6 @@ AVCodec ff_tta_decoder = {
|
| 455 | 455 |
.init = tta_decode_init, |
| 456 | 456 |
.close = tta_decode_close, |
| 457 | 457 |
.decode = tta_decode_frame, |
| 458 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 458 | 459 |
.long_name = NULL_IF_CONFIG_SMALL("True Audio (TTA)"),
|
| 459 | 460 |
}; |
| ... | ... |
@@ -174,6 +174,7 @@ static const ModeTab mode_44_48 = {
|
| 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 {
|
| 195 | 195 |
float *curr_frame; ///< non-interleaved output |
| 196 | 196 |
float *prev_frame; ///< non-interleaved previous frame |
| 197 | 197 |
int last_block_pos[2]; |
| 198 |
+ int discarded_packets; |
|
| 198 | 199 |
|
| 199 | 200 |
float *cos_tabs[3]; |
| 200 | 201 |
|
| ... | ... |
@@ -676,6 +678,9 @@ static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, |
| 676 | 676 |
i); |
| 677 | 677 |
} |
| 678 | 678 |
|
| 679 |
+ if (!out) |
|
| 680 |
+ return; |
|
| 681 |
+ |
|
| 679 | 682 |
size2 = tctx->last_block_pos[0]; |
| 680 | 683 |
size1 = mtab->size - size2; |
| 681 | 684 |
if (tctx->avctx->channels == 2) {
|
| ... | ... |
@@ -811,16 +816,16 @@ static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb, |
| 811 | 811 |
} |
| 812 | 812 |
|
| 813 | 813 |
static int twin_decode_frame(AVCodecContext * avctx, void *data, |
| 814 |
- int *data_size, AVPacket *avpkt) |
|
| 814 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 815 | 815 |
{
|
| 816 | 816 |
const uint8_t *buf = avpkt->data; |
| 817 | 817 |
int buf_size = avpkt->size; |
| 818 | 818 |
TwinContext *tctx = avctx->priv_data; |
| 819 | 819 |
GetBitContext gb; |
| 820 | 820 |
const ModeTab *mtab = tctx->mtab; |
| 821 |
- float *out = data; |
|
| 821 |
+ float *out = NULL; |
|
| 822 | 822 |
enum FrameType ftype; |
| 823 |
- int window_type, out_size; |
|
| 823 |
+ int window_type, ret; |
|
| 824 | 824 |
static const enum FrameType wtype_to_ftype_table[] = {
|
| 825 | 825 |
FT_LONG, FT_LONG, FT_SHORT, FT_LONG, |
| 826 | 826 |
FT_MEDIUM, FT_LONG, FT_LONG, FT_MEDIUM, FT_MEDIUM |
| ... | ... |
@@ -832,11 +837,14 @@ static int twin_decode_frame(AVCodecContext * avctx, void *data, |
| 832 | 832 |
return AVERROR(EINVAL); |
| 833 | 833 |
} |
| 834 | 834 |
|
| 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); |
|
| 835 |
+ /* get output buffer */ |
|
| 836 |
+ if (tctx->discarded_packets >= 2) {
|
|
| 837 |
+ tctx->frame.nb_samples = mtab->size; |
|
| 838 |
+ if ((ret = avctx->get_buffer(avctx, &tctx->frame)) < 0) {
|
|
| 839 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 840 |
+ return ret; |
|
| 841 |
+ } |
|
| 842 |
+ out = (float *)tctx->frame.data[0]; |
|
| 840 | 843 |
} |
| 841 | 844 |
|
| 842 | 845 |
init_get_bits(&gb, buf, buf_size * 8); |
| ... | ... |
@@ -856,12 +864,14 @@ static int twin_decode_frame(AVCodecContext * avctx, void *data, |
| 856 | 856 |
|
| 857 | 857 |
FFSWAP(float*, tctx->curr_frame, tctx->prev_frame); |
| 858 | 858 |
|
| 859 |
- if (tctx->avctx->frame_number < 2) {
|
|
| 860 |
- *data_size=0; |
|
| 859 |
+ if (tctx->discarded_packets < 2) {
|
|
| 860 |
+ tctx->discarded_packets++; |
|
| 861 |
+ *got_frame_ptr = 0; |
|
| 861 | 862 |
return buf_size; |
| 862 | 863 |
} |
| 863 | 864 |
|
| 864 |
- *data_size = out_size; |
|
| 865 |
+ *got_frame_ptr = 1; |
|
| 866 |
+ *(AVFrame *)data = tctx->frame;; |
|
| 865 | 867 |
|
| 866 | 868 |
return buf_size; |
| 867 | 869 |
} |
| ... | ... |
@@ -1153,6 +1163,9 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) |
| 1153 | 1153 |
|
| 1154 | 1154 |
memset_float(tctx->bark_hist[0][0], 0.1, FF_ARRAY_ELEMS(tctx->bark_hist)); |
| 1155 | 1155 |
|
| 1156 |
+ avcodec_get_frame_defaults(&tctx->frame); |
|
| 1157 |
+ avctx->coded_frame = &tctx->frame; |
|
| 1158 |
+ |
|
| 1156 | 1159 |
return 0; |
| 1157 | 1160 |
} |
| 1158 | 1161 |
|
| ... | ... |
@@ -1164,5 +1177,6 @@ AVCodec ff_twinvq_decoder = {
|
| 1164 | 1164 |
.init = twin_decode_init, |
| 1165 | 1165 |
.close = twin_decode_close, |
| 1166 | 1166 |
.decode = twin_decode_frame, |
| 1167 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1167 | 1168 |
.long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"),
|
| 1168 | 1169 |
}; |
| ... | ... |
@@ -127,7 +127,10 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height){
|
| 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 |
| 213 | 213 |
*height+=2; // some of the optimized chroma MC reads one line too much |
| 214 | 214 |
// which is also done in mpeg decoders with lowres > 0 |
| 215 | 215 |
|
| 216 |
- linesize_align[0] = |
|
| 217 |
- linesize_align[1] = |
|
| 218 |
- linesize_align[2] = |
|
| 219 |
- linesize_align[3] = STRIDE_ALIGN; |
|
| 216 |
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) |
|
| 217 |
+ linesize_align[i] = STRIDE_ALIGN; |
|
| 220 | 218 |
//STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes |
| 221 | 219 |
//we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the |
| 222 | 220 |
//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 |
| 225 | 225 |
if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 || |
| 226 | 226 |
s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F || |
| 227 | 227 |
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; |
|
| 228 |
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) |
|
| 229 |
+ linesize_align[i] = 16; |
|
| 231 | 230 |
} |
| 232 | 231 |
#endif |
| 233 | 232 |
} |
| 234 | 233 |
|
| 235 | 234 |
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
|
| 236 | 235 |
int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w; |
| 237 |
- int linesize_align[4]; |
|
| 236 |
+ int linesize_align[AV_NUM_DATA_POINTERS]; |
|
| 238 | 237 |
int align; |
| 239 | 238 |
avcodec_align_dimensions2(s, width, height, linesize_align); |
| 240 | 239 |
align = FFMAX(linesize_align[0], linesize_align[3]); |
| ... | ... |
@@ -260,7 +260,108 @@ void ff_init_buffer_info(AVCodecContext *s, AVFrame *pic) |
| 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){
|
| 295 | 295 |
return -1; |
| 296 | 296 |
} |
| 297 | 297 |
|
| 298 |
- for(i=0; i<4; i++){
|
|
| 298 |
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
|
|
| 299 | 299 |
av_freep(&buf->base[i]); |
| 300 | 300 |
buf->data[i]= NULL; |
| 301 | 301 |
} |
| ... | ... |
@@ -310,7 +411,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
|
| 310 | 310 |
int tmpsize; |
| 311 | 311 |
int unaligned; |
| 312 | 312 |
AVPicture picture; |
| 313 |
- int stride_align[4]; |
|
| 313 |
+ int stride_align[AV_NUM_DATA_POINTERS]; |
|
| 314 | 314 |
const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; |
| 315 | 315 |
|
| 316 | 316 |
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){
|
| 363 | 363 |
else |
| 364 | 364 |
buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (pixel_size*EDGE_WIDTH>>h_shift), stride_align[i]); |
| 365 | 365 |
} |
| 366 |
+ for (; i < AV_NUM_DATA_POINTERS; i++) {
|
|
| 367 |
+ buf->base[i] = buf->data[i] = NULL; |
|
| 368 |
+ buf->linesize[i] = 0; |
|
| 369 |
+ } |
|
| 366 | 370 |
if(size[1] && !size[2]) |
| 367 | 371 |
ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt); |
| 368 | 372 |
buf->width = s->width; |
| ... | ... |
@@ -372,11 +477,12 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
|
| 372 | 372 |
} |
| 373 | 373 |
pic->type= FF_BUFFER_TYPE_INTERNAL; |
| 374 | 374 |
|
| 375 |
- for(i=0; i<4; i++){
|
|
| 375 |
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
|
|
| 376 | 376 |
pic->base[i]= buf->base[i]; |
| 377 | 377 |
pic->data[i]= buf->data[i]; |
| 378 | 378 |
pic->linesize[i]= buf->linesize[i]; |
| 379 | 379 |
} |
| 380 |
+ pic->extended_data = pic->data; |
|
| 380 | 381 |
avci->buffer_count++; |
| 381 | 382 |
|
| 382 | 383 |
if (s->pkt) {
|
| ... | ... |
@@ -399,11 +505,25 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
|
| 399 | 399 |
return 0; |
| 400 | 400 |
} |
| 401 | 401 |
|
| 402 |
+int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame) |
|
| 403 |
+{
|
|
| 404 |
+ switch (avctx->codec_type) {
|
|
| 405 |
+ case AVMEDIA_TYPE_VIDEO: |
|
| 406 |
+ return video_get_buffer(avctx, frame); |
|
| 407 |
+ case AVMEDIA_TYPE_AUDIO: |
|
| 408 |
+ return audio_get_buffer(avctx, frame); |
|
| 409 |
+ default: |
|
| 410 |
+ return -1; |
|
| 411 |
+ } |
|
| 412 |
+} |
|
| 413 |
+ |
|
| 402 | 414 |
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
|
| 403 | 415 |
int i; |
| 404 | 416 |
InternalBuffer *buf, *last; |
| 405 | 417 |
AVCodecInternal *avci = s->internal; |
| 406 | 418 |
|
| 419 |
+ assert(s->codec_type == AVMEDIA_TYPE_VIDEO); |
|
| 420 |
+ |
|
| 407 | 421 |
assert(pic->type==FF_BUFFER_TYPE_INTERNAL); |
| 408 | 422 |
assert(avci->buffer_count); |
| 409 | 423 |
|
| ... | ... |
@@ -421,7 +541,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
|
| 421 | 421 |
FFSWAP(InternalBuffer, *buf, *last); |
| 422 | 422 |
} |
| 423 | 423 |
|
| 424 |
- for(i=0; i<4; i++){
|
|
| 424 |
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
|
|
| 425 | 425 |
pic->data[i]=NULL; |
| 426 | 426 |
// pic->base[i]=NULL; |
| 427 | 427 |
} |
| ... | ... |
@@ -436,6 +556,8 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
|
| 436 | 436 |
AVFrame temp_pic; |
| 437 | 437 |
int i; |
| 438 | 438 |
|
| 439 |
+ assert(s->codec_type == AVMEDIA_TYPE_VIDEO); |
|
| 440 |
+ |
|
| 439 | 441 |
/* If no picture return a new buffer */ |
| 440 | 442 |
if(pic->data[0] == NULL) {
|
| 441 | 443 |
/* We will copy from buffer, so must be readable */ |
| ... | ... |
@@ -455,7 +577,7 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
|
| 455 | 455 |
* Not internal type and reget_buffer not overridden, emulate cr buffer |
| 456 | 456 |
*/ |
| 457 | 457 |
temp_pic = *pic; |
| 458 |
- for(i = 0; i < 4; i++) |
|
| 458 |
+ for(i = 0; i < AV_NUM_DATA_POINTERS; i++) |
|
| 459 | 459 |
pic->data[i] = pic->base[i] = NULL; |
| 460 | 460 |
pic->opaque = NULL; |
| 461 | 461 |
/* Allocate new frame */ |
| ... | ... |
@@ -862,36 +984,73 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi |
| 862 | 862 |
return ret; |
| 863 | 863 |
} |
| 864 | 864 |
|
| 865 |
+#if FF_API_OLD_DECODE_AUDIO |
|
| 865 | 866 |
int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, |
| 866 | 867 |
int *frame_size_ptr, |
| 867 | 868 |
AVPacket *avpkt) |
| 868 | 869 |
{
|
| 869 |
- int ret; |
|
| 870 |
+ AVFrame frame; |
|
| 871 |
+ int ret, got_frame = 0; |
|
| 872 |
+ |
|
| 873 |
+ if (avctx->get_buffer != avcodec_default_get_buffer) {
|
|
| 874 |
+ av_log(avctx, AV_LOG_ERROR, "A custom get_buffer() cannot be used with " |
|
| 875 |
+ "avcodec_decode_audio3()\n"); |
|
| 876 |
+ return AVERROR(EINVAL); |
|
| 877 |
+ } |
|
| 878 |
+ |
|
| 879 |
+ ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt); |
|
| 880 |
+ |
|
| 881 |
+ if (ret >= 0 && got_frame) {
|
|
| 882 |
+ int ch, plane_size; |
|
| 883 |
+ int planar = av_sample_fmt_is_planar(avctx->sample_fmt); |
|
| 884 |
+ int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels, |
|
| 885 |
+ frame.nb_samples, |
|
| 886 |
+ avctx->sample_fmt, 1); |
|
| 887 |
+ if (*frame_size_ptr < data_size) {
|
|
| 888 |
+ av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for " |
|
| 889 |
+ "the current frame (%d < %d)\n", *frame_size_ptr, data_size); |
|
| 890 |
+ return AVERROR(EINVAL); |
|
| 891 |
+ } |
|
| 892 |
+ |
|
| 893 |
+ memcpy(samples, frame.extended_data[0], plane_size); |
|
| 894 |
+ |
|
| 895 |
+ if (planar && avctx->channels > 1) {
|
|
| 896 |
+ uint8_t *out = ((uint8_t *)samples) + plane_size; |
|
| 897 |
+ for (ch = 1; ch < avctx->channels; ch++) {
|
|
| 898 |
+ memcpy(out, frame.extended_data[ch], plane_size); |
|
| 899 |
+ out += plane_size; |
|
| 900 |
+ } |
|
| 901 |
+ } |
|
| 902 |
+ *frame_size_ptr = data_size; |
|
| 903 |
+ } else {
|
|
| 904 |
+ *frame_size_ptr = 0; |
|
| 905 |
+ } |
|
| 906 |
+ return ret; |
|
| 907 |
+} |
|
| 908 |
+#endif |
|
| 909 |
+ |
|
| 910 |
+int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, |
|
| 911 |
+ AVFrame *frame, |
|
| 912 |
+ int *got_frame_ptr, |
|
| 913 |
+ AVPacket *avpkt) |
|
| 914 |
+{
|
|
| 915 |
+ int ret = 0; |
|
| 916 |
+ |
|
| 917 |
+ *got_frame_ptr = 0; |
|
| 870 | 918 |
|
| 871 | 919 |
if (!avpkt->data && avpkt->size) {
|
| 872 | 920 |
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); |
| 873 | 921 |
return AVERROR(EINVAL); |
| 874 | 922 |
} |
| 875 | 923 |
|
| 876 |
- if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
|
|
| 924 |
+ if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
|
|
| 877 | 925 |
av_packet_split_side_data(avpkt); |
| 878 | 926 |
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; |
|
| 927 |
+ ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt); |
|
| 928 |
+ if (ret >= 0 && *got_frame_ptr) {
|
|
| 929 |
+ avctx->frame_number++; |
|
| 930 |
+ frame->pkt_dts = avpkt->dts; |
|
| 888 | 931 |
} |
| 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 | 932 |
} |
| 896 | 933 |
return ret; |
| 897 | 934 |
} |
| ... | ... |
@@ -1230,7 +1389,8 @@ void avcodec_flush_buffers(AVCodecContext *avctx) |
| 1230 | 1230 |
avctx->codec->flush(avctx); |
| 1231 | 1231 |
} |
| 1232 | 1232 |
|
| 1233 |
-void avcodec_default_free_buffers(AVCodecContext *s){
|
|
| 1233 |
+static void video_free_buffers(AVCodecContext *s) |
|
| 1234 |
+{
|
|
| 1234 | 1235 |
AVCodecInternal *avci = s->internal; |
| 1235 | 1236 |
int i, j; |
| 1236 | 1237 |
|
| ... | ... |
@@ -1252,6 +1412,37 @@ void avcodec_default_free_buffers(AVCodecContext *s){
|
| 1252 | 1252 |
avci->buffer_count=0; |
| 1253 | 1253 |
} |
| 1254 | 1254 |
|
| 1255 |
+static void audio_free_buffers(AVCodecContext *avctx) |
|
| 1256 |
+{
|
|
| 1257 |
+ AVCodecInternal *avci = avctx->internal; |
|
| 1258 |
+ InternalBuffer *buf; |
|
| 1259 |
+ |
|
| 1260 |
+ if (!avci->buffer) |
|
| 1261 |
+ return; |
|
| 1262 |
+ buf = avci->buffer; |
|
| 1263 |
+ |
|
| 1264 |
+ if (buf->extended_data) {
|
|
| 1265 |
+ av_free(buf->extended_data[0]); |
|
| 1266 |
+ if (buf->extended_data != buf->data) |
|
| 1267 |
+ av_free(buf->extended_data); |
|
| 1268 |
+ } |
|
| 1269 |
+ av_freep(&avci->buffer); |
|
| 1270 |
+} |
|
| 1271 |
+ |
|
| 1272 |
+void avcodec_default_free_buffers(AVCodecContext *avctx) |
|
| 1273 |
+{
|
|
| 1274 |
+ switch (avctx->codec_type) {
|
|
| 1275 |
+ case AVMEDIA_TYPE_VIDEO: |
|
| 1276 |
+ video_free_buffers(avctx); |
|
| 1277 |
+ break; |
|
| 1278 |
+ case AVMEDIA_TYPE_AUDIO: |
|
| 1279 |
+ audio_free_buffers(avctx); |
|
| 1280 |
+ break; |
|
| 1281 |
+ default: |
|
| 1282 |
+ break; |
|
| 1283 |
+ } |
|
| 1284 |
+} |
|
| 1285 |
+ |
|
| 1255 | 1286 |
#if FF_API_OLD_FF_PICT_TYPES |
| 1256 | 1287 |
char av_get_pict_type_char(int pict_type){
|
| 1257 | 1288 |
return av_get_picture_type_char(pict_type); |
| ... | ... |
@@ -21,8 +21,8 @@ |
| 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 @@ |
| 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) |
| 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) |
| 507 | 507 |
|
| 508 | 508 |
s->chunk_size = avctx->block_align + avctx->channels * (s->out_bps == 2); |
| 509 | 509 |
|
| 510 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 511 |
+ avctx->coded_frame = &s->frame; |
|
| 512 |
+ |
|
| 510 | 513 |
av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, " |
| 511 | 514 |
"block align = %d, sample rate = %d\n", |
| 512 | 515 |
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, |
| 544 | 544 |
} |
| 545 | 545 |
} |
| 546 | 546 |
|
| 547 |
-static int vmdaudio_decode_frame(AVCodecContext *avctx, |
|
| 548 |
- void *data, int *data_size, |
|
| 549 |
- AVPacket *avpkt) |
|
| 547 |
+static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data, |
|
| 548 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 550 | 549 |
{
|
| 551 | 550 |
const uint8_t *buf = avpkt->data; |
| 552 | 551 |
const uint8_t *buf_end; |
| 553 | 552 |
int buf_size = avpkt->size; |
| 554 | 553 |
VmdAudioContext *s = avctx->priv_data; |
| 555 | 554 |
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; |
|
| 555 |
+ int ret; |
|
| 556 |
+ uint8_t *output_samples_u8; |
|
| 557 |
+ int16_t *output_samples_s16; |
|
| 559 | 558 |
|
| 560 | 559 |
if (buf_size < 16) {
|
| 561 | 560 |
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n"); |
| 562 |
- *data_size = 0; |
|
| 561 |
+ *got_frame_ptr = 0; |
|
| 563 | 562 |
return buf_size; |
| 564 | 563 |
} |
| 565 | 564 |
|
| ... | ... |
@@ -590,10 +593,15 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, |
| 590 | 590 |
|
| 591 | 591 |
/* ensure output buffer is large enough */ |
| 592 | 592 |
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; |
|
| 593 |
+ |
|
| 594 |
+ /* get output buffer */ |
|
| 595 |
+ s->frame.nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels; |
|
| 596 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 597 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 598 |
+ return ret; |
|
| 599 |
+ } |
|
| 600 |
+ output_samples_u8 = s->frame.data[0]; |
|
| 601 |
+ output_samples_s16 = (int16_t *)s->frame.data[0]; |
|
| 597 | 602 |
|
| 598 | 603 |
/* decode silent chunks */ |
| 599 | 604 |
if (silent_chunks > 0) {
|
| ... | ... |
@@ -623,7 +631,9 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, |
| 623 | 623 |
} |
| 624 | 624 |
} |
| 625 | 625 |
|
| 626 |
- *data_size = out_size; |
|
| 626 |
+ *got_frame_ptr = 1; |
|
| 627 |
+ *(AVFrame *)data = s->frame; |
|
| 628 |
+ |
|
| 627 | 629 |
return avpkt->size; |
| 628 | 630 |
} |
| 629 | 631 |
|
| ... | ... |
@@ -651,5 +661,6 @@ AVCodec ff_vmdaudio_decoder = {
|
| 651 | 651 |
.priv_data_size = sizeof(VmdAudioContext), |
| 652 | 652 |
.init = vmdaudio_decode_init, |
| 653 | 653 |
.decode = vmdaudio_decode_frame, |
| 654 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 654 | 655 |
.long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"),
|
| 655 | 656 |
}; |
| ... | ... |
@@ -125,6 +125,7 @@ typedef struct {
|
| 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) |
| 1037 | 1037 |
avccontext->sample_rate = vc->audio_samplerate; |
| 1038 | 1038 |
avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2; |
| 1039 | 1039 |
|
| 1040 |
+ avcodec_get_frame_defaults(&vc->frame); |
|
| 1041 |
+ avccontext->coded_frame = &vc->frame; |
|
| 1042 |
+ |
|
| 1040 | 1043 |
return 0; |
| 1041 | 1044 |
} |
| 1042 | 1045 |
|
| ... | ... |
@@ -1609,16 +1613,15 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) |
| 1609 | 1609 |
|
| 1610 | 1610 |
// Return the decoded audio packet through the standard api |
| 1611 | 1611 |
|
| 1612 |
-static int vorbis_decode_frame(AVCodecContext *avccontext, |
|
| 1613 |
- void *data, int *data_size, |
|
| 1614 |
- AVPacket *avpkt) |
|
| 1612 |
+static int vorbis_decode_frame(AVCodecContext *avccontext, void *data, |
|
| 1613 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1615 | 1614 |
{
|
| 1616 | 1615 |
const uint8_t *buf = avpkt->data; |
| 1617 | 1616 |
int buf_size = avpkt->size; |
| 1618 | 1617 |
vorbis_context *vc = avccontext->priv_data; |
| 1619 | 1618 |
GetBitContext *gb = &(vc->gb); |
| 1620 | 1619 |
const float *channel_ptrs[255]; |
| 1621 |
- int i, len, out_size; |
|
| 1620 |
+ int i, len, ret; |
|
| 1622 | 1621 |
|
| 1623 | 1622 |
av_dlog(NULL, "packet length %d \n", buf_size); |
| 1624 | 1623 |
|
| ... | ... |
@@ -1629,18 +1632,18 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, |
| 1629 | 1629 |
|
| 1630 | 1630 |
if (!vc->first_frame) {
|
| 1631 | 1631 |
vc->first_frame = 1; |
| 1632 |
- *data_size = 0; |
|
| 1632 |
+ *got_frame_ptr = 0; |
|
| 1633 | 1633 |
return buf_size; |
| 1634 | 1634 |
} |
| 1635 | 1635 |
|
| 1636 | 1636 |
av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", |
| 1637 | 1637 |
get_bits_count(gb) / 8, get_bits_count(gb) % 8, len); |
| 1638 | 1638 |
|
| 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); |
|
| 1639 |
+ /* get output buffer */ |
|
| 1640 |
+ vc->frame.nb_samples = len; |
|
| 1641 |
+ if ((ret = avccontext->get_buffer(avccontext, &vc->frame)) < 0) {
|
|
| 1642 |
+ av_log(avccontext, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1643 |
+ return ret; |
|
| 1644 | 1644 |
} |
| 1645 | 1645 |
|
| 1646 | 1646 |
if (vc->audio_channels > 8) {
|
| ... | ... |
@@ -1653,12 +1656,15 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, |
| 1653 | 1653 |
} |
| 1654 | 1654 |
|
| 1655 | 1655 |
if (avccontext->sample_fmt == AV_SAMPLE_FMT_FLT) |
| 1656 |
- vc->fmt_conv.float_interleave(data, channel_ptrs, len, vc->audio_channels); |
|
| 1656 |
+ vc->fmt_conv.float_interleave((float *)vc->frame.data[0], channel_ptrs, |
|
| 1657 |
+ len, vc->audio_channels); |
|
| 1657 | 1658 |
else |
| 1658 |
- vc->fmt_conv.float_to_int16_interleave(data, channel_ptrs, len, |
|
| 1659 |
+ vc->fmt_conv.float_to_int16_interleave((int16_t *)vc->frame.data[0], |
|
| 1660 |
+ channel_ptrs, len, |
|
| 1659 | 1661 |
vc->audio_channels); |
| 1660 | 1662 |
|
| 1661 |
- *data_size = out_size; |
|
| 1663 |
+ *got_frame_ptr = 1; |
|
| 1664 |
+ *(AVFrame *)data = vc->frame; |
|
| 1662 | 1665 |
|
| 1663 | 1666 |
return buf_size; |
| 1664 | 1667 |
} |
| ... | ... |
@@ -1682,6 +1688,7 @@ AVCodec ff_vorbis_decoder = {
|
| 1682 | 1682 |
.init = vorbis_decode_init, |
| 1683 | 1683 |
.close = vorbis_decode_close, |
| 1684 | 1684 |
.decode = vorbis_decode_frame, |
| 1685 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 1685 | 1686 |
.long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
|
| 1686 | 1687 |
.channel_layouts = ff_vorbis_channel_layouts, |
| 1687 | 1688 |
.sample_fmts = (const enum AVSampleFormat[]) {
|
| ... | ... |
@@ -1335,8 +1335,8 @@ end: |
| 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) |
| 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) |
| 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, |
| 1568 | 1568 |
VP8Context *s = avctx->priv_data; |
| 1569 | 1569 |
int ret, mb_x, mb_y, i, y, referenced; |
| 1570 | 1570 |
enum AVDiscard skip_thresh; |
| 1571 |
- AVFrame *av_uninit(curframe), *prev_frame = s->framep[VP56_FRAME_CURRENT]; |
|
| 1571 |
+ AVFrame *av_uninit(curframe), *prev_frame; |
|
| 1572 | 1572 |
|
| 1573 | 1573 |
release_queued_segmaps(s, 0); |
| 1574 | 1574 |
|
| 1575 | 1575 |
if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0) |
| 1576 | 1576 |
return ret; |
| 1577 | 1577 |
|
| 1578 |
+ prev_frame = s->framep[VP56_FRAME_CURRENT]; |
|
| 1579 |
+ |
|
| 1578 | 1580 |
referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT |
| 1579 | 1581 |
|| s->update_altref == VP56_FRAME_CURRENT; |
| 1580 | 1582 |
|
| ... | ... |
@@ -1815,6 +1816,7 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo |
| 1815 | 1815 |
if (s->macroblocks_base && |
| 1816 | 1816 |
(s_src->mb_width != s->mb_width || s_src->mb_height != s->mb_height)) {
|
| 1817 | 1817 |
free_buffers(s); |
| 1818 |
+ s->maps_are_invalid = 1; |
|
| 1818 | 1819 |
} |
| 1819 | 1820 |
|
| 1820 | 1821 |
s->prob[0] = s_src->prob[!s_src->update_probabilities]; |
| ... | ... |
@@ -115,8 +115,6 @@ typedef struct WavpackFrameContext {
|
| 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 {
|
| 125 | 125 |
|
| 126 | 126 |
typedef struct WavpackContext {
|
| 127 | 127 |
AVCodecContext *avctx; |
| 128 |
+ AVFrame frame; |
|
| 128 | 129 |
|
| 129 | 130 |
WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS]; |
| 130 | 131 |
int fdec_num; |
| ... | ... |
@@ -133,7 +132,6 @@ typedef struct WavpackContext {
|
| 133 | 133 |
int mkv_mode; |
| 134 | 134 |
int block; |
| 135 | 135 |
int samples; |
| 136 |
- int samples_left; |
|
| 137 | 136 |
int ch_offset; |
| 138 | 137 |
} WavpackContext; |
| 139 | 138 |
|
| ... | ... |
@@ -485,7 +483,6 @@ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) |
| 485 | 485 |
static void wv_reset_saved_context(WavpackFrameContext *s) |
| 486 | 486 |
{
|
| 487 | 487 |
s->pos = 0; |
| 488 |
- s->samples_left = 0; |
|
| 489 | 488 |
s->sc.crc = s->extra_sc.crc = 0xFFFFFFFF; |
| 490 | 489 |
} |
| 491 | 490 |
|
| ... | ... |
@@ -502,8 +499,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo |
| 502 | 502 |
float *dstfl = dst; |
| 503 | 503 |
const int channel_pad = s->avctx->channels - 2; |
| 504 | 504 |
|
| 505 |
- if(s->samples_left == s->samples) |
|
| 506 |
- s->one = s->zero = s->zeroes = 0; |
|
| 505 |
+ s->one = s->zero = s->zeroes = 0; |
|
| 507 | 506 |
do{
|
| 508 | 507 |
L = wv_get_value(s, gb, 0, &last); |
| 509 | 508 |
if(last) break; |
| ... | ... |
@@ -594,13 +590,8 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, vo |
| 594 | 594 |
dst16 += channel_pad; |
| 595 | 595 |
} |
| 596 | 596 |
count++; |
| 597 |
- }while(!last && count < s->max_samples); |
|
| 597 |
+ } while (!last && count < s->samples); |
|
| 598 | 598 |
|
| 599 |
- if (last) |
|
| 600 |
- s->samples_left = 0; |
|
| 601 |
- else |
|
| 602 |
- s->samples_left -= count; |
|
| 603 |
- if(!s->samples_left){
|
|
| 604 | 599 |
wv_reset_saved_context(s); |
| 605 | 600 |
if(crc != s->CRC){
|
| 606 | 601 |
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 |
| 610 | 610 |
av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n"); |
| 611 | 611 |
return -1; |
| 612 | 612 |
} |
| 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 |
- } |
|
| 613 |
+ |
|
| 622 | 614 |
return count * 2; |
| 623 | 615 |
} |
| 624 | 616 |
|
| ... | ... |
@@ -635,8 +618,7 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void |
| 635 | 635 |
float *dstfl = dst; |
| 636 | 636 |
const int channel_stride = s->avctx->channels; |
| 637 | 637 |
|
| 638 |
- if(s->samples_left == s->samples) |
|
| 639 |
- s->one = s->zero = s->zeroes = 0; |
|
| 638 |
+ s->one = s->zero = s->zeroes = 0; |
|
| 640 | 639 |
do{
|
| 641 | 640 |
T = wv_get_value(s, gb, 0, &last); |
| 642 | 641 |
S = 0; |
| ... | ... |
@@ -675,13 +657,8 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void |
| 675 | 675 |
dst16 += channel_stride; |
| 676 | 676 |
} |
| 677 | 677 |
count++; |
| 678 |
- }while(!last && count < s->max_samples); |
|
| 678 |
+ } while (!last && count < s->samples); |
|
| 679 | 679 |
|
| 680 |
- if (last) |
|
| 681 |
- s->samples_left = 0; |
|
| 682 |
- else |
|
| 683 |
- s->samples_left -= count; |
|
| 684 |
- if(!s->samples_left){
|
|
| 685 | 680 |
wv_reset_saved_context(s); |
| 686 | 681 |
if(crc != s->CRC){
|
| 687 | 682 |
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 |
| 691 | 691 |
av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n"); |
| 692 | 692 |
return -1; |
| 693 | 693 |
} |
| 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 |
- } |
|
| 694 |
+ |
|
| 703 | 695 |
return count; |
| 704 | 696 |
} |
| 705 | 697 |
|
| ... | ... |
@@ -743,6 +712,9 @@ static av_cold int wavpack_decode_init(AVCodecContext *avctx) |
| 743 | 743 |
|
| 744 | 744 |
s->fdec_num = 0; |
| 745 | 745 |
|
| 746 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 747 |
+ avctx->coded_frame = &s->frame; |
|
| 748 |
+ |
|
| 746 | 749 |
return 0; |
| 747 | 750 |
} |
| 748 | 751 |
|
| ... | ... |
@@ -759,7 +731,7 @@ static av_cold int wavpack_decode_end(AVCodecContext *avctx) |
| 759 | 759 |
} |
| 760 | 760 |
|
| 761 | 761 |
static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 762 |
- void *data, int *data_size, |
|
| 762 |
+ void *data, int *got_frame_ptr, |
|
| 763 | 763 |
const uint8_t *buf, int buf_size) |
| 764 | 764 |
{
|
| 765 | 765 |
WavpackContext *wc = avctx->priv_data; |
| ... | ... |
@@ -774,7 +746,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 774 | 774 |
int bpp, chan, chmask; |
| 775 | 775 |
|
| 776 | 776 |
if (buf_size == 0){
|
| 777 |
- *data_size = 0; |
|
| 777 |
+ *got_frame_ptr = 0; |
|
| 778 | 778 |
return 0; |
| 779 | 779 |
} |
| 780 | 780 |
|
| ... | ... |
@@ -789,18 +761,16 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 789 | 789 |
return -1; |
| 790 | 790 |
} |
| 791 | 791 |
|
| 792 |
- if(!s->samples_left){
|
|
| 793 | 792 |
memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr)); |
| 794 | 793 |
memset(s->ch, 0, sizeof(s->ch)); |
| 795 | 794 |
s->extra_bits = 0; |
| 796 | 795 |
s->and = s->or = s->shift = 0; |
| 797 | 796 |
s->got_extra_bits = 0; |
| 798 |
- } |
|
| 799 | 797 |
|
| 800 | 798 |
if(!wc->mkv_mode){
|
| 801 | 799 |
s->samples = AV_RL32(buf); buf += 4; |
| 802 | 800 |
if(!s->samples){
|
| 803 |
- *data_size = 0; |
|
| 801 |
+ *got_frame_ptr = 0; |
|
| 804 | 802 |
return 0; |
| 805 | 803 |
} |
| 806 | 804 |
}else{
|
| ... | ... |
@@ -829,13 +799,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 829 | 829 |
|
| 830 | 830 |
wc->ch_offset += 1 + s->stereo; |
| 831 | 831 |
|
| 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 | 832 |
// parse metadata blocks |
| 840 | 833 |
while(buf < buf_end){
|
| 841 | 834 |
id = *buf++; |
| ... | ... |
@@ -1064,7 +1027,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 1064 | 1064 |
} |
| 1065 | 1065 |
if(id & WP_IDF_ODD) buf++; |
| 1066 | 1066 |
} |
| 1067 |
- if(!s->samples_left){
|
|
| 1067 |
+ |
|
| 1068 | 1068 |
if(!got_terms){
|
| 1069 | 1069 |
av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n"); |
| 1070 | 1070 |
return -1; |
| ... | ... |
@@ -1101,16 +1064,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 1101 | 1101 |
s->got_extra_bits = 0; |
| 1102 | 1102 |
} |
| 1103 | 1103 |
} |
| 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 | 1104 |
|
| 1115 | 1105 |
if(s->stereo_in){
|
| 1116 | 1106 |
if(avctx->sample_fmt == AV_SAMPLE_FMT_S16) |
| ... | ... |
@@ -1167,7 +1120,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, |
| 1167 | 1167 |
} |
| 1168 | 1168 |
} |
| 1169 | 1169 |
|
| 1170 |
- wc->samples_left = s->samples_left; |
|
| 1170 |
+ *got_frame_ptr = 1; |
|
| 1171 | 1171 |
|
| 1172 | 1172 |
return samplecount * bpp; |
| 1173 | 1173 |
} |
| ... | ... |
@@ -1181,23 +1134,40 @@ static void wavpack_decode_flush(AVCodecContext *avctx) |
| 1181 | 1181 |
wv_reset_saved_context(s->fdec[i]); |
| 1182 | 1182 |
} |
| 1183 | 1183 |
|
| 1184 |
-static int wavpack_decode_frame(AVCodecContext *avctx, |
|
| 1185 |
- void *data, int *data_size, |
|
| 1186 |
- AVPacket *avpkt) |
|
| 1184 |
+static int wavpack_decode_frame(AVCodecContext *avctx, void *data, |
|
| 1185 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1187 | 1186 |
{
|
| 1188 | 1187 |
WavpackContext *s = avctx->priv_data; |
| 1189 | 1188 |
const uint8_t *buf = avpkt->data; |
| 1190 | 1189 |
int buf_size = avpkt->size; |
| 1191 |
- int frame_size; |
|
| 1190 |
+ int frame_size, ret; |
|
| 1192 | 1191 |
int samplecount = 0; |
| 1193 | 1192 |
|
| 1194 | 1193 |
s->block = 0; |
| 1195 |
- s->samples_left = 0; |
|
| 1196 | 1194 |
s->ch_offset = 0; |
| 1197 | 1195 |
|
| 1196 |
+ /* determine number of samples */ |
|
| 1198 | 1197 |
if(s->mkv_mode){
|
| 1199 | 1198 |
s->samples = AV_RL32(buf); buf += 4; |
| 1199 |
+ } else {
|
|
| 1200 |
+ if (s->multichannel) |
|
| 1201 |
+ s->samples = AV_RL32(buf + 4); |
|
| 1202 |
+ else |
|
| 1203 |
+ s->samples = AV_RL32(buf); |
|
| 1204 |
+ } |
|
| 1205 |
+ if (s->samples <= 0) {
|
|
| 1206 |
+ av_log(avctx, AV_LOG_ERROR, "Invalid number of samples: %d\n", |
|
| 1207 |
+ s->samples); |
|
| 1208 |
+ return AVERROR(EINVAL); |
|
| 1209 |
+ } |
|
| 1210 |
+ |
|
| 1211 |
+ /* get output buffer */ |
|
| 1212 |
+ s->frame.nb_samples = s->samples; |
|
| 1213 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 1214 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1215 |
+ return ret; |
|
| 1200 | 1216 |
} |
| 1217 |
+ |
|
| 1201 | 1218 |
while(buf_size > 0){
|
| 1202 | 1219 |
if(!s->multichannel){
|
| 1203 | 1220 |
frame_size = buf_size; |
| ... | ... |
@@ -1216,17 +1186,19 @@ static int wavpack_decode_frame(AVCodecContext *avctx, |
| 1216 | 1216 |
wavpack_decode_flush(avctx); |
| 1217 | 1217 |
return -1; |
| 1218 | 1218 |
} |
| 1219 |
- if((samplecount = wavpack_decode_block(avctx, s->block, data, |
|
| 1220 |
- data_size, buf, frame_size)) < 0) {
|
|
| 1219 |
+ if((samplecount = wavpack_decode_block(avctx, s->block, s->frame.data[0], |
|
| 1220 |
+ got_frame_ptr, buf, frame_size)) < 0) {
|
|
| 1221 | 1221 |
wavpack_decode_flush(avctx); |
| 1222 | 1222 |
return -1; |
| 1223 | 1223 |
} |
| 1224 | 1224 |
s->block++; |
| 1225 | 1225 |
buf += frame_size; buf_size -= frame_size; |
| 1226 | 1226 |
} |
| 1227 |
- *data_size = samplecount * avctx->channels; |
|
| 1228 | 1227 |
|
| 1229 |
- return s->samples_left > 0 ? 0 : avpkt->size; |
|
| 1228 |
+ if (*got_frame_ptr) |
|
| 1229 |
+ *(AVFrame *)data = s->frame; |
|
| 1230 |
+ |
|
| 1231 |
+ return avpkt->size; |
|
| 1230 | 1232 |
} |
| 1231 | 1233 |
|
| 1232 | 1234 |
AVCodec ff_wavpack_decoder = {
|
| ... | ... |
@@ -1238,6 +1210,6 @@ AVCodec ff_wavpack_decoder = {
|
| 1238 | 1238 |
.close = wavpack_decode_end, |
| 1239 | 1239 |
.decode = wavpack_decode_frame, |
| 1240 | 1240 |
.flush = wavpack_decode_flush, |
| 1241 |
- .capabilities = CODEC_CAP_SUBFRAMES, |
|
| 1241 |
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, |
|
| 1242 | 1242 |
.long_name = NULL_IF_CONFIG_SMALL("WavPack"),
|
| 1243 | 1243 |
}; |
| ... | ... |
@@ -136,6 +136,10 @@ static int wma_decode_init(AVCodecContext * avctx) |
| 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) |
| 814 | 814 |
return 0; |
| 815 | 815 |
} |
| 816 | 816 |
|
| 817 |
-static int wma_decode_superframe(AVCodecContext *avctx, |
|
| 818 |
- void *data, int *data_size, |
|
| 819 |
- AVPacket *avpkt) |
|
| 817 |
+static int wma_decode_superframe(AVCodecContext *avctx, void *data, |
|
| 818 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 820 | 819 |
{
|
| 821 | 820 |
const uint8_t *buf = avpkt->data; |
| 822 | 821 |
int buf_size = avpkt->size; |
| 823 | 822 |
WMACodecContext *s = avctx->priv_data; |
| 824 |
- int nb_frames, bit_offset, i, pos, len, out_size; |
|
| 823 |
+ int nb_frames, bit_offset, i, pos, len, ret; |
|
| 825 | 824 |
uint8_t *q; |
| 826 | 825 |
int16_t *samples; |
| 827 | 826 |
|
| ... | ... |
@@ -836,8 +839,6 @@ static int wma_decode_superframe(AVCodecContext *avctx, |
| 836 | 836 |
if(s->block_align) |
| 837 | 837 |
buf_size = s->block_align; |
| 838 | 838 |
|
| 839 |
- samples = data; |
|
| 840 |
- |
|
| 841 | 839 |
init_get_bits(&s->gb, buf, buf_size*8); |
| 842 | 840 |
|
| 843 | 841 |
if (s->use_bit_reservoir) {
|
| ... | ... |
@@ -848,12 +849,13 @@ static int wma_decode_superframe(AVCodecContext *avctx, |
| 848 | 848 |
nb_frames = 1; |
| 849 | 849 |
} |
| 850 | 850 |
|
| 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; |
|
| 851 |
+ /* get output buffer */ |
|
| 852 |
+ s->frame.nb_samples = nb_frames * s->frame_len; |
|
| 853 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 854 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 855 |
+ return ret; |
|
| 856 | 856 |
} |
| 857 |
+ samples = (int16_t *)s->frame.data[0]; |
|
| 857 | 858 |
|
| 858 | 859 |
if (s->use_bit_reservoir) {
|
| 859 | 860 |
bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3); |
| ... | ... |
@@ -920,7 +922,10 @@ static int wma_decode_superframe(AVCodecContext *avctx, |
| 920 | 920 |
} |
| 921 | 921 |
|
| 922 | 922 |
//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d outbytes:%d eaten:%d\n", s->frame_len_bits, s->block_len_bits, s->frame_len, s->block_len, (int8_t *)samples - (int8_t *)data, s->block_align); |
| 923 |
- *data_size = out_size; |
|
| 923 |
+ |
|
| 924 |
+ *got_frame_ptr = 1; |
|
| 925 |
+ *(AVFrame *)data = s->frame; |
|
| 926 |
+ |
|
| 924 | 927 |
return buf_size; |
| 925 | 928 |
fail: |
| 926 | 929 |
/* when error, we reset the bit reservoir */ |
| ... | ... |
@@ -945,6 +950,7 @@ AVCodec ff_wmav1_decoder = {
|
| 945 | 945 |
.close = ff_wma_end, |
| 946 | 946 |
.decode = wma_decode_superframe, |
| 947 | 947 |
.flush = flush, |
| 948 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 948 | 949 |
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
|
| 949 | 950 |
}; |
| 950 | 951 |
|
| ... | ... |
@@ -957,5 +963,6 @@ AVCodec ff_wmav2_decoder = {
|
| 957 | 957 |
.close = ff_wma_end, |
| 958 | 958 |
.decode = wma_decode_superframe, |
| 959 | 959 |
.flush = flush, |
| 960 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 960 | 961 |
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
|
| 961 | 962 |
}; |
| ... | ... |
@@ -167,6 +167,7 @@ typedef struct {
|
| 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 {
|
| 209 | 209 |
uint32_t frame_num; ///< current frame number (not used for decoding) |
| 210 | 210 |
GetBitContext gb; ///< bitstream reader context |
| 211 | 211 |
int buf_bit_size; ///< buffer size in bits |
| 212 |
- float* samples; ///< current samplebuffer pointer |
|
| 213 |
- float* samples_end; ///< maximum samplebuffer pointer |
|
| 214 | 212 |
uint8_t drc_gain; ///< gain for the DRC tool |
| 215 | 213 |
int8_t skip_frame; ///< skip output step |
| 216 | 214 |
int8_t parsed_all_subframes; ///< all subframes decoded? |
| ... | ... |
@@ -453,6 +452,10 @@ static av_cold int decode_init(AVCodecContext *avctx) |
| 453 | 453 |
dump_context(s); |
| 454 | 454 |
|
| 455 | 455 |
avctx->channel_layout = channel_mask; |
| 456 |
+ |
|
| 457 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 458 |
+ avctx->coded_frame = &s->frame; |
|
| 459 |
+ |
|
| 456 | 460 |
return 0; |
| 457 | 461 |
} |
| 458 | 462 |
|
| ... | ... |
@@ -1279,22 +1282,15 @@ static int decode_subframe(WMAProDecodeCtx *s) |
| 1279 | 1279 |
*@return 0 if the trailer bit indicates that this is the last frame, |
| 1280 | 1280 |
* 1 if there are additional frames |
| 1281 | 1281 |
*/ |
| 1282 |
-static int decode_frame(WMAProDecodeCtx *s) |
|
| 1282 |
+static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr) |
|
| 1283 | 1283 |
{
|
| 1284 |
+ AVCodecContext *avctx = s->avctx; |
|
| 1284 | 1285 |
GetBitContext* gb = &s->gb; |
| 1285 | 1286 |
int more_frames = 0; |
| 1286 | 1287 |
int len = 0; |
| 1287 |
- int i; |
|
| 1288 |
+ int i, ret; |
|
| 1288 | 1289 |
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 |
- } |
|
| 1290 |
+ float *samples; |
|
| 1298 | 1291 |
|
| 1299 | 1292 |
/** get frame length */ |
| 1300 | 1293 |
if (s->len_prefix) |
| ... | ... |
@@ -1360,10 +1356,19 @@ static int decode_frame(WMAProDecodeCtx *s) |
| 1360 | 1360 |
} |
| 1361 | 1361 |
} |
| 1362 | 1362 |
|
| 1363 |
+ /* get output buffer */ |
|
| 1364 |
+ s->frame.nb_samples = s->samples_per_frame; |
|
| 1365 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 1366 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1367 |
+ s->packet_loss = 1; |
|
| 1368 |
+ return 0; |
|
| 1369 |
+ } |
|
| 1370 |
+ samples = (float *)s->frame.data[0]; |
|
| 1371 |
+ |
|
| 1363 | 1372 |
/** interleave samples and write them to the output buffer */ |
| 1364 | 1373 |
for (i = 0; i < s->num_channels; i++) |
| 1365 | 1374 |
out_ptr[i] = s->channel[i].out; |
| 1366 |
- s->fmt_conv.float_interleave(s->samples, out_ptr, s->samples_per_frame, |
|
| 1375 |
+ s->fmt_conv.float_interleave(samples, out_ptr, s->samples_per_frame, |
|
| 1367 | 1376 |
s->num_channels); |
| 1368 | 1377 |
|
| 1369 | 1378 |
for (i = 0; i < s->num_channels; i++) {
|
| ... | ... |
@@ -1375,8 +1380,10 @@ static int decode_frame(WMAProDecodeCtx *s) |
| 1375 | 1375 |
|
| 1376 | 1376 |
if (s->skip_frame) {
|
| 1377 | 1377 |
s->skip_frame = 0; |
| 1378 |
- } else |
|
| 1379 |
- s->samples += s->num_channels * s->samples_per_frame; |
|
| 1378 |
+ *got_frame_ptr = 0; |
|
| 1379 |
+ } else {
|
|
| 1380 |
+ *got_frame_ptr = 1; |
|
| 1381 |
+ } |
|
| 1380 | 1382 |
|
| 1381 | 1383 |
if (s->len_prefix) {
|
| 1382 | 1384 |
if (len != (get_bits_count(gb) - s->frame_offset) + 2) {
|
| ... | ... |
@@ -1473,8 +1480,8 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, |
| 1473 | 1473 |
*@param avpkt input packet |
| 1474 | 1474 |
*@return number of bytes that were read from the input buffer |
| 1475 | 1475 |
*/ |
| 1476 |
-static int decode_packet(AVCodecContext *avctx, |
|
| 1477 |
- void *data, int *data_size, AVPacket* avpkt) |
|
| 1476 |
+static int decode_packet(AVCodecContext *avctx, void *data, |
|
| 1477 |
+ int *got_frame_ptr, AVPacket* avpkt) |
|
| 1478 | 1478 |
{
|
| 1479 | 1479 |
WMAProDecodeCtx *s = avctx->priv_data; |
| 1480 | 1480 |
GetBitContext* gb = &s->pgb; |
| ... | ... |
@@ -1483,9 +1490,7 @@ static int decode_packet(AVCodecContext *avctx, |
| 1483 | 1483 |
int num_bits_prev_frame; |
| 1484 | 1484 |
int packet_sequence_number; |
| 1485 | 1485 |
|
| 1486 |
- s->samples = data; |
|
| 1487 |
- s->samples_end = (float*)((int8_t*)data + *data_size); |
|
| 1488 |
- *data_size = 0; |
|
| 1486 |
+ *got_frame_ptr = 0; |
|
| 1489 | 1487 |
|
| 1490 | 1488 |
if (s->packet_done || s->packet_loss) {
|
| 1491 | 1489 |
s->packet_done = 0; |
| ... | ... |
@@ -1532,7 +1537,7 @@ static int decode_packet(AVCodecContext *avctx, |
| 1532 | 1532 |
|
| 1533 | 1533 |
/** decode the cross packet frame if it is valid */ |
| 1534 | 1534 |
if (!s->packet_loss) |
| 1535 |
- decode_frame(s); |
|
| 1535 |
+ decode_frame(s, got_frame_ptr); |
|
| 1536 | 1536 |
} else if (s->num_saved_bits - s->frame_offset) {
|
| 1537 | 1537 |
av_dlog(avctx, "ignoring %x previously saved bits\n", |
| 1538 | 1538 |
s->num_saved_bits - s->frame_offset); |
| ... | ... |
@@ -1555,7 +1560,7 @@ static int decode_packet(AVCodecContext *avctx, |
| 1555 | 1555 |
(frame_size = show_bits(gb, s->log2_frame_size)) && |
| 1556 | 1556 |
frame_size <= remaining_bits(s, gb)) {
|
| 1557 | 1557 |
save_bits(s, gb, frame_size, 0); |
| 1558 |
- s->packet_done = !decode_frame(s); |
|
| 1558 |
+ s->packet_done = !decode_frame(s, got_frame_ptr); |
|
| 1559 | 1559 |
} else if (!s->len_prefix |
| 1560 | 1560 |
&& s->num_saved_bits > get_bits_count(&s->gb)) {
|
| 1561 | 1561 |
/** when the frames do not have a length prefix, we don't know |
| ... | ... |
@@ -1565,7 +1570,7 @@ static int decode_packet(AVCodecContext *avctx, |
| 1565 | 1565 |
therefore we save the incoming packet first, then we append |
| 1566 | 1566 |
the "previous frame" data from the next packet so that |
| 1567 | 1567 |
we get a buffer that only contains full frames */ |
| 1568 |
- s->packet_done = !decode_frame(s); |
|
| 1568 |
+ s->packet_done = !decode_frame(s, got_frame_ptr); |
|
| 1569 | 1569 |
} else |
| 1570 | 1570 |
s->packet_done = 1; |
| 1571 | 1571 |
} |
| ... | ... |
@@ -1577,10 +1582,14 @@ static int decode_packet(AVCodecContext *avctx, |
| 1577 | 1577 |
save_bits(s, gb, remaining_bits(s, gb), 0); |
| 1578 | 1578 |
} |
| 1579 | 1579 |
|
| 1580 |
- *data_size = (int8_t *)s->samples - (int8_t *)data; |
|
| 1581 | 1580 |
s->packet_offset = get_bits_count(gb) & 7; |
| 1581 |
+ if (s->packet_loss) |
|
| 1582 |
+ return AVERROR_INVALIDDATA; |
|
| 1583 |
+ |
|
| 1584 |
+ if (*got_frame_ptr) |
|
| 1585 |
+ *(AVFrame *)data = s->frame; |
|
| 1582 | 1586 |
|
| 1583 |
- return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; |
|
| 1587 |
+ return get_bits_count(gb) >> 3; |
|
| 1584 | 1588 |
} |
| 1585 | 1589 |
|
| 1586 | 1590 |
/** |
| ... | ... |
@@ -1611,7 +1620,7 @@ AVCodec ff_wmapro_decoder = {
|
| 1611 | 1611 |
.init = decode_init, |
| 1612 | 1612 |
.close = decode_end, |
| 1613 | 1613 |
.decode = decode_packet, |
| 1614 |
- .capabilities = CODEC_CAP_SUBFRAMES, |
|
| 1614 |
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, |
|
| 1615 | 1615 |
.flush= flush, |
| 1616 | 1616 |
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"),
|
| 1617 | 1617 |
}; |
| ... | ... |
@@ -131,6 +131,7 @@ typedef struct {
|
| 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) |
| 438 | 438 |
|
| 439 | 439 |
ctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
| 440 | 440 |
|
| 441 |
+ avcodec_get_frame_defaults(&s->frame); |
|
| 442 |
+ ctx->coded_frame = &s->frame; |
|
| 443 |
+ |
|
| 441 | 444 |
return 0; |
| 442 | 445 |
} |
| 443 | 446 |
|
| ... | ... |
@@ -1725,17 +1729,17 @@ static int check_bits_for_superframe(GetBitContext *orig_gb, |
| 1725 | 1725 |
* @return 0 on success, <0 on error or 1 if there was not enough data to |
| 1726 | 1726 |
* fully parse the superframe |
| 1727 | 1727 |
*/ |
| 1728 |
-static int synth_superframe(AVCodecContext *ctx, |
|
| 1729 |
- float *samples, int *data_size) |
|
| 1728 |
+static int synth_superframe(AVCodecContext *ctx, int *got_frame_ptr) |
|
| 1730 | 1729 |
{
|
| 1731 | 1730 |
WMAVoiceContext *s = ctx->priv_data; |
| 1732 | 1731 |
GetBitContext *gb = &s->gb, s_gb; |
| 1733 |
- int n, res, out_size, n_samples = 480; |
|
| 1732 |
+ int n, res, n_samples = 480; |
|
| 1734 | 1733 |
double lsps[MAX_FRAMES][MAX_LSPS]; |
| 1735 | 1734 |
const double *mean_lsf = s->lsps == 16 ? |
| 1736 | 1735 |
wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode]; |
| 1737 | 1736 |
float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12]; |
| 1738 | 1737 |
float synth[MAX_LSPS + MAX_SFRAMESIZE]; |
| 1738 |
+ float *samples; |
|
| 1739 | 1739 |
|
| 1740 | 1740 |
memcpy(synth, s->synth_history, |
| 1741 | 1741 |
s->lsps * sizeof(*synth)); |
| ... | ... |
@@ -1749,7 +1753,7 @@ static int synth_superframe(AVCodecContext *ctx, |
| 1749 | 1749 |
} |
| 1750 | 1750 |
|
| 1751 | 1751 |
if ((res = check_bits_for_superframe(gb, s)) == 1) {
|
| 1752 |
- *data_size = 0; |
|
| 1752 |
+ *got_frame_ptr = 0; |
|
| 1753 | 1753 |
return 1; |
| 1754 | 1754 |
} |
| 1755 | 1755 |
|
| ... | ... |
@@ -1792,13 +1796,14 @@ static int synth_superframe(AVCodecContext *ctx, |
| 1792 | 1792 |
stabilize_lsps(lsps[n], s->lsps); |
| 1793 | 1793 |
} |
| 1794 | 1794 |
|
| 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; |
|
| 1795 |
+ /* get output buffer */ |
|
| 1796 |
+ s->frame.nb_samples = 480; |
|
| 1797 |
+ if ((res = ctx->get_buffer(ctx, &s->frame)) < 0) {
|
|
| 1798 |
+ av_log(ctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 1799 |
+ return res; |
|
| 1801 | 1800 |
} |
| 1801 |
+ s->frame.nb_samples = n_samples; |
|
| 1802 |
+ samples = (float *)s->frame.data[0]; |
|
| 1802 | 1803 |
|
| 1803 | 1804 |
/* Parse frames, optionally preceeded by per-frame (independent) LSPs. */ |
| 1804 | 1805 |
for (n = 0; n < 3; n++) {
|
| ... | ... |
@@ -1820,7 +1825,7 @@ static int synth_superframe(AVCodecContext *ctx, |
| 1820 | 1820 |
lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1], |
| 1821 | 1821 |
&excitation[s->history_nsamples + n * MAX_FRAMESIZE], |
| 1822 | 1822 |
&synth[s->lsps + n * MAX_FRAMESIZE]))) {
|
| 1823 |
- *data_size = 0; |
|
| 1823 |
+ *got_frame_ptr = 0; |
|
| 1824 | 1824 |
return res; |
| 1825 | 1825 |
} |
| 1826 | 1826 |
} |
| ... | ... |
@@ -1833,8 +1838,7 @@ static int synth_superframe(AVCodecContext *ctx, |
| 1833 | 1833 |
skip_bits(gb, 10 * (res + 1)); |
| 1834 | 1834 |
} |
| 1835 | 1835 |
|
| 1836 |
- /* Specify nr. of output samples */ |
|
| 1837 |
- *data_size = out_size; |
|
| 1836 |
+ *got_frame_ptr = 1; |
|
| 1838 | 1837 |
|
| 1839 | 1838 |
/* Update history */ |
| 1840 | 1839 |
memcpy(s->prev_lsps, lsps[2], |
| ... | ... |
@@ -1922,7 +1926,7 @@ static void copy_bits(PutBitContext *pb, |
| 1922 | 1922 |
* For more information about frames, see #synth_superframe(). |
| 1923 | 1923 |
*/ |
| 1924 | 1924 |
static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, |
| 1925 |
- int *data_size, AVPacket *avpkt) |
|
| 1925 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
| 1926 | 1926 |
{
|
| 1927 | 1927 |
WMAVoiceContext *s = ctx->priv_data; |
| 1928 | 1928 |
GetBitContext *gb = &s->gb; |
| ... | ... |
@@ -1935,7 +1939,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, |
| 1935 | 1935 |
* capping the packet size at ctx->block_align. */ |
| 1936 | 1936 |
for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align); |
| 1937 | 1937 |
if (!size) {
|
| 1938 |
- *data_size = 0; |
|
| 1938 |
+ *got_frame_ptr = 0; |
|
| 1939 | 1939 |
return 0; |
| 1940 | 1940 |
} |
| 1941 | 1941 |
init_get_bits(&s->gb, avpkt->data, size << 3); |
| ... | ... |
@@ -1956,10 +1960,11 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, |
| 1956 | 1956 |
copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits); |
| 1957 | 1957 |
flush_put_bits(&s->pb); |
| 1958 | 1958 |
s->sframe_cache_size += s->spillover_nbits; |
| 1959 |
- if ((res = synth_superframe(ctx, data, data_size)) == 0 && |
|
| 1960 |
- *data_size > 0) {
|
|
| 1959 |
+ if ((res = synth_superframe(ctx, got_frame_ptr)) == 0 && |
|
| 1960 |
+ *got_frame_ptr) {
|
|
| 1961 | 1961 |
cnt += s->spillover_nbits; |
| 1962 | 1962 |
s->skip_bits_next = cnt & 7; |
| 1963 |
+ *(AVFrame *)data = s->frame; |
|
| 1963 | 1964 |
return cnt >> 3; |
| 1964 | 1965 |
} else |
| 1965 | 1966 |
skip_bits_long (gb, s->spillover_nbits - cnt + |
| ... | ... |
@@ -1974,11 +1979,12 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, |
| 1974 | 1974 |
s->sframe_cache_size = 0; |
| 1975 | 1975 |
s->skip_bits_next = 0; |
| 1976 | 1976 |
pos = get_bits_left(gb); |
| 1977 |
- if ((res = synth_superframe(ctx, data, data_size)) < 0) {
|
|
| 1977 |
+ if ((res = synth_superframe(ctx, got_frame_ptr)) < 0) {
|
|
| 1978 | 1978 |
return res; |
| 1979 |
- } else if (*data_size > 0) {
|
|
| 1979 |
+ } else if (*got_frame_ptr) {
|
|
| 1980 | 1980 |
int cnt = get_bits_count(gb); |
| 1981 | 1981 |
s->skip_bits_next = cnt & 7; |
| 1982 |
+ *(AVFrame *)data = s->frame; |
|
| 1982 | 1983 |
return cnt >> 3; |
| 1983 | 1984 |
} else if ((s->sframe_cache_size = pos) > 0) {
|
| 1984 | 1985 |
/* rewind bit reader to start of last (incomplete) superframe... */ |
| ... | ... |
@@ -2046,7 +2052,7 @@ AVCodec ff_wmavoice_decoder = {
|
| 2046 | 2046 |
.init = wmavoice_decode_init, |
| 2047 | 2047 |
.close = wmavoice_decode_end, |
| 2048 | 2048 |
.decode = wmavoice_decode_packet, |
| 2049 |
- .capabilities = CODEC_CAP_SUBFRAMES, |
|
| 2049 |
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, |
|
| 2050 | 2050 |
.flush = wmavoice_flush, |
| 2051 | 2051 |
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),
|
| 2052 | 2052 |
}; |
| ... | ... |
@@ -37,26 +37,37 @@ static const int8_t ws_adpcm_4bit[] = {
|
| 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, |
| 71 | 71 |
in_size = AV_RL16(&buf[2]); |
| 72 | 72 |
buf += 4; |
| 73 | 73 |
|
| 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 | 74 |
if (in_size > buf_size) {
|
| 79 | 75 |
av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n"); |
| 80 | 76 |
return -1; |
| 81 | 77 |
} |
| 78 |
+ |
|
| 79 |
+ /* get output buffer */ |
|
| 80 |
+ s->frame.nb_samples = out_size; |
|
| 81 |
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
|
| 82 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 83 |
+ return ret; |
|
| 84 |
+ } |
|
| 85 |
+ samples = s->frame.data[0]; |
|
| 82 | 86 |
samples_end = samples + out_size; |
| 83 | 87 |
|
| 84 | 88 |
if (in_size == out_size) {
|
| 85 | 89 |
memcpy(samples, buf, out_size); |
| 86 |
- *data_size = out_size; |
|
| 90 |
+ *got_frame_ptr = 1; |
|
| 91 |
+ *(AVFrame *)data = s->frame; |
|
| 87 | 92 |
return buf_size; |
| 88 | 93 |
} |
| 89 | 94 |
|
| ... | ... |
@@ -159,7 +175,9 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, void *data, |
| 159 | 159 |
} |
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 |
- *data_size = samples - (uint8_t *)data; |
|
| 162 |
+ s->frame.nb_samples = samples - s->frame.data[0]; |
|
| 163 |
+ *got_frame_ptr = 1; |
|
| 164 |
+ *(AVFrame *)data = s->frame; |
|
| 163 | 165 |
|
| 164 | 166 |
return buf_size; |
| 165 | 167 |
} |
| ... | ... |
@@ -168,7 +186,9 @@ AVCodec ff_ws_snd1_decoder = {
|
| 168 | 168 |
.name = "ws_snd1", |
| 169 | 169 |
.type = AVMEDIA_TYPE_AUDIO, |
| 170 | 170 |
.id = CODEC_ID_WESTWOOD_SND1, |
| 171 |
+ .priv_data_size = sizeof(WSSndContext), |
|
| 171 | 172 |
.init = ws_snd_decode_init, |
| 172 | 173 |
.decode = ws_snd_decode_frame, |
| 174 |
+ .capabilities = CODEC_CAP_DR1, |
|
| 173 | 175 |
.long_name = NULL_IF_CONFIG_SMALL("Westwood Audio (SND1)"),
|
| 174 | 176 |
}; |
| ... | ... |
@@ -37,7 +37,7 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf |
| 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); |
| ... | ... |
@@ -550,7 +550,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 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 |
| 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) |
| 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 |
| 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 = {
|
| 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, |
| 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, |
| 1997 | 1997 |
/* sdp_read_header initializes this again */ |
| 1998 | 1998 |
ff_network_close(); |
| 1999 | 1999 |
|
| 2000 |
+ rt->media_type_mask = (1 << (AVMEDIA_TYPE_DATA+1)) - 1; |
|
| 2001 |
+ |
|
| 2000 | 2002 |
ret = sdp_read_header(s, ap); |
| 2001 | 2003 |
s->pb = NULL; |
| 2002 | 2004 |
return ret; |