Message ID | 20201102093738.12430-2-zane@zanevaniperen.com |
---|---|
State | Superseded |
Headers | show |
Series | AMV muxing and adpcm_ima_amv encoding support | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
Zane van Iperen: > The format doesn't allow for anything else. > > Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> > --- > libavcodec/adpcm.c | 5 ++++- > libavcodec/utils.c | 2 +- > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c > index 701b125c47..d34fd6c6e1 100644 > --- a/libavcodec/adpcm.c > +++ b/libavcodec/adpcm.c > @@ -110,6 +110,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) > unsigned int max_channels = 2; > > switch(avctx->codec->id) { > + case AV_CODEC_ID_ADPCM_IMA_AMV: > case AV_CODEC_ID_ADPCM_IMA_CUNNING: > max_channels = 1; > break; > @@ -1684,6 +1685,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, > } > break; > case AV_CODEC_ID_ADPCM_IMA_AMV: > + av_assert0(avctx->channels == 1); > + Which check ensures that this assert won't be triggered? > c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); > c->status[0].step_index = bytestream2_get_byteu(&gb); > bytestream2_skipu(&gb, 5); > @@ -1693,7 +1696,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, > return AVERROR_INVALIDDATA; > } > > - for (n = nb_samples >> (1 - st); n > 0; n--) { > + for (n = nb_samples >> 1; n > 0; n--) { > int v = bytestream2_get_byteu(&gb); > > *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3); > diff --git a/libavcodec/utils.c b/libavcodec/utils.c > index 110496cc44..71d51ddad6 100644 > --- a/libavcodec/utils.c > +++ b/libavcodec/utils.c > @@ -1695,7 +1695,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, > case AV_CODEC_ID_ADPCM_IMA_SMJPEG: > return (frame_bytes - 4) * 2 / ch; > case AV_CODEC_ID_ADPCM_IMA_AMV: > - return (frame_bytes - 8) * 2 / ch; > + return (frame_bytes - 8) * 2; > case AV_CODEC_ID_ADPCM_THP: > case AV_CODEC_ID_ADPCM_THP_LE: > if (extradata) >
On 2/11/20 7:48 pm, Andreas Rheinhardt wrote: > > Zane van Iperen: >> The format doesn't allow for anything else. >> >> Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> >> --- >> libavcodec/adpcm.c | 5 ++++- >> libavcodec/utils.c | 2 +- >> 2 files changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c >> index 701b125c47..d34fd6c6e1 100644 >> --- a/libavcodec/adpcm.c >> +++ b/libavcodec/adpcm.c >> @@ -110,6 +110,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) >> unsigned int max_channels = 2; >> >> switch(avctx->codec->id) { >> + case AV_CODEC_ID_ADPCM_IMA_AMV: >> case AV_CODEC_ID_ADPCM_IMA_CUNNING: >> max_channels = 1; >> break; >> @@ -1684,6 +1685,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, >> } >> break; >> case AV_CODEC_ID_ADPCM_IMA_AMV: >> + av_assert0(avctx->channels == 1); >> + > > Which check ensures that this assert won't be triggered? > At the very top of the patch, just above "case AV_CODEC_ID_ADPCM_IMA_CUNNING:". max_channels is set to 1, so it'll bail before it gets to the assert.
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 701b125c47..d34fd6c6e1 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -110,6 +110,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) unsigned int max_channels = 2; switch(avctx->codec->id) { + case AV_CODEC_ID_ADPCM_IMA_AMV: case AV_CODEC_ID_ADPCM_IMA_CUNNING: max_channels = 1; break; @@ -1684,6 +1685,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_IMA_AMV: + av_assert0(avctx->channels == 1); + c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); c->status[0].step_index = bytestream2_get_byteu(&gb); bytestream2_skipu(&gb, 5); @@ -1693,7 +1696,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } - for (n = nb_samples >> (1 - st); n > 0; n--) { + for (n = nb_samples >> 1; n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 110496cc44..71d51ddad6 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1695,7 +1695,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, case AV_CODEC_ID_ADPCM_IMA_SMJPEG: return (frame_bytes - 4) * 2 / ch; case AV_CODEC_ID_ADPCM_IMA_AMV: - return (frame_bytes - 8) * 2 / ch; + return (frame_bytes - 8) * 2; case AV_CODEC_ID_ADPCM_THP: case AV_CODEC_ID_ADPCM_THP_LE: if (extradata)
The format doesn't allow for anything else. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> --- libavcodec/adpcm.c | 5 ++++- libavcodec/utils.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)