[FFmpeg-cvslog] avcodec/s302m: fix AVOption flags
ffmpeg | branch: master | foo86 | Tue Jun 27 12:59:15 2017 +0300| [f8b1a70412b592dff774e306fd63963369ea6810] | committer: James Almer avcodec/s302m: fix AVOption flags Reviewed-by: Paul B Mahol Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f8b1a70412b592dff774e306fd63963369ea6810 --- libavcodec/s302m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index a68ac79f2c..4350d97f0a 100644 --- a/libavcodec/s302m.c +++ b/libavcodec/s302m.c @@ -201,7 +201,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data, return avpkt->size; } -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_DECODING_PARAM static const AVOption s302m_options[] = { {"non_pcm_mode", "Chooses what to do with NON-PCM", offsetof(S302Context, non_pcm_mode), AV_OPT_TYPE_INT, {.i64 = 3}, 0, 3, FLAGS, "non_pcm_mode"}, {"copy", "Pass NON-PCM through unchanged" , 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 3, FLAGS, "non_pcm_mode"}, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: move some enumeration typedefs into headers
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:31 2017 +0300| [f6b86b62f785a67a356c87f5ea483a1cbe338191] | committer: James Almer avcodec/dca: move some enumeration typedefs into headers These values will be used by the parser. Prefix them with DCA_ appropriately. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f6b86b62f785a67a356c87f5ea483a1cbe338191 --- libavcodec/dca_core.c | 68 +++ libavcodec/dca_core.h | 28 + libavcodec/dca_lbr.c | 9 ++- libavcodec/dca_lbr.h | 5 4 files changed, 55 insertions(+), 55 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 36040f6f9d..16210b89f8 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -35,35 +35,7 @@ enum HeaderType { HEADER_XXCH }; -enum AudioMode { -AMODE_MONO, // Mode 0: A (mono) -AMODE_MONO_DUAL,// Mode 1: A + B (dual mono) -AMODE_STEREO, // Mode 2: L + R (stereo) -AMODE_STEREO_SUMDIFF, // Mode 3: (L+R) + (L-R) (sum-diff) -AMODE_STEREO_TOTAL, // Mode 4: LT + RT (left and right total) -AMODE_3F, // Mode 5: C + L + R -AMODE_2F1R, // Mode 6: L + R + S -AMODE_3F1R, // Mode 7: C + L + R + S -AMODE_2F2R, // Mode 8: L + R + SL + SR -AMODE_3F2R, // Mode 9: C + L + R + SL + SR - -AMODE_COUNT -}; - -enum ExtAudioType { -EXT_AUDIO_XCH = 0, -EXT_AUDIO_X96 = 2, -EXT_AUDIO_XXCH = 6 -}; - -enum LFEFlag { -LFE_FLAG_NONE, -LFE_FLAG_128, -LFE_FLAG_64, -LFE_FLAG_INVALID -}; - -static const int8_t prm_ch_to_spkr_map[AMODE_COUNT][5] = { +static const int8_t prm_ch_to_spkr_map[DCA_AMODE_COUNT][5] = { { DCA_SPEAKER_C,-1, -1, -1, -1 }, { DCA_SPEAKER_L, DCA_SPEAKER_R, -1, -1, -1 }, { DCA_SPEAKER_L, DCA_SPEAKER_R, -1, -1, -1 }, @@ -76,7 +48,7 @@ static const int8_t prm_ch_to_spkr_map[AMODE_COUNT][5] = { { DCA_SPEAKER_C, DCA_SPEAKER_L, DCA_SPEAKER_R, DCA_SPEAKER_Ls, DCA_SPEAKER_Rs } }; -static const uint8_t audio_mode_ch_mask[AMODE_COUNT] = { +static const uint8_t audio_mode_ch_mask[DCA_AMODE_COUNT] = { DCA_SPEAKER_LAYOUT_MONO, DCA_SPEAKER_LAYOUT_STEREO, DCA_SPEAKER_LAYOUT_STEREO, @@ -139,7 +111,7 @@ static int parse_frame_header(DCACoreDecoder *s) // Audio channel arrangement s->audio_mode = get_bits(&s->gb, 6); -if (s->audio_mode >= AMODE_COUNT) { +if (s->audio_mode >= DCA_AMODE_COUNT) { av_log(s->avctx, AV_LOG_ERROR, "Unsupported audio channel arrangement (%d)\n", s->audio_mode); return AVERROR_PATCHWELCOME; } @@ -180,7 +152,7 @@ static int parse_frame_header(DCACoreDecoder *s) // Low frequency effects flag s->lfe_present = get_bits(&s->gb, 2); -if (s->lfe_present == LFE_FLAG_INVALID) { +if (s->lfe_present == DCA_LFE_FLAG_INVALID) { av_log(s->avctx, AV_LOG_ERROR, "Invalid low frequency effects flag\n"); return AVERROR_INVALIDDATA; } @@ -1783,7 +1755,7 @@ static int parse_optional_info(DCACoreDecoder *s) // must be done backwards from the end of core frame to work around // sync word aliasing issues. switch (s->ext_audio_type) { -case EXT_AUDIO_XCH: +case DCA_EXT_AUDIO_XCH: if (dca->request_channel_layout) break; @@ -1813,7 +1785,7 @@ static int parse_optional_info(DCACoreDecoder *s) } break; -case EXT_AUDIO_X96: +case DCA_EXT_AUDIO_X96: // The distance between X96 sync word and end of the core frame // must be equal to X96 frame size. Minimum X96 frame size is 96 // bytes. @@ -1836,7 +1808,7 @@ static int parse_optional_info(DCACoreDecoder *s) } break; -case EXT_AUDIO_XXCH: +case DCA_EXT_AUDIO_XXCH: if (dca->request_channel_layout) break; @@ -2102,7 +2074,7 @@ int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth) int nlfesamples = s->npcmblocks >> 1; // Check LFF -if (s->lfe_present == LFE_FLAG_128) { +if (s->lfe_present == DCA_LFE_FLAG_128) { av_log(s->avctx, AV_LOG_ERROR, "Fixed point mode doesn't support LFF=1\n"); return AVERROR(EINVAL); } @@ -2152,7 +2124,7 @@ static int filter_frame_fixed(DCACoreDecoder *s, AVFrame *frame) // Undo embedded XCH downmix if (s->es_format && (s->ext_audio_mask & DCA_CSS_XCH) -&& s->audio_mode >= AMODE_2F2R) { +&& s->audio_mode
[FFmpeg-cvslog] avcodec/dca: move bits per sample array to dca.c
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:32 2017 +0300| [9e37cc11012f23e39b63032b5daac03621340a4f] | committer: James Almer avcodec/dca: move bits per sample array to dca.c It will be used by the parser. This change avoids unwanted parser dependency on dcadata. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e37cc11012f23e39b63032b5daac03621340a4f --- libavcodec/dca.c | 4 libavcodec/dca.h | 2 ++ libavcodec/dcadata.c | 4 libavcodec/dcadata.h | 2 -- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 58f340e6da..fb796191d6 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -45,6 +45,10 @@ const uint8_t ff_dca_freq_ranges[16] = { 0, 1, 2, 3, 4, 1, 2, 3, 4, 4, 0, 1, 2, 3, 4, 4 }; +const uint8_t ff_dca_bits_per_sample[8] = { +16, 16, 20, 20, 0, 24, 24, 0 +}; + int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size) { diff --git a/libavcodec/dca.h b/libavcodec/dca.h index bd96bc9ee3..1d10de4b94 100644 --- a/libavcodec/dca.h +++ b/libavcodec/dca.h @@ -156,6 +156,8 @@ extern av_export const uint32_t avpriv_dca_sample_rates[16]; extern const uint32_t ff_dca_sampling_freqs[16]; extern const uint8_t ff_dca_freq_ranges[16]; +extern const uint8_t ff_dca_bits_per_sample[8]; + /** * Convert bitstream to one representation based on sync marker diff --git a/libavcodec/dcadata.c b/libavcodec/dcadata.c index eaef01875a..1b646a7aa6 100644 --- a/libavcodec/dcadata.c +++ b/libavcodec/dcadata.c @@ -42,10 +42,6 @@ const uint8_t ff_dca_channels[16] = { 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8 }; -const uint8_t ff_dca_bits_per_sample[8] = { -16, 16, 20, 20, 0, 24, 24, 0 -}; - const uint8_t ff_dca_dmix_primary_nch[8] = { 1, 2, 2, 3, 3, 4, 4, 0 }; diff --git a/libavcodec/dcadata.h b/libavcodec/dcadata.h index 9dd6eba7f1..5aa85b3414 100644 --- a/libavcodec/dcadata.h +++ b/libavcodec/dcadata.h @@ -32,8 +32,6 @@ extern const uint32_t ff_dca_bit_rates[32]; extern const uint8_t ff_dca_channels[16]; -extern const uint8_t ff_dca_bits_per_sample[8]; - extern const uint8_t ff_dca_dmix_primary_nch[8]; extern const uint8_t ff_dca_quant_index_sel_nbits[DCA_CODE_BOOKS]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_parser: switch to common frame header parsing function
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:35 2017 +0300| [e54b9be1ffd669c76458324206935c8927a7c705] | committer: James Almer avcodec/dca_parser: switch to common frame header parsing function Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e54b9be1ffd669c76458324206935c8927a7c705 --- libavcodec/dca_parser.c | 26 +++--- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index e5bea3347c..6107358773 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -192,10 +192,11 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, int buf_size, int *duration, int *sample_rate) { GetBitContext gb; -uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; -int ret, sample_blocks; +DCACoreFrameHeader h; +uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; +int ret; -if (buf_size < 12) +if (buf_size < DCA_CORE_FRAME_HEADER_SIZE) return AVERROR_INVALIDDATA; if (AV_RB32(buf) == DCA_SYNCWORD_SUBSTREAM) { @@ -255,21 +256,16 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, return AVERROR_INVALIDDATA; } -if ((ret = avpriv_dca_convert_bitstream(buf, 12, hdr, 12)) < 0) +if ((ret = avpriv_dca_convert_bitstream(buf, DCA_CORE_FRAME_HEADER_SIZE, +hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0) return ret; - -init_get_bits(&gb, hdr, 96); - -skip_bits_long(&gb, 39); -sample_blocks = get_bits(&gb, 7) + 1; -if (sample_blocks < 8) +if ((ret = init_get_bits8(&gb, hdr, ret)) < 0) +return ret; +if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0) return AVERROR_INVALIDDATA; -*duration = 256 * (sample_blocks / 8); -skip_bits(&gb, 20); -*sample_rate = avpriv_dca_sample_rates[get_bits(&gb, 4)]; -if (*sample_rate == 0) -return AVERROR_INVALIDDATA; +*duration = 256 * (h.npcmblocks / 8); +*sample_rate = avpriv_dca_sample_rates[h.sr_code]; return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec: add avpriv_dca_parse_core_frame_header()
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:33 2017 +0300| [2123ddb4251bf39bde8b38a1307a0f6154d260e6] | committer: James Almer avcodec: add avpriv_dca_parse_core_frame_header() There are 3 different places where DCA core frame header is parsed: decoder, parser and demuxer. Each one uses ad-hoc code. Add common core frame header parsing function that will be used in all places. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2123ddb4251bf39bde8b38a1307a0f6154d260e6 --- libavcodec/dca.c | 60 libavcodec/dca.h | 49 ++ libavcodec/version.h | 4 ++-- 3 files changed, 111 insertions(+), 2 deletions(-) diff --git a/libavcodec/dca.c b/libavcodec/dca.c index fb796191d6..39f8f3d81c 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -28,7 +28,9 @@ #include "libavutil/error.h" #include "dca.h" +#include "dca_core.h" #include "dca_syncwords.h" +#include "get_bits.h" #include "put_bits.h" const uint32_t avpriv_dca_sample_rates[16] = { @@ -85,3 +87,61 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, return AVERROR_INVALIDDATA; } } + +int avpriv_dca_parse_core_frame_header(GetBitContext *gb, DCACoreFrameHeader *h) +{ +if (get_bits_long(gb, 32) != DCA_SYNCWORD_CORE_BE) +return DCA_PARSE_ERROR_SYNC_WORD; + +h->normal_frame = get_bits1(gb); +h->deficit_samples = get_bits(gb, 5) + 1; +if (h->deficit_samples != DCA_PCMBLOCK_SAMPLES) +return DCA_PARSE_ERROR_DEFICIT_SAMPLES; + +h->crc_present = get_bits1(gb); +h->npcmblocks = get_bits(gb, 7) + 1; +if (h->npcmblocks & (DCA_SUBBAND_SAMPLES - 1)) +return DCA_PARSE_ERROR_PCM_BLOCKS; + +h->frame_size = get_bits(gb, 14) + 1; +if (h->frame_size < 96) +return DCA_PARSE_ERROR_FRAME_SIZE; + +h->audio_mode = get_bits(gb, 6); +if (h->audio_mode >= DCA_AMODE_COUNT) +return DCA_PARSE_ERROR_AMODE; + +h->sr_code = get_bits(gb, 4); +if (!avpriv_dca_sample_rates[h->sr_code]) +return DCA_PARSE_ERROR_SAMPLE_RATE; + +h->br_code = get_bits(gb, 5); +if (get_bits1(gb)) +return DCA_PARSE_ERROR_RESERVED_BIT; + +h->drc_present = get_bits1(gb); +h->ts_present = get_bits1(gb); +h->aux_present = get_bits1(gb); +h->hdcd_master = get_bits1(gb); +h->ext_audio_type = get_bits(gb, 3); +h->ext_audio_present = get_bits1(gb); +h->sync_ssf = get_bits1(gb); +h->lfe_present = get_bits(gb, 2); +if (h->lfe_present == DCA_LFE_FLAG_INVALID) +return DCA_PARSE_ERROR_LFE_FLAG; + +h->predictor_history = get_bits1(gb); +if (h->crc_present) +skip_bits(gb, 16); +h->filter_perfect = get_bits1(gb); +h->encoder_rev = get_bits(gb, 4); +h->copy_hist = get_bits(gb, 2); +h->pcmr_code = get_bits(gb, 3); +if (!ff_dca_bits_per_sample[h->pcmr_code]) +return DCA_PARSE_ERROR_PCM_RES; + +h->sumdiff_front = get_bits1(gb); +h->sumdiff_surround = get_bits1(gb); +h->dn_code = get_bits(gb, 4); +return 0; +} diff --git a/libavcodec/dca.h b/libavcodec/dca.h index 1d10de4b94..cf6204e554 100644 --- a/libavcodec/dca.h +++ b/libavcodec/dca.h @@ -32,6 +32,49 @@ #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" +#include "get_bits.h" + +#define DCA_CORE_FRAME_HEADER_SIZE 18 + +enum DCAParseError { +DCA_PARSE_ERROR_SYNC_WORD = -1, +DCA_PARSE_ERROR_DEFICIT_SAMPLES = -2, +DCA_PARSE_ERROR_PCM_BLOCKS = -3, +DCA_PARSE_ERROR_FRAME_SIZE = -4, +DCA_PARSE_ERROR_AMODE = -5, +DCA_PARSE_ERROR_SAMPLE_RATE = -6, +DCA_PARSE_ERROR_RESERVED_BIT= -7, +DCA_PARSE_ERROR_LFE_FLAG= -8, +DCA_PARSE_ERROR_PCM_RES = -9 +}; + +typedef struct DCACoreFrameHeader { +uint8_t normal_frame; ///< Frame type +uint8_t deficit_samples;///< Deficit sample count +uint8_t crc_present;///< CRC present flag +uint8_t npcmblocks; ///< Number of PCM sample blocks +uint16_tframe_size; ///< Primary frame byte size +uint8_t audio_mode; ///< Audio channel arrangement +uint8_t sr_code;///< Core audio sampling frequency +uint8_t br_code;///< Transmission bit rate +uint8_t drc_present;///< Embedded dynamic range flag +uint8_t ts_present; ///< Embedded time stamp flag +uint8_t aux_present;///< Auxiliary data flag +uint8_t hdcd_master;///< HDCD mastering flag +uint8_t ext_audio_type; ///< Extension audio descriptor flag +
[FFmpeg-cvslog] avcodec/dca_core: switch to common frame header parsing function
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:34 2017 +0300| [33fc6c17a6e76ec2894e656cfeba5bcba9498778] | committer: James Almer avcodec/dca_core: switch to common frame header parsing function Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=33fc6c17a6e76ec2894e656cfeba5bcba9498778 --- libavcodec/dca_core.c | 149 +- 1 file changed, 51 insertions(+), 98 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 16210b89f8..090191dfa9 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -81,114 +81,68 @@ static void get_array(GetBitContext *s, int32_t *array, int size, int n) // 5.3.1 - Bit stream header static int parse_frame_header(DCACoreDecoder *s) { -int normal_frame, pcmr_index; +DCACoreFrameHeader h = { 0 }; +int err = avpriv_dca_parse_core_frame_header(&s->gb, &h); -// Frame type -normal_frame = get_bits1(&s->gb); +if (err < 0) { +switch (err) { +case DCA_PARSE_ERROR_DEFICIT_SAMPLES: +av_log(s->avctx, AV_LOG_ERROR, "Deficit samples are not supported\n"); +return h.normal_frame ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME; -// Deficit sample count -if (get_bits(&s->gb, 5) != DCA_PCMBLOCK_SAMPLES - 1) { -av_log(s->avctx, AV_LOG_ERROR, "Deficit samples are not supported\n"); -return normal_frame ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME; -} - -// CRC present flag -s->crc_present = get_bits1(&s->gb); - -// Number of PCM sample blocks -s->npcmblocks = get_bits(&s->gb, 7) + 1; -if (s->npcmblocks & (DCA_SUBBAND_SAMPLES - 1)) { -av_log(s->avctx, AV_LOG_ERROR, "Unsupported number of PCM sample blocks (%d)\n", s->npcmblocks); -return (s->npcmblocks < 6 || normal_frame) ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME; -} - -// Primary frame byte size -s->frame_size = get_bits(&s->gb, 14) + 1; -if (s->frame_size < 96) { -av_log(s->avctx, AV_LOG_ERROR, "Invalid core frame size (%d bytes)\n", s->frame_size); -return AVERROR_INVALIDDATA; -} - -// Audio channel arrangement -s->audio_mode = get_bits(&s->gb, 6); -if (s->audio_mode >= DCA_AMODE_COUNT) { -av_log(s->avctx, AV_LOG_ERROR, "Unsupported audio channel arrangement (%d)\n", s->audio_mode); -return AVERROR_PATCHWELCOME; -} - -// Core audio sampling frequency -s->sample_rate = avpriv_dca_sample_rates[get_bits(&s->gb, 4)]; -if (!s->sample_rate) { -av_log(s->avctx, AV_LOG_ERROR, "Invalid core audio sampling frequency\n"); -return AVERROR_INVALIDDATA; -} - -// Transmission bit rate -s->bit_rate = ff_dca_bit_rates[get_bits(&s->gb, 5)]; - -// Reserved field -skip_bits1(&s->gb); - -// Embedded dynamic range flag -s->drc_present = get_bits1(&s->gb); - -// Embedded time stamp flag -s->ts_present = get_bits1(&s->gb); - -// Auxiliary data flag -s->aux_present = get_bits1(&s->gb); - -// HDCD mastering flag -skip_bits1(&s->gb); +case DCA_PARSE_ERROR_PCM_BLOCKS: +av_log(s->avctx, AV_LOG_ERROR, "Unsupported number of PCM sample blocks (%d)\n", h.npcmblocks); +return (h.npcmblocks < 6 || h.normal_frame) ? AVERROR_INVALIDDATA : AVERROR_PATCHWELCOME; -// Extension audio descriptor flag -s->ext_audio_type = get_bits(&s->gb, 3); - -// Extended coding flag -s->ext_audio_present = get_bits1(&s->gb); - -// Audio sync word insertion flag -s->sync_ssf = get_bits1(&s->gb); - -// Low frequency effects flag -s->lfe_present = get_bits(&s->gb, 2); -if (s->lfe_present == DCA_LFE_FLAG_INVALID) { -av_log(s->avctx, AV_LOG_ERROR, "Invalid low frequency effects flag\n"); -return AVERROR_INVALIDDATA; -} +case DCA_PARSE_ERROR_FRAME_SIZE: +av_log(s->avctx, AV_LOG_ERROR, "Invalid core frame size (%d bytes)\n", h.frame_size); +return AVERROR_INVALIDDATA; -// Predictor history flag switch -s->predictor_history = get_bits1(&s->gb); +case DCA_PARSE_ERROR_AMODE: +av_log(s->avctx, AV_LOG_ERROR, "Unsupported audio channel arrangement (%d)\n", h.audio_mode); +return AVERROR_PATCHWELCOME; -// Header CRC check bytes -if (s->crc_present) -skip_bits(&s->gb, 16); +case DCA_PARSE_ERROR_SAMPLE_RATE: +av_log(s->avctx, AV_LOG_ERROR, "Invalid core audio sampling frequency\n"); +return AVERROR_INVALIDDATA;
[FFmpeg-cvslog] avcodec/dca_parser: export profile information
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:37 2017 +0300| [4b6c212e859f49360f50c4d67b999769cc7cc2c6] | committer: James Almer avcodec/dca_parser: export profile information Permits applications to access DTS profile information without having to decode a frame. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4b6c212e859f49360f50c4d67b999769cc7cc2c6 --- libavcodec/dca_parser.c | 44 +++- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 6107358773..390f7975f9 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -23,6 +23,7 @@ */ #include "dca.h" +#include "dca_core.h" #include "dca_exss.h" #include "dca_syncwords.h" #include "get_bits.h" @@ -189,19 +190,19 @@ static av_cold int dca_parse_init(AVCodecParserContext *s) } static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, -int buf_size, int *duration, int *sample_rate) +int buf_size, int *duration, int *sample_rate, +int *profile) { +DCAExssAsset *asset = &pc1->exss.assets[0]; GetBitContext gb; DCACoreFrameHeader h; uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; -int ret; +int ret, frame_size; if (buf_size < DCA_CORE_FRAME_HEADER_SIZE) return AVERROR_INVALIDDATA; if (AV_RB32(buf) == DCA_SYNCWORD_SUBSTREAM) { -DCAExssAsset *asset = &pc1->exss.assets[0]; - if ((ret = ff_dca_exss_parse(&pc1->exss, buf, buf_size)) < 0) return ret; @@ -226,6 +227,7 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, *sample_rate = ff_dca_sampling_freqs[pc1->sr_code]; *duration = 1024 << ff_dca_freq_ranges[pc1->sr_code]; +*profile = FF_PROFILE_DTS_EXPRESS; return 0; } @@ -250,6 +252,7 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, *sample_rate = asset->max_sample_rate; *duration = (1 + (*sample_rate > 96000)) << nsamples_log2; +*profile = FF_PROFILE_DTS_HD_MA; return 0; } @@ -266,6 +269,37 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, *duration = 256 * (h.npcmblocks / 8); *sample_rate = avpriv_dca_sample_rates[h.sr_code]; +if (*profile != FF_PROFILE_UNKNOWN) +return 0; + +*profile = FF_PROFILE_DTS; +if (h.ext_audio_present) { +switch (h.ext_audio_type) { +case DCA_EXT_AUDIO_XCH: +case DCA_EXT_AUDIO_XXCH: +*profile = FF_PROFILE_DTS_ES; +break; +case DCA_EXT_AUDIO_X96: +*profile = FF_PROFILE_DTS_96_24; +break; +} +} + +frame_size = FFALIGN(h.frame_size, 4); +if (buf_size - 4 < frame_size) +return 0; + +buf += frame_size; +buf_size -= frame_size; +if (AV_RB32(buf) != DCA_SYNCWORD_SUBSTREAM) +return 0; +if (ff_dca_exss_parse(&pc1->exss, buf, buf_size) < 0) +return 0; + +if (asset->extension_mask & DCA_EXSS_XLL) +*profile = FF_PROFILE_DTS_HD_MA; +else if (asset->extension_mask & (DCA_EXSS_XBR | DCA_EXSS_XXCH | DCA_EXSS_X96)) +*profile = FF_PROFILE_DTS_HD_HRA; return 0; } @@ -298,7 +332,7 @@ static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx, } /* read the duration and sample rate from the frame header */ -if (!dca_parse_params(pc1, buf, buf_size, &duration, &sample_rate)) { +if (!dca_parse_params(pc1, buf, buf_size, &duration, &sample_rate, &avctx->profile)) { if (!avctx->sample_rate) avctx->sample_rate = sample_rate; s->duration = av_rescale(duration, avctx->sample_rate, sample_rate); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_parser: avoid use of magic values
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:38 2017 +0300| [07a7f08b1e4b4679a3f9a60ecc45cae5078bc414] | committer: James Almer avcodec/dca_parser: avoid use of magic values Duration computation can be simplified because number of PCM blocks is only allowed to be a multiple of 8. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=07a7f08b1e4b4679a3f9a60ecc45cae5078bc414 --- libavcodec/dca_parser.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 390f7975f9..7e99b16bf0 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -25,6 +25,7 @@ #include "dca.h" #include "dca_core.h" #include "dca_exss.h" +#include "dca_lbr.h" #include "dca_syncwords.h" #include "get_bits.h" #include "parser.h" @@ -214,9 +215,9 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, return AVERROR_INVALIDDATA; switch (get_bits(&gb, 8)) { -case 2: +case DCA_LBR_HEADER_DECODER_INIT: pc1->sr_code = get_bits(&gb, 8); -case 1: +case DCA_LBR_HEADER_SYNC_ONLY: break; default: return AVERROR_INVALIDDATA; @@ -267,7 +268,7 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0) return AVERROR_INVALIDDATA; -*duration = 256 * (h.npcmblocks / 8); +*duration = h.npcmblocks * DCA_PCMBLOCK_SAMPLES; *sample_rate = avpriv_dca_sample_rates[h.sr_code]; if (*profile != FF_PROFILE_UNKNOWN) return 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: avoid using bitstream reader in a non-standard way
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:40 2017 +0300| [012620aa1b40b0642e3081871059a1be98411df4] | committer: James Almer avcodec/dca: avoid using bitstream reader in a non-standard way Use proper get_bits.h functions instead of directly accessing index. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=012620aa1b40b0642e3081871059a1be98411df4 --- libavcodec/dca_core.c | 12 +++- libavcodec/dca_core.h | 1 + libavcodec/dca_xll.c | 2 +- libavcodec/dcadec.h | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 4a7ea4e3f3..3add9f812b 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -1804,6 +1804,7 @@ int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size) if ((ret = init_get_bits8(&s->gb, data, size)) < 0) return ret; +s->gb_in = s->gb; if ((ret = parse_frame_header(s)) < 0) return ret; @@ -1831,7 +1832,6 @@ int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset { AVCodecContext *avctx = s->avctx; DCAContext *dca = avctx->priv_data; -GetBitContext gb = s->gb; int exss_mask = asset ? asset->extension_mask : 0; int ret = 0, ext = 0; @@ -1843,11 +1843,13 @@ int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset ret = parse_xxch_frame(s); ext = DCA_EXSS_XXCH; } else if (s->xxch_pos) { -s->gb.index = s->xxch_pos; +s->gb = s->gb_in; +skip_bits_long(&s->gb, s->xxch_pos); ret = parse_xxch_frame(s); ext = DCA_CSS_XXCH; } else if (s->xch_pos) { -s->gb.index = s->xch_pos; +s->gb = s->gb_in; +skip_bits_long(&s->gb, s->xch_pos); ret = parse_xch_frame(s); ext = DCA_CSS_XCH; } @@ -1889,8 +1891,8 @@ int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset s->ext_audio_mask |= DCA_EXSS_X96; } } else if (s->x96_pos) { -s->gb = gb; -s->gb.index = s->x96_pos; +s->gb = s->gb_in; +skip_bits_long(&s->gb, s->x96_pos); if ((ret = parse_x96_frame(s)) < 0) { if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE)) return ret; diff --git a/libavcodec/dca_core.h b/libavcodec/dca_core.h index cce0ffd7b1..10128d1e32 100644 --- a/libavcodec/dca_core.h +++ b/libavcodec/dca_core.h @@ -101,6 +101,7 @@ typedef struct DCADSPData { typedef struct DCACoreDecoder { AVCodecContext *avctx; GetBitContext gb; +GetBitContext gb_in; // Bit stream header int crc_present;///< CRC present flag diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c index 38a1999fc8..d265cab8df 100644 --- a/libavcodec/dca_xll.c +++ b/libavcodec/dca_xll.c @@ -1028,7 +1028,7 @@ static int parse_band_data(DCAXllDecoder *s) return ret; chs_clear_band_data(s, c, band, seg); } -s->gb.index = navi_pos; +skip_bits_long(&s->gb, navi_pos - get_bits_count(&s->gb)); } navi_ptr++; } diff --git a/libavcodec/dcadec.h b/libavcodec/dcadec.h index 456f3c433b..9da8d3b444 100644 --- a/libavcodec/dcadec.h +++ b/libavcodec/dcadec.h @@ -88,9 +88,9 @@ static inline int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s, static inline int ff_dca_seek_bits(GetBitContext *s, int p) { -if (p < s->index || p > s->size_in_bits) +if (p < get_bits_count(s) || p > s->size_in_bits) return -1; -s->index = p; +skip_bits_long(s, p - get_bits_count(s)); return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_core: probe extension headers directly
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:39 2017 +0300| [902cd30e9b72d3ad5dfe01b27e3dd0928ad88562] | committer: James Almer avcodec/dca_core: probe extension headers directly Avoid using bitstream reader in a non-standard way by directly accessing index. Use bit shifting/masking operations instead. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=902cd30e9b72d3ad5dfe01b27e3dd0928ad88562 --- libavcodec/dca_core.c | 31 --- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 090191dfa9..4a7ea4e3f3 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -1704,6 +1704,7 @@ static int parse_optional_info(DCACoreDecoder *s) int sync_pos = FFMIN(s->frame_size / 4, s->gb.size_in_bits / 32) - 1; int last_pos = get_bits_count(&s->gb) / 32; int size, dist; +uint32_t w1, w2 = 0; // Search for extension sync words aligned on 4-byte boundary. Search // must be done backwards from the end of core frame to work around @@ -1718,15 +1719,15 @@ static int parse_optional_info(DCACoreDecoder *s) // compatibility with legacy bitstreams. Minimum XCH frame size is // 96 bytes. AMODE and PCHS are further checked to reduce // probability of alias sync detection. -for (; sync_pos >= last_pos; sync_pos--) { -if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_XCH) { -s->gb.index = (sync_pos + 1) * 32; -size = get_bits(&s->gb, 10) + 1; +for (; sync_pos >= last_pos; sync_pos--, w2 = w1) { +w1 = AV_RB32(s->gb.buffer + sync_pos * 4); +if (w1 == DCA_SYNCWORD_XCH) { +size = (w2 >> 22) + 1; dist = s->frame_size - sync_pos * 4; if (size >= 96 && (size == dist || size - 1 == dist) -&& get_bits(&s->gb, 7) == 0x08) { -s->xch_pos = get_bits_count(&s->gb); +&& (w2 >> 15 & 0x7f) == 0x08) { +s->xch_pos = sync_pos * 32 + 49; break; } } @@ -1743,13 +1744,13 @@ static int parse_optional_info(DCACoreDecoder *s) // The distance between X96 sync word and end of the core frame // must be equal to X96 frame size. Minimum X96 frame size is 96 // bytes. -for (; sync_pos >= last_pos; sync_pos--) { -if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_X96) { -s->gb.index = (sync_pos + 1) * 32; -size = get_bits(&s->gb, 12) + 1; +for (; sync_pos >= last_pos; sync_pos--, w2 = w1) { +w1 = AV_RB32(s->gb.buffer + sync_pos * 4); +if (w1 == DCA_SYNCWORD_X96) { +size = (w2 >> 20) + 1; dist = s->frame_size - sync_pos * 4; if (size >= 96 && size == dist) { -s->x96_pos = get_bits_count(&s->gb); +s->x96_pos = sync_pos * 32 + 44; break; } } @@ -1768,10 +1769,10 @@ static int parse_optional_info(DCACoreDecoder *s) // XXCH frame header CRC must be valid. Minimum XXCH frame header // size is 11 bytes. -for (; sync_pos >= last_pos; sync_pos--) { -if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_XXCH) { -s->gb.index = (sync_pos + 1) * 32; -size = get_bits(&s->gb, 6) + 1; +for (; sync_pos >= last_pos; sync_pos--, w2 = w1) { +w1 = AV_RB32(s->gb.buffer + sync_pos * 4); +if (w1 == DCA_SYNCWORD_XXCH) { +size = (w2 >> 26) + 1; dist = s->gb.size_in_bits / 8 - sync_pos * 4; if (size >= 11 && size <= dist && !av_crc(dca->crctab, 0x, s->gb.buffer + ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/dtsdec: switch to common frame header parsing function
ffmpeg | branch: master | foo86 | Mon Jul 10 17:11:36 2017 +0300| [3b7ec920af42f1dc3676b72db9e617227c220436] | committer: James Almer avformat/dtsdec: switch to common frame header parsing function This makes probing for regular DTS more strict because more header fields are checked and values not supported by decoder are now rejected. Also fixes an issue original code had with 14-bit streams: 96 bits of header were expected, however only 84 bits were converted, which was not enough to parse LFE flag. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3b7ec920af42f1dc3676b72db9e617227c220436 --- libavformat/dtsdec.c | 39 +-- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c index 8c985b8877..6e0048f9bc 100644 --- a/libavformat/dtsdec.c +++ b/libavformat/dtsdec.c @@ -35,13 +35,13 @@ static int dts_probe(AVProbeData *p) uint32_t state = -1; int markers[4*16] = {0}; int exss_markers = 0, exss_nextpos = 0; -int sum, max, pos, i; +int sum, max, pos, ret, i; int64_t diff = 0; -uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; +uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; for (pos = FFMIN(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) { -int marker, sample_blocks, sample_rate, sr_code, framesize; -int lfe, wide_hdr, hdr_size; +int marker, wide_hdr, hdr_size, framesize; +DCACoreFrameHeader h; GetBitContext gb; bufp = buf = p->buf + pos; @@ -98,36 +98,15 @@ static int dts_probe(AVProbeData *p) else continue; -if (avpriv_dca_convert_bitstream(buf-2, 12, hdr, 12) < 0) +if ((ret = avpriv_dca_convert_bitstream(buf - 2, DCA_CORE_FRAME_HEADER_SIZE, +hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0) continue; - -init_get_bits(&gb, hdr, 96); -skip_bits_long(&gb, 39); - -sample_blocks = get_bits(&gb, 7) + 1; -if (sample_blocks < 8) +if (init_get_bits8(&gb, hdr, ret) < 0) continue; - -framesize = get_bits(&gb, 14) + 1; -if (framesize < 95) -continue; - -skip_bits(&gb, 6); -sr_code = get_bits(&gb, 4); -sample_rate = avpriv_dca_sample_rates[sr_code]; -if (sample_rate == 0) -continue; - -get_bits(&gb, 5); -if (get_bits(&gb, 1)) -continue; - -skip_bits_long(&gb, 9); -lfe = get_bits(&gb, 2); -if (lfe > 2) +if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0) continue; -marker += 4* sr_code; +marker += 4 * h.sr_code; markers[marker] ++; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec: add Dolby E decoder
ffmpeg | branch: master | foo86 | Sat Jul 1 17:03:46 2017 +0300| [930fe4b1f75d4176a7226fccdcbd6c68b816a1b7] | committer: Paul B Mahol avcodec: add Dolby E decoder > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=930fe4b1f75d4176a7226fccdcbd6c68b816a1b7 --- configure | 1 + doc/general.texi| 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 + libavcodec/dolby_e.c| 707 ++ libavcodec/dolby_e.h| 733 libavcodec/version.h| 2 +- 9 files changed, 1453 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 3a146ed857..5811ee149a 100755 --- a/configure +++ b/configure @@ -2402,6 +2402,7 @@ dds_decoder_select="texturedsp" dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc" dnxhd_decoder_select="blockdsp idctdsp" dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp" +dolby_e_decoder_select="mdct" dvvideo_decoder_select="dvprofile idctdsp" dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp" dxa_decoder_select="zlib" diff --git a/doc/general.texi b/doc/general.texi index 8f582d586f..d95ef31fde 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1001,6 +1001,7 @@ following image formats are supported: @tab All versions except 5.1 are supported. @item DCA (DTS Coherent Acoustics) @tab X @tab X @tab supported extensions: XCh, XXCH, X96, XBR, XLL, LBR (partially) +@item Dolby E @tab @tab X @item DPCM id RoQ@tab X @tab X @tab Used in Quake III, Jedi Knight 2 and other computer games. @item DPCM Interplay @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 59029a853c..357fa1a361 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -251,6 +251,7 @@ OBJS-$(CONFIG_DIRAC_DECODER) += diracdec.o dirac.o diracdsp.o diractab OBJS-$(CONFIG_DFA_DECODER) += dfa.o OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o +OBJS-$(CONFIG_DOLBY_E_DECODER) += dolby_e.o kbdwin.o OBJS-$(CONFIG_DPX_DECODER) += dpx.o OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o OBJS-$(CONFIG_DSD_LSBF_DECODER)+= dsddec.o dsd.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 0243f47358..4712592a5f 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -423,6 +423,7 @@ static void register_all(void) REGISTER_DECODER(BMV_AUDIO, bmv_audio); REGISTER_DECODER(COOK, cook); REGISTER_ENCDEC (DCA, dca); +REGISTER_DECODER(DOLBY_E, dolby_e); REGISTER_DECODER(DSD_LSBF, dsd_lsbf); REGISTER_DECODER(DSD_MSBF, dsd_msbf); REGISTER_DECODER(DSD_LSBF_PLANAR, dsd_lsbf_planar); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index b697afa0ae..c594993766 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -639,6 +639,7 @@ enum AVCodecID { AV_CODEC_ID_DST, AV_CODEC_ID_ATRAC3AL, AV_CODEC_ID_ATRAC3PAL, +AV_CODEC_ID_DOLBY_E, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index caff7e665d..6f43b68b83 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2671,6 +2671,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .props = AV_CODEC_PROP_LOSSY, }, { +.id= AV_CODEC_ID_DOLBY_E, +.type = AVMEDIA_TYPE_AUDIO, +.name = "dolby_e", +.long_name = NULL_IF_CONFIG_SMALL("Dolby E"), +.props = AV_CODEC_PROP_LOSSY, +}, +{ .id= AV_CODEC_ID_G729, .type = AVMEDIA_TYPE_AUDIO, .name = "g729", diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c new file mode 100644 index 00..63187e9977 --- /dev/null +++ b/libavcodec/dolby_e.c @@ -0,0 +1,707 @@ +/* + * Copyright (C) 2017 foo86 + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of
[FFmpeg-cvslog] avformat: add SMPTE 337M demuxer
ffmpeg | branch: master | foo86 | Sat Jul 1 17:06:27 2017 +0300| [f04ef268164f7e88bef809fb028c6fa01b024ea3] | committer: Paul B Mahol avformat: add SMPTE 337M demuxer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f04ef268164f7e88bef809fb028c6fa01b024ea3 --- Changelog| 1 + doc/general.texi | 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/s337m.c | 206 +++ libavformat/version.h| 2 +- 6 files changed, 211 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 927cf1c858..187ae7950a 100644 --- a/Changelog +++ b/Changelog @@ -28,6 +28,7 @@ version : - support for decoding through D3D11VA in ffmpeg - limiter video filter - libvmaf video filter +- Dolby E decoder and SMPTE 337M demuxer version 3.3: - CrystalHD decoder moved to new decode API diff --git a/doc/general.texi b/doc/general.texi index d95ef31fde..036c8c25d4 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -520,6 +520,7 @@ library: @tab Multimedia format used by many games. @item SMJPEG@tab X @tab X @tab Used in certain Loki game ports. +@item SMPTE 337M encapsulation @tab @tab X @item Smush @tab @tab X @tab Multimedia format used in some LucasArts games. @item Sony OpenMG (OMA) @tab X @tab X diff --git a/libavformat/Makefile b/libavformat/Makefile index 80aeed22c0..b0ef82cdd4 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -432,6 +432,7 @@ OBJS-$(CONFIG_RTSP_DEMUXER) += rtsp.o rtspdec.o httpauth.o \ urldecode.o OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \ urldecode.o +OBJS-$(CONFIG_S337M_DEMUXER) += s337m.o spdif.o OBJS-$(CONFIG_SAMI_DEMUXER) += samidec.o subtitles.o OBJS-$(CONFIG_SAP_DEMUXER) += sapdec.o OBJS-$(CONFIG_SAP_MUXER) += sapenc.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index a0e2fb8c85..1ebc14231c 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -267,6 +267,7 @@ static void register_all(void) REGISTER_MUXDEMUX(RTP, rtp); REGISTER_MUXER (RTP_MPEGTS, rtp_mpegts); REGISTER_MUXDEMUX(RTSP, rtsp); +REGISTER_DEMUXER (S337M,s337m); REGISTER_DEMUXER (SAMI, sami); REGISTER_MUXDEMUX(SAP, sap); REGISTER_DEMUXER (SBG, sbg); diff --git a/libavformat/s337m.c b/libavformat/s337m.c new file mode 100644 index 00..1f4ba5edaf --- /dev/null +++ b/libavformat/s337m.c @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2017 foo86 + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "spdif.h" + +#define MARKER_16LE 0x72F81F4E +#define MARKER_20LE 0x20876FF0E154 +#define MARKER_24LE 0x72F8961F4EA5 + +#define IS_16LE_MARKER(state) ((state & 0x) == MARKER_16LE) +#define IS_20LE_MARKER(state) ((state & 0xF0F0) == MARKER_20LE) +#define IS_24LE_MARKER(state) ((state & 0x) == MARKER_24LE) +#define IS_LE_MARKER(state) (IS_16LE_MARKER(state) || IS_20LE_MARKER(state) || IS_24LE_MARKER(state)) + +static int s337m_get_offset_and_codec(AVFormatContext *s, + uint64_t state, + int data_type, int data_size, + int *offset, enum AVCodecID *codec) +{ +int word_bits; + +if (IS_16LE_MARKER(state)) { +word_bits = 16; +} else if (IS_20LE_MARKER(state)) { +data_type >>= 8; +data_size >>= 4; +word_bits = 20; +} else { +data_type >>= 8; +word_bits = 24; +} + +if ((data_type & 0x1F) != 0x1C) { +if (s) +avpriv_report_missing_feature(s, "Data type %#x in SMPTE 337M", data_type & 0x1F); +return AVERROR_PATCHWELCOME; +} + +if (codec) +*co
[FFmpeg-cvslog] MAINTAINERS: add myself
ffmpeg | branch: master | foo86 | Fri Jul 21 15:22:53 2017 +0300| [67af24da0dc2eceb06d2bb4ce1bf54fa13275d00] | committer: James Almer MAINTAINERS: add myself Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67af24da0dc2eceb06d2bb4ce1bf54fa13275d00 --- MAINTAINERS | 4 1 file changed, 4 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 60aae12faa..ae0e08d121 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -159,8 +159,10 @@ Codecs: crystalhd.c Philip Langdale cscd.cReimar Doeffinger cuvid.c Timo Rothenpieler + dca* foo86 dirac*Rostislav Pehlivanov dnxhd*Baptiste Coudurier + dolby_e* foo86 dpcm.cMike Melanson dss_sp.c Oleksij Rempel dv.c Roman Shaposhnik @@ -394,6 +396,7 @@ Muxers/Demuxers: crc.c Michael Niedermayer daud.cReimar Doeffinger dss.c Oleksij Rempel + dtsdec.c foo86 dtshddec.cPaul B Mahol dv.c Roman Shaposhnik electronicarts.c Peter Ross @@ -465,6 +468,7 @@ Muxers/Demuxers: rtpdec_vc2hq.*, rtpenc_vc2hq.*Thomas Volkert rtpdec_vp9.c Thomas Volkert rtpenc_mpv.*, rtpenc_aac.*Martin Storsjo + s337m.c foo86 sbgdec.c Nicolas George sdp.c Martin Storsjo segafilm.cMike Melanson ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dcaadpcm: fix use of uninitialized variable
ffmpeg | branch: master | foo86 | Sat Jul 22 18:20:04 2017 +0300| [dd4b7badb416a5c2688da7310a7fe80fe4e4f209] | committer: foo86 avcodec/dcaadpcm: fix use of uninitialized variable Fixes CID 1409924. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dd4b7badb416a5c2688da7310a7fe80fe4e4f209 --- libavcodec/dcaadpcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dcaadpcm.c b/libavcodec/dcaadpcm.c index cc82241a5f..9f615e3793 100644 --- a/libavcodec/dcaadpcm.c +++ b/libavcodec/dcaadpcm.c @@ -80,7 +80,7 @@ static int64_t find_best_filter(const DCAADPCMEncContext *s, const int32_t *in, { const premultiplied_coeffs *precalc_data = s->private_data; int i, j, k = 0; -int vq; +int vq = -1; int64_t err; int64_t min_err = 1ll << 62; int64_t corr[15]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dcaadpcm: check for av_malloc() failure
ffmpeg | branch: master | foo86 | Sat Jul 22 18:16:13 2017 +0300| [34fb84a97d112d85091369e9ef9ce177a05644e9] | committer: foo86 avcodec/dcaadpcm: check for av_malloc() failure Fixes CID 1409915. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34fb84a97d112d85091369e9ef9ce177a05644e9 --- libavcodec/dcaadpcm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/dcaadpcm.c b/libavcodec/dcaadpcm.c index 8742c7ccf6..cc82241a5f 100644 --- a/libavcodec/dcaadpcm.c +++ b/libavcodec/dcaadpcm.c @@ -215,6 +215,9 @@ av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s) return -1; s->private_data = av_malloc(sizeof(premultiplied_coeffs) * DCA_ADPCM_VQCODEBOOK_SZ); +if (!s->private_data) +return AVERROR(ENOMEM); + precalc(s->private_data); return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dolby_e: add AV_CODEC_CAP_CHANNEL_CONF capability
ffmpeg | branch: master | foo86 | Sat Jul 22 17:18:47 2017 +0300| [0689cc2475557339a00240d05b7fc4fcb70e21cd] | committer: foo86 avcodec/dolby_e: add AV_CODEC_CAP_CHANNEL_CONF capability > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0689cc2475557339a00240d05b7fc4fcb70e21cd --- libavcodec/dolby_e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index 6f390d959f..f811db4d8e 100644 --- a/libavcodec/dolby_e.c +++ b/libavcodec/dolby_e.c @@ -701,7 +701,7 @@ AVCodec ff_dolby_e_decoder = { .decode = dolby_e_decode_frame, .close = dolby_e_close, .flush = dolby_e_flush, -.capabilities = AV_CODEC_CAP_DR1, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dolby_e: add 'f' suffixes to floating point literals
ffmpeg | branch: master | foo86 | Sat Jul 22 17:13:04 2017 +0300| [56277f6d1905af033d58588c631956dcb19fdf7a] | committer: foo86 avcodec/dolby_e: add 'f' suffixes to floating point literals > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=56277f6d1905af033d58588c631956dcb19fdf7a --- libavcodec/dolby_e.h | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libavcodec/dolby_e.h b/libavcodec/dolby_e.h index 055e1121cf..0390233720 100644 --- a/libavcodec/dolby_e.h +++ b/libavcodec/dolby_e.h @@ -649,30 +649,30 @@ static av_cold void init_tables(void) int i, j; for (i = 1; i < 17; i++) -mantissa_tab1[i][0] = 1.0 / (1 << i - 1); +mantissa_tab1[i][0] = 1.0f / (1 << i - 1); for (i = 2; i < 16; i++) { -mantissa_tab1[i][1] = 1.0 / ((1 << i) - 1); -mantissa_tab1[i][2] = 0.5 / ((1 << i) - 1); -mantissa_tab1[i][3] = 0.25 / ((1 << i) - 1); +mantissa_tab1[i][1] = 1.0f / ((1 << i) - 1); +mantissa_tab1[i][2] = 0.5f / ((1 << i) - 1); +mantissa_tab1[i][3] = 0.25f / ((1 << i) - 1); } -mantissa_tab1[i][1] = 0.5 / (1 << 15); -mantissa_tab1[i][2] = 0.75 / (1 << 15); -mantissa_tab1[i][3] = 0.875 / (1 << 15); +mantissa_tab1[i][1] = 0.5f / (1 << 15); +mantissa_tab1[i][2] = 0.75f / (1 << 15); +mantissa_tab1[i][3] = 0.875f / (1 << 15); for (i = 1; i < 17; i++) { -mantissa_tab2[i][1] = mantissa_tab1[i][0] * 0.5; -mantissa_tab2[i][2] = mantissa_tab1[i][0] * 0.75; -mantissa_tab2[i][3] = mantissa_tab1[i][0] * 0.875; +mantissa_tab2[i][1] = mantissa_tab1[i][0] * 0.5f; +mantissa_tab2[i][2] = mantissa_tab1[i][0] * 0.75f; +mantissa_tab2[i][3] = mantissa_tab1[i][0] * 0.875f; for (j = 1; j < 4; j++) -mantissa_tab3[i][j] = 1.0 / (1 << i) + 1.0 / (1 << j) - 1.0 / (1 << i + j); +mantissa_tab3[i][j] = 1.0f / (1 << i) + 1.0f / (1 << j) - 1.0f / (1 << i + j); } -mantissa_tab3[1][3] = 0.6875; +mantissa_tab3[1][3] = 0.6875f; for (i = 0; i < 25; i++) { -exponent_tab[i * 2] = 1.0 / (1 << i); +exponent_tab[i * 2] = 1.0f / (1 << i); exponent_tab[i * 2 + 1] = M_SQRT1_2 / (1 << i); } @@ -680,7 +680,7 @@ static av_cold void init_tables(void) gain_tab[i] = exp2f((i - 960) / 64.0f); // short 1 -ff_kbd_window_init(window, 3.0, 128); +ff_kbd_window_init(window, 3.0f, 128); for (i = 0; i < 128; i++) window[128 + i] = window[127 - i]; @@ -704,12 +704,12 @@ static av_cold void init_tables(void) for (i = 0; i < 128; i++) window[960 + i] = window[i]; for (i = 0; i < 64; i++) -window[1088 + i] = 1.0; +window[1088 + i] = 1.0f; // long -ff_kbd_window_init(window + 1408, 3.0, 256); +ff_kbd_window_init(window + 1408, 3.0f, 256); for (i = 0; i < 640; i++) -window[1664 + i] = 1.0; +window[1664 + i] = 1.0f; for (i = 0; i < 256; i++) window[2304 + i] = window[1152 + i] = window[1663 - i]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/s337m: fix potentially undefined pointer arithmetic
ffmpeg | branch: master | foo86 | Sat Jul 22 17:27:28 2017 +0300| [6029b8a6bbc8bbf7799108582e71078ec0bde1cf] | committer: foo86 avformat/s337m: fix potentially undefined pointer arithmetic Use integer position instead of pointer for loop variable. Also only skip header fields after header has been fully validated. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6029b8a6bbc8bbf7799108582e71078ec0bde1cf --- libavformat/s337m.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavformat/s337m.c b/libavformat/s337m.c index 1f4ba5edaf..2e85d487b5 100644 --- a/libavformat/s337m.c +++ b/libavformat/s337m.c @@ -86,22 +86,21 @@ static int s337m_probe(AVProbeData *p) { uint64_t state = 0; int markers[3] = { 0 }; -int i, sum, max, data_type, data_size, offset; +int i, pos, sum, max, data_type, data_size, offset; uint8_t *buf; -for (buf = p->buf; buf < p->buf + p->buf_size; buf++) { -state = (state << 8) | *buf; +for (pos = 0; pos < p->buf_size; pos++) { +state = (state << 8) | p->buf[pos]; if (!IS_LE_MARKER(state)) continue; +buf = p->buf + pos + 1; if (IS_16LE_MARKER(state)) { -data_type = AV_RL16(buf + 1); -data_size = AV_RL16(buf + 3); -buf += 4; +data_type = AV_RL16(buf); +data_size = AV_RL16(buf + 2); } else { -data_type = AV_RL24(buf + 1); -data_size = AV_RL24(buf + 4); -buf += 6; +data_type = AV_RL24(buf); +data_size = AV_RL24(buf + 3); } if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, &offset, NULL)) @@ -110,7 +109,8 @@ static int s337m_probe(AVProbeData *p) i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2; markers[i]++; -buf += offset; +pos += IS_16LE_MARKER(state) ? 4 : 6; +pos += offset; state = 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dolby_e: fix potentially undefined pointer arithmetic
ffmpeg | branch: master | foo86 | Sat Jul 22 17:19:25 2017 +0300| [5e715b583dab85735660b15a8d217a69164675fe] | committer: foo86 avcodec/dolby_e: fix potentially undefined pointer arithmetic Avoid undefined behavior in skip_input() by checking that enough data is available before incrementing input pointer. Check return values of parse_key() and skip_input() and exit early with error if there is not enough data. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5e715b583dab85735660b15a8d217a69164675fe --- libavcodec/dolby_e.c | 45 - 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index f811db4d8e..91a00ce878 100644 --- a/libavcodec/dolby_e.c +++ b/libavcodec/dolby_e.c @@ -28,21 +28,28 @@ #include "dolby_e.h" #include "fft.h" -static void skip_input(DBEContext *s, int nb_words) +static int skip_input(DBEContext *s, int nb_words) { +if (nb_words > s->input_size) { +av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n"); +return AVERROR_INVALIDDATA; +} + s->input += nb_words * s->word_bytes; s->input_size -= nb_words; +return 0; } static int parse_key(DBEContext *s) { -int key = 0; - -if (s->key_present && s->input_size > 0) -key = AV_RB24(s->input) >> 24 - s->word_bits; - -skip_input(s, s->key_present); -return key; +if (s->key_present) { +uint8_t *key = s->input; +int ret = skip_input(s, 1); +if (ret < 0) +return ret; +return AV_RB24(key) >> 24 - s->word_bits; +} +return 0; } static int convert_input(DBEContext *s, int nb_words, int key) @@ -83,8 +90,10 @@ static int convert_input(DBEContext *s, int nb_words, int key) static int parse_metadata(DBEContext *s) { -int i, ret, key = parse_key(s), mtd_size; +int i, ret, key, mtd_size; +if ((key = parse_key(s)) < 0) +return key; if ((ret = convert_input(s, 1, key)) < 0) return ret; @@ -135,14 +144,13 @@ static int parse_metadata(DBEContext *s) return AVERROR_INVALIDDATA; } -skip_input(s, mtd_size + 1); -return 0; +return skip_input(s, mtd_size + 1); } static int parse_metadata_ext(DBEContext *s) { if (s->mtd_ext_size) -skip_input(s, s->key_present + s->mtd_ext_size + 1); +return skip_input(s, s->key_present + s->mtd_ext_size + 1); return 0; } @@ -455,7 +463,10 @@ static int parse_channel(DBEContext *s, int ch, int seg_id) static int parse_audio(DBEContext *s, int start, int end, int seg_id) { -int ch, ret, key = parse_key(s); +int ch, ret, key; + +if ((key = parse_key(s)) < 0) +return key; for (ch = start; ch < end; ch++) { if (!s->ch_size[ch]) { @@ -469,17 +480,17 @@ static int parse_audio(DBEContext *s, int start, int end, int seg_id) return ret; s->channels[seg_id][ch].nb_groups = 0; } -skip_input(s, s->ch_size[ch]); +if ((ret = skip_input(s, s->ch_size[ch])) < 0) +return ret; } -skip_input(s, 1); -return 0; +return skip_input(s, 1); } static int parse_meter(DBEContext *s) { if (s->meter_size) -skip_input(s, s->key_present + s->meter_size + 1); +return skip_input(s, s->key_present + s->meter_size + 1); return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_parser: revert to conservative sync distance estimation
ffmpeg | branch: master | foo86 | Mon Oct 9 16:12:19 2017 +0300| [23990950e35eff0b96f843c396a62a6429ea25ec] | committer: foo86 avcodec/dca_parser: revert to conservative sync distance estimation Fixes regression introduced by commit a0349ae27c127df8c72de1c30dc4090360ec7ef4 when parsing 14-bit streams with excessive frame size stored in header. Fixes ticket #6723. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=23990950e35eff0b96f843c396a62a6429ea25ec --- libavcodec/dca_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 11ddb8f188..80d665985e 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -124,13 +124,13 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, break; case DCA_SYNCWORD_CORE_14B_BE: if (size == 4) { -pc1->framesize = CORE_FRAMESIZE(STATE_14(state)) * 8 / 14 * 2; +pc1->framesize = CORE_FRAMESIZE(STATE_14(state)); start_found= 4; } break; case DCA_SYNCWORD_CORE_14B_LE: if (size == 4) { -pc1->framesize = CORE_FRAMESIZE(STATE_14(STATE_LE(state))) * 8 / 14 * 2; +pc1->framesize = CORE_FRAMESIZE(STATE_14(STATE_LE(state))); start_found= 4; } break; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_core: always limit frame size to data size
ffmpeg | branch: master | foo86 | Mon Oct 9 16:26:06 2017 +0300| [73789b85a759f3874112618120194e1712d7adcd] | committer: foo86 avcodec/dca_core: always limit frame size to data size Silences pointless error message when decoding DTS-in-WAV stream with excessive frame size stored in header. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=73789b85a759f3874112618120194e1712d7adcd --- libavcodec/dca_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 6cb1f30a3c..accc5efd51 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -1816,7 +1816,7 @@ int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size) return ret; // Workaround for DTS in WAV -if (s->frame_size > size && s->frame_size < size + 4) +if (s->frame_size > size) s->frame_size = size; if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] fate: add Dolby E test
ffmpeg | branch: master | foo86 | Mon Jul 31 23:33:05 2017 +0300| [b74877206e5f16cf78466534ac1ae86ecd347e5d] | committer: James Almer fate: add Dolby E test Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b74877206e5f16cf78466534ac1ae86ecd347e5d --- tests/fate/audio.mak | 5 + 1 file changed, 5 insertions(+) diff --git a/tests/fate/audio.mak b/tests/fate/audio.mak index 40c4ca7b75..4fab472f90 100644 --- a/tests/fate/audio.mak +++ b/tests/fate/audio.mak @@ -19,6 +19,11 @@ fate-bmv-audio: CMD = framecrc -i $(TARGET_SAMPLES)/bmv/SURFING-partial.BMV -vn FATE_SAMPLES_AUDIO-$(call DEMDEC, DSICIN, DSICINAUDIO) += fate-delphine-cin-audio fate-delphine-cin-audio: CMD = framecrc -i $(TARGET_SAMPLES)/delphine-cin/LOGO-partial.CIN -vn +FATE_SAMPLES_AUDIO-$(call DEMDEC, S337M, DOLBY_E) += fate-dolby-e +fate-dolby-e: CMD = pcm -i $(TARGET_SAMPLES)/dolby_e/16-11 +fate-dolby-e: CMP = oneoff +fate-dolby-e: REF = $(SAMPLES)/dolby_e/16-11.pcm + FATE_SAMPLES_AUDIO-$(call DEMDEC, DSS, DSS_SP) += fate-dss-lp fate-dss-sp fate-dss-lp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/lp.dss -frames 30 fate-dss-sp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/sp.dss -frames 30 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: add support for 20-bit XLL
ffmpeg | branch: master | foo86 | Sat Jan 7 12:26:43 2017 +0300| [000638431ccc206f280d8246855062afe0284f80] | committer: James Almer avcodec/dca: add support for 20-bit XLL Fixes ticket #6063. Reviewed-by: Paul B Mahol Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=000638431ccc206f280d8246855062afe0284f80 --- libavcodec/dca_xll.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c index 1d616c2..1320aaf 100644 --- a/libavcodec/dca_xll.c +++ b/libavcodec/dca_xll.c @@ -143,7 +143,7 @@ static int chs_parse_header(DCAXllDecoder *s, DCAXllChSet *c, DCAExssAsset *asse // Storage unit width c->storage_bit_res = get_bits(&s->gb, 5) + 1; -if (c->storage_bit_res != 16 && c->storage_bit_res != 24) { +if (c->storage_bit_res != 16 && c->storage_bit_res != 20 && c->storage_bit_res != 24) { avpriv_request_sample(s->avctx, "%d-bit XLL storage resolution", c->storage_bit_res); return AVERROR_PATCHWELCOME; } @@ -1415,9 +1415,12 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame) switch (p->storage_bit_res) { case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; +shift = 16 - p->pcm_bit_res; break; +case 20: case 24: avctx->sample_fmt = AV_SAMPLE_FMT_S32P; +shift = 24 - p->pcm_bit_res; break; default: return AVERROR(EINVAL); @@ -1438,7 +1441,6 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame) s->output_mask); } -shift = p->storage_bit_res - p->pcm_bit_res; for (i = 0; i < avctx->channels; i++) { int32_t *samples = s->output_samples[ch_remap[i]]; if (frame->format == AV_SAMPLE_FMT_S16P) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/libdcadec: fix request_channel_layout
ffmpeg | branch: master | foo86 | Mon Dec 7 18:47:47 2015 +0300| [704654ea170c158419ded9591d8fb9895aca32be] | committer: Michael Niedermayer avcodec/libdcadec: fix request_channel_layout Take request_channel_layout as a hint and don't force 2.0 downmix by using both the 2CH and 6CH flags together. Remove warnings about missing coefficients because they are no longer relevant. Honor AV_CH_LAYOUT_NATIVE and make it possible for native DTS channel layout to be output. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=704654ea170c158419ded9591d8fb9895aca32be --- libavcodec/libdcadec.c | 25 + 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/libavcodec/libdcadec.c b/libavcodec/libdcadec.c index e802076..6166c9d 100644 --- a/libavcodec/libdcadec.c +++ b/libavcodec/libdcadec.c @@ -34,7 +34,6 @@ typedef struct DCADecContext { struct dcadec_context *ctx; uint8_t *buffer; int buffer_size; -int downmix_warned; } DCADecContext; static int dcadec_decode_frame(AVCodecContext *avctx, void *data, @@ -134,17 +133,6 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, if (exss = dcadec_context_get_exss_info(s->ctx)) { enum AVMatrixEncoding matrix_encoding = AV_MATRIX_ENCODING_NONE; -if (!s->downmix_warned) { -uint64_t layout = avctx->request_channel_layout; - -if (((layout == AV_CH_LAYOUT_STEREO_DOWNMIX || layout == AV_CH_LAYOUT_STEREO) && !exss->embedded_stereo) || -( layout == AV_CH_LAYOUT_5POINT1 && !exss->embedded_6ch)) -av_log(avctx, AV_LOG_WARNING, "%s downmix was requested but no custom coefficients are available, " - "this may result in clipping\n", - layout == AV_CH_LAYOUT_5POINT1 ? "5.1" : "Stereo"); -s->downmix_warned = 1; -} - switch(exss->matrix_encoding) { case DCADEC_MATRIX_ENCODING_SURROUND: matrix_encoding = AV_MATRIX_ENCODING_DOLBY; @@ -209,21 +197,18 @@ static av_cold int dcadec_init(AVCodecContext *avctx) if (avctx->flags & AV_CODEC_FLAG_BITEXACT) flags |= DCADEC_FLAG_CORE_BIT_EXACT; -if (avctx->request_channel_layout > 0 && avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE) { +if (avctx->request_channel_layout) { switch (avctx->request_channel_layout) { case AV_CH_LAYOUT_STEREO: case AV_CH_LAYOUT_STEREO_DOWNMIX: -/* libdcadec ignores the 2ch flag if used alone when no custom downmix coefficients - are available, silently outputting a 5.1 downmix if possible instead. - Using both the 2ch and 6ch flags together forces a 2ch downmix using default - coefficients in such cases. This matches the behavior of the 6ch flag when used - alone, where a 5.1 downmix is generated if possible, regardless of custom - coefficients being available or not. */ -flags |= DCADEC_FLAG_KEEP_DMIX_2CH | DCADEC_FLAG_KEEP_DMIX_6CH; +flags |= DCADEC_FLAG_KEEP_DMIX_2CH; break; case AV_CH_LAYOUT_5POINT1: flags |= DCADEC_FLAG_KEEP_DMIX_6CH; break; +case AV_CH_LAYOUT_NATIVE: +flags |= DCADEC_FLAG_NATIVE_LAYOUT; +break; default: av_log(avctx, AV_LOG_WARNING, "Invalid request_channel_layout\n"); break; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/libdcadec: implement logging callback
ffmpeg | branch: master | foo86 | Mon Dec 7 18:48:13 2015 +0300| [704b278361add7c819b4c3725938c4424328e268] | committer: Michael Niedermayer avcodec/libdcadec: implement logging callback Don't print a warning when dcadec_context_filter() returns positive warning code. Most relevant warnings are now output through the callback function. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=704b278361add7c819b4c3725938c4424328e268 --- libavcodec/libdcadec.c | 31 +-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/libavcodec/libdcadec.c b/libavcodec/libdcadec.c index 6166c9d..e15d1b5 100644 --- a/libavcodec/libdcadec.c +++ b/libavcodec/libdcadec.c @@ -36,6 +36,33 @@ typedef struct DCADecContext { int buffer_size; } DCADecContext; +static void my_log_cb(int level, const char *file, int line, + const char *message, void *cbarg) +{ +int av_level; + +switch (level) { +case DCADEC_LOG_ERROR: +av_level = AV_LOG_ERROR; +break; +case DCADEC_LOG_WARNING: +av_level = AV_LOG_WARNING; +break; +case DCADEC_LOG_INFO: +av_level = AV_LOG_INFO; +break; +case DCADEC_LOG_VERBOSE: +av_level = AV_LOG_VERBOSE; +break; +case DCADEC_LOG_DEBUG: +default: +av_level = AV_LOG_DEBUG; +break; +} + +av_log(cbarg, av_level, "%s\n", message); +} + static int dcadec_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { @@ -77,8 +104,6 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, &sample_rate, &bits_per_sample, &profile)) < 0) { av_log(avctx, AV_LOG_ERROR, "dcadec_context_filter() failed: %d (%s)\n", -ret, dcadec_strerror(ret)); return AVERROR_EXTERNAL; -} else if (ret > 0) { -av_log(avctx, AV_LOG_WARNING, "dcadec_context_filter() warning: %d (%s)\n", ret, dcadec_strerror(ret)); } avctx->channels = av_get_channel_layout_nb_channels(channel_mask); @@ -219,6 +244,8 @@ static av_cold int dcadec_init(AVCodecContext *avctx) if (!s->ctx) return AVERROR(ENOMEM); +dcadec_context_set_log_cb(s->ctx, my_log_cb, avctx); + avctx->sample_fmt = AV_SAMPLE_FMT_S32P; avctx->bits_per_raw_sample = 24; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/libdcadec: honor -err_detect option
ffmpeg | branch: master | foo86 | Mon Dec 7 18:48:53 2015 +0300| [ff6dd5851bffe9518f2e814a2f4892f0aa4fd6f9] | committer: Michael Niedermayer avcodec/libdcadec: honor -err_detect option Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff6dd5851bffe9518f2e814a2f4892f0aa4fd6f9 --- libavcodec/libdcadec.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/libdcadec.c b/libavcodec/libdcadec.c index 8e3bc61..79fa331 100644 --- a/libavcodec/libdcadec.c +++ b/libavcodec/libdcadec.c @@ -225,6 +225,9 @@ static av_cold int dcadec_init(AVCodecContext *avctx) if (avctx->flags & AV_CODEC_FLAG_BITEXACT) flags |= DCADEC_FLAG_CORE_BIT_EXACT; +if (avctx->err_recognition & AV_EF_EXPLODE) +flags |= DCADEC_FLAG_STRICT; + if (avctx->request_channel_layout) { switch (avctx->request_channel_layout) { case AV_CH_LAYOUT_STEREO: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/libdcadec: add some useful options
ffmpeg | branch: master | foo86 | Mon Dec 7 18:48:34 2015 +0300| [de12aa51b6bfa563656b9b510c2c8a88e858dade] | committer: Michael Niedermayer avcodec/libdcadec: add some useful options Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de12aa51b6bfa563656b9b510c2c8a88e858dade --- libavcodec/libdcadec.c | 38 ++ 1 file changed, 38 insertions(+) diff --git a/libavcodec/libdcadec.c b/libavcodec/libdcadec.c index e15d1b5..8e3bc61 100644 --- a/libavcodec/libdcadec.c +++ b/libavcodec/libdcadec.c @@ -31,9 +31,12 @@ #include "internal.h" typedef struct DCADecContext { +const AVClass *class; struct dcadec_context *ctx; uint8_t *buffer; int buffer_size; +int lfe_filter; +int core_only; } DCADecContext; static void my_log_cb(int level, const char *file, int line, @@ -240,6 +243,20 @@ static av_cold int dcadec_init(AVCodecContext *avctx) } } +if (s->core_only) +flags |= DCADEC_FLAG_CORE_ONLY; + +switch (s->lfe_filter) { +#if DCADEC_API_VERSION >= DCADEC_VERSION_CODE(0, 1, 0) +case 1: +flags |= DCADEC_FLAG_CORE_LFE_IIR; +break; +#endif +case 2: +flags |= DCADEC_FLAG_CORE_LFE_FIR; +break; +} + s->ctx = dcadec_context_create(flags); if (!s->ctx) return AVERROR(ENOMEM); @@ -252,6 +269,26 @@ static av_cold int dcadec_init(AVCodecContext *avctx) return 0; } +#define OFFSET(x) offsetof(DCADecContext, x) +#define PARAM AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM + +static const AVOption dcadec_options[] = { +{ "lfe_filter", "Lossy LFE channel interpolation filter", OFFSET(lfe_filter), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, PARAM, "lfe_filter" }, +{ "default","Library default",0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, PARAM, "lfe_filter" }, +{ "iir","IIR filter", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, PARAM, "lfe_filter" }, +{ "fir","FIR filter", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, PARAM, "lfe_filter" }, +{ "core_only", "Decode core only without extensions", OFFSET(core_only), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, PARAM }, +{ NULL } +}; + +static const AVClass dcadec_class = { +.class_name = "libdcadec decoder", +.item_name = av_default_item_name, +.option = dcadec_options, +.version= LIBAVUTIL_VERSION_INT, +.category = AV_CLASS_CATEGORY_DECODER, +}; + static const AVProfile profiles[] = { { FF_PROFILE_DTS, "DTS" }, { FF_PROFILE_DTS_ES, "DTS-ES" }, @@ -275,5 +312,6 @@ AVCodec ff_libdcadec_decoder = { .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, +.priv_class = &dcadec_class, .profiles = NULL_IF_CONFIG_SMALL(profiles), }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: add DTS Express (LBR) decoder
ffmpeg | branch: master | foo86 | Sun May 1 18:43:00 2016 +0300| [6c44696b3d504eb87d60915919074da530cd379f] | committer: James Almer avcodec/dca: add DTS Express (LBR) decoder Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6c44696b3d504eb87d60915919074da530cd379f --- Changelog|1 + libavcodec/Makefile |2 +- libavcodec/dca_lbr.c | 1825 ++ libavcodec/dca_lbr.h | 130 libavcodec/dcadata.c | 466 + libavcodec/dcadata.h | 47 ++ libavcodec/dcadec.c | 22 +- libavcodec/dcadec.h |5 +- libavcodec/dcadsp.c | 74 ++ libavcodec/dcadsp.h |7 + libavcodec/dcahuff.c | 244 ++- libavcodec/dcahuff.h | 13 + 12 files changed, 2830 insertions(+), 6 deletions(-) diff --git a/Changelog b/Changelog index ad2f6ba..6dd0a14 100644 --- a/Changelog +++ b/Changelog @@ -31,6 +31,7 @@ version : - Duck TrueMotion 2.0 Real Time decoder - Wideband Single-bit Data (WSD) demuxer - VAAPI-accelerated H.264/HEVC/MJPEG encoding +- DTS Express (LBR) decoder version 3.0: - Common Encryption (CENC) MP4 encoding and decoding support diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 347e15a..1ee3977 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -232,7 +232,7 @@ OBJS-$(CONFIG_CPIA_DECODER)+= cpia.o OBJS-$(CONFIG_CSCD_DECODER)+= cscd.o OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \ - dca_core.o dca_exss.o dca_xll.o \ + dca_core.o dca_exss.o dca_xll.o dca_lbr.o \ dcadsp.o dcadct.o synth_filter.o OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o OBJS-$(CONFIG_DDS_DECODER) += dds.o diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c new file mode 100644 index 000..595187c --- /dev/null +++ b/libavcodec/dca_lbr.c @@ -0,0 +1,1825 @@ +/* + * Copyright (C) 2016 foo86 + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define UNCHECKED_BITSTREAM_READER 1 +#define BITSTREAM_READER_LE + +#include "libavutil/channel_layout.h" + +#include "dcadec.h" +#include "dcadata.h" +#include "dcahuff.h" +#include "dca_syncwords.h" +#include "bytestream.h" + +#define AMP_MAX 56 + +enum LBRHeader { +LBR_HEADER_SYNC_ONLY= 1, +LBR_HEADER_DECODER_INIT = 2 +}; + +enum LBRFlags { +LBR_FLAG_24_BIT = 0x01, +LBR_FLAG_LFE_PRESENT= 0x02, +LBR_FLAG_BAND_LIMIT_2_3 = 0x04, +LBR_FLAG_BAND_LIMIT_1_2 = 0x08, +LBR_FLAG_BAND_LIMIT_1_3 = 0x0c, +LBR_FLAG_BAND_LIMIT_1_4 = 0x10, +LBR_FLAG_BAND_LIMIT_1_8 = 0x18, +LBR_FLAG_BAND_LIMIT_NONE= 0x14, +LBR_FLAG_BAND_LIMIT_MASK= 0x1c, +LBR_FLAG_DMIX_STEREO= 0x20, +LBR_FLAG_DMIX_MULTI_CH = 0x40 +}; + +enum LBRChunkTypes { +LBR_CHUNK_NULL = 0x00, +LBR_CHUNK_PAD = 0x01, +LBR_CHUNK_FRAME = 0x04, +LBR_CHUNK_FRAME_NO_CSUM = 0x06, +LBR_CHUNK_LFE = 0x0a, +LBR_CHUNK_ECS = 0x0b, +LBR_CHUNK_RESERVED_1= 0x0c, +LBR_CHUNK_RESERVED_2= 0x0d, +LBR_CHUNK_SCF = 0x0e, +LBR_CHUNK_TONAL = 0x10, +LBR_CHUNK_TONAL_GRP_1 = 0x11, +LBR_CHUNK_TONAL_GRP_2 = 0x12, +LBR_CHUNK_TONAL_GRP_3 = 0x13, +LBR_CHUNK_TONAL_GRP_4 = 0x14, +LBR_CHUNK_TONAL_GRP_5 = 0x15, +LBR_CHUNK_TONAL_SCF = 0x16, +LBR_CHUNK_TONAL_SCF_GRP_1 = 0x17, +LBR_CHUNK_TONAL_SCF_GRP_2 = 0x18, +LBR_CHUNK_TONAL_SCF_GRP_3 = 0x19, +LBR_CHUNK_TONAL_SCF_GRP_4 = 0x1a, +LBR_CHUNK_TONAL_SCF_GRP_5 = 0x1b, +LBR_CHUNK_RES_GRID_LR = 0x30, +LBR_CHUNK_RES_GRID_LR_LAST = 0x3f, +LBR_CHUNK_RES_GRID_HR = 0x40, +LBR_CHUNK_RES_GRID_HR_LAST = 0x4f, +LBR_CHUNK_RES_TS_1 = 0x50, +LBR_CHUNK_RES_TS_1_LAST = 0x5f, +LBR_CHUNK_RES_TS_2 = 0x60, +LBR_CHUNK_RES_TS_2_LAST = 0x6f
[FFmpeg-cvslog] avcodec/dca: print error message when no frame is found in packet
ffmpeg | branch: master | foo86 | Fri May 13 12:48:25 2016 +0300| [365b0c13e461a5d92e9e689e8f09301fb3255b93] | committer: Michael Niedermayer avcodec/dca: print error message when no frame is found in packet Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=365b0c13e461a5d92e9e689e8f09301fb3255b93 --- libavcodec/dcadec.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index 303b0c2..f31b658 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -179,8 +179,10 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, for (i = 0, ret = AVERROR_INVALIDDATA; i < input_size - MIN_PACKET_SIZE + 1 && ret < 0; i++) ret = convert_bitstream(input + i, input_size - i, s->buffer, s->buffer_size); -if (ret < 0) +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); return ret; +} input = s->buffer; input_size = ret; @@ -296,6 +298,9 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, } s->core_residual_valid = !!(s->core.filter_mode & DCA_FILTER_MODE_FIXED); } else { +av_log(avctx, AV_LOG_ERROR, "No valid DCA sub-stream found\n"); +if (s->core_only) +av_log(avctx, AV_LOG_WARNING, "Consider disabling 'core_only' option\n"); return AVERROR_INVALIDDATA; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: remove Rice code length limit
ffmpeg | branch: master | foo86 | Fri May 13 12:48:23 2016 +0300| [e0706e9cc8f30a8242d2b140edace7bf76170506] | committer: James Almer avcodec/dca: remove Rice code length limit Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e0706e9cc8f30a8242d2b140edace7bf76170506 --- libavcodec/dca_xll.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c index 316af27..e43ee6a 100644 --- a/libavcodec/dca_xll.c +++ b/libavcodec/dca_xll.c @@ -32,7 +32,7 @@ static int get_linear(GetBitContext *gb, int n) static int get_rice_un(GetBitContext *gb, int k) { -unsigned int v = get_unary(gb, 1, 128); +unsigned int v = get_unary(gb, 1, get_bits_left(gb)); return (v << k) | get_bits_long(gb, k); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: remove useless debug message
ffmpeg | branch: master | foo86 | Fri May 13 12:48:32 2016 +0300| [b5cda23039115e2bb83304462723c5f198c4418e] | committer: James Almer avcodec/dca: remove useless debug message Most DTS-in-WAV streams trigger this, making debug output hard to read. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5cda23039115e2bb83304462723c5f198c4418e --- libavcodec/dca_core.c |4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index f6c22ca..46825ed 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -1921,10 +1921,8 @@ int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size) return ret; // Workaround for DTS in WAV -if (s->frame_size > size && s->frame_size < size + 4) { -av_log(s->avctx, AV_LOG_DEBUG, "Working around excessive core frame size (%d > %d)\n", s->frame_size, size); +if (s->frame_size > size && s->frame_size < size + 4) s->frame_size = size; -} if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) { av_log(s->avctx, AV_LOG_ERROR, "Read past end of core frame\n"); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: don't set initial sample_fmt
ffmpeg | branch: master | foo86 | Fri May 13 12:48:26 2016 +0300| [39f7620d76c7a133535ed7a535f7a74fefa6e435] | committer: James Almer avcodec/dca: don't set initial sample_fmt Valid sample_fmt will be set by dcadec_decode_frame() based on stream type. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39f7620d76c7a133535ed7a535f7a74fefa6e435 --- libavcodec/dcadec.c |3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index f31b658..417632f 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -378,9 +378,6 @@ static av_cold int dcadec_init(AVCodecContext *avctx) break; } -avctx->sample_fmt = AV_SAMPLE_FMT_S32P; -avctx->bits_per_raw_sample = 24; - return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_parser: improve frame end search
ffmpeg | branch: master | foo86 | Fri May 13 12:48:28 2016 +0300| [a0349ae27c127df8c72de1c30dc4090360ec7ef4] | committer: James Almer avcodec/dca_parser: improve frame end search Parse core frame size directly when searching for frame end instead of using value extracted from previous frame. Account for unused bits when calculating sync word distance for 14-bit streams to avoid alias sync detection. Parse EXSS frame size and skip over EXSS frame to avoid alias sync detection. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0349ae27c127df8c72de1c30dc4090360ec7ef4 --- libavcodec/dca_parser.c | 94 --- 1 file changed, 80 insertions(+), 14 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index bde7dfe..0b09ba5 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -47,6 +47,14 @@ typedef struct DCAParseContext { #define CORE_MARKER(state) ((state >> 16) & 0x) #define EXSS_MARKER(state) (state & 0x) +#define STATE_LE(state) (((state & 0xFF00FF00) >> 8) | ((state & 0x00FF00FF) << 8)) +#define STATE_14(state) (((state & 0x3FFF) >> 8) | ((state & 0x3FFF) >> 6)) + +#define CORE_FRAMESIZE(state) (((state >> 4) & 0x3FFF) + 1) +#define EXSS_FRAMESIZE(state) ((state & 0x20) ? \ + ((state >> 5) & 0xF) + 1 : \ + ((state >> 13) & 0x0) + 1) + /** * Find the end of the current frame in the bitstream. * @return the position of the first byte of the next frame, or -1 @@ -54,12 +62,13 @@ typedef struct DCAParseContext { static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, int buf_size) { -int start_found, i; +int start_found, size, i; uint64_t state; ParseContext *pc = &pc1->pc; start_found = pc->frame_start_found; state = pc->state64; +size= pc1->size; i = 0; if (!start_found) { @@ -80,15 +89,75 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, } } } + if (start_found) { for (; i < buf_size; i++) { -pc1->size++; +size++; state = (state << 8) | buf[i]; + +if (start_found == 1) { +switch (pc1->lastmarker) { +case DCA_SYNCWORD_CORE_BE: +if (size == 2) { +pc1->framesize = CORE_FRAMESIZE(state); +start_found= 2; +} +break; +case DCA_SYNCWORD_CORE_LE: +if (size == 2) { +pc1->framesize = CORE_FRAMESIZE(STATE_LE(state)); +start_found= 2; +} +break; +case DCA_SYNCWORD_CORE_14B_BE: +if (size == 4) { +pc1->framesize = CORE_FRAMESIZE(STATE_14(state)) * 8 / 14 * 2; +start_found= 2; +} +break; +case DCA_SYNCWORD_CORE_14B_LE: +if (size == 4) { +pc1->framesize = CORE_FRAMESIZE(STATE_14(STATE_LE(state))) * 8 / 14 * 2; +start_found= 2; +} +break; +case DCA_SYNCWORD_SUBSTREAM: +if (size == 6) { +pc1->framesize = EXSS_FRAMESIZE(state); +start_found= 2; +} +break; +default: +av_assert0(0); +} +continue; +} + +if (pc1->lastmarker == DCA_SYNCWORD_CORE_BE) { +if (pc1->framesize > size + 2) +continue; + +if (start_found == 2 && IS_EXSS_MARKER(state)) { +pc1->framesize = size + 2; +start_found= 3; +continue; +} + +if (start_found == 3) { +if (size == pc1->framesize + 4) { +pc1->framesize += EXSS_FRAMESIZE(state); +start_found = 4; +} +continue; +} +} + +if (pc1->framesize > size) +continue; + if (IS_MARKER(state) && (pc1->lastmarker == CORE_MARKER(state) || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) { -if (pc1->framesize > pc1->size) -
[FFmpeg-cvslog] avcodec/dca: simplify 'residual ok' flag tracking
ffmpeg | branch: master | foo86 | Fri May 13 12:48:24 2016 +0300| [801dbf0269b1bb5bc70c550e971491e0aea9eb70] | committer: James Almer avcodec/dca: simplify 'residual ok' flag tracking Move this from separate structure field to a packet flag. Behavior should be equivalent, except that residual flag is now properly cleared when packet has no core frame at all. Also print a message when forcing recovery mode due to invalid residual to make debugging easier. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=801dbf0269b1bb5bc70c550e971491e0aea9eb70 --- libavcodec/dcadec.c | 32 ++-- libavcodec/dcadec.h |7 --- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index 417632f..565242d 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -193,10 +193,8 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, if (AV_RB32(input) == DCA_SYNCWORD_CORE_BE) { int frame_size; -if ((ret = ff_dca_core_parse(&s->core, input, input_size)) < 0) { -s->core_residual_valid = 0; +if ((ret = ff_dca_core_parse(&s->core, input, input_size)) < 0) return ret; -} s->packet |= DCA_PACKET_CORE; @@ -265,19 +263,20 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, if (s->xll.chset[0].freq == 96000 && s->core.sample_rate == 48000) x96_synth = 1; -if ((ret = ff_dca_core_filter_fixed(&s->core, x96_synth)) < 0) { -s->core_residual_valid = 0; +if ((ret = ff_dca_core_filter_fixed(&s->core, x96_synth)) < 0) return ret; -} // Force lossy downmixed output on the first core frame filtered. // This prevents audible clicks when seeking and is consistent with // what reference decoder does when there are multiple channel sets. -if (!s->core_residual_valid) { -if (s->xll.nreschsets > 0 && s->xll.nchsets > 1) -s->packet |= DCA_PACKET_RECOVERY; -s->core_residual_valid = 1; +if (!(prev_packet & DCA_PACKET_RESIDUAL) && s->xll.nreschsets > 0 +&& s->xll.nchsets > 1) { +av_log(avctx, AV_LOG_VERBOSE, "Forcing XLL recovery mode\n"); +s->packet |= DCA_PACKET_RECOVERY; } + +// Set 'residual ok' flag for the next frame +s->packet |= DCA_PACKET_RESIDUAL; } if ((ret = ff_dca_xll_filter_frame(&s->xll, frame)) < 0) { @@ -286,17 +285,14 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, return ret; if (ret != AVERROR_INVALIDDATA || (avctx->err_recognition & AV_EF_EXPLODE)) return ret; -if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0) { -s->core_residual_valid = 0; +if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0) return ret; -} } } else if (s->packet & DCA_PACKET_CORE) { -if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0) { -s->core_residual_valid = 0; +if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0) return ret; -} -s->core_residual_valid = !!(s->core.filter_mode & DCA_FILTER_MODE_FIXED); +if (s->core.filter_mode & DCA_FILTER_MODE_FIXED) +s->packet |= DCA_PACKET_RESIDUAL; } else { av_log(avctx, AV_LOG_ERROR, "No valid DCA sub-stream found\n"); if (s->core_only) @@ -317,7 +313,7 @@ static av_cold void dcadec_flush(AVCodecContext *avctx) ff_dca_xll_flush(&s->xll); ff_dca_lbr_flush(&s->lbr); -s->core_residual_valid = 0; +s->packet &= DCA_PACKET_MASK; } static av_cold int dcadec_close(AVCodecContext *avctx) diff --git a/libavcodec/dcadec.h b/libavcodec/dcadec.h index 5e47077..8528332 100644 --- a/libavcodec/dcadec.h +++ b/libavcodec/dcadec.h @@ -40,7 +40,10 @@ #define DCA_PACKET_EXSS 0x02 #define DCA_PACKET_XLL 0x04 #define DCA_PACKET_LBR 0x08 -#define DCA_PACKET_RECOVERY 0x10 +#define DCA_PACKET_MASK 0x0f + +#define DCA_PACKET_RECOVERY 0x10///< Sync error recovery flag +#define DCA_PACKET_RESIDUAL 0x20///< Core valid for residual decoding typedef struct DCAContext { const AVClass *class; ///< class for AVOptions @@ -60,8 +63,6 @@ typedef struct DCAContext { int packet; ///< Packet flags -int core_
[FFmpeg-cvslog] avcodec/dca: use LUT for LBR frequency ranges
ffmpeg | branch: master | foo86 | Fri May 13 12:48:27 2016 +0300| [64fe1eebddbbf705d0c25d000c102bfca5558682] | committer: James Almer avcodec/dca: use LUT for LBR frequency ranges Values for unsupported frequencies > 48000 Hz are still included (parser will make use of them). Also convert sampling frequencies array to unsigned. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=64fe1eebddbbf705d0c25d000c102bfca5558682 --- libavcodec/dca_lbr.c | 15 +-- libavcodec/dcadata.c |6 +- libavcodec/dcadata.h |3 ++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c index 9a7f4cd..f116ab9 100644 --- a/libavcodec/dca_lbr.c +++ b/libavcodec/dca_lbr.c @@ -1000,15 +1000,15 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb) int old_band_limit = s->band_limit; int old_nchannels = s->nchannels; int version, bit_rate_hi; -unsigned int code; +unsigned int sr_code; // Sample rate of LBR audio -code = bytestream2_get_byte(gb); -if (code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) { +sr_code = bytestream2_get_byte(gb); +if (sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sample rate\n"); return AVERROR_INVALIDDATA; } -s->sample_rate = ff_dca_sampling_freqs[code]; +s->sample_rate = ff_dca_sampling_freqs[sr_code]; if (s->sample_rate > 48000) { avpriv_report_missing_feature(s->avctx, "%d Hz LBR sample rate", s->sample_rate); return AVERROR_PATCHWELCOME; @@ -1076,12 +1076,7 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb) } // Setup frequency range -if (s->sample_rate < 14000) -s->freq_range = 0; -else if (s->sample_rate < 28000) -s->freq_range = 1; -else -s->freq_range = 2; +s->freq_range = ff_dca_freq_ranges[sr_code]; // Setup resolution profile if (s->bit_rate_orig >= 44000 * (s->nchannels_total + 2)) diff --git a/libavcodec/dcadata.c b/libavcodec/dcadata.c index 53be01d..2d533d0 100644 --- a/libavcodec/dcadata.c +++ b/libavcodec/dcadata.c @@ -8725,11 +8725,15 @@ const int32_t ff_dca_xll_band_coeff[20] = { 3259333, -5074941, 6928550, -8204883 }; -const int32_t ff_dca_sampling_freqs[16] = { +const uint32_t ff_dca_sampling_freqs[16] = { 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200, 176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000, }; +const uint8_t ff_dca_freq_ranges[16] = { +0, 1, 2, 3, 4, 1, 2, 3, 4, 4, 0, 1, 2, 3, 4, 4 +}; + const uint16_t ff_dca_avg_g3_freqs[3] = { 16000, 18000, 24000 }; const uint16_t ff_dca_fst_amp[44] = { diff --git a/libavcodec/dcadata.h b/libavcodec/dcadata.h index 0c54225..1ef1342 100644 --- a/libavcodec/dcadata.h +++ b/libavcodec/dcadata.h @@ -71,7 +71,8 @@ extern const uint16_t ff_dca_xll_refl_coeff[128]; extern const int32_t ff_dca_xll_band_coeff[20]; -extern const int32_t ff_dca_sampling_freqs[16]; +extern const uint32_t ff_dca_sampling_freqs[16]; +extern const uint8_t ff_dca_freq_ranges[16]; extern const uint16_t ff_dca_avg_g3_freqs[3]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_exss: always update downmix flags
ffmpeg | branch: master | foo86 | Mon May 23 18:41:27 2016 +0300| [9bd1d79584c6f99ec12c85c458eaa9ca826b2d12] | committer: Michael Niedermayer avcodec/dca_exss: always update downmix flags Fixes potential parsing failure when total number of channels indicated by EXSS asset descriptor decreases mid-stream and stale embedded downmix flags are referenced. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9bd1d79584c6f99ec12c85c458eaa9ca826b2d12 --- libavcodec/dca_exss.c |6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/dca_exss.c b/libavcodec/dca_exss.c index 87b2f42..28f138f 100644 --- a/libavcodec/dca_exss.c +++ b/libavcodec/dca_exss.c @@ -112,12 +112,10 @@ static int parse_descriptor(DCAExssParser *s, DCAExssAsset *asset) int nspeakers[8]; // Embedded stereo flag -if (asset->nchannels_total > 2) -asset->embedded_stereo = get_bits1(&s->gb); +asset->embedded_stereo = asset->nchannels_total > 2 && get_bits1(&s->gb); // Embedded 6 channels flag -if (asset->nchannels_total > 6) -asset->embedded_6ch = get_bits1(&s->gb); +asset->embedded_6ch = asset->nchannels_total > 6 && get_bits1(&s->gb); // Speaker mask enabled flag if (asset->spkr_mask_enabled = get_bits1(&s->gb)) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_exss: prepare to be called from parser context
ffmpeg | branch: master | foo86 | Mon May 23 17:58:41 2016 +0300| [72a9a7e9cbc26771b14b880dd45d29a2064bf8ee] | committer: James Almer avcodec/dca_exss: prepare to be called from parser context Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72a9a7e9cbc26771b14b880dd45d29a2064bf8ee --- libavcodec/dca_exss.c | 31 --- libavcodec/dca_exss.h |2 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/libavcodec/dca_exss.c b/libavcodec/dca_exss.c index 28f138f..fcabd07 100644 --- a/libavcodec/dca_exss.c +++ b/libavcodec/dca_exss.c @@ -128,7 +128,8 @@ static int parse_descriptor(DCAExssParser *s, DCAExssAsset *asset) // Number of speaker remapping sets if ((spkr_remap_nsets = get_bits(&s->gb, 3)) && !spkr_mask_nbits) { -av_log(s->avctx, AV_LOG_ERROR, "Speaker mask disabled yet there are remapping sets\n"); +if (s->avctx) +av_log(s->avctx, AV_LOG_ERROR, "Speaker mask disabled yet there are remapping sets\n"); return AVERROR_INVALIDDATA; } @@ -213,7 +214,8 @@ static int parse_descriptor(DCAExssParser *s, DCAExssAsset *asset) for (i = 0; i < s->nmixoutconfigs; i++) { if (!s->nmixoutchs[i]) { -av_log(s->avctx, AV_LOG_ERROR, "Invalid speaker layout mask for mixing configuration\n"); +if (s->avctx) +av_log(s->avctx, AV_LOG_ERROR, "Invalid speaker layout mask for mixing configuration\n"); return AVERROR_INVALIDDATA; } for (j = 0; j < nchannels_dmix; j++) { @@ -310,7 +312,8 @@ static int parse_descriptor(DCAExssParser *s, DCAExssAsset *asset) // Reserved // Zero pad if (ff_dca_seek_bits(&s->gb, descr_pos + descr_size * 8)) { -av_log(s->avctx, AV_LOG_ERROR, "Read past end of EXSS asset descriptor\n"); +if (s->avctx) +av_log(s->avctx, AV_LOG_ERROR, "Read past end of EXSS asset descriptor\n"); return AVERROR_INVALIDDATA; } @@ -373,7 +376,7 @@ static int set_exss_offsets(DCAExssAsset *asset) return 0; } -int ff_dca_exss_parse(DCAExssParser *s, uint8_t *data, int size) +int ff_dca_exss_parse(DCAExssParser *s, const uint8_t *data, int size) { int i, ret, offset, wide_hdr, header_size; @@ -396,7 +399,7 @@ int ff_dca_exss_parse(DCAExssParser *s, uint8_t *data, int size) header_size = get_bits(&s->gb, 8 + 4 * wide_hdr) + 1; // Check CRC -if (ff_dca_check_crc(s->avctx, &s->gb, 32 + 8, header_size * 8)) { +if (s->avctx && ff_dca_check_crc(s->avctx, &s->gb, 32 + 8, header_size * 8)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid EXSS header checksum\n"); return AVERROR_INVALIDDATA; } @@ -406,7 +409,8 @@ int ff_dca_exss_parse(DCAExssParser *s, uint8_t *data, int size) // Number of bytes of extension substream s->exss_size = get_bits(&s->gb, s->exss_size_nbits) + 1; if (s->exss_size > size) { -av_log(s->avctx, AV_LOG_ERROR, "Packet too short for EXSS frame\n"); +if (s->avctx) +av_log(s->avctx, AV_LOG_ERROR, "Packet too short for EXSS frame\n"); return AVERROR_INVALIDDATA; } @@ -428,14 +432,16 @@ int ff_dca_exss_parse(DCAExssParser *s, uint8_t *data, int size) // Number of defined audio presentations s->npresents = get_bits(&s->gb, 3) + 1; if (s->npresents > 1) { -avpriv_request_sample(s->avctx, "%d audio presentations", s->npresents); +if (s->avctx) +avpriv_request_sample(s->avctx, "%d audio presentations", s->npresents); return AVERROR_PATCHWELCOME; } // Number of audio assets in extension substream s->nassets = get_bits(&s->gb, 3) + 1; if (s->nassets > 1) { -avpriv_request_sample(s->avctx, "%d audio assets", s->nassets); +if (s->avctx) +avpriv_request_sample(s->avctx, "%d audio assets", s->nassets); return AVERROR_PATCHWELCOME; } @@ -476,7 +482,8 @@ int ff_dca_exss_parse(DCAExssParser *s, uint8_t *data, int size) s->assets[i].asset_size = get_bits(&s->gb, s->exss_size_nbits) + 1; offset += s->assets[i].asset_size; if (offset > s->exss_size) { -av_log(s->avctx, AV_LOG_ERROR, "EXSS asset out of bounds\n"); +if (s->avctx) +av_log(s->avctx, AV_LOG_ERROR, "EXSS asset out of bounds\n"); return AVERROR_INVA
[FFmpeg-cvslog] avcodec/dca_parser: set duration for core-less streams
ffmpeg | branch: master | foo86 | Mon May 23 17:58:42 2016 +0300| [cb55c5b49e6d21709d0ea1bf93cc30a577b1de35] | committer: James Almer avcodec/dca_parser: set duration for core-less streams Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cb55c5b49e6d21709d0ea1bf93cc30a577b1de35 --- libavcodec/dca_parser.c | 68 --- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 0b09ba5..308df53 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -23,6 +23,8 @@ */ #include "dca.h" +#include "dcadata.h" +#include "dca_exss.h" #include "dca_syncwords.h" #include "get_bits.h" #include "parser.h" @@ -32,6 +34,8 @@ typedef struct DCAParseContext { uint32_t lastmarker; int size; int framesize; +DCAExssParser exss; +unsigned int sr_code; } DCAParseContext; #define IS_CORE_MARKER(state) \ @@ -177,11 +181,12 @@ static av_cold int dca_parse_init(AVCodecParserContext *s) DCAParseContext *pc1 = s->priv_data; pc1->lastmarker = 0; +pc1->sr_code = -1; return 0; } -static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, -int *sample_rate) +static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, +int buf_size, int *duration, int *sample_rate) { GetBitContext gb; uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; @@ -190,6 +195,63 @@ static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, if (buf_size < 12) return AVERROR_INVALIDDATA; +if (AV_RB32(buf) == DCA_SYNCWORD_SUBSTREAM) { +DCAExssAsset *asset = &pc1->exss.assets[0]; + +if ((ret = ff_dca_exss_parse(&pc1->exss, buf, buf_size)) < 0) +return ret; + +if (asset->extension_mask & DCA_EXSS_LBR) { +if ((ret = init_get_bits8(&gb, buf + asset->lbr_offset, asset->lbr_size)) < 0) +return ret; + +if (get_bits_long(&gb, 32) != DCA_SYNCWORD_LBR) +return AVERROR_INVALIDDATA; + +switch (get_bits(&gb, 8)) { +case 2: +pc1->sr_code = get_bits(&gb, 8); +case 1: +break; +default: +return AVERROR_INVALIDDATA; +} + +if (pc1->sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) +return AVERROR_INVALIDDATA; + +*sample_rate = ff_dca_sampling_freqs[pc1->sr_code]; +*duration = 1024 << ff_dca_freq_ranges[pc1->sr_code]; +return 0; +} + +if (asset->extension_mask & DCA_EXSS_XLL) { +int nsamples_log2; + +if ((ret = init_get_bits8(&gb, buf + asset->xll_offset, asset->xll_size)) < 0) +return ret; + +if (get_bits_long(&gb, 32) != DCA_SYNCWORD_XLL) +return AVERROR_INVALIDDATA; + +if (get_bits(&gb, 4)) +return AVERROR_INVALIDDATA; + +skip_bits(&gb, 8); +skip_bits_long(&gb, get_bits(&gb, 5) + 1); +skip_bits(&gb, 4); +nsamples_log2 = get_bits(&gb, 4) + get_bits(&gb, 4); +if (nsamples_log2 > 24) +return AVERROR_INVALIDDATA; + +*sample_rate = asset->max_sample_rate; +*duration = (1 + (*sample_rate > 96000)) << nsamples_log2; +return 0; +} + +return AVERROR_INVALIDDATA; +} + if ((ret = avpriv_dca_convert_bitstream(buf, 12, hdr, 12)) < 0) return ret; @@ -230,7 +292,7 @@ static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx, } /* read the duration and sample rate from the frame header */ -if (!dca_parse_params(buf, buf_size, &duration, &sample_rate)) { +if (!dca_parse_params(pc1, buf, buf_size, &duration, &sample_rate)) { if (!avctx->sample_rate) avctx->sample_rate = sample_rate; s->duration = av_rescale(duration, avctx->sample_rate, sample_rate); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: move EXSS sampling frequency arrays to dca.c
ffmpeg | branch: master | foo86 | Thu May 26 14:29:35 2016 +0300| [a0f76b825c8105acb4428ea60146687e90cfdc83] | committer: James Almer avcodec/dca: move EXSS sampling frequency arrays to dca.c Avoids unwanted parser dependency on dcadata. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0f76b825c8105acb4428ea60146687e90cfdc83 --- libavcodec/Makefile |2 +- libavcodec/dca.c|9 + libavcodec/dca.h|3 +++ libavcodec/dca_exss.c |1 - libavcodec/dca_parser.c |1 - libavcodec/dcadata.c|9 - libavcodec/dcadata.h|3 --- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 224ccf7..46dd9e1 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -900,7 +900,7 @@ OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o -OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o dca_exss.o dcadata.o dca.o +OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o dca_exss.o dca.o OBJS-$(CONFIG_DIRAC_PARSER)+= dirac_parser.o OBJS-$(CONFIG_DNXHD_PARSER)+= dnxhd_parser.o OBJS-$(CONFIG_DPX_PARSER) += dpx_parser.o diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 714509b..f11c73c 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -36,6 +36,15 @@ const uint32_t avpriv_dca_sample_rates[16] = { 12000, 24000, 48000, 96000, 192000 }; +const uint32_t ff_dca_sampling_freqs[16] = { + 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200, +176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000, +}; + +const uint8_t ff_dca_freq_ranges[16] = { +0, 1, 2, 3, 4, 1, 2, 3, 4, 4, 0, 1, 2, 3, 4, 4 +}; + int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size) { diff --git a/libavcodec/dca.h b/libavcodec/dca.h index a1ac763..bd96bc9 100644 --- a/libavcodec/dca.h +++ b/libavcodec/dca.h @@ -154,6 +154,9 @@ enum DCADownMixType { extern av_export const uint32_t avpriv_dca_sample_rates[16]; +extern const uint32_t ff_dca_sampling_freqs[16]; +extern const uint8_t ff_dca_freq_ranges[16]; + /** * Convert bitstream to one representation based on sync marker */ diff --git a/libavcodec/dca_exss.c b/libavcodec/dca_exss.c index fcabd07..e873088 100644 --- a/libavcodec/dca_exss.c +++ b/libavcodec/dca_exss.c @@ -19,7 +19,6 @@ */ #include "dcadec.h" -#include "dcadata.h" static void parse_xll_parameters(DCAExssParser *s, DCAExssAsset *asset) { diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 308df53..d76b548 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -23,7 +23,6 @@ */ #include "dca.h" -#include "dcadata.h" #include "dca_exss.h" #include "dca_syncwords.h" #include "get_bits.h" diff --git a/libavcodec/dcadata.c b/libavcodec/dcadata.c index 2d533d0..39aea73 100644 --- a/libavcodec/dcadata.c +++ b/libavcodec/dcadata.c @@ -8725,15 +8725,6 @@ const int32_t ff_dca_xll_band_coeff[20] = { 3259333, -5074941, 6928550, -8204883 }; -const uint32_t ff_dca_sampling_freqs[16] = { - 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200, -176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000, -}; - -const uint8_t ff_dca_freq_ranges[16] = { -0, 1, 2, 3, 4, 1, 2, 3, 4, 4, 0, 1, 2, 3, 4, 4 -}; - const uint16_t ff_dca_avg_g3_freqs[3] = { 16000, 18000, 24000 }; const uint16_t ff_dca_fst_amp[44] = { diff --git a/libavcodec/dcadata.h b/libavcodec/dcadata.h index 1ef1342..17aa712 100644 --- a/libavcodec/dcadata.h +++ b/libavcodec/dcadata.h @@ -71,9 +71,6 @@ extern const uint16_t ff_dca_xll_refl_coeff[128]; extern const int32_t ff_dca_xll_band_coeff[20]; -extern const uint32_t ff_dca_sampling_freqs[16]; -extern const uint8_t ff_dca_freq_ranges[16]; - extern const uint16_t ff_dca_avg_g3_freqs[3]; extern const uint16_t ff_dca_fst_amp[44]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: require checked bitstream reader
ffmpeg | branch: master | foo86 | Fri May 13 12:48:30 2016 +0300| [d1f558b3628d3ab99fd93a98b5758ef1be45a5da] | committer: James Almer avcodec/dca: require checked bitstream reader Remove half-working attempt at supporting unchecked bitstream reader by always copying input data into intermediate buffer with large amount of padding at the end. Convert LBR decoder to checked bitstream reader. Convert dcadec_decode_frame() to parse input data directly if possible. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d1f558b3628d3ab99fd93a98b5758ef1be45a5da --- libavcodec/dca_lbr.c |1 - libavcodec/dca_xll.c |2 +- libavcodec/dcadec.c | 44 libavcodec/dcadec.h |2 -- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c index f116ab9..342603c 100644 --- a/libavcodec/dca_lbr.c +++ b/libavcodec/dca_lbr.c @@ -18,7 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define UNCHECKED_BITSTREAM_READER 1 #define BITSTREAM_READER_LE #include "libavutil/channel_layout.h" diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c index e43ee6a..1d616c2 100644 --- a/libavcodec/dca_xll.c +++ b/libavcodec/dca_xll.c @@ -1070,7 +1070,7 @@ static int copy_to_pbr(DCAXllDecoder *s, uint8_t *data, int size, int delay) if (size > DCA_XLL_PBR_BUFFER_MAX) return AVERROR(ENOSPC); -if (!s->pbr_buffer && !(s->pbr_buffer = av_malloc(DCA_XLL_PBR_BUFFER_MAX + DCA_BUFFER_PADDING_SIZE))) +if (!s->pbr_buffer && !(s->pbr_buffer = av_malloc(DCA_XLL_PBR_BUFFER_MAX + AV_INPUT_BUFFER_PADDING_SIZE))) return AVERROR(ENOMEM); memcpy(s->pbr_buffer, data, size); diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index 565242d..4146a85 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -141,22 +141,6 @@ void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, } } -static int convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size) -{ -switch (AV_RB32(src)) { -case DCA_SYNCWORD_CORE_BE: -case DCA_SYNCWORD_SUBSTREAM: -memcpy(dst, src, src_size); -return src_size; -case DCA_SYNCWORD_CORE_LE: -case DCA_SYNCWORD_CORE_14B_BE: -case DCA_SYNCWORD_CORE_14B_LE: -return avpriv_dca_convert_bitstream(src, src_size, dst, max_size); -default: -return AVERROR_INVALIDDATA; -} -} - static int dcadec_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { @@ -165,27 +149,31 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, uint8_t *input = avpkt->data; int input_size = avpkt->size; int i, ret, prev_packet = s->packet; +uint32_t mrk; if (input_size < MIN_PACKET_SIZE || input_size > MAX_PACKET_SIZE) { av_log(avctx, AV_LOG_ERROR, "Invalid packet size\n"); return AVERROR_INVALIDDATA; } -av_fast_malloc(&s->buffer, &s->buffer_size, - FFALIGN(input_size, 4096) + DCA_BUFFER_PADDING_SIZE); -if (!s->buffer) -return AVERROR(ENOMEM); +// Convert input to BE format +mrk = AV_RB32(input); +if (mrk != DCA_SYNCWORD_CORE_BE && mrk != DCA_SYNCWORD_SUBSTREAM) { +av_fast_padded_malloc(&s->buffer, &s->buffer_size, input_size); +if (!s->buffer) +return AVERROR(ENOMEM); -for (i = 0, ret = AVERROR_INVALIDDATA; i < input_size - MIN_PACKET_SIZE + 1 && ret < 0; i++) -ret = convert_bitstream(input + i, input_size - i, s->buffer, s->buffer_size); +for (i = 0, ret = AVERROR_INVALIDDATA; i < input_size - MIN_PACKET_SIZE + 1 && ret < 0; i++) +ret = avpriv_dca_convert_bitstream(input + i, input_size - i, s->buffer, s->buffer_size); -if (ret < 0) { -av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); -return ret; -} +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); +return ret; +} -input = s->buffer; -input_size = ret; +input = s->buffer; +input_size = ret; +} s->packet = 0; diff --git a/libavcodec/dcadec.h b/libavcodec/dcadec.h index 8528332..456f3c4 100644 --- a/libavcodec/dcadec.h +++ b/libavcodec/dcadec.h @@ -34,8 +34,6 @@ #include "dca_xll.h" #include "dca_lbr.h" -#define DCA_BUFFER_PADDING_SIZE 1024 - #define DCA_PACKET_CORE 0x01 #define DCA_PACKET_EXSS 0x02 #define DCA_PACKET_XLL 0x04 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: support EXSS marker in avpriv_dca_convert_bitstream()
ffmpeg | branch: master | foo86 | Fri May 13 12:48:31 2016 +0300| [054a2c9fdf64f0fcac17dfa424492e9184002dc3] | committer: James Almer avcodec/dca: support EXSS marker in avpriv_dca_convert_bitstream() This is now required by dcadec_decode_frame(). All remaining users of avpriv_dca_convert_bitstream() have been updated to expect EXSS marker. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=054a2c9fdf64f0fcac17dfa424492e9184002dc3 --- libavcodec/dca.c |1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dca.c b/libavcodec/dca.c index f11c73c..58f340e 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -58,6 +58,7 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, mrk = AV_RB32(src); switch (mrk) { case DCA_SYNCWORD_CORE_BE: +case DCA_SYNCWORD_SUBSTREAM: memcpy(dst, src, src_size); return src_size; case DCA_SYNCWORD_CORE_LE: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_parser: simplify state machine
ffmpeg | branch: master | foo86 | Tue May 31 14:46:13 2016 +0300| [1f7b67a1caef19842533e2831350312d5b6c3f5f] | committer: James Almer avcodec/dca_parser: simplify state machine Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f7b67a1caef19842533e2831350312d5b6c3f5f --- libavcodec/dca_parser.c | 34 +++--- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index d76b548..1521a5b 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -109,25 +109,25 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, case DCA_SYNCWORD_CORE_LE: if (size == 2) { pc1->framesize = CORE_FRAMESIZE(STATE_LE(state)); -start_found= 2; +start_found= 4; } break; case DCA_SYNCWORD_CORE_14B_BE: if (size == 4) { pc1->framesize = CORE_FRAMESIZE(STATE_14(state)) * 8 / 14 * 2; -start_found= 2; +start_found= 4; } break; case DCA_SYNCWORD_CORE_14B_LE: if (size == 4) { pc1->framesize = CORE_FRAMESIZE(STATE_14(STATE_LE(state))) * 8 / 14 * 2; -start_found= 2; +start_found= 4; } break; case DCA_SYNCWORD_SUBSTREAM: if (size == 6) { pc1->framesize = EXSS_FRAMESIZE(state); -start_found= 2; +start_found= 4; } break; default: @@ -136,23 +136,19 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, continue; } -if (pc1->lastmarker == DCA_SYNCWORD_CORE_BE) { -if (pc1->framesize > size + 2) -continue; - -if (start_found == 2 && IS_EXSS_MARKER(state)) { -pc1->framesize = size + 2; -start_found= 3; -continue; -} +if (start_found == 2 && IS_EXSS_MARKER(state) && +pc1->framesize <= size + 2) { +pc1->framesize = size + 2; +start_found = 3; +continue; +} -if (start_found == 3) { -if (size == pc1->framesize + 4) { -pc1->framesize += EXSS_FRAMESIZE(state); -start_found = 4; -} -continue; +if (start_found == 3) { +if (size == pc1->framesize + 4) { +pc1->framesize += EXSS_FRAMESIZE(state); +start_found = 4; } +continue; } if (pc1->framesize > size) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_parser: skip initial padding
ffmpeg | branch: master | foo86 | Tue May 31 14:46:14 2016 +0300| [214e63f8511330e8da8d69b5ea402ff0a4f17316] | committer: James Almer avcodec/dca_parser: skip initial padding Padding before the first sync word can be very large for DTS-in-WAV streams. There is no reason to include this padding in parsed packet. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=214e63f8511330e8da8d69b5ea402ff0a4f17316 --- libavcodec/dca_parser.c | 41 - 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 1521a5b..e5bea33 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -33,6 +33,7 @@ typedef struct DCAParseContext { uint32_t lastmarker; int size; int framesize; +unsigned int startpos; DCAExssParser exss; unsigned int sr_code; } DCAParseContext; @@ -75,20 +76,27 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, i = 0; if (!start_found) { -for (i = 0; i < buf_size; i++) { +for (; i < buf_size; i++) { +size++; state = (state << 8) | buf[i]; -if (IS_MARKER(state)) { -if (!pc1->lastmarker || -pc1->lastmarker == CORE_MARKER(state) || -pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) { -start_found = 1; -if (IS_EXSS_MARKER(state)) -pc1->lastmarker = EXSS_MARKER(state); -else -pc1->lastmarker = CORE_MARKER(state); -i++; -break; -} + +if (IS_MARKER(state) && +(!pc1->lastmarker || + pc1->lastmarker == CORE_MARKER(state) || + pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) { +if (!pc1->lastmarker) +pc1->startpos = IS_EXSS_MARKER(state) ? size - 4 : size - 6; + +if (IS_EXSS_MARKER(state)) +pc1->lastmarker = EXSS_MARKER(state); +else +pc1->lastmarker = CORE_MARKER(state); + +start_found = 1; +size= 0; + +i++; +break; } } } @@ -284,6 +292,13 @@ static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx, *poutbuf_size = 0; return buf_size; } + +/* skip initial padding */ +if (buf_size > pc1->startpos) { +buf += pc1->startpos; +buf_size -= pc1->startpos; +} +pc1->startpos = 0; } /* read the duration and sample rate from the frame header */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/dtsdec: Extend DTS core sync word
ffmpeg | branch: master | foo86 | Tue Apr 28 17:47:53 2015 +0300| [191dd219d9c955a379cf52b18731c334ae70e475] | committer: Michael Niedermayer avformat/dtsdec: Extend DTS core sync word Check extended sync word for 16-bit LE and BE core streams to reduce probability of alias sync detection. Previously sync word extension was checked only for 14-bit streams. This follows up the similar change in avcodec/dca_parser. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=191dd219d9c955a379cf52b18731c334ae70e475 --- libavformat/dtsdec.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c index 50b14c6..da0fb61 100644 --- a/libavformat/dtsdec.c +++ b/libavformat/dtsdec.c @@ -50,9 +50,11 @@ static int dts_probe(AVProbeData *p) diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4)); /* regular bitstream */ -if (state == DCA_SYNCWORD_CORE_BE) +if (state == DCA_SYNCWORD_CORE_BE && +(bytestream_get_be16(&bufp) & 0xFC00) == 0xFC00) marker = 0; -else if (state == DCA_SYNCWORD_CORE_LE) +else if (state == DCA_SYNCWORD_CORE_LE && + (bytestream_get_be16(&bufp) & 0x00FC) == 0x00FC) marker = 1; /* 14 bits big-endian bitstream */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca_parser: Extend DTS core sync word and fix existing check
ffmpeg | branch: master | foo86 | Wed Apr 29 14:14:55 2015 +0300| [e80b2b9c81716a5d9f559c04cfe69d76b04e4cd3] | committer: Michael Niedermayer avcodec/dca_parser: Extend DTS core sync word and fix existing check Check extended sync word for 16-bit LE and BE core streams to reduce probability of alias sync detection. Previously sync word extension was checked only for 14-bit streams (and this check did not properly work across buffer boundary). Use 64-bit parser state to make extended sync word detection work across buffer boundary. This is sufficient to make the sample in ticket #4492 parse successfully. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e80b2b9c81716a5d9f559c04cfe69d76b04e4cd3 --- libavcodec/dca_parser.c | 42 +- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 9797760..26e2f50 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -32,13 +32,20 @@ typedef struct DCAParseContext { uint32_t lastmarker; int size; int framesize; -int hd_pos; } DCAParseContext; -#define IS_MARKER(state, i, buf, buf_size) \ -((state == DCA_SYNCWORD_CORE_14B_LE && (i < buf_size - 2) && (buf[i + 1] & 0xF0) == 0xF0 && buf[i + 2] == 0x07) || \ - (state == DCA_SYNCWORD_CORE_14B_BE && (i < buf_size - 2) && buf[i + 1] == 0x07 && (buf[i + 2] & 0xF0) == 0xF0) || \ - state == DCA_SYNCWORD_CORE_LE || state == DCA_SYNCWORD_CORE_BE || state == DCA_SYNCWORD_SUBSTREAM) +#define IS_CORE_MARKER(state) \ +(((state & 0xF0FF) == (((uint64_t)DCA_SYNCWORD_CORE_14B_LE << 16) | 0xF007)) || \ + ((state & 0xFFF0) == (((uint64_t)DCA_SYNCWORD_CORE_14B_BE << 16) | 0x07F0)) || \ + ((state & 0x00FC) == (((uint64_t)DCA_SYNCWORD_CORE_LE << 16) | 0x00FC)) || \ + ((state & 0xFC00) == (((uint64_t)DCA_SYNCWORD_CORE_BE << 16) | 0xFC00))) + +#define IS_EXSS_MARKER(state) ((state & 0x) == DCA_SYNCWORD_SUBSTREAM) + +#define IS_MARKER(state)(IS_CORE_MARKER(state) || IS_EXSS_MARKER(state)) + +#define CORE_MARKER(state) ((state >> 16) & 0x) +#define EXSS_MARKER(state) (state & 0x) /** * Find the end of the current frame in the bitstream. @@ -48,20 +55,23 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, int buf_size) { int start_found, i; -uint32_t state; +uint64_t state; ParseContext *pc = &pc1->pc; start_found = pc->frame_start_found; -state = pc->state; +state = pc->state64; i = 0; if (!start_found) { for (i = 0; i < buf_size; i++) { state = (state << 8) | buf[i]; -if (IS_MARKER(state, i, buf, buf_size)) { -if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) { -start_found = 1; -pc1->lastmarker = state; +if (IS_MARKER(state)) { +if (!pc1->lastmarker || CORE_MARKER(state) == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) { +start_found = 1; +if (IS_EXSS_MARKER(state)) +pc1->lastmarker = EXSS_MARKER(state); +else +pc1->lastmarker = CORE_MARKER(state); i++; break; } @@ -72,20 +82,18 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, for (; i < buf_size; i++) { pc1->size++; state = (state << 8) | buf[i]; -if (state == DCA_SYNCWORD_SUBSTREAM && !pc1->hd_pos) -pc1->hd_pos = pc1->size; -if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) { +if (IS_MARKER(state) && (CORE_MARKER(state) == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) { if (pc1->framesize > pc1->size) continue; pc->frame_start_found = 0; -pc->state = -1; +pc->state64 = -1; pc1->size = 0; -return i - 3; +return IS_EXSS_MARKER(state) ? i - 3 : i - 5; } } } pc->frame_start_found = start_found; -pc->state = state; +pc->state64 = state; return END_NOT_FOUND; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dca_parser: Extend DTS core sync word and fix existing check
ffmpeg | branch: master | foo86 | Wed Apr 29 11:14:55 2015 +0300| [0670acc4f1c4ceb16968818a654e07a3f550a8c9] | committer: Luca Barbato dca_parser: Extend DTS core sync word and fix existing check The previous version checked for 14-bit streams and did not properly work across buffer boundaries. Use the 64-bit parser state to make extended sync word detection work across buffer boundary and check the extended sync word for 16-bit LE and BE core streams to reduce probability of alias sync detection. Signed-off-by: Michael Niedermayer Signed-off-by: Luca Barbato > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0670acc4f1c4ceb16968818a654e07a3f550a8c9 --- libavcodec/dca_parser.c | 48 +++ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c index 401402d..d827daa 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c @@ -32,13 +32,20 @@ typedef struct DCAParseContext { uint32_t lastmarker; int size; int framesize; -int hd_pos; } DCAParseContext; -#define IS_MARKER(state, i, buf, buf_size) \ -((state == DCA_SYNCWORD_CORE_14B_LE && (i < buf_size - 2) && (buf[i + 1] & 0xF0) == 0xF0 && buf[i + 2] == 0x07) || \ - (state == DCA_SYNCWORD_CORE_14B_BE && (i < buf_size - 2) && buf[i + 1] == 0x07 && (buf[i + 2] & 0xF0) == 0xF0) || \ - state == DCA_SYNCWORD_CORE_LE || state == DCA_SYNCWORD_CORE_BE) +#define IS_CORE_MARKER(state) \ +(((state & 0xF0FF) == (((uint64_t)DCA_SYNCWORD_CORE_14B_LE << 16) | 0xF007)) || \ + ((state & 0xFFF0) == (((uint64_t)DCA_SYNCWORD_CORE_14B_BE << 16) | 0x07F0)) || \ + ((state & 0x00FC) == (((uint64_t)DCA_SYNCWORD_CORE_LE << 16) | 0x00FC)) || \ + ((state & 0xFC00) == (((uint64_t)DCA_SYNCWORD_CORE_BE << 16) | 0xFC00))) + +#define IS_EXSS_MARKER(state) ((state & 0x) == DCA_SYNCWORD_SUBSTREAM) + +#define IS_MARKER(state)(IS_CORE_MARKER(state) || IS_EXSS_MARKER(state)) + +#define CORE_MARKER(state) ((state >> 16) & 0x) +#define EXSS_MARKER(state) (state & 0x) /** * Find the end of the current frame in the bitstream. @@ -48,24 +55,25 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, int buf_size) { int start_found, i; -uint32_t state; +uint64_t state; ParseContext *pc = &pc1->pc; start_found = pc->frame_start_found; -state = pc->state; +state = pc->state64; i = 0; if (!start_found) { for (i = 0; i < buf_size; i++) { state = (state << 8) | buf[i]; -if (IS_MARKER(state, i, buf, buf_size)) { -if (pc1->lastmarker && state == pc1->lastmarker) { +if (IS_MARKER(state)) { +if (!pc1->lastmarker || +pc1->lastmarker == CORE_MARKER(state) || +pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) { start_found = 1; -i++; -break; -} else if (!pc1->lastmarker) { -start_found = 1; -pc1->lastmarker = state; +if (IS_EXSS_MARKER(state)) +pc1->lastmarker = EXSS_MARKER(state); +else +pc1->lastmarker = CORE_MARKER(state); i++; break; } @@ -76,20 +84,20 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, for (; i < buf_size; i++) { pc1->size++; state = (state << 8) | buf[i]; -if (state == DCA_SYNCWORD_SUBSTREAM && !pc1->hd_pos) -pc1->hd_pos = pc1->size; -if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) { +if (IS_MARKER(state) && +(pc1->lastmarker == CORE_MARKER(state) || + pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) { if (pc1->framesize > pc1->size) continue; pc->frame_start_found = 0; -pc->state = -1; +pc->state64 = -1; pc1->size = 0; -return i - 3; +return IS_EXSS_MARKER(state) ? i - 3 : i - 5; } } } pc->frame_start_found = start_found; -pc->state = state; +pc->state64 = state; return END_NOT_FOUND; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/synth_filter: add more filters
ffmpeg | branch: master | foo86 | Fri Jan 8 00:49:56 2016 +0300| [5b1b536e2b7cb5a7fa0b4995ccb760a701c4efd7] | committer: Hendrik Leppkes avcodec/synth_filter: add more filters > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5b1b536e2b7cb5a7fa0b4995ccb760a701c4efd7 --- libavcodec/synth_filter.c | 116 - libavcodec/synth_filter.h | 13 + 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/libavcodec/synth_filter.c b/libavcodec/synth_filter.c index 9eab9c5..1c5dab5 100644 --- a/libavcodec/synth_filter.c +++ b/libavcodec/synth_filter.c @@ -1,5 +1,6 @@ /* * copyright (c) 2008 Michael Niedermayer + * Copyright (C) 2016 foo86 * * This file is part of FFmpeg. * @@ -19,6 +20,8 @@ */ #include "fft.h" +#include "dcadct.h" +#include "dcamath.h" #include "synth_filter.h" static void synth_filter_float(FFTContext *imdct, @@ -57,9 +60,120 @@ static void synth_filter_float(FFTContext *imdct, *synth_buf_offset = (*synth_buf_offset - 32) & 511; } +static void synth_filter_float_64(FFTContext *imdct, + float *synth_buf_ptr, int *synth_buf_offset, + float synth_buf2[64], const float window[1024], + float out[64], const float in[64], float scale) +{ +float *synth_buf = synth_buf_ptr + *synth_buf_offset; +int i, j; + +imdct->imdct_half(imdct, synth_buf, in); + +for (i = 0; i < 32; i++) { +float a = synth_buf2[i ]; +float b = synth_buf2[i + 32]; +float c = 0; +float d = 0; +for (j = 0; j < 1024 - *synth_buf_offset; j += 128) { +a += window[i + j ] * (-synth_buf[31 - i + j ]); +b += window[i + j + 32] * ( synth_buf[ i + j ]); +c += window[i + j + 64] * ( synth_buf[32 + i + j ]); +d += window[i + j + 96] * ( synth_buf[63 - i + j ]); +} +for ( ; j < 1024; j += 128) { +a += window[i + j ] * (-synth_buf[31 - i + j - 1024]); +b += window[i + j + 32] * ( synth_buf[ i + j - 1024]); +c += window[i + j + 64] * ( synth_buf[32 + i + j - 1024]); +d += window[i + j + 96] * ( synth_buf[63 - i + j - 1024]); +} +out[i ] = a * scale; +out[i + 32] = b * scale; +synth_buf2[i ] = c; +synth_buf2[i + 32] = d; +} + +*synth_buf_offset = (*synth_buf_offset - 64) & 1023; +} + +static void synth_filter_fixed(DCADCTContext *imdct, + int32_t *synth_buf_ptr, int *synth_buf_offset, + int32_t synth_buf2[32], const int32_t window[512], + int32_t out[32], const int32_t in[32]) +{ +int32_t *synth_buf = synth_buf_ptr + *synth_buf_offset; +int i, j; + +imdct->imdct_half[0](synth_buf, in); + +for (i = 0; i < 16; i++) { +int64_t a = synth_buf2[i ] * (INT64_C(1) << 21); +int64_t b = synth_buf2[i + 16] * (INT64_C(1) << 21); +int64_t c = 0; +int64_t d = 0; +for (j = 0; j < 512 - *synth_buf_offset; j += 64) { +a += (int64_t)window[i + j ] * synth_buf[ i + j ]; +b += (int64_t)window[i + j + 16] * synth_buf[15 - i + j ]; +c += (int64_t)window[i + j + 32] * synth_buf[16 + i + j ]; +d += (int64_t)window[i + j + 48] * synth_buf[31 - i + j ]; +} +for ( ; j < 512; j += 64) { +a += (int64_t)window[i + j ] * synth_buf[ i + j - 512]; +b += (int64_t)window[i + j + 16] * synth_buf[15 - i + j - 512]; +c += (int64_t)window[i + j + 32] * synth_buf[16 + i + j - 512]; +d += (int64_t)window[i + j + 48] * synth_buf[31 - i + j - 512]; +} +out[i ] = clip23(norm21(a)); +out[i + 16] = clip23(norm21(b)); +synth_buf2[i ] = norm21(c); +synth_buf2[i + 16] = norm21(d); +} + +*synth_buf_offset = (*synth_buf_offset - 32) & 511; +} + +static void synth_filter_fixed_64(DCADCTContext *imdct, + int32_t *synth_buf_ptr, int *synth_buf_offset, + int32_t synth_buf2[64], const int32_t window[1024], + int32_t out[64], const int32_t in[64]) +{ +int32_t *synth_buf = synth_buf_ptr + *synth_buf_offset; +int i, j; + +imdct->imdct_half[1](synth_buf, in); + +for (i = 0; i < 32; i++) { +int64_t a = synth_buf2[i ] * (INT64_C(1) << 20); +int64_t b = synth_buf2[i + 32] * (INT64_C(1) << 20); +int64_t c = 0; +int64_t d = 0; +for (j = 0; j < 1024 - *synth_buf_offset; j += 128) { +a += (int64_t)window[
[FFmpeg-cvslog] avcodec/dca: add generic defines
ffmpeg | branch: master | foo86 | Sat Jan 16 11:56:26 2016 +0300| [0930b2dd1f01213ca1f08aff3a9b8b0d5515cede] | committer: Hendrik Leppkes avcodec/dca: add generic defines > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0930b2dd1f01213ca1f08aff3a9b8b0d5515cede --- libavcodec/dca.h | 94 ++ 1 file changed, 94 insertions(+) diff --git a/libavcodec/dca.h b/libavcodec/dca.h index ea3f9c5..ccb02af 100644 --- a/libavcodec/dca.h +++ b/libavcodec/dca.h @@ -4,6 +4,7 @@ * Copyright (C) 2004 Benjamin Zores * Copyright (C) 2006 Benjamin Larsson * Copyright (C) 2007 Konstantin Shishkov + * Copyright (C) 2016 foo86 * * This file is part of FFmpeg. * @@ -30,6 +31,99 @@ #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" +enum DCASpeaker { +DCA_SPEAKER_C,DCA_SPEAKER_L,DCA_SPEAKER_R,DCA_SPEAKER_Ls, +DCA_SPEAKER_Rs, DCA_SPEAKER_LFE1, DCA_SPEAKER_Cs, DCA_SPEAKER_Lsr, +DCA_SPEAKER_Rsr, DCA_SPEAKER_Lss, DCA_SPEAKER_Rss, DCA_SPEAKER_Lc, +DCA_SPEAKER_Rc, DCA_SPEAKER_Lh, DCA_SPEAKER_Ch, DCA_SPEAKER_Rh, +DCA_SPEAKER_LFE2, DCA_SPEAKER_Lw, DCA_SPEAKER_Rw, DCA_SPEAKER_Oh, +DCA_SPEAKER_Lhs, DCA_SPEAKER_Rhs, DCA_SPEAKER_Chr, DCA_SPEAKER_Lhr, +DCA_SPEAKER_Rhr, DCA_SPEAKER_Cl, DCA_SPEAKER_Ll, DCA_SPEAKER_Rl, +DCA_SPEAKER_RSV1, DCA_SPEAKER_RSV2, DCA_SPEAKER_RSV3, DCA_SPEAKER_RSV4, + +DCA_SPEAKER_COUNT +}; + +enum DCASpeakerMask { +DCA_SPEAKER_MASK_C = 0x0001, +DCA_SPEAKER_MASK_L = 0x0002, +DCA_SPEAKER_MASK_R = 0x0004, +DCA_SPEAKER_MASK_Ls= 0x0008, +DCA_SPEAKER_MASK_Rs= 0x0010, +DCA_SPEAKER_MASK_LFE1 = 0x0020, +DCA_SPEAKER_MASK_Cs= 0x0040, +DCA_SPEAKER_MASK_Lsr = 0x0080, +DCA_SPEAKER_MASK_Rsr = 0x0100, +DCA_SPEAKER_MASK_Lss = 0x0200, +DCA_SPEAKER_MASK_Rss = 0x0400, +DCA_SPEAKER_MASK_Lc= 0x0800, +DCA_SPEAKER_MASK_Rc= 0x1000, +DCA_SPEAKER_MASK_Lh= 0x2000, +DCA_SPEAKER_MASK_Ch= 0x4000, +DCA_SPEAKER_MASK_Rh= 0x8000, +DCA_SPEAKER_MASK_LFE2 = 0x0001, +DCA_SPEAKER_MASK_Lw= 0x0002, +DCA_SPEAKER_MASK_Rw= 0x0004, +DCA_SPEAKER_MASK_Oh= 0x0008, +DCA_SPEAKER_MASK_Lhs = 0x0010, +DCA_SPEAKER_MASK_Rhs = 0x0020, +DCA_SPEAKER_MASK_Chr = 0x0040, +DCA_SPEAKER_MASK_Lhr = 0x0080, +DCA_SPEAKER_MASK_Rhr = 0x0100, +DCA_SPEAKER_MASK_Cl= 0x0200, +DCA_SPEAKER_MASK_Ll= 0x0400, +DCA_SPEAKER_MASK_Rl= 0x0800, +}; + +#define DCA_SPEAKER_LAYOUT_MONO (DCA_SPEAKER_MASK_C) +#define DCA_SPEAKER_LAYOUT_STEREO (DCA_SPEAKER_MASK_L | DCA_SPEAKER_MASK_R) +#define DCA_SPEAKER_LAYOUT_2POINT1 (DCA_SPEAKER_LAYOUT_STEREO | DCA_SPEAKER_MASK_LFE1) +#define DCA_SPEAKER_LAYOUT_3_0 (DCA_SPEAKER_LAYOUT_STEREO | DCA_SPEAKER_MASK_C) +#define DCA_SPEAKER_LAYOUT_2_1 (DCA_SPEAKER_LAYOUT_STEREO | DCA_SPEAKER_MASK_Cs) +#define DCA_SPEAKER_LAYOUT_3_1 (DCA_SPEAKER_LAYOUT_3_0 | DCA_SPEAKER_MASK_Cs) +#define DCA_SPEAKER_LAYOUT_2_2 (DCA_SPEAKER_LAYOUT_STEREO | DCA_SPEAKER_MASK_Ls | DCA_SPEAKER_MASK_Rs) +#define DCA_SPEAKER_LAYOUT_5POINT0 (DCA_SPEAKER_LAYOUT_3_0 | DCA_SPEAKER_MASK_Ls | DCA_SPEAKER_MASK_Rs) +#define DCA_SPEAKER_LAYOUT_5POINT1 (DCA_SPEAKER_LAYOUT_5POINT0 | DCA_SPEAKER_MASK_LFE1) +#define DCA_SPEAKER_LAYOUT_7POINT0_WIDE (DCA_SPEAKER_LAYOUT_5POINT0 | DCA_SPEAKER_MASK_Lw | DCA_SPEAKER_MASK_Rw) +#define DCA_SPEAKER_LAYOUT_7POINT1_WIDE (DCA_SPEAKER_LAYOUT_7POINT0_WIDE | DCA_SPEAKER_MASK_LFE1) + +#define DCA_HAS_STEREO(mask) \ +((mask & DCA_SPEAKER_LAYOUT_STEREO) == DCA_SPEAKER_LAYOUT_STEREO) + +enum DCARepresentationType { +DCA_REPR_TYPE_LtRt = 2, +DCA_REPR_TYPE_LhRh = 3 +}; + +enum DCAExtensionMask { +DCA_CSS_CORE = 0x001, +DCA_CSS_XXCH = 0x002, +DCA_CSS_X96= 0x004, +DCA_CSS_XCH= 0x008, +DCA_CSS_MASK = 0x00f, +DCA_EXSS_CORE = 0x010, +DCA_EXSS_XBR = 0x020, +DCA_EXSS_XXCH = 0x040, +DCA_EXSS_X96 = 0x080, +DCA_EXSS_LBR = 0x100, +DCA_EXSS_XLL = 0x200, +DCA_EXSS_RSV1 = 0x400, +DCA_EXSS_RSV2 = 0x800, +DCA_EXSS_MASK = 0xff0, +}; + +enum DCADownMixType { +DCA_DMIX_TYPE_1_0, +DCA_DMIX_TYPE_LoRo, +DCA_DMIX_TYPE_LtRt, +DCA_DMIX_TYPE_3_0, +DCA_DMIX_TYPE_2_1, +DCA_DMIX_TYPE_2_2, +DCA_DMIX_TYPE_3_1, + +DCA_DMIX_TYPE_COUNT +}; + extern av_export const uint32_t avpriv_dca_sample_rates[16]; /** ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: add math helpers and fixed point DCT
ffmpeg | branch: master | foo86 | Fri Jan 8 00:48:57 2016 +0300| [4a53b83691ac1c1feefe8749756b149c31ad4ccb] | committer: Hendrik Leppkes avcodec/dca: add math helpers and fixed point DCT > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4a53b83691ac1c1feefe8749756b149c31ad4ccb --- libavcodec/dcadct.c | 362 ++ libavcodec/dcadct.h | 32 + libavcodec/dcamath.h | 55 3 files changed, 449 insertions(+) diff --git a/libavcodec/dcadct.c b/libavcodec/dcadct.c new file mode 100644 index 000..1082aa8 --- /dev/null +++ b/libavcodec/dcadct.c @@ -0,0 +1,362 @@ +/* + * Copyright (C) 2016 foo86 + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" + +#include "dcadct.h" +#include "dcamath.h" + +static void sum_a(const int *input, int *output, int len) +{ +int i; + +for (i = 0; i < len; i++) +output[i] = input[2 * i] + input[2 * i + 1]; +} + +static void sum_b(const int *input, int *output, int len) +{ +int i; + +output[0] = input[0]; +for (i = 1; i < len; i++) +output[i] = input[2 * i] + input[2 * i - 1]; +} + +static void sum_c(const int *input, int *output, int len) +{ +int i; + +for (i = 0; i < len; i++) +output[i] = input[2 * i]; +} + +static void sum_d(const int *input, int *output, int len) +{ +int i; + +output[0] = input[1]; +for (i = 1; i < len; i++) +output[i] = input[2 * i - 1] + input[2 * i + 1]; +} + +static void dct_a(const int *input, int *output) +{ +static const int cos_mod[8][8] = { + { 8348215, 8027397, 7398092, 6484482, 5321677, 3954362, 2435084, 87 }, + { 8027397, 5321677, 87, -3954362, -7398092, -8348215, -6484482, -2435084 }, + { 7398092, 87, -6484482, -8027397, -2435084, 5321677, 8348215, 3954362 }, + { 6484482, -3954362, -8027397, 87, 8348215, 2435084, -7398092, -5321677 }, + { 5321677, -7398092, -2435084, 8348215, -87, -8027397, 3954362, 6484482 }, + { 3954362, -8348215, 5321677, 2435084, -8027397, 6484482, 87, -7398092 }, + { 2435084, -6484482, 8348215, -7398092, 3954362, 87, -5321677, 8027397 }, + { 87, -2435084, 3954362, -5321677, 6484482, -7398092, 8027397, -8348215 } +}; + +int i, j; + +for (i = 0; i < 8; i++) { +int64_t res = 0; +for (j = 0; j < 8; j++) +res += (int64_t)cos_mod[i][j] * input[j]; +output[i] = norm23(res); +} +} + +static void dct_b(const int *input, int *output) +{ +static const int cos_mod[8][7] = { +{ 8227423, 7750063, 6974873, 5931642, 4660461, 3210181, 1636536 }, +{ 6974873, 3210181, -1636536, -5931642, -8227423, -7750063, -4660461 }, +{ 4660461, -3210181, -8227423, -5931642, 1636536, 7750063, 6974873 }, +{ 1636536, -7750063, -4660461, 5931642, 6974873, -3210181, -8227423 }, +{ -1636536, -7750063, 4660461, 5931642, -6974873, -3210181, 8227423 }, +{ -4660461, -3210181, 8227423, -5931642, -1636536, 7750063, -6974873 }, +{ -6974873, 3210181, 1636536, -5931642, 8227423, -7750063, 4660461 }, +{ -8227423, 7750063, -6974873, 5931642, -4660461, 3210181, -1636536 } +}; + +int i, j; + +for (i = 0; i < 8; i++) { +int64_t res = input[0] * (INT64_C(1) << 23); +for (j = 0; j < 7; j++) +res += (int64_t)cos_mod[i][j] * input[1 + j]; +output[i] = norm23(res); +} +} + +static void mod_a(const int *input, int *output) +{ +static const int cos_mod[16] = { + 4199362, 4240198, 4323885, 4454708, + 4639772, 4890013, 5221943, 5660703, + -6245623, -7040975, -8158494, -9809974, +-12450076, -17261920, -28585092, -85479984 +}; + +int i, k; + +for (i = 0; i < 8; i++) +output[i] = mul23(cos_mod[i], input[i] + input[8 + i]); + +for (i = 8, k = 7; i < 16; i++, k--) +output[i] = mul23(cos_mod[i], input[k] - input[8 + k]); +} + +static void mod_b(int *input, int *output) +{ +static co
[FFmpeg-cvslog] avcodec/dca: add REV1AUX sync word
ffmpeg | branch: master | foo86 | Thu Jan 7 16:37:46 2016 +0300| [64f6d17b405b4b4f09071ea40acefbf0fa842b38] | committer: Hendrik Leppkes avcodec/dca: add REV1AUX sync word > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=64f6d17b405b4b4f09071ea40acefbf0fa842b38 --- libavcodec/dca_syncwords.h |1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h index 6981cb8..4d2cd5f 100644 --- a/libavcodec/dca_syncwords.h +++ b/libavcodec/dca_syncwords.h @@ -31,5 +31,6 @@ #defineDCA_SYNCWORD_XLL 0x41A29547U #defineDCA_SYNCWORD_SUBSTREAM0x64582025U #defineDCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U +#defineDCA_SYNCWORD_REV1AUX 0x9A1105A0U #endif /* AVCODEC_DCA_SYNCWORDS_H */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/synth_filter: fix whitespace
ffmpeg | branch: master | foo86 | Thu Jan 7 17:27:00 2016 +0300| [8984806a510bc797c360cf0a01074a80bdb64b21] | committer: Hendrik Leppkes avcodec/synth_filter: fix whitespace > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8984806a510bc797c360cf0a01074a80bdb64b21 --- libavcodec/synth_filter.c | 45 +++-- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/libavcodec/synth_filter.c b/libavcodec/synth_filter.c index 8dfca00..9eab9c5 100644 --- a/libavcodec/synth_filter.c +++ b/libavcodec/synth_filter.c @@ -22,38 +22,39 @@ #include "synth_filter.h" static void synth_filter_float(FFTContext *imdct, - float *synth_buf_ptr, int *synth_buf_offset, - float synth_buf2[32], const float window[512], - float out[32], const float in[32], float scale) + float *synth_buf_ptr, int *synth_buf_offset, + float synth_buf2[32], const float window[512], + float out[32], const float in[32], float scale) { -float *synth_buf= synth_buf_ptr + *synth_buf_offset; +float *synth_buf = synth_buf_ptr + *synth_buf_offset; int i, j; imdct->imdct_half(imdct, synth_buf, in); -for (i = 0; i < 16; i++){ -float a= synth_buf2[i ]; -float b= synth_buf2[i + 16]; -float c= 0; -float d= 0; -for (j = 0; j < 512 - *synth_buf_offset; j += 64){ -a += window[i + j ]*(-synth_buf[15 - i + j ]); -b += window[i + j + 16]*( synth_buf[ i + j ]); -c += window[i + j + 32]*( synth_buf[16 + i + j ]); -d += window[i + j + 48]*( synth_buf[31 - i + j ]); +for (i = 0; i < 16; i++) { +float a = synth_buf2[i ]; +float b = synth_buf2[i + 16]; +float c = 0; +float d = 0; +for (j = 0; j < 512 - *synth_buf_offset; j += 64) { +a += window[i + j ] * (-synth_buf[15 - i + j ]); +b += window[i + j + 16] * ( synth_buf[ i + j ]); +c += window[i + j + 32] * ( synth_buf[16 + i + j ]); +d += window[i + j + 48] * ( synth_buf[31 - i + j ]); } -for ( ; j < 512; j += 64){ -a += window[i + j ]*(-synth_buf[15 - i + j - 512]); -b += window[i + j + 16]*( synth_buf[ i + j - 512]); -c += window[i + j + 32]*( synth_buf[16 + i + j - 512]); -d += window[i + j + 48]*( synth_buf[31 - i + j - 512]); +for ( ; j < 512; j += 64) { +a += window[i + j ] * (-synth_buf[15 - i + j - 512]); +b += window[i + j + 16] * ( synth_buf[ i + j - 512]); +c += window[i + j + 32] * ( synth_buf[16 + i + j - 512]); +d += window[i + j + 48] * ( synth_buf[31 - i + j - 512]); } -out[i ] = a*scale; -out[i + 16] = b*scale; +out[i ] = a * scale; +out[i + 16] = b * scale; synth_buf2[i ] = c; synth_buf2[i + 16] = d; } -*synth_buf_offset= (*synth_buf_offset - 32)&511; + +*synth_buf_offset = (*synth_buf_offset - 32) & 511; } av_cold void ff_synth_filter_init(SynthFilterContext *c) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: add more tables
ffmpeg | branch: master | foo86 | Thu Jan 7 17:15:22 2016 +0300| [9a0a3bbeaaf498061c357755443beab16b25c4f5] | committer: Hendrik Leppkes avcodec/dca: add more tables > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9a0a3bbeaaf498061c357755443beab16b25c4f5 --- libavcodec/dcadata.c | 622 +- libavcodec/dcadata.h | 24 +- 2 files changed, 641 insertions(+), 5 deletions(-) diff --git a/libavcodec/dcadata.c b/libavcodec/dcadata.c index 0d0c218..e991134 100644 --- a/libavcodec/dcadata.c +++ b/libavcodec/dcadata.c @@ -42,8 +42,12 @@ const uint8_t ff_dca_channels[16] = { 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8 }; -const uint8_t ff_dca_bits_per_sample[7] = { -16, 16, 20, 20, 0, 24, 24 +const uint8_t ff_dca_bits_per_sample[8] = { +16, 16, 20, 20, 0, 24, 24, 0 +}; + +const uint8_t ff_dca_dmix_primary_nch[8] = { +1, 2, 2, 3, 3, 4, 4, 0 }; /* ADPCM data */ @@ -4180,6 +4184,37 @@ const uint32_t ff_dca_scale_factor_quant7[128] = { 5011872, 5688529, 6456542, 7328245, 8317638, 0, 0, 0 }; +const uint32_t ff_dca_joint_scale_factors[129] = { + 3288,3490,3691,3909,4144,4387,4647,4924, + 5218,5528,5855,6199,6568,6963,7374,7810, + 8271,8758,9278,9831, 10410, 11031, 11685, 12373, + 13103, 13883, 14705, 15578, 16500, 17482, 18514, 19613, + 20770, 22003, 23312, 24688, 26156, 27699, 29343, 31080, + 32925, 34871, 36943, 39133, 41448, 43906, 46506, 49258, + 52177, 55273, 58544, 62017, 65691, 69584, 73711, 78073, + 82703, 87602, 92795, 98289, 104111, 110285, 116820, 123740, + 131072, 138840, 147069, 155776, 165012, 174785, 185145, 196117, + 207735, 220042, 233086, 246894, 261523, 277017, 293434, 310823, + 329236, 348748, 369409, 391303, 414490, 439043, 465064, 492621, + 521805, 552725, 585475, 620170, 656920, 695843, 737073, 780745, + 827008, 876014, 927923, 982902, 1041144, 1102834, 1168181, 1237404, +1310720, 1388382, 1470649, 1557790, 1650098, 1747876, 1851441, 1961147, +2077355, 2200441, 2330825, 2468935, 2615232, 2770195, 2934335, 3108206, +3292378, 3487463, 3694108, 3913000, 4144862, 4390455, 4650611, 4926176, +5218066 +}; + +const uint32_t ff_dca_scale_factor_adj[4] = { +4194304, 4718592, 5242880, 6029312 +}; + +const uint32_t ff_dca_quant_levels[32] = { + 1, 3, 5, 7, 9, 13, 17, 25, + 32, 64, 128, 256,512, 1024, 2048,4096, + 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, +2097152, 4194304, 8388608, 0, 0, 0, 0, 0 +}; + /* 20bits unsigned fractional binary codes */ const uint32_t ff_dca_lossy_quant[32] = { 0, 6710886, 4194304, 3355443, 2474639, 2097152, 1761608, 1426063, @@ -8032,6 +8067,562 @@ DECLARE_ALIGNED(16, const float, ff_dca_fir_64bands)[1024] = { 7.0950903150874990e-8, 7.1279389866041690e-8, }; +DECLARE_ALIGNED(16, const int32_t, ff_dca_fir_32bands_perfect_fixed)[512] = { + 0,0, -3, -10, + -35, -105, -218, -141, +-170, -216, -239, -254, +-257, -251, -235, -212, +-267, -317, -362, -400, +-425, -434, -427, -373, +-339, -593, -321, -120, + -39, -16,0,1, + 1,1, -3, -1, + -6, -38, -93, -496, +-723, -970,-1235,-1501, + -1753,-1978,-2163,-2295, + -2891,-2915,-2860,-2726, + -2517,-2243,-1915,-1590, + -1192, -252, -117, -22, + -6, -13, 12, 14, + 32, 25, 469, 942, +1403, 1421, 1239, 2838, +3539, 4259, 5002, 5716, +6365, 6908, 7311, 7545, + 11680,12355,12785,12951, + 12841,12453,11803,10864, +9762, 7099, 6725, 5954, +4284, 2584, 215, 379, + 557, 701, -29, -687, + -1578,-2749,-4076,-7933, + -10049, -12133, -14039, -15752, + -17213, -18400, -19291, -19878, + -1444,-3005,-4523,-5927, + -7143,-8093,-8713,-8939, + -8700,-9481,-7515,-5279, + -2725, 61, 5763, 6113, +7571, 6735,17126,20165, + 23328,26775,30310,32639, + 35464,38064,40423,42512, + 44261,45632,46578,46974, + -45572, -45008, -43753, -41661, + -38655, -34660, -29587, -23375, + -15998,-7631, 2472,13
[FFmpeg-cvslog] avcodec/dca: simplify condition
ffmpeg | branch: master | foo86 | Wed Mar 2 22:32:10 2016 +0300| [00e3717b4a21d93bdf822588a9f6fbfd1fca27a5] | committer: Michael Niedermayer avcodec/dca: simplify condition Reviewed-by: Hendrik Leppkes Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=00e3717b4a21d93bdf822588a9f6fbfd1fca27a5 --- libavcodec/dca_xll.c | 17 ++--- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c index ffe8ef3..5e6cf35 100644 --- a/libavcodec/dca_xll.c +++ b/libavcodec/dca_xll.c @@ -460,19 +460,14 @@ static int chs_parse_band_data(DCAXllDecoder *s, DCAXllChSet *c, int band, int s // Unpack Rice coding flag // 0 - linear code, 1 - Rice code c->rice_code_flag[i] = get_bits1(&s->gb); -if (!c->seg_common && c->rice_code_flag[i]) { -// Unpack Hybrid Rice coding flag -// 0 - Rice code, 1 - Hybrid Rice code -if (get_bits1(&s->gb)) -// Unpack binary code length for isolated samples -c->bitalloc_hybrid_linear[i] = get_bits(&s->gb, c->nabits) + 1; -else -// 0 indicates no Hybrid Rice coding -c->bitalloc_hybrid_linear[i] = 0; -} else { +// Unpack Hybrid Rice coding flag +// 0 - Rice code, 1 - Hybrid Rice code +if (!c->seg_common && c->rice_code_flag[i] && get_bits1(&s->gb)) +// Unpack binary code length for isolated samples +c->bitalloc_hybrid_linear[i] = get_bits(&s->gb, c->nabits) + 1; +else // 0 indicates no Hybrid Rice coding c->bitalloc_hybrid_linear[i] = 0; -} } // Unpack coding parameters ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: fix av_cold placement in declarations
ffmpeg | branch: master | foo86 | Wed Mar 2 22:31:46 2016 +0300| [89813487491afbca5472e8a4af262eedb4aead02] | committer: Michael Niedermayer avcodec/dca: fix av_cold placement in declarations Reviewed-by: Hendrik Leppkes Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=89813487491afbca5472e8a4af262eedb4aead02 --- libavcodec/dca_xll.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c index cd1af81..ffe8ef3 100644 --- a/libavcodec/dca_xll.c +++ b/libavcodec/dca_xll.c @@ -602,7 +602,7 @@ static int chs_parse_band_data(DCAXllDecoder *s, DCAXllChSet *c, int band, int s return 0; } -static void av_cold chs_clear_band_data(DCAXllDecoder *s, DCAXllChSet *c, int band, int seg) +static av_cold void chs_clear_band_data(DCAXllDecoder *s, DCAXllChSet *c, int band, int seg) { DCAXllBand *b = &c->bands[band]; int i, offset, nsamples; @@ -1242,7 +1242,7 @@ static void scale_down_mix(DCAXllDecoder *s, DCAXllChSet *o, int band) // Clear all band data and replace non-residual encoded channels with lossy // counterparts -static void av_cold force_lossy_output(DCAXllDecoder *s, DCAXllChSet *c) +static av_cold void force_lossy_output(DCAXllDecoder *s, DCAXllChSet *c) { DCAContext *dca = s->avctx->priv_data; int band, ch; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: clear X96 channels if nothing was decoded
ffmpeg | branch: master | foo86 | Wed Mar 2 22:31:10 2016 +0300| [db44b599805fdd96940cf2e5a336f872648bbda1] | committer: Michael Niedermayer avcodec/dca: clear X96 channels if nothing was decoded The first X96 channel set can have more channels than core, causing X96 decoding to be skipped. Clear the number of decoded X96 channels to zero in this rudimentary case. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db44b599805fdd96940cf2e5a336f872648bbda1 --- libavcodec/dca_core.c |1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 48a8f61..d9f1a4c 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -1760,6 +1760,7 @@ static int parse_x96_frame_exss(DCACoreDecoder *s) return ret; // Channel set data +s->x96_nchannels = 0; for (i = 0, x96_base_ch = 0; i < x96_nchsets; i++) { header_pos = get_bits_count(&s->gb); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: clear X96 channels if nothing was decoded
ffmpeg | branch: release/3.0 | foo86 | Wed Mar 2 22:31:10 2016 +0300| [da6ccfe18ebbe7af41ba07edd64b6d1b8650ced2] | committer: Michael Niedermayer avcodec/dca: clear X96 channels if nothing was decoded The first X96 channel set can have more channels than core, causing X96 decoding to be skipped. Clear the number of decoded X96 channels to zero in this rudimentary case. Signed-off-by: Michael Niedermayer (cherry picked from commit db44b599805fdd96940cf2e5a336f872648bbda1) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=da6ccfe18ebbe7af41ba07edd64b6d1b8650ced2 --- libavcodec/dca_core.c |1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 48a8f61..d9f1a4c 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -1760,6 +1760,7 @@ static int parse_x96_frame_exss(DCACoreDecoder *s) return ret; // Channel set data +s->x96_nchannels = 0; for (i = 0, x96_base_ch = 0; i < x96_nchsets; i++) { header_pos = get_bits_count(&s->gb); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dcaenc: move channel reordering tables to dcaenc.h
ffmpeg | branch: master | foo86 | Wed Apr 27 10:20:20 2016 -0700| [b286ff69c03e648453fd161f8ff1c4fcce396fa8] | committer: James Almer avcodec/dcaenc: move channel reordering tables to dcaenc.h DCA core decoder no longer uses fixed tables for channel reordering. Move them into private encoder header (and drop ff_dca_ prefix). Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b286ff69c03e648453fd161f8ff1c4fcce396fa8 --- libavcodec/dcadata.c | 42 -- libavcodec/dcadata.h |5 - libavcodec/dcaenc.c |6 +++--- libavcodec/dcaenc.h | 42 ++ 4 files changed, 45 insertions(+), 50 deletions(-) diff --git a/libavcodec/dcadata.c b/libavcodec/dcadata.c index e991134..3f8d8e9 100644 --- a/libavcodec/dcadata.c +++ b/libavcodec/dcadata.c @@ -8730,48 +8730,6 @@ const int32_t ff_dca_sampling_freqs[16] = { 176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000, }; -const int8_t ff_dca_lfe_index[16] = { -1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 1, 3, 2, 3 -}; - -const int8_t ff_dca_channel_reorder_lfe[16][9] = { -{ 0, -1, -1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -{ 2, 0, 1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, 3, -1, -1, -1, -1, -1, -1 }, -{ 2, 0, 1, 4, -1, -1, -1, -1, -1 }, -{ 0, 1, 3, 4, -1, -1, -1, -1, -1 }, -{ 2, 0, 1, 4, 5, -1, -1, -1, -1 }, -{ 3, 4, 0, 1, 5, 6, -1, -1, -1 }, -{ 2, 0, 1, 4, 5, 6, -1, -1, -1 }, -{ 0, 6, 4, 5, 2, 3, -1, -1, -1 }, -{ 4, 2, 5, 0, 1, 6, 7, -1, -1 }, -{ 5, 6, 0, 1, 7, 3, 8, 4, -1 }, -{ 4, 2, 5, 0, 1, 6, 8, 7, -1 }, -}; - -const int8_t ff_dca_channel_reorder_nolfe[16][9] = { -{ 0, -1, -1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -{ 2, 0, 1, -1, -1, -1, -1, -1, -1 }, -{ 0, 1, 2, -1, -1, -1, -1, -1, -1 }, -{ 2, 0, 1, 3, -1, -1, -1, -1, -1 }, -{ 0, 1, 2, 3, -1, -1, -1, -1, -1 }, -{ 2, 0, 1, 3, 4, -1, -1, -1, -1 }, -{ 2, 3, 0, 1, 4, 5, -1, -1, -1 }, -{ 2, 0, 1, 3, 4, 5, -1, -1, -1 }, -{ 0, 5, 3, 4, 1, 2, -1, -1, -1 }, -{ 3, 2, 4, 0, 1, 5, 6, -1, -1 }, -{ 4, 5, 0, 1, 6, 2, 7, 3, -1 }, -{ 3, 2, 4, 0, 1, 5, 7, 6, -1 }, -}; - const uint16_t ff_dca_vlc_offs[63] = { 0, 512, 640, 768, 1282, 1794, 2436, 3080, 3770, 4454, 5364, 5372, 5380, 5388, 5392, 5396, 5412, 5420, 5428, 5460, 5492, 5508, diff --git a/libavcodec/dcadata.h b/libavcodec/dcadata.h index d864251..83c2ce8 100644 --- a/libavcodec/dcadata.h +++ b/libavcodec/dcadata.h @@ -73,11 +73,6 @@ extern const int32_t ff_dca_xll_band_coeff[20]; extern const int32_t ff_dca_sampling_freqs[16]; -extern const int8_t ff_dca_lfe_index[16]; - -extern const int8_t ff_dca_channel_reorder_lfe[16][9]; -extern const int8_t ff_dca_channel_reorder_nolfe[16][9]; - extern const uint16_t ff_dca_vlc_offs[63]; #endif /* AVCODEC_DCADATA_H */ diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index d562a27..6bb7d29 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -137,9 +137,9 @@ static int encode_init(AVCodecContext *avctx) if (c->lfe_channel) { c->fullband_channels--; -c->channel_order_tab = ff_dca_channel_reorder_lfe[c->channel_config]; +c->channel_order_tab = channel_reorder_lfe[c->channel_config]; } else { -c->channel_order_tab = ff_dca_channel_reorder_nolfe[c->channel_config]; +c->channel_order_tab = channel_reorder_nolfe[c->channel_config]; } for (i = 0; i < 9; i++) { @@ -303,7 +303,7 @@ static void subband_transform(DCAEncContext *c, const int32_t *input) static void lfe_downsample(DCAEncContext *c, const int32_t *input) { /* FIXME: make 128x LFE downsampling possible */ -const int lfech = ff_dca_lfe_index[c->channel_config]; +const int lfech = lfe_index[c->channel_config]; int i, j, lfes; int32_t hist[512]; int32_t accum; diff --git a/libavcodec/dcaenc.h b/libavcodec/dcaenc.h index bafc3c0..eccfb42 100644 --- a/libavcodec/dcaenc.h +++ b/libavcodec/dcaenc.h @@ -103,4 +103,46 @@ static const int bit_consumption[27] = { 272, 288, 304, 320, 336, 352, 368, }; +static const int8_t lfe_index[16] = { +1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 1, 3, 2, 3 +}; + +static const int8_t channel_reorder_lfe[16][9] = { +{ 0, -1, -1, -1, -1, -1, -1, -1, -1 }, +{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, +{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, +{ 0, 1, -1, -1, -1, -1, -1, -1, -1 }, +{ 0, 1, -1, -1,
[FFmpeg-cvslog] avcodec/dcaenc: reuse shared quant levels table
ffmpeg | branch: master | foo86 | Wed Apr 27 10:19:54 2016 -0700| [de28e73cce03b1de8b63683b70e4d0241161cca1] | committer: James Almer avcodec/dcaenc: reuse shared quant levels table Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de28e73cce03b1de8b63683b70e4d0241161cca1 --- libavcodec/dcaenc.c |8 libavcodec/dcaenc.h |7 --- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index ab40e37..d562a27 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -683,7 +683,7 @@ static int calc_one_scale(int32_t peak_cb, int abits, softfloat *quant) continue; our_quant.m = mul32(scalefactor_inv[our_nscale - try_remove].m, stepsize_inv[abits].m); our_quant.e = scalefactor_inv[our_nscale - try_remove].e + stepsize_inv[abits].e - 17; -if ((quant_levels[abits] - 1) / 2 < quantize_value(peak, our_quant)) +if ((ff_dca_quant_levels[abits] - 1) / 2 < quantize_value(peak, our_quant)) continue; our_nscale -= try_remove; } @@ -693,7 +693,7 @@ static int calc_one_scale(int32_t peak_cb, int abits, softfloat *quant) quant->m = mul32(scalefactor_inv[our_nscale].m, stepsize_inv[abits].m); quant->e = scalefactor_inv[our_nscale].e + stepsize_inv[abits].e - 17; -av_assert0((quant_levels[abits] - 1) / 2 >= quantize_value(peak, *quant)); +av_assert0((ff_dca_quant_levels[abits] - 1) / 2 >= quantize_value(peak, *quant)); return our_nscale; } @@ -858,9 +858,9 @@ static void put_subframe_samples(DCAEncContext *c, int ss, int band, int ch) for (i = 0; i < 8; i += 4) { sum = 0; for (j = 3; j >= 0; j--) { -sum *= quant_levels[c->abits[band][ch]]; +sum *= ff_dca_quant_levels[c->abits[band][ch]]; sum += c->quantized[ss * 8 + i + j][band][ch]; -sum += (quant_levels[c->abits[band][ch]] - 1) / 2; +sum += (ff_dca_quant_levels[c->abits[band][ch]] - 1) / 2; } put_bits(&c->pb, bit_consumption[c->abits[band][ch]] / 4, sum); } diff --git a/libavcodec/dcaenc.h b/libavcodec/dcaenc.h index 0443ca6..bafc3c0 100644 --- a/libavcodec/dcaenc.h +++ b/libavcodec/dcaenc.h @@ -103,11 +103,4 @@ static const int bit_consumption[27] = { 272, 288, 304, 320, 336, 352, 368, }; -/* Table B.5: Selection of quantization levels and codebooks */ -static const int quant_levels[27] = { -1, 3, 5, 7, 9, 13, 17, 25, 32, 64, -128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, -131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, -}; - #endif /* AVCODEC_DCAENC_H */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: move channel counter utility into dca.h
ffmpeg | branch: master | foo86 | Sun May 1 08:42:14 2016 -0700| [1fee770a1cece01f1e31a3127f7039e784a449eb] | committer: James Almer avcodec/dca: move channel counter utility into dca.h Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1fee770a1cece01f1e31a3127f7039e784a449eb --- libavcodec/dca.h | 28 libavcodec/dca_exss.c |9 ++--- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/libavcodec/dca.h b/libavcodec/dca.h index ccb02af..a1ac763 100644 --- a/libavcodec/dca.h +++ b/libavcodec/dca.h @@ -28,6 +28,7 @@ #include +#include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" @@ -90,6 +91,33 @@ enum DCASpeakerMask { #define DCA_HAS_STEREO(mask) \ ((mask & DCA_SPEAKER_LAYOUT_STEREO) == DCA_SPEAKER_LAYOUT_STEREO) +enum DCASpeakerPair { +DCA_SPEAKER_PAIR_C = 0x0001, +DCA_SPEAKER_PAIR_LR = 0x0002, +DCA_SPEAKER_PAIR_LsRs = 0x0004, +DCA_SPEAKER_PAIR_LFE1 = 0x0008, +DCA_SPEAKER_PAIR_Cs = 0x0010, +DCA_SPEAKER_PAIR_LhRh = 0x0020, +DCA_SPEAKER_PAIR_LsrRsr = 0x0040, +DCA_SPEAKER_PAIR_Ch = 0x0080, +DCA_SPEAKER_PAIR_Oh = 0x0100, +DCA_SPEAKER_PAIR_LcRc = 0x0200, +DCA_SPEAKER_PAIR_LwRw = 0x0400, +DCA_SPEAKER_PAIR_LssRss = 0x0800, +DCA_SPEAKER_PAIR_LFE2 = 0x1000, +DCA_SPEAKER_PAIR_LhsRhs = 0x2000, +DCA_SPEAKER_PAIR_Chr= 0x4000, +DCA_SPEAKER_PAIR_LhrRhr = 0x8000 +}; + +/** + * Return number of individual channels in DCASpeakerPair mask + */ +static inline int ff_dca_count_chs_for_mask(unsigned int mask) +{ +return av_popcount((mask & 0x) | ((mask & 0xae66) << 16)); +} + enum DCARepresentationType { DCA_REPR_TYPE_LtRt = 2, DCA_REPR_TYPE_LhRh = 3 diff --git a/libavcodec/dca_exss.c b/libavcodec/dca_exss.c index 4579f23..36314c2 100644 --- a/libavcodec/dca_exss.c +++ b/libavcodec/dca_exss.c @@ -21,11 +21,6 @@ #include "dcadec.h" #include "dcadata.h" -static int count_chs_for_mask(int mask) -{ -return av_popcount(mask) + av_popcount(mask & 0xae66); -} - static void parse_xll_parameters(DCAExssParser *s, DCAExssAsset *asset) { // Size of XLL data in extension substream @@ -141,7 +136,7 @@ static int parse_descriptor(DCAExssParser *s, DCAExssAsset *asset) // Standard loudspeaker layout mask for (i = 0; i < spkr_remap_nsets; i++) -nspeakers[i] = count_chs_for_mask(get_bits(&s->gb, spkr_mask_nbits)); +nspeakers[i] = ff_dca_count_chs_for_mask(get_bits(&s->gb, spkr_mask_nbits)); for (i = 0; i < spkr_remap_nsets; i++) { // Number of channels to be decoded for speaker remapping @@ -470,7 +465,7 @@ int ff_dca_exss_parse(DCAExssParser *s, uint8_t *data, int size) // Speaker layout mask for mixer output channels for (i = 0; i < s->nmixoutconfigs; i++) -s->nmixoutchs[i] = count_chs_for_mask(get_bits(&s->gb, spkr_mask_nbits)); +s->nmixoutchs[i] = ff_dca_count_chs_for_mask(get_bits(&s->gb, spkr_mask_nbits)); } } else { s->npresents = 1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: move huffman data into separate object file
ffmpeg | branch: master | foo86 | Sun May 1 08:41:43 2016 -0700| [2df7d4fa4524b6f83c65428d75192267a2d0c113] | committer: James Almer avcodec/dca: move huffman data into separate object file Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2df7d4fa4524b6f83c65428d75192267a2d0c113 --- libavcodec/Makefile |2 +- libavcodec/dca_core.c | 70 +--- libavcodec/dca_core.h |2 +- libavcodec/dcadata.c |9 - libavcodec/dcadata.h |2 - libavcodec/dcadec.c |4 +- libavcodec/dcahuff.c | 1099 + libavcodec/dcahuff.h | 1023 + 8 files changed, 1124 insertions(+), 1087 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 8f63261..2fd43a0 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -230,7 +230,7 @@ OBJS-$(CONFIG_COMFORTNOISE_ENCODER)+= cngenc.o OBJS-$(CONFIG_CPIA_DECODER)+= cpia.o OBJS-$(CONFIG_CSCD_DECODER)+= cscd.o OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o -OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o\ +OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \ dca_core.o dca_exss.o dca_xll.o \ dcadsp.o dcadct.o synth_filter.o OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index d9f1a4c..fc4fdf4 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -100,62 +100,6 @@ static const uint8_t quant_index_group_size[DCA_CODE_BOOKS] = { 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 }; -typedef struct DCAVLC { -int offset; ///< Code values offset -int max_depth; ///< Parameter for get_vlc2() -VLC vlc[7]; ///< Actual codes -} DCAVLC; - -static DCAVLC vlc_bit_allocation; -static DCAVLC vlc_transition_mode; -static DCAVLC vlc_scale_factor; -static DCAVLC vlc_quant_index[DCA_CODE_BOOKS]; - -static av_cold void dca_init_vlcs(void) -{ -static VLC_TYPE dca_table[23622][2]; -static int vlcs_initialized = 0; -int i, j, k; - -if (vlcs_initialized) -return; - -#define DCA_INIT_VLC(vlc, a, b, c, d) \ -do { \ -vlc.table = &dca_table[ff_dca_vlc_offs[k]]; \ -vlc.table_allocated = ff_dca_vlc_offs[k + 1] - ff_dca_vlc_offs[k]; \ -init_vlc(&vlc, a, b, c, 1, 1, d, 2, 2, INIT_VLC_USE_NEW_STATIC); \ -} while (0) - -vlc_bit_allocation.offset= 1; -vlc_bit_allocation.max_depth = 2; -for (i = 0, k = 0; i < 5; i++, k++) -DCA_INIT_VLC(vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12, - bitalloc_12_bits[i], bitalloc_12_codes[i]); - -vlc_scale_factor.offset= -64; -vlc_scale_factor.max_depth = 2; -for (i = 0; i < 5; i++, k++) -DCA_INIT_VLC(vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129, - scales_bits[i], scales_codes[i]); - -vlc_transition_mode.offset= 0; -vlc_transition_mode.max_depth = 1; -for (i = 0; i < 4; i++, k++) -DCA_INIT_VLC(vlc_transition_mode.vlc[i], tmode_vlc_bits[i], 4, - tmode_bits[i], tmode_codes[i]); - -for (i = 0; i < DCA_CODE_BOOKS; i++) { -vlc_quant_index[i].offset= bitalloc_offsets[i]; -vlc_quant_index[i].max_depth = 1 + (i > 4); -for (j = 0; j < quant_index_group_size[i]; j++, k++) -DCA_INIT_VLC(vlc_quant_index[i].vlc[j], bitalloc_maxbits[i][j], - bitalloc_sizes[i], bitalloc_bits[i][j], bitalloc_codes[i][j]); -} - -vlcs_initialized = 1; -} - static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i) { return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, v->max_depth) + v->offset; @@ -498,7 +442,7 @@ static inline int parse_scale(DCACoreDecoder *s, int *scale_index, int sel) // If Huffman code was used, the difference of scales was encoded if (sel < 5) -*scale_index += dca_get_vlc(&s->gb, &vlc_scale_factor, sel); +*scale_index += dca_get_vlc(&s->gb, &ff_dca_vlc_scale_factor, sel); else *scale_index = get_bits(&s->gb, sel + 1); @@ -517,7 +461,7 @@ static inline int parse_joint_scale(DCACoreDecoder *s, int sel) // Absolute value was encoded even when Huffman code was used if (sel < 5) -scale_index = dca_get_vlc(&s->gb, &vlc_scale_factor, sel); +scale_index = dca_get_vlc(&s->gb, &ff_dca_vlc_scale_factor, sel); else scale_index = get_bits(&s->gb, sel + 1); @@ -569,7 +513,7 @@ static int parse_subframe_header(DCACoreDecoder *s, int sf,
[FFmpeg-cvslog] avcodec/dca: fix sync word search error condition
ffmpeg | branch: master | foo86 | Mon May 2 23:44:47 2016 +0300| [ce2f9fdb0a92956aedfa2c564d1374a2f1eebfbd] | committer: Michael Niedermayer avcodec/dca: fix sync word search error condition This didn't actually check if sync word was found and always errored out with "-err_detect explode" option enabled. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce2f9fdb0a92956aedfa2c564d1374a2f1eebfbd --- libavcodec/dca_core.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index fc4fdf4..58c78f7 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -1844,9 +1844,10 @@ static int parse_optional_info(DCACoreDecoder *s) } } -if (s->avctx->err_recognition & AV_EF_EXPLODE) { +if (!s->xch_pos) { av_log(s->avctx, AV_LOG_ERROR, "XCH sync word not found\n"); -return AVERROR_INVALIDDATA; +if (s->avctx->err_recognition & AV_EF_EXPLODE) +return AVERROR_INVALIDDATA; } break; @@ -1866,9 +1867,10 @@ static int parse_optional_info(DCACoreDecoder *s) } } -if (s->avctx->err_recognition & AV_EF_EXPLODE) { +if (!s->x96_pos) { av_log(s->avctx, AV_LOG_ERROR, "X96 sync word not found\n"); -return AVERROR_INVALIDDATA; +if (s->avctx->err_recognition & AV_EF_EXPLODE) +return AVERROR_INVALIDDATA; } break; @@ -1891,9 +1893,10 @@ static int parse_optional_info(DCACoreDecoder *s) } } -if (s->avctx->err_recognition & AV_EF_EXPLODE) { +if (!s->xxch_pos) { av_log(s->avctx, AV_LOG_ERROR, "XXCH sync word not found\n"); -return AVERROR_INVALIDDATA; +if (s->avctx->err_recognition & AV_EF_EXPLODE) +return AVERROR_INVALIDDATA; } break; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: fix sync word search error condition
ffmpeg | branch: release/3.0 | foo86 | Mon May 2 23:44:47 2016 +0300| [08c21bcb5dfd609167327a7900be6292fd0e51c1] | committer: James Almer avcodec/dca: fix sync word search error condition This didn't actually check if sync word was found and always errored out with "-err_detect explode" option enabled. Signed-off-by: Michael Niedermayer (cherry picked from commit ce2f9fdb0a92956aedfa2c564d1374a2f1eebfbd) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=08c21bcb5dfd609167327a7900be6292fd0e51c1 --- libavcodec/dca_core.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index d9f1a4c..19496e9 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -1900,9 +1900,10 @@ static int parse_optional_info(DCACoreDecoder *s) } } -if (s->avctx->err_recognition & AV_EF_EXPLODE) { +if (!s->xch_pos) { av_log(s->avctx, AV_LOG_ERROR, "XCH sync word not found\n"); -return AVERROR_INVALIDDATA; +if (s->avctx->err_recognition & AV_EF_EXPLODE) +return AVERROR_INVALIDDATA; } break; @@ -1922,9 +1923,10 @@ static int parse_optional_info(DCACoreDecoder *s) } } -if (s->avctx->err_recognition & AV_EF_EXPLODE) { +if (!s->x96_pos) { av_log(s->avctx, AV_LOG_ERROR, "X96 sync word not found\n"); -return AVERROR_INVALIDDATA; +if (s->avctx->err_recognition & AV_EF_EXPLODE) +return AVERROR_INVALIDDATA; } break; @@ -1947,9 +1949,10 @@ static int parse_optional_info(DCACoreDecoder *s) } } -if (s->avctx->err_recognition & AV_EF_EXPLODE) { +if (!s->xxch_pos) { av_log(s->avctx, AV_LOG_ERROR, "XXCH sync word not found\n"); -return AVERROR_INVALIDDATA; +if (s->avctx->err_recognition & AV_EF_EXPLODE) +return AVERROR_INVALIDDATA; } break; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/dca: convert to AVCRC
ffmpeg | branch: master | foo86 | Tue May 3 03:42:36 2016 +0300| [b7d267399b0ab53d2dc00ee191707df4cc8bd536] | committer: James Almer avcodec/dca: convert to AVCRC Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7d267399b0ab53d2dc00ee191707df4cc8bd536 --- libavcodec/dca_core.c | 25 ++--- libavcodec/dca_exss.c |3 +-- libavcodec/dca_xll.c |9 +++-- libavcodec/dcadec.c | 29 ++--- libavcodec/dcadec.h | 19 +-- 5 files changed, 33 insertions(+), 52 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 58c78f7..f6c22ca 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -269,8 +269,7 @@ static int parse_coding_header(DCACoreDecoder *s, enum HeaderType header, int xc // Check CRC if (s->xxch_crc_present -&& (s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) -&& ff_dca_check_crc(&s->gb, header_pos, header_pos + header_size * 8)) { +&& ff_dca_check_crc(s->avctx, &s->gb, header_pos, header_pos + header_size * 8)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid XXCH channel set header checksum\n"); return AVERROR_INVALIDDATA; } @@ -977,8 +976,7 @@ static int parse_xxch_frame(DCACoreDecoder *s) header_size = get_bits(&s->gb, 6) + 1; // Check XXCH frame header CRC -if ((s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) -&& ff_dca_check_crc(&s->gb, header_pos + 32, header_pos + header_size * 8)) { +if (ff_dca_check_crc(s->avctx, &s->gb, header_pos + 32, header_pos + header_size * 8)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid XXCH frame header checksum\n"); return AVERROR_INVALIDDATA; } @@ -1193,8 +1191,7 @@ static int parse_xbr_frame(DCACoreDecoder *s) header_size = get_bits(&s->gb, 6) + 1; // Check XBR frame header CRC -if ((s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) -&& ff_dca_check_crc(&s->gb, header_pos + 32, header_pos + header_size * 8)) { +if (ff_dca_check_crc(s->avctx, &s->gb, header_pos + 32, header_pos + header_size * 8)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid XBR frame header checksum\n"); return AVERROR_INVALIDDATA; } @@ -1509,8 +1506,7 @@ static int parse_x96_coding_header(DCACoreDecoder *s, int exss, int xch_base) // Check CRC if (s->x96_crc_present -&& (s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) -&& ff_dca_check_crc(&s->gb, header_pos, header_pos + header_size * 8)) { +&& ff_dca_check_crc(s->avctx, &s->gb, header_pos, header_pos + header_size * 8)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid X96 channel set header checksum\n"); return AVERROR_INVALIDDATA; } @@ -1665,8 +1661,7 @@ static int parse_x96_frame_exss(DCACoreDecoder *s) header_size = get_bits(&s->gb, 6) + 1; // Check X96 frame header CRC -if ((s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) -&& ff_dca_check_crc(&s->gb, header_pos + 32, header_pos + header_size * 8)) { +if (ff_dca_check_crc(s->avctx, &s->gb, header_pos + 32, header_pos + header_size * 8)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid X96 frame header checksum\n"); return AVERROR_INVALIDDATA; } @@ -1785,8 +1780,7 @@ static int parse_aux_data(DCACoreDecoder *s) skip_bits(&s->gb, 16); // Check CRC -if ((s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) -&& ff_dca_check_crc(&s->gb, aux_pos, get_bits_count(&s->gb))) { +if (ff_dca_check_crc(s->avctx, &s->gb, aux_pos, get_bits_count(&s->gb))) { av_log(s->avctx, AV_LOG_ERROR, "Invalid auxiliary data checksum\n"); return AVERROR_INVALIDDATA; } @@ -1884,9 +1878,10 @@ static int parse_optional_info(DCACoreDecoder *s) if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_XXCH) { s->gb.index = (sync_pos + 1) * 32; size = get_bits(&s->gb, 6) + 1; -if (size >= 11 && -!ff_dca_check_crc(&s->gb, (sync_pos + 1) * 32, - sync_pos * 32 + size * 8)) { +dist = s->gb.size_in_bits / 8 - sync_pos * 4; +if (size >= 11 && size <= dist && +!av_crc(dca->crctab, 0x, s->gb.buffer + +
[FFmpeg-cvslog] avformat/dtsdec: detect core-less streams
ffmpeg | branch: master | foo86 | Tue May 3 16:06:41 2016 +0300| [bb7c55807090ee77621c4a4692d00a231b722e1a] | committer: James Almer avformat/dtsdec: detect core-less streams Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bb7c55807090ee77621c4a4692d00a231b722e1a --- libavformat/dtsdec.c | 47 --- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c index ef28391..702a417 100644 --- a/libavformat/dtsdec.c +++ b/libavformat/dtsdec.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/crc.h" + #include "libavcodec/bytestream.h" #include "libavcodec/dca.h" #include "libavcodec/dca_syncwords.h" @@ -32,23 +34,51 @@ static int dts_probe(AVProbeData *p) const uint8_t *buf, *bufp; uint32_t state = -1; int markers[4*16] = {0}; -int sum, max, i; +int exss_markers = 0, exss_nextpos = 0; +int sum, max, pos, i; int64_t diff = 0; uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; +const AVCRC *crctab = av_crc_get_table(AV_CRC_16_CCITT); -buf = p->buf + FFMIN(4096, p->buf_size); - -for(; buf < (p->buf+p->buf_size)-2; buf+=2) { +for (pos = FFMIN(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) { int marker, sample_blocks, sample_rate, sr_code, framesize; -int lfe; +int lfe, wide_hdr, hdr_size; GetBitContext gb; -bufp = buf; +bufp = buf = p->buf + pos; state = (state << 16) | bytestream_get_be16(&bufp); -if (buf - p->buf >= 4) +if (pos >= 4) diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4)); +/* extension substream (EXSS) */ +if (state == DCA_SYNCWORD_SUBSTREAM) { +if (pos < exss_nextpos) +continue; + +init_get_bits(&gb, buf - 2, 96); +skip_bits_long(&gb, 42); + +wide_hdr = get_bits1(&gb); +hdr_size = get_bits(&gb, 8 + 4 * wide_hdr) + 1; +framesize = get_bits(&gb, 16 + 4 * wide_hdr) + 1; +if (hdr_size & 3 || framesize & 3) +continue; +if (hdr_size < 16 || framesize < hdr_size) +continue; +if (pos - 2 + hdr_size > p->buf_size) +continue; +if (av_crc(crctab, 0x, buf + 3, hdr_size - 5)) +continue; + +if (pos == exss_nextpos) +exss_markers++; +else +exss_markers = FFMAX(1, exss_markers - 1); +exss_nextpos = pos + framesize; +continue; +} + /* regular bitstream */ if (state == DCA_SYNCWORD_CORE_BE && (bytestream_get_be16(&bufp) & 0xFC00) == 0xFC00) @@ -103,6 +133,9 @@ static int dts_probe(AVProbeData *p) markers[marker] ++; } +if (exss_markers > 3) +return AVPROBE_SCORE_EXTENSION + 1; + sum = max = 0; for (i=0; ihttp://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog