diff options
author | foo86 <foobaz86@gmail.com> | 2016-05-03 03:42:36 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2016-05-03 16:40:43 -0300 |
commit | b7d267399b0ab53d2dc00ee191707df4cc8bd536 (patch) | |
tree | 5cbdf1a4c0ec8c96a82f9880f06b8179588837b9 /libavcodec/dcadec.h | |
parent | 77a7ff8f0501c0cca268f55241d57ed7b6b6fac3 (diff) | |
download | ffmpeg-b7d267399b0ab53d2dc00ee191707df4cc8bd536.tar.gz |
avcodec/dca: convert to AVCRC
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/dcadec.h')
-rw-r--r-- | libavcodec/dcadec.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libavcodec/dcadec.h b/libavcodec/dcadec.h index 6726121d3a..0d8a145edf 100644 --- a/libavcodec/dcadec.h +++ b/libavcodec/dcadec.h @@ -22,6 +22,7 @@ #define AVCODEC_DCADEC_H #include "libavutil/common.h" +#include "libavutil/crc.h" #include "libavutil/float_dsp.h" #include "avcodec.h" @@ -49,6 +50,8 @@ typedef struct DCAContext { DCADSPContext dcadsp; + const AVCRC *crctab; + uint8_t *buffer; ///< Packet buffer unsigned int buffer_size; @@ -62,13 +65,25 @@ typedef struct DCAContext { int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask); -int ff_dca_check_crc(GetBitContext *s, int p1, int p2); - void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples, int *coeff_l, int nsamples, int ch_mask); void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, int *coeff_l, int nsamples, int ch_mask); +static inline int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s, + int p1, int p2) +{ + DCAContext *dca = avctx->priv_data; + + if (!(avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL))) + return 0; + if (((p1 | p2) & 7) || p1 < 0 || p2 > s->size_in_bits || p2 - p1 < 16) + return -1; + if (av_crc(dca->crctab, 0xffff, s->buffer + p1 / 8, (p2 - p1) / 8)) + return -1; + return 0; +} + static inline int ff_dca_seek_bits(GetBitContext *s, int p) { if (p < s->index || p > s->size_in_bits) |