[FFmpeg-cvslog] r11092 - in trunk: libavcodec/Makefile libavcodec/allcodecs.c libavcodec/avcodec.h libavcodec/pcm.c libavcodec/utils.c libavformat/electronicarts.c
aurel
subversion
Sun Nov 25 17:32:47 CET 2007
Author: aurel
Date: Sun Nov 25 17:32:47 2007
New Revision: 11092
Log:
add pcm_s16le_planar support for electronicarts files
Modified:
trunk/libavcodec/Makefile
trunk/libavcodec/allcodecs.c
trunk/libavcodec/avcodec.h
trunk/libavcodec/pcm.c
trunk/libavcodec/utils.c
trunk/libavformat/electronicarts.c
Modified: trunk/libavcodec/Makefile
==============================================================================
--- trunk/libavcodec/Makefile (original)
+++ trunk/libavcodec/Makefile Sun Nov 25 17:32:47 2007
@@ -245,6 +245,7 @@ OBJS-$(CONFIG_PCM_S24DAUD_DECODER) +
OBJS-$(CONFIG_PCM_S24DAUD_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_ENCODER) += pcm.o
+OBJS-$(CONFIG_PCM_S16LE_PLANAR_DECODER)+= pcm.o
OBJS-$(CONFIG_PCM_S16BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16BE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_U16LE_DECODER) += pcm.o
Modified: trunk/libavcodec/allcodecs.c
==============================================================================
--- trunk/libavcodec/allcodecs.c (original)
+++ trunk/libavcodec/allcodecs.c Sun Nov 25 17:32:47 2007
@@ -211,6 +211,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (PCM_S8, pcm_s8);
REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);
REGISTER_ENCDEC (PCM_S16LE, pcm_s16le);
+ REGISTER_DECODER (PCM_S16LE_PLANAR, pcm_s16le_planar);
REGISTER_ENCDEC (PCM_S24BE, pcm_s24be);
REGISTER_ENCDEC (PCM_S24DAUD, pcm_s24daud);
REGISTER_ENCDEC (PCM_S24LE, pcm_s24le);
Modified: trunk/libavcodec/avcodec.h
==============================================================================
--- trunk/libavcodec/avcodec.h (original)
+++ trunk/libavcodec/avcodec.h Sun Nov 25 17:32:47 2007
@@ -189,6 +189,7 @@ enum CodecID {
CODEC_ID_PCM_U24BE,
CODEC_ID_PCM_S24DAUD,
CODEC_ID_PCM_ZORK,
+ CODEC_ID_PCM_S16LE_PLANAR,
/* various ADPCM codecs */
CODEC_ID_ADPCM_IMA_QT= 0x11000,
Modified: trunk/libavcodec/pcm.c
==============================================================================
--- trunk/libavcodec/pcm.c (original)
+++ trunk/libavcodec/pcm.c Sun Nov 25 17:32:47 2007
@@ -28,6 +28,8 @@
#include "bitstream.h" // for ff_reverse
#include "bytestream.h"
+#define MAX_CHANNELS 64
+
/* from g711.c by SUN microsystems (unrestricted use) */
#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
@@ -374,15 +376,15 @@ static int pcm_decode_frame(AVCodecConte
uint8_t *buf, int buf_size)
{
PCMDecode *s = avctx->priv_data;
- int n;
+ int c, n;
short *samples;
- uint8_t *src;
+ uint8_t *src, *src2[MAX_CHANNELS];
samples = data;
src = buf;
n= av_get_bits_per_sample(avctx->codec_id)/8;
- if(n && buf_size % n){
+ if((n && buf_size % n) || avctx->channels > MAX_CHANNELS){
av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
return -1;
}
@@ -390,6 +392,10 @@ static int pcm_decode_frame(AVCodecConte
buf_size= FFMIN(buf_size, *data_size/2);
*data_size=0;
+ n = buf_size/avctx->channels;
+ for(c=0;c<avctx->channels;c++)
+ src2[c] = &src[c*n];
+
switch(avctx->codec->id) {
case CODEC_ID_PCM_S32LE:
decode_to16(4, 1, 0, &src, &samples, buf_size);
@@ -430,6 +436,12 @@ static int pcm_decode_frame(AVCodecConte
*samples++ = bytestream_get_le16(&src);
}
break;
+ case CODEC_ID_PCM_S16LE_PLANAR:
+ for(n>>=1;n>0;n--)
+ for(c=0;c<avctx->channels;c++)
+ *samples++ = bytestream_get_le16(&src2[c]);
+ src = src2[avctx->channels-1];
+ break;
case CODEC_ID_PCM_S16BE:
n = buf_size >> 1;
for(;n>0;n--) {
@@ -528,6 +540,7 @@ PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le)
PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
+PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, pcm_s16le_planar);
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
Modified: trunk/libavcodec/utils.c
==============================================================================
--- trunk/libavcodec/utils.c (original)
+++ trunk/libavcodec/utils.c Sun Nov 25 17:32:47 2007
@@ -1189,6 +1189,7 @@ void avcodec_string(char *buf, int buf_s
break;
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
+ case CODEC_ID_PCM_S16LE_PLANAR:
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE:
bitrate = enc->sample_rate * enc->channels * 16;
@@ -1314,6 +1315,7 @@ int av_get_bits_per_sample(enum CodecID
return 8;
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_S16LE:
+ case CODEC_ID_PCM_S16LE_PLANAR:
case CODEC_ID_PCM_U16BE:
case CODEC_ID_PCM_U16LE:
return 16;
Modified: trunk/libavformat/electronicarts.c
==============================================================================
--- trunk/libavformat/electronicarts.c (original)
+++ trunk/libavformat/electronicarts.c Sun Nov 25 17:32:47 2007
@@ -91,7 +91,7 @@ static int process_audio_header_elements
int inHeader = 1;
EaDemuxContext *ea = s->priv_data;
ByteIOContext *pb = s->pb;
- int compression_type = -1, revision = -1;
+ int compression_type = -1, revision = -1, revision2 = -1;
ea->bytes = 2;
ea->sample_rate = -1;
@@ -136,6 +136,10 @@ static int process_audio_header_elements
av_log (s, AV_LOG_INFO, "exited audio subheader\n");
inSubheader = 0;
break;
+ case 0xA0:
+ revision2 = read_arbitary(pb);
+ av_log (s, AV_LOG_INFO, "revision2 (element 0xA0) set to 0x%08x\n", revision2);
+ break;
case 0xFF:
av_log (s, AV_LOG_INFO, "end of header block reached (within audio subheader)\n");
inSubheader = 0;
@@ -165,10 +169,17 @@ static int process_audio_header_elements
case 1: ea->audio_codec = CODEC_ID_ADPCM_EA_R1; break;
case 2: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break;
case 3: ea->audio_codec = CODEC_ID_ADPCM_EA_R3; break;
+ case -1: break;
default:
av_log(s, AV_LOG_ERROR, "unsupported stream type; revision=%i\n", revision);
return 0;
}
+ switch (revision2) {
+ case 8: ea->audio_codec = CODEC_ID_PCM_S16LE_PLANAR; break;
+ default:
+ av_log(s, AV_LOG_ERROR, "unsupported stream type; revision2=%i\n", revision2);
+ return 0;
+ }
break;
default:
av_log(s, AV_LOG_ERROR, "unsupported stream type; compression_type=%i\n", compression_type);
@@ -392,6 +403,9 @@ static int ea_read_packet(AVFormatContex
if (!ea->audio_codec) {
url_fskip(pb, chunk_size);
break;
+ } else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR) {
+ url_fskip(pb, 12); /* planar header */
+ chunk_size -= 12;
}
ret = av_get_packet(pb, pkt, chunk_size);
if (ret != chunk_size)
More information about the ffmpeg-cvslog
mailing list