1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

add CODEC_ID_PCM_F32BE (32-bit floating point PCM big endian decoder)

Originally committed as revision 14409 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Peter Ross 2008-07-26 07:08:15 +00:00
parent fef744d404
commit aa29709ec8
5 changed files with 40 additions and 1 deletions

View File

@ -639,6 +639,7 @@ static void do_audio_out(AVFormatContext *s,
case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32LE:
case CODEC_ID_PCM_U32BE: case CODEC_ID_PCM_U32BE:
case CODEC_ID_PCM_F32BE:
size_out = size_out << 1; size_out = size_out << 1;
break; break;
case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24LE:

View File

@ -218,6 +218,7 @@ void avcodec_register_all(void)
/* PCM codecs */ /* PCM codecs */
REGISTER_ENCDEC (PCM_ALAW, pcm_alaw); REGISTER_ENCDEC (PCM_ALAW, pcm_alaw);
REGISTER_DECODER (PCM_DVD, pcm_dvd); REGISTER_DECODER (PCM_DVD, pcm_dvd);
REGISTER_ENCDEC (PCM_F32BE, pcm_f32be);
REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw); REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw);
REGISTER_ENCDEC (PCM_S8, pcm_s8); REGISTER_ENCDEC (PCM_S8, pcm_s8);
REGISTER_ENCDEC (PCM_S16BE, pcm_s16be); REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);

View File

@ -30,7 +30,7 @@
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#define LIBAVCODEC_VERSION_MAJOR 51 #define LIBAVCODEC_VERSION_MAJOR 51
#define LIBAVCODEC_VERSION_MINOR 60 #define LIBAVCODEC_VERSION_MINOR 61
#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@ -210,6 +210,7 @@ enum CodecID {
CODEC_ID_PCM_ZORK, CODEC_ID_PCM_ZORK,
CODEC_ID_PCM_S16LE_PLANAR, CODEC_ID_PCM_S16LE_PLANAR,
CODEC_ID_PCM_DVD, CODEC_ID_PCM_DVD,
CODEC_ID_PCM_F32BE,
/* various ADPCM codecs */ /* various ADPCM codecs */
CODEC_ID_ADPCM_IMA_QT= 0x11000, CODEC_ID_ADPCM_IMA_QT= 0x11000,

View File

@ -107,6 +107,9 @@ static av_cold void build_xlaw_table(uint8_t *linear_to_xlaw,
static av_cold int pcm_encode_init(AVCodecContext *avctx) static av_cold int pcm_encode_init(AVCodecContext *avctx)
{ {
avctx->frame_size = 1; avctx->frame_size = 1;
if (avctx->codec->id==CODEC_ID_PCM_F32BE && avctx->sample_fmt!=SAMPLE_FMT_FLT) {
return -1;
}
switch(avctx->codec->id) { switch(avctx->codec->id) {
case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_ALAW:
build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5); build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5);
@ -123,6 +126,7 @@ static av_cold int pcm_encode_init(AVCodecContext *avctx)
case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32LE:
case CODEC_ID_PCM_U32BE: case CODEC_ID_PCM_U32BE:
case CODEC_ID_PCM_F32BE:
avctx->block_align = 4 * avctx->channels; avctx->block_align = 4 * avctx->channels;
break; break;
case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24LE:
@ -198,6 +202,7 @@ static int pcm_encode_frame(AVCodecContext *avctx,
case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32LE:
case CODEC_ID_PCM_U32BE: case CODEC_ID_PCM_U32BE:
case CODEC_ID_PCM_F32BE:
sample_size = 4; sample_size = 4;
break; break;
case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24LE:
@ -222,6 +227,16 @@ static int pcm_encode_frame(AVCodecContext *avctx,
dst = frame; dst = frame;
switch(avctx->codec->id) { switch(avctx->codec->id) {
case CODEC_ID_PCM_F32BE:
{
float *fsamples = data;
for(;n>0;n--) {
float fv = *fsamples++;
bytestream_put_be32(&dst, av_flt2int(fv));
}
samples = (void*)fsamples;
}
break;
case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32LE:
encode_from16(4, 1, 0, &samples, &dst, n); encode_from16(4, 1, 0, &samples, &dst, n);
break; break;
@ -342,6 +357,15 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx)
default: default:
break; break;
} }
switch(avctx->codec->id) {
case CODEC_ID_PCM_F32BE:
avctx->sample_fmt = SAMPLE_FMT_FLT;
break;
default:
avctx->sample_fmt = SAMPLE_FMT_S16;
break;
}
return 0; return 0;
} }
@ -407,6 +431,15 @@ static int pcm_decode_frame(AVCodecContext *avctx,
src2[c] = &src[c*n]; src2[c] = &src[c*n];
switch(avctx->codec->id) { switch(avctx->codec->id) {
case CODEC_ID_PCM_F32BE:
{
float *fsamples = data;
n = buf_size >> 2;
for(;n>0;n--)
*fsamples++ = av_int2flt(bytestream_get_be32(&src));
samples = (void*)fsamples;
break;
}
case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32LE:
decode_to16(4, 1, 0, &src, &samples, buf_size); decode_to16(4, 1, 0, &src, &samples, buf_size);
break; break;
@ -559,6 +592,7 @@ AVCodec name ## _decoder = { \
/* Note: Do not forget to add new entries to the Makefile as well. */ /* Note: Do not forget to add new entries to the Makefile as well. */
PCM_CODEC (CODEC_ID_PCM_ALAW, pcm_alaw, "A-law PCM"); PCM_CODEC (CODEC_ID_PCM_ALAW, pcm_alaw, "A-law PCM");
PCM_CODEC (CODEC_ID_PCM_DVD, pcm_dvd, "signed 16|20|24-bit big-endian PCM"); PCM_CODEC (CODEC_ID_PCM_DVD, pcm_dvd, "signed 16|20|24-bit big-endian PCM");
PCM_CODEC (CODEC_ID_PCM_F32BE, pcm_f32be, "32-bit floating point big-endian PCM");
PCM_CODEC (CODEC_ID_PCM_MULAW, pcm_mulaw, "mu-law PCM"); PCM_CODEC (CODEC_ID_PCM_MULAW, pcm_mulaw, "mu-law PCM");
PCM_CODEC (CODEC_ID_PCM_S8, pcm_s8, "signed 8-bit PCM"); PCM_CODEC (CODEC_ID_PCM_S8, pcm_s8, "signed 8-bit PCM");
PCM_CODEC (CODEC_ID_PCM_S16BE, pcm_s16be, "signed 16-bit big-endian PCM"); PCM_CODEC (CODEC_ID_PCM_S16BE, pcm_s16be, "signed 16-bit big-endian PCM");

View File

@ -1155,6 +1155,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32LE:
case CODEC_ID_PCM_U32BE: case CODEC_ID_PCM_U32BE:
case CODEC_ID_PCM_F32BE:
bitrate = enc->sample_rate * enc->channels * 32; bitrate = enc->sample_rate * enc->channels * 32;
break; break;
case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24LE:
@ -1301,6 +1302,7 @@ int av_get_bits_per_sample(enum CodecID codec_id){
case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_U32BE: case CODEC_ID_PCM_U32BE:
case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32LE:
case CODEC_ID_PCM_F32BE:
return 32; return 32;
default: default:
return 0; return 0;