diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-04 01:12:34 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-04 01:12:34 +0100 |
commit | ad1c8dd6734f0aa7a7a87b4669a166715c114b46 (patch) | |
tree | c03c08f30bf1a7e8d9859abc48de3391bb05c6a0 /libavcodec/alac.c | |
parent | d6da16dca5a64ed7ab2db54710a0c703f179d3ba (diff) | |
parent | fd16f567987524a769d5d4f1f69089f000386ac2 (diff) | |
download | ffmpeg-ad1c8dd6734f0aa7a7a87b4669a166715c114b46.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
fate: add dxtory test
adx_parser: rewrite.
adxdec: Validate channel count to fix a division by zero.
adxdec: Do not require extradata.
cmdutils: K&R reformatting cosmetics
alacdec: implement the 2-pass prediction type.
alacenc: implement the 2-pass prediction type.
alacenc: do not generate invalid multi-channel ALAC files
alacdec: fill in missing or guessed info about the extradata format.
utvideo: proper median prediction for interlaced videos
lavu: bump lavu minor for av_popcount64
dca: K&R formatting cosmetics
dct: K&R formatting cosmetics
lavf: flush decoders in avformat_find_stream_info().
win32: detect number of CPUs using affinity
Add av_popcount64
snow: Restore three mistakenly removed casts.
Conflicts:
cmdutils.c
doc/APIchanges
libavcodec/adx_parser.c
libavcodec/adxdec.c
libavcodec/alacenc.c
libavutil/avutil.h
tests/fate/screen.mak
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/alac.c')
-rw-r--r-- | libavcodec/alac.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c index c08d2848ed..70e1a6438b 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -25,27 +25,23 @@ * @author 2005 David Hammerton * @see http://crazney.net/programs/itunes/alac.html * - * Note: This decoder expects a 36- (0x24-)byte QuickTime atom to be + * Note: This decoder expects a 36-byte QuickTime atom to be * passed through the extradata[_size] fields. This atom is tacked onto * the end of an 'alac' stsd atom and has the following format: - * bytes 0-3 atom size (0x24), big-endian - * bytes 4-7 atom type ('alac', not the 'alac' tag from start of stsd) - * bytes 8-35 data bytes needed by decoder * - * Extradata: - * 32bit size - * 32bit tag (=alac) - * 32bit zero? - * 32bit max sample per frame - * 8bit ?? (zero?) + * 32bit atom size + * 32bit tag ("alac") + * 32bit tag version (0) + * 32bit samples per frame (used when not set explicitly in the frames) + * 8bit compatible version (0) * 8bit sample size - * 8bit history mult - * 8bit initial history - * 8bit kmodifier - * 8bit channels? - * 16bit ?? - * 32bit max coded frame size - * 32bit bitrate? + * 8bit history mult (40) + * 8bit initial history (14) + * 8bit kmodifier (10) + * 8bit channels + * 16bit maxRun (255) + * 32bit max coded frame size (0 means unknown) + * 32bit average bitrate (0 means unknown) * 32bit samplerate */ @@ -464,24 +460,29 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data, if(ret<0) return ret; - if (prediction_type[ch] == 0) { - /* adaptive fir */ - predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], - alac->outputsamples_buffer[ch], - outputsamples, - readsamplesize, - predictor_coef_table[ch], - predictor_coef_num[ch], - prediction_quantitization[ch]); - } else { - av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[ch]); - /* I think the only other prediction type (or perhaps this is - * just a boolean?) runs adaptive fir twice.. like: - * predictor_decompress_fir_adapt(predictor_error, tempout, ...) - * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) - * little strange.. + /* adaptive FIR filter */ + if (prediction_type[ch] == 15) { + /* Prediction type 15 runs the adaptive FIR twice. + * The first pass uses the special-case coef_num = 31, while + * the second pass uses the coefs from the bitstream. + * + * However, this prediction type is not currently used by the + * reference encoder. */ + predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], + alac->predicterror_buffer[ch], + outputsamples, readsamplesize, + NULL, 31, 0); + } else if (prediction_type[ch] > 0) { + av_log(avctx, AV_LOG_WARNING, "unknown prediction type: %i\n", + prediction_type[ch]); } + predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], + alac->outputsamples_buffer[ch], + outputsamples, readsamplesize, + predictor_coef_table[ch], + predictor_coef_num[ch], + prediction_quantitization[ch]); } } else { /* not compressed, easy case */ @@ -584,7 +585,7 @@ static int alac_set_info(ALACContext *alac) ptr += 4; /* size */ ptr += 4; /* alac */ - ptr += 4; /* 0 ? */ + ptr += 4; /* version */ if(AV_RB32(ptr) >= UINT_MAX/4){ av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n"); @@ -593,15 +594,15 @@ static int alac_set_info(ALACContext *alac) /* buffer size / 2 ? */ alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr); - ptr++; /* ??? */ + ptr++; /* compatible version */ alac->setinfo_sample_size = *ptr++; alac->setinfo_rice_historymult = *ptr++; alac->setinfo_rice_initialhistory = *ptr++; alac->setinfo_rice_kmodifier = *ptr++; alac->numchannels = *ptr++; - bytestream_get_be16(&ptr); /* ??? */ + bytestream_get_be16(&ptr); /* maxRun */ bytestream_get_be32(&ptr); /* max coded frame size */ - bytestream_get_be32(&ptr); /* bitrate ? */ + bytestream_get_be32(&ptr); /* average bitrate */ bytestream_get_be32(&ptr); /* samplerate */ return 0; |