summaryrefslogtreecommitdiff
path: root/apps/codecs/libcook
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libcook')
-rw-r--r--apps/codecs/libcook/cook.c25
-rw-r--r--apps/codecs/libcook/main.c6
2 files changed, 21 insertions, 10 deletions
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)
708 * Cook initialization 708 * Cook initialization
709 */ 709 */
710 710
711int cook_decode_init(RMContext *rmctx, COOKContext *q) 711static inline uint16_t get_uint16be(uint8_t *buf)
712{ 712{
713 return (uint16_t)((buf[0] << 8)|buf[1]);
714}
715
716static inline uint32_t get_uint32be(uint8_t *buf)
717{
718 return (uint32_t)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
719}
720
721 int cook_decode_init(RMContext *rmctx, COOKContext *q)
722 {
723
713 /* cook extradata */ 724 /* cook extradata */
714 q->cookversion = rmctx->cook_version; 725 q->cookversion = get_uint32be(rmctx->codec_extradata);
715 q->samples_per_frame = rmctx->samples_pf_pc; 726 q->samples_per_frame = get_uint16be(&rmctx->codec_extradata[4]);
716 q->subbands = rmctx->nb_subbands; 727 q->subbands = get_uint16be(&rmctx->codec_extradata[6]);
717 q->extradata_size = rmctx->extradata_size; 728 q->extradata_size = rmctx->extradata_size;
718 if (q->extradata_size >= 16){ 729 if (q->extradata_size >= 16){
719 q->js_subband_start = rmctx->js_subband_start; 730 q->js_subband_start = get_uint16be(&rmctx->codec_extradata[12]);
720 q->js_vlc_bits = rmctx->js_vlc_bits; 731 q->js_vlc_bits = get_uint16be(&rmctx->codec_extradata[14]);
721 } 732 }
722 733
723 /* Take data from the RMContext (RM container). */ 734 /* 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) {
58 return(fd); 58 return(fd);
59} 59}
60 60
61void close_wav(int fd, RMContext *rmctx) { 61void close_wav(int fd, RMContext *rmctx, COOKContext *q) {
62 int x,res; 62 int x,res;
63 int filesize; 63 int filesize;
64 int bytes_per_sample = 2; 64 int bytes_per_sample = 2;
65 int samples_per_frame = rmctx->samples_pf_pc; 65 int samples_per_frame = q->samples_per_frame;
66 int nb_channels = rmctx->nb_channels; 66 int nb_channels = rmctx->nb_channels;
67 int sample_rate = rmctx->sample_rate; 67 int sample_rate = rmctx->sample_rate;
68 int nb_frames = rmctx->audio_framesize/rmctx->block_align * rmctx->nb_packets - 2; // first 2 frames have no valid audio; skipped in output 68 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[])
182 packet_count -= rmctx.audio_pkt_cnt; 182 packet_count -= rmctx.audio_pkt_cnt;
183 rmctx.audio_pkt_cnt = 0; 183 rmctx.audio_pkt_cnt = 0;
184 } 184 }
185 close_wav(fd_dec,&rmctx); 185 close_wav(fd_dec, &rmctx, &q);
186 close(fd); 186 close(fd);
187 187
188 188