summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/cook.c2
-rw-r--r--apps/codecs/libcook/cook.c25
-rw-r--r--apps/codecs/libcook/main.c6
-rw-r--r--apps/codecs/librm/rm.c31
-rw-r--r--apps/codecs/librm/rm.h16
-rw-r--r--apps/metadata/rm.c33
6 files changed, 45 insertions, 68 deletions
diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c
index fe818be905..ec30b3e6bc 100644
--- a/apps/codecs/cook.c
+++ b/apps/codecs/cook.c
@@ -156,7 +156,7 @@ seek_start :
return CODEC_ERROR;
}
- ci->pcmbuf_insert(outbuf, NULL, rmctx.samples_pf_pc / rmctx.nb_channels);
+ ci->pcmbuf_insert(outbuf, NULL, q.samples_per_frame / rmctx.nb_channels);
ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i);
}
packet_count -= rmctx.audio_pkt_cnt;
diff --git a/apps/codecs/libcook/cook.c b/apps/codecs/libcook/cook.c
index ba5fbab6a1..315fe0aaff 100644
--- a/apps/codecs/libcook/cook.c
+++ b/apps/codecs/libcook/cook.c
@@ -708,16 +708,27 @@ static void dump_cook_context(COOKContext *q)
* Cook initialization
*/
-int cook_decode_init(RMContext *rmctx, COOKContext *q)
-{
+static inline uint16_t get_uint16be(uint8_t *buf)
+{
+ return (uint16_t)((buf[0] << 8)|buf[1]);
+}
+
+static inline uint32_t get_uint32be(uint8_t *buf)
+{
+ return (uint32_t)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
+}
+
+ int cook_decode_init(RMContext *rmctx, COOKContext *q)
+ {
+
/* cook extradata */
- q->cookversion = rmctx->cook_version;
- q->samples_per_frame = rmctx->samples_pf_pc;
- q->subbands = rmctx->nb_subbands;
+ q->cookversion = get_uint32be(rmctx->codec_extradata);
+ q->samples_per_frame = get_uint16be(&rmctx->codec_extradata[4]);
+ q->subbands = get_uint16be(&rmctx->codec_extradata[6]);
q->extradata_size = rmctx->extradata_size;
if (q->extradata_size >= 16){
- q->js_subband_start = rmctx->js_subband_start;
- q->js_vlc_bits = rmctx->js_vlc_bits;
+ q->js_subband_start = get_uint16be(&rmctx->codec_extradata[12]);
+ q->js_vlc_bits = get_uint16be(&rmctx->codec_extradata[14]);
}
/* Take data from the RMContext (RM container). */
diff --git a/apps/codecs/libcook/main.c b/apps/codecs/libcook/main.c
index fd20f98871..3f5d3e8528 100644
--- a/apps/codecs/libcook/main.c
+++ b/apps/codecs/libcook/main.c
@@ -58,11 +58,11 @@ int open_wav(char* filename) {
return(fd);
}
-void close_wav(int fd, RMContext *rmctx) {
+void close_wav(int fd, RMContext *rmctx, COOKContext *q) {
int x,res;
int filesize;
int bytes_per_sample = 2;
- int samples_per_frame = rmctx->samples_pf_pc;
+ int samples_per_frame = q->samples_per_frame;
int nb_channels = rmctx->nb_channels;
int sample_rate = rmctx->sample_rate;
int nb_frames = rmctx->audio_framesize/rmctx->block_align * rmctx->nb_packets - 2; // first 2 frames have no valid audio; skipped in output
@@ -182,7 +182,7 @@ int main(int argc, char *argv[])
packet_count -= rmctx.audio_pkt_cnt;
rmctx.audio_pkt_cnt = 0;
}
- close_wav(fd_dec,&rmctx);
+ close_wav(fd_dec, &rmctx, &q);
close(fd);
diff --git a/apps/codecs/librm/rm.c b/apps/codecs/librm/rm.c
index bfad7e8b36..c9c40986ba 100644
--- a/apps/codecs/librm/rm.c
+++ b/apps/codecs/librm/rm.c
@@ -95,27 +95,14 @@ static int read_uint32be(int fd, uint32_t* buf)
}
-
-static int read_cook_extradata(int fd, RMContext *rmctx) {
- read_uint32be(fd, &rmctx->cook_version);
- read_uint16be(fd, &rmctx->samples_pf_pc);
- read_uint16be(fd, &rmctx->nb_subbands);
- if(rmctx->extradata_size == 16) {
- read_uint32be(fd, &rmctx->unused);
- read_uint16be(fd, &rmctx->js_subband_start);
- read_uint16be(fd, &rmctx->js_vlc_bits);
- }
- return rmctx->extradata_size; /* for 'skipped' */
-}
-
static void print_cook_extradata(RMContext *rmctx) {
- DEBUGF(" cook_version = 0x%08x\n", rmctx->cook_version);
- DEBUGF(" samples_per_frame_per_channel = %d\n", rmctx->samples_pf_pc);
- DEBUGF(" number_of_subbands_in_freq_domain = %d\n", rmctx->nb_subbands);
- if(rmctx->extradata_size == 16) {
- DEBUGF(" joint_stereo_subband_start = %d\n",rmctx->js_subband_start);
- DEBUGF(" joint_stereo_vlc_bits = %d\n", rmctx->js_vlc_bits);
+ DEBUGF(" cook_version = 0x%08x\n", get_uint32be(rmctx->codec_extradata));
+ DEBUGF(" samples_per_frame_per_channel = %d\n", get_uint16be(&rmctx->codec_extradata[4]));
+ DEBUGF(" number_of_subbands_in_freq_domain = %d\n", get_uint16be(&rmctx->codec_extradata[6]));
+ if(rmctx->extradata_size == 16) {
+ DEBUGF(" joint_stereo_subband_start = %d\n",get_uint16be(&rmctx->codec_extradata[12]));
+ DEBUGF(" joint_stereo_vlc_bits = %d\n", get_uint16be(&rmctx->codec_extradata[14]));
}
}
@@ -250,10 +237,8 @@ static int real_read_audio_stream_info(int fd, RMContext *rmctx)
read_uint32be(fd, &rmctx->extradata_size);
skipped += 4;
- if(!strncmp(fourcc2str(fourcc),"cook",4)){
- skipped += read_cook_extradata(fd, rmctx);
- rmctx->codec_type = cook;
- }
+ read(fd, rmctx->codec_extradata, rmctx->extradata_size);
+ skipped += rmctx->extradata_size;
DEBUGF(" flavor = %d\n",flavor);
diff --git a/apps/codecs/librm/rm.h b/apps/codecs/librm/rm.h
index a0c386e824..ee72c1fc04 100644
--- a/apps/codecs/librm/rm.h
+++ b/apps/codecs/librm/rm.h
@@ -24,7 +24,9 @@
#include <stdio.h>
#include <inttypes.h>
-enum codecs{cook};
+#define MAX_EXTRADATA_SIZE 16
+
+enum codecs{cook, aac};
typedef struct rm_packet
{
uint8_t *frames[100]; /* Pointers to ordered audio frames in buffer */
@@ -62,20 +64,14 @@ typedef struct rm_context
uint16_t block_align;
uint32_t nb_packets;
int frame_number;
- uint32_t extradata_size;
uint16_t sample_rate;
uint16_t nb_channels;
uint32_t bit_rate;
uint16_t flags;
- /*cook extradata*/
- uint32_t cook_version;
- uint16_t samples_pf_pc; /* samples per frame per channel */
- uint16_t nb_subbands; /* number of subbands in the frequency domain */
- /* extra 8 bytes for joint-stereo data */
- uint32_t unused;
- uint16_t js_subband_start; /* joint stereo subband start */
- uint16_t js_vlc_bits;
+ /*codec extradata*/
+ uint32_t extradata_size;
+ uint8_t codec_extradata[MAX_EXTRADATA_SIZE];
} RMContext;
diff --git a/apps/metadata/rm.c b/apps/metadata/rm.c
index 7866bb7c55..bfaa803be7 100644
--- a/apps/metadata/rm.c
+++ b/apps/metadata/rm.c
@@ -38,26 +38,14 @@
#define DEBUGF(...)
#endif
-static inline int read_cook_extradata(int fd, RMContext *rmctx) {
- read_uint32be(fd, &rmctx->cook_version);
- read_uint16be(fd, &rmctx->samples_pf_pc);
- read_uint16be(fd, &rmctx->nb_subbands);
- if(rmctx->extradata_size == 16) {
- lseek(fd, sizeof(uint32_t), SEEK_CUR); /* reserved */
- read_uint16be(fd, &rmctx->js_subband_start);
- read_uint16be(fd, &rmctx->js_vlc_bits);
- }
- return rmctx->extradata_size; /* for 'skipped' */
-}
-
static inline void print_cook_extradata(RMContext *rmctx) {
- DEBUGF(" cook_version = 0x%08lx\n", rmctx->cook_version);
- DEBUGF(" samples_per_frame_per_channel = %d\n", rmctx->samples_pf_pc);
- DEBUGF(" number_of_subbands_in_freq_domain = %d\n", rmctx->nb_subbands);
- if(rmctx->extradata_size == 16) {
- DEBUGF(" joint_stereo_subband_start = %d\n",rmctx->js_subband_start);
- DEBUGF(" joint_stereo_vlc_bits = %d\n", rmctx->js_vlc_bits);
+ DEBUGF(" cook_version = 0x%08x\n", get_uint32be(rmctx->codec_extradata));
+ DEBUGF(" samples_per_frame_per_channel = %d\n", get_uint16be(&rmctx->codec_extradata[4]));
+ DEBUGF(" number_of_subbands_in_freq_domain = %d\n", get_uint16be(&rmctx->codec_extradata[6]));
+ if(rmctx->extradata_size == 16) {
+ DEBUGF(" joint_stereo_subband_start = %d\n",get_uint16be(&rmctx->codec_extradata[12]));
+ DEBUGF(" joint_stereo_vlc_bits = %d\n", get_uint16be(&rmctx->codec_extradata[14]));
}
}
@@ -174,13 +162,10 @@ static inline int real_read_audio_stream_info(int fd, RMContext *rmctx)
read_uint32be(fd, &rmctx->extradata_size);
skipped += 4;
- /*if(!strncmp(fourcc2str(fourcc),"cook",4)){
- skipped += read_cook_extradata(fd, rmctx);
- rmctx->codec_type = cook;
- }*/
+ read(fd, rmctx->codec_extradata, rmctx->extradata_size);
+ skipped += rmctx->extradata_size;
switch(fourcc) {
- case FOURCC('c','o','o','k'):
- skipped += read_cook_extradata(fd, rmctx);
+ case FOURCC('c','o','o','k'):
rmctx->codec_type = cook;
break;