summaryrefslogtreecommitdiff
path: root/libavcodec/pcm-mpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-13 01:56:33 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-13 01:56:33 +0100
commitb25a265a5c921d2d223a8aeff2f918894d515934 (patch)
tree480f9648f685220520a344ac293f66e307abfc5c /libavcodec/pcm-mpeg.c
parent2d38081b4f65f23077cb1b27f2d08c82c45afa05 (diff)
parentbd3e07c82ae558c2cc3616115161827630826ec1 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: pcm-mpeg: convert to bytestream2 API Revert "h264: clear trailing bits in partially parsed NAL units" remove iwmmxt optimizations mimic: do not continue if swap_buf_size is 0 mimic: convert to bytestream2 API frwu: use MKTAG to check marker instead of AV_RL32 txd: port to bytestream2 API c93: convert to bytestream2 API iff: make .long_name more descriptive FATE: add test for cdxl demuxer rtsp: Fix a typo Conflicts: libavcodec/arm/dsputil_iwmmxt.c libavcodec/arm/dsputil_iwmmxt_rnd_template.c libavcodec/arm/mpegvideo_iwmmxt.c libavcodec/c93.c libavcodec/txd.c libavutil/arm/cpu.c tests/fate/demux.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pcm-mpeg.c')
-rw-r--r--libavcodec/pcm-mpeg.c110
1 files changed, 56 insertions, 54 deletions
diff --git a/libavcodec/pcm-mpeg.c b/libavcodec/pcm-mpeg.c
index aea3ff79c6..9c49a0d9ec 100644
--- a/libavcodec/pcm-mpeg.c
+++ b/libavcodec/pcm-mpeg.c
@@ -141,6 +141,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
const uint8_t *src = avpkt->data;
int buf_size = avpkt->size;
PCMBRDecode *s = avctx->priv_data;
+ GetByteContext gb;
int num_source_channels, channel, retval;
int sample_size, samples;
int16_t *dst16;
@@ -156,6 +157,8 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
src += 4;
buf_size -= 4;
+ bytestream2_init(&gb, src, buf_size);
+
/* There's always an even number of channels in the source */
num_source_channels = FFALIGN(avctx->channels, 2);
sample_size = (num_source_channels * (avctx->sample_fmt == AV_SAMPLE_FMT_S16 ? 16 : 24)) >> 3;
@@ -179,15 +182,15 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
samples *= num_source_channels;
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
#if HAVE_BIGENDIAN
- memcpy(dst16, src, buf_size);
+ bytestream2_get_buffer(&gb, dst16, buf_size);
#else
do {
- *dst16++ = bytestream_get_be16(&src);
+ *dst16++ = bytestream2_get_be16u(&gb);
} while (--samples);
#endif
} else {
do {
- *dst32++ = bytestream_get_be24(&src) << 8;
+ *dst32++ = bytestream2_get_be24u(&gb) << 8;
} while (--samples);
}
break;
@@ -199,24 +202,23 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
#if HAVE_BIGENDIAN
- memcpy(dst16, src, avctx->channels * 2);
+ bytestream2_get_buffer(&gb, dst16, avctx->channels * 2);
dst16 += avctx->channels;
- src += sample_size;
#else
channel = avctx->channels;
do {
- *dst16++ = bytestream_get_be16(&src);
+ *dst16++ = bytestream2_get_be16u(&gb);
} while (--channel);
- src += 2;
#endif
+ bytestream2_skip(&gb, 2);
} while (--samples);
} else {
do {
channel = avctx->channels;
do {
- *dst32++ = bytestream_get_be24(&src) << 8;
+ *dst32++ = bytestream2_get_be24u(&gb) << 8;
} while (--channel);
- src += 3;
+ bytestream2_skip(&gb, 3);
} while (--samples);
}
break;
@@ -224,22 +226,22 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
case AV_CH_LAYOUT_5POINT1:
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
- dst16[0] = bytestream_get_be16(&src);
- dst16[1] = bytestream_get_be16(&src);
- dst16[2] = bytestream_get_be16(&src);
- dst16[4] = bytestream_get_be16(&src);
- dst16[5] = bytestream_get_be16(&src);
- dst16[3] = bytestream_get_be16(&src);
+ dst16[0] = bytestream2_get_be16u(&gb);
+ dst16[1] = bytestream2_get_be16u(&gb);
+ dst16[2] = bytestream2_get_be16u(&gb);
+ dst16[4] = bytestream2_get_be16u(&gb);
+ dst16[5] = bytestream2_get_be16u(&gb);
+ dst16[3] = bytestream2_get_be16u(&gb);
dst16 += 6;
} while (--samples);
} else {
do {
- dst32[0] = bytestream_get_be24(&src) << 8;
- dst32[1] = bytestream_get_be24(&src) << 8;
- dst32[2] = bytestream_get_be24(&src) << 8;
- dst32[4] = bytestream_get_be24(&src) << 8;
- dst32[5] = bytestream_get_be24(&src) << 8;
- dst32[3] = bytestream_get_be24(&src) << 8;
+ dst32[0] = bytestream2_get_be24u(&gb) << 8;
+ dst32[1] = bytestream2_get_be24u(&gb) << 8;
+ dst32[2] = bytestream2_get_be24u(&gb) << 8;
+ dst32[4] = bytestream2_get_be24u(&gb) << 8;
+ dst32[5] = bytestream2_get_be24u(&gb) << 8;
+ dst32[3] = bytestream2_get_be24u(&gb) << 8;
dst32 += 6;
} while (--samples);
}
@@ -248,27 +250,27 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
case AV_CH_LAYOUT_7POINT0:
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
- dst16[0] = bytestream_get_be16(&src);
- dst16[1] = bytestream_get_be16(&src);
- dst16[2] = bytestream_get_be16(&src);
- dst16[5] = bytestream_get_be16(&src);
- dst16[3] = bytestream_get_be16(&src);
- dst16[4] = bytestream_get_be16(&src);
- dst16[6] = bytestream_get_be16(&src);
+ dst16[0] = bytestream2_get_be16u(&gb);
+ dst16[1] = bytestream2_get_be16u(&gb);
+ dst16[2] = bytestream2_get_be16u(&gb);
+ dst16[5] = bytestream2_get_be16u(&gb);
+ dst16[3] = bytestream2_get_be16u(&gb);
+ dst16[4] = bytestream2_get_be16u(&gb);
+ dst16[6] = bytestream2_get_be16u(&gb);
dst16 += 7;
- src += 2;
+ bytestream2_skip(&gb, 2);
} while (--samples);
} else {
do {
- dst32[0] = bytestream_get_be24(&src) << 8;
- dst32[1] = bytestream_get_be24(&src) << 8;
- dst32[2] = bytestream_get_be24(&src) << 8;
- dst32[5] = bytestream_get_be24(&src) << 8;
- dst32[3] = bytestream_get_be24(&src) << 8;
- dst32[4] = bytestream_get_be24(&src) << 8;
- dst32[6] = bytestream_get_be24(&src) << 8;
+ dst32[0] = bytestream2_get_be24u(&gb) << 8;
+ dst32[1] = bytestream2_get_be24u(&gb) << 8;
+ dst32[2] = bytestream2_get_be24u(&gb) << 8;
+ dst32[5] = bytestream2_get_be24u(&gb) << 8;
+ dst32[3] = bytestream2_get_be24u(&gb) << 8;
+ dst32[4] = bytestream2_get_be24u(&gb) << 8;
+ dst32[6] = bytestream2_get_be24u(&gb) << 8;
dst32 += 7;
- src += 3;
+ bytestream2_skip(&gb, 3);
} while (--samples);
}
break;
@@ -276,26 +278,26 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
case AV_CH_LAYOUT_7POINT1:
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
- dst16[0] = bytestream_get_be16(&src);
- dst16[1] = bytestream_get_be16(&src);
- dst16[2] = bytestream_get_be16(&src);
- dst16[6] = bytestream_get_be16(&src);
- dst16[4] = bytestream_get_be16(&src);
- dst16[5] = bytestream_get_be16(&src);
- dst16[7] = bytestream_get_be16(&src);
- dst16[3] = bytestream_get_be16(&src);
+ dst16[0] = bytestream2_get_be16u(&gb);
+ dst16[1] = bytestream2_get_be16u(&gb);
+ dst16[2] = bytestream2_get_be16u(&gb);
+ dst16[6] = bytestream2_get_be16u(&gb);
+ dst16[4] = bytestream2_get_be16u(&gb);
+ dst16[5] = bytestream2_get_be16u(&gb);
+ dst16[7] = bytestream2_get_be16u(&gb);
+ dst16[3] = bytestream2_get_be16u(&gb);
dst16 += 8;
} while (--samples);
} else {
do {
- dst32[0] = bytestream_get_be24(&src) << 8;
- dst32[1] = bytestream_get_be24(&src) << 8;
- dst32[2] = bytestream_get_be24(&src) << 8;
- dst32[6] = bytestream_get_be24(&src) << 8;
- dst32[4] = bytestream_get_be24(&src) << 8;
- dst32[5] = bytestream_get_be24(&src) << 8;
- dst32[7] = bytestream_get_be24(&src) << 8;
- dst32[3] = bytestream_get_be24(&src) << 8;
+ dst32[0] = bytestream2_get_be24u(&gb) << 8;
+ dst32[1] = bytestream2_get_be24u(&gb) << 8;
+ dst32[2] = bytestream2_get_be24u(&gb) << 8;
+ dst32[6] = bytestream2_get_be24u(&gb) << 8;
+ dst32[4] = bytestream2_get_be24u(&gb) << 8;
+ dst32[5] = bytestream2_get_be24u(&gb) << 8;
+ dst32[7] = bytestream2_get_be24u(&gb) << 8;
+ dst32[3] = bytestream2_get_be24u(&gb) << 8;
dst32 += 8;
} while (--samples);
}
@@ -306,7 +308,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
- retval = src - avpkt->data;
+ retval = bytestream2_tell(&gb);
if (avctx->debug & FF_DEBUG_BITSTREAM)
av_dlog(avctx, "pcm_bluray_decode_frame: decoded %d -> %d bytes\n",
retval, buf_size);