diff options
Diffstat (limited to 'ffmpeg/libavcodec/mlpdec.c')
| -rw-r--r-- | ffmpeg/libavcodec/mlpdec.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/ffmpeg/libavcodec/mlpdec.c b/ffmpeg/libavcodec/mlpdec.c index a7c79a4..88cafc2 100644 --- a/ffmpeg/libavcodec/mlpdec.c +++ b/ffmpeg/libavcodec/mlpdec.c @@ -27,6 +27,7 @@ #include <stdint.h> #include "avcodec.h" +#include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/channel_layout.h" #include "get_bits.h" @@ -362,10 +363,22 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) * substream is Stereo. Subsequent substreams' layouts are indicated in the * major sync. */ if (m->avctx->codec_id == AV_CODEC_ID_MLP) { + if (mh.stream_type != 0xbb) { + avpriv_request_sample(m->avctx, + "unexpected stream_type %X in MLP", + mh.stream_type); + return AVERROR_PATCHWELCOME; + } if ((substr = (mh.num_substreams > 1))) m->substream[0].ch_layout = AV_CH_LAYOUT_STEREO; m->substream[substr].ch_layout = mh.channel_layout_mlp; } else { + if (mh.stream_type != 0xba) { + avpriv_request_sample(m->avctx, + "unexpected stream_type %X in !MLP", + mh.stream_type); + return AVERROR_PATCHWELCOME; + } if ((substr = (mh.num_substreams > 1))) m->substream[0].ch_layout = AV_CH_LAYOUT_STEREO; if (mh.num_substreams > 2) @@ -401,10 +414,10 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, uint8_t checksum; uint8_t lossless_check; int start_count = get_bits_count(gbp); - const int max_matrix_channel = m->avctx->codec_id == AV_CODEC_ID_MLP - ? MAX_MATRIX_CHANNEL_MLP - : MAX_MATRIX_CHANNEL_TRUEHD; - int max_channel, min_channel, matrix_channel; + int min_channel, max_channel, max_matrix_channel; + const int std_max_matrix_channel = m->avctx->codec_id == AV_CODEC_ID_MLP + ? MAX_MATRIX_CHANNEL_MLP + : MAX_MATRIX_CHANNEL_TRUEHD; sync_word = get_bits(gbp, 13); @@ -423,18 +436,18 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, skip_bits(gbp, 16); /* Output timestamp */ - min_channel = get_bits(gbp, 4); - max_channel = get_bits(gbp, 4); - matrix_channel = get_bits(gbp, 4); + min_channel = get_bits(gbp, 4); + max_channel = get_bits(gbp, 4); + max_matrix_channel = get_bits(gbp, 4); - if (matrix_channel > max_matrix_channel) { + if (max_matrix_channel > std_max_matrix_channel) { av_log(m->avctx, AV_LOG_ERROR, "Max matrix channel cannot be greater than %d.\n", - max_matrix_channel); + std_max_matrix_channel); return AVERROR_INVALIDDATA; } - if (max_channel != matrix_channel) { + if (max_channel != max_matrix_channel) { av_log(m->avctx, AV_LOG_ERROR, "Max channel must be equal max matrix channel.\n"); return AVERROR_INVALIDDATA; @@ -456,11 +469,12 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, return AVERROR_INVALIDDATA; } - s->min_channel = min_channel; - s->max_channel = max_channel; - s->max_matrix_channel = matrix_channel; + s->min_channel = min_channel; + s->max_channel = max_channel; + s->max_matrix_channel = max_matrix_channel; #if FF_API_REQUEST_CHANNELS +FF_DISABLE_DEPRECATION_WARNINGS if (m->avctx->request_channels > 0 && m->avctx->request_channels <= s->max_channel + 1 && m->max_decoded_substream > substr) { @@ -469,6 +483,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, "Further substreams will be skipped.\n", s->max_channel + 1, substr); m->max_decoded_substream = substr; +FF_ENABLE_DEPRECATION_WARNINGS } else #endif if (m->avctx->request_channel_layout == s->ch_layout && @@ -635,7 +650,7 @@ static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, /* TODO: Check validity of state data. */ for (i = 0; i < order; i++) - fp->state[i] = get_sbits(gbp, state_bits) << state_shift; + fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0; } } @@ -1067,7 +1082,7 @@ static int read_access_unit(AVCodecContext *avctx, void* data, int ret; if (buf_size < 4) - return 0; + return AVERROR_INVALIDDATA; length = (AV_RB16(buf) & 0xfff) * 2; @@ -1249,24 +1264,24 @@ error: #if CONFIG_MLP_DECODER AVCodec ff_mlp_decoder = { .name = "mlp", + .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_MLP, .priv_data_size = sizeof(MLPDecodeContext), .init = mlp_decode_init, .decode = read_access_unit, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"), }; #endif #if CONFIG_TRUEHD_DECODER AVCodec ff_truehd_decoder = { .name = "truehd", + .long_name = NULL_IF_CONFIG_SMALL("TrueHD"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_TRUEHD, .priv_data_size = sizeof(MLPDecodeContext), .init = mlp_decode_init, .decode = read_access_unit, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("TrueHD"), }; #endif /* CONFIG_TRUEHD_DECODER */ |
