[FFmpeg-cvslog] avcodec/shorten: support decoding AIFF-C variant
Paul B Mahol
git at videolan.org
Fri Feb 24 00:03:36 EET 2017
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Feb 23 22:58:53 2017 +0100| [20789372da911ab46ce59667380126a87389190a] | committer: Paul B Mahol
avcodec/shorten: support decoding AIFF-C variant
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=20789372da911ab46ce59667380126a87389190a
---
configure | 2 +-
libavcodec/shorten.c | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 6431313..396333d 100755
--- a/configure
+++ b/configure
@@ -2513,7 +2513,7 @@ rv20_encoder_select="h263_encoder"
rv30_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp"
rv40_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp"
screenpresso_decoder_select="zlib"
-shorten_decoder_select="golomb"
+shorten_decoder_select="golomb bswapdsp"
sipr_decoder_select="lsp"
snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp"
snow_encoder_select="aandcttables dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder"
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index e4cef61..ff90d12 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -27,6 +27,7 @@
#include <limits.h>
#include "avcodec.h"
+#include "bswapdsp.h"
#include "bytestream.h"
#include "get_bits.h"
#include "golomb.h"
@@ -109,6 +110,8 @@ typedef struct ShortenContext {
int32_t lpcqoffset;
int got_header;
int got_quit_command;
+ int swap;
+ BswapDSPContext bdsp;
} ShortenContext;
static av_cold int shorten_decode_init(AVCodecContext *avctx)
@@ -116,6 +119,8 @@ static av_cold int shorten_decode_init(AVCodecContext *avctx)
ShortenContext *s = avctx->priv_data;
s->avctx = avctx;
+ ff_bswapdsp_init(&s->bdsp);
+
return 0;
}
@@ -202,6 +207,7 @@ static int init_offset(ShortenContext *s)
static int decode_aiff_header(AVCodecContext *avctx, const uint8_t *header,
int header_size)
{
+ ShortenContext *s = avctx->priv_data;
int len, bps, exp;
GetByteContext gb;
uint64_t val;
@@ -217,7 +223,8 @@ static int decode_aiff_header(AVCodecContext *avctx, const uint8_t *header,
bytestream2_skip(&gb, 4); /* chunk size */
tag = bytestream2_get_le32(&gb);
- if (tag != MKTAG('A', 'I', 'F', 'F')) {
+ if (tag != MKTAG('A', 'I', 'F', 'F') &&
+ tag != MKTAG('A', 'I', 'F', 'C')) {
av_log(avctx, AV_LOG_ERROR, "missing AIFF tag\n");
return AVERROR_INVALIDDATA;
}
@@ -241,6 +248,8 @@ static int decode_aiff_header(AVCodecContext *avctx, const uint8_t *header,
bps = bytestream2_get_be16(&gb);
avctx->bits_per_coded_sample = bps;
+ s->swap = tag == MKTAG('A', 'I', 'F', 'C');
+
if (bps != 16 && bps != 8) {
av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample: %d\n", bps);
return AVERROR(ENOSYS);
@@ -721,6 +730,11 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,
break;
}
}
+ if (s->swap && s->internal_ftype != TYPE_U8)
+ s->bdsp.bswap16_buf(((uint16_t **)frame->extended_data)[chan],
+ ((uint16_t **)frame->extended_data)[chan],
+ s->blocksize);
+
}
*got_frame_ptr = 1;
More information about the ffmpeg-cvslog
mailing list