Commit c3e81d0c authored by pross's avatar pross

Use memcpy() for PCM S16/S32 codecs when codec byte-order matches machine byte-order.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@14784 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent e6fb6740
...@@ -172,13 +172,6 @@ static int pcm_encode_frame(AVCodecContext *avctx, ...@@ -172,13 +172,6 @@ static int pcm_encode_frame(AVCodecContext *avctx,
} }
switch(avctx->codec->id) { switch(avctx->codec->id) {
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
ENCODE(int32_t, be32, samples, dst, n, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
ENCODE(int32_t, le32, samples, dst, n, 0, 0)
break;
case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32LE:
ENCODE(uint32_t, le32, samples, dst, n, 0, 0x80000000) ENCODE(uint32_t, le32, samples, dst, n, 0, 0x80000000)
break; break;
...@@ -206,12 +199,6 @@ static int pcm_encode_frame(AVCodecContext *avctx, ...@@ -206,12 +199,6 @@ static int pcm_encode_frame(AVCodecContext *avctx,
samples++; samples++;
} }
break; break;
case CODEC_ID_PCM_S16LE:
ENCODE(int16_t, le16, samples, dst, n, 0, 0)
break;
case CODEC_ID_PCM_S16BE:
ENCODE(int16_t, be16, samples, dst, n, 0, 0)
break;
case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16LE:
ENCODE(uint16_t, le16, samples, dst, n, 0, 0x8000) ENCODE(uint16_t, le16, samples, dst, n, 0, 0x8000)
break; break;
...@@ -225,9 +212,30 @@ static int pcm_encode_frame(AVCodecContext *avctx, ...@@ -225,9 +212,30 @@ static int pcm_encode_frame(AVCodecContext *avctx,
*dst++ = v - 128; *dst++ = v - 128;
} }
break; break;
#if WORDS_BIGENDIAN
case CODEC_ID_PCM_S32LE:
ENCODE(int32_t, le32, samples, dst, n, 0, 0)
break;
case CODEC_ID_PCM_S16LE:
ENCODE(int16_t, le16, samples, dst, n, 0, 0)
break;
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_S16BE:
#else
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
ENCODE(int32_t, be32, samples, dst, n, 0, 0)
break;
case CODEC_ID_PCM_S16BE:
ENCODE(int16_t, be16, samples, dst, n, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_S16LE:
#endif /* WORDS_BIGENDIAN */
case CODEC_ID_PCM_U8: case CODEC_ID_PCM_U8:
memcpy(dst, samples, n); memcpy(dst, samples, n*sample_size);
dst += n; dst += n*sample_size;
break; break;
case CODEC_ID_PCM_ZORK: case CODEC_ID_PCM_ZORK:
for(;n>0;n--) { for(;n>0;n--) {
...@@ -347,13 +355,6 @@ static int pcm_decode_frame(AVCodecContext *avctx, ...@@ -347,13 +355,6 @@ static int pcm_decode_frame(AVCodecContext *avctx,
n = buf_size/sample_size; n = buf_size/sample_size;
switch(avctx->codec->id) { switch(avctx->codec->id) {
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
DECODE(int32_t, be32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
DECODE(int32_t, le32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32LE:
DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000) DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000)
break; break;
...@@ -380,9 +381,6 @@ static int pcm_decode_frame(AVCodecContext *avctx, ...@@ -380,9 +381,6 @@ static int pcm_decode_frame(AVCodecContext *avctx,
(ff_reverse[v & 0xff] << 8); (ff_reverse[v & 0xff] << 8);
} }
break; break;
case CODEC_ID_PCM_S16LE:
DECODE(int16_t, le16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16LE_PLANAR: case CODEC_ID_PCM_S16LE_PLANAR:
n /= avctx->channels; n /= avctx->channels;
for(c=0;c<avctx->channels;c++) for(c=0;c<avctx->channels;c++)
...@@ -392,9 +390,6 @@ static int pcm_decode_frame(AVCodecContext *avctx, ...@@ -392,9 +390,6 @@ static int pcm_decode_frame(AVCodecContext *avctx,
*samples++ = bytestream_get_le16(&src2[c]); *samples++ = bytestream_get_le16(&src2[c]);
src = src2[avctx->channels-1]; src = src2[avctx->channels-1];
break; break;
case CODEC_ID_PCM_S16BE:
DECODE(int16_t, be16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16LE:
DECODE(uint16_t, le16, src, samples, n, 0, 0x8000) DECODE(uint16_t, le16, src, samples, n, 0, 0x8000)
break; break;
...@@ -408,10 +403,31 @@ static int pcm_decode_frame(AVCodecContext *avctx, ...@@ -408,10 +403,31 @@ static int pcm_decode_frame(AVCodecContext *avctx,
} }
samples= (short*)dstu8; samples= (short*)dstu8;
break; break;
#if WORDS_BIGENDIAN
case CODEC_ID_PCM_S32LE:
DECODE(int32_t, le32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16LE:
DECODE(int16_t, le16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_S16BE:
#else
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
DECODE(int32_t, be32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16BE:
DECODE(int16_t, be16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_S16LE:
#endif /* WORDS_BIGENDIAN */
case CODEC_ID_PCM_U8: case CODEC_ID_PCM_U8:
memcpy(samples, src, n); memcpy(samples, src, n*sample_size);
src += n; src += n*sample_size;
samples = (short*)((uint8_t*)data + n); samples = (short*)((uint8_t*)data + n*sample_size);
break; break;
case CODEC_ID_PCM_ZORK: case CODEC_ID_PCM_ZORK:
for(;n>0;n--) { for(;n>0;n--) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment