diff options
Diffstat (limited to 'apps/codecs/librm/rm.c')
-rw-r--r-- | apps/codecs/librm/rm.c | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/apps/codecs/librm/rm.c b/apps/codecs/librm/rm.c index 80ecbbbd97..d721ceb81f 100644 --- a/apps/codecs/librm/rm.c +++ b/apps/codecs/librm/rm.c | |||
@@ -29,26 +29,6 @@ | |||
29 | 29 | ||
30 | #define SWAP(a, b) do{uint8_t SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) | 30 | #define SWAP(a, b) do{uint8_t SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) |
31 | 31 | ||
32 | void advance_buffer(uint8_t **buf, int val) | ||
33 | { | ||
34 | *buf += val; | ||
35 | } | ||
36 | |||
37 | static uint8_t get_uint8(uint8_t *buf) | ||
38 | { | ||
39 | return (uint8_t)buf[0]; | ||
40 | } | ||
41 | |||
42 | static uint16_t get_uint16be(uint8_t *buf) | ||
43 | { | ||
44 | return (uint16_t)((buf[0] << 8)|buf[1]); | ||
45 | } | ||
46 | |||
47 | static uint32_t get_uint32be(uint8_t *buf) | ||
48 | { | ||
49 | return (uint32_t)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); | ||
50 | } | ||
51 | |||
52 | #ifdef TEST | 32 | #ifdef TEST |
53 | #include <fcntl.h> | 33 | #include <fcntl.h> |
54 | #include <unistd.h> | 34 | #include <unistd.h> |
@@ -99,12 +79,12 @@ static int read_uint32be(int fd, uint32_t* buf) | |||
99 | 79 | ||
100 | static void print_cook_extradata(RMContext *rmctx) { | 80 | static void print_cook_extradata(RMContext *rmctx) { |
101 | 81 | ||
102 | DEBUGF(" cook_version = 0x%08x\n", get_uint32be(rmctx->codec_extradata)); | 82 | DEBUGF(" cook_version = 0x%08x\n", rm_get_uint32be(rmctx->codec_extradata)); |
103 | DEBUGF(" samples_per_frame_per_channel = %d\n", get_uint16be(&rmctx->codec_extradata[4])); | 83 | DEBUGF(" samples_per_frame_per_channel = %d\n", rm_get_uint16be(&rmctx->codec_extradata[4])); |
104 | DEBUGF(" number_of_subbands_in_freq_domain = %d\n", get_uint16be(&rmctx->codec_extradata[6])); | 84 | DEBUGF(" number_of_subbands_in_freq_domain = %d\n", rm_get_uint16be(&rmctx->codec_extradata[6])); |
105 | if(rmctx->extradata_size == 16) { | 85 | if(rmctx->extradata_size == 16) { |
106 | DEBUGF(" joint_stereo_subband_start = %d\n",get_uint16be(&rmctx->codec_extradata[12])); | 86 | DEBUGF(" joint_stereo_subband_start = %d\n",rm_get_uint16be(&rmctx->codec_extradata[12])); |
107 | DEBUGF(" joint_stereo_vlc_bits = %d\n", get_uint16be(&rmctx->codec_extradata[14])); | 87 | DEBUGF(" joint_stereo_vlc_bits = %d\n", rm_get_uint16be(&rmctx->codec_extradata[14])); |
108 | } | 88 | } |
109 | } | 89 | } |
110 | 90 | ||
@@ -532,7 +512,7 @@ int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt) | |||
532 | do | 512 | do |
533 | { | 513 | { |
534 | y = rmctx->sub_packet_cnt; | 514 | y = rmctx->sub_packet_cnt; |
535 | pkt->version = get_uint16be(*src); | 515 | pkt->version = rm_get_uint16be(*src); |
536 | 516 | ||
537 | /* Simple error checking */ | 517 | /* Simple error checking */ |
538 | if(pkt->version != 0 && pkt->version != 1) | 518 | if(pkt->version != 0 && pkt->version != 1) |
@@ -541,18 +521,18 @@ int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt) | |||
541 | return -1; | 521 | return -1; |
542 | } | 522 | } |
543 | 523 | ||
544 | pkt->length = get_uint16be(*src+2); | 524 | pkt->length = rm_get_uint16be(*src+2); |
545 | pkt->stream_number = get_uint16be(*src+4); | 525 | pkt->stream_number = rm_get_uint16be(*src+4); |
546 | pkt->timestamp = get_uint32be(*src+6); | 526 | pkt->timestamp = rm_get_uint32be(*src+6); |
547 | /*DEBUGF(" version = %d\n" | 527 | /*DEBUGF(" version = %d\n" |
548 | " length = %d\n" | 528 | " length = %d\n" |
549 | " stream = %d\n" | 529 | " stream = %d\n" |
550 | " timestamp= %d\n\n",pkt->version,pkt->length,pkt->stream_number,pkt->timestamp);*/ | 530 | " timestamp= %d\n\n",pkt->version,pkt->length,pkt->stream_number,pkt->timestamp);*/ |
551 | unknown = get_uint8(*src+10); | 531 | unknown = rm_get_uint8(*src+10); |
552 | pkt->flags = get_uint8(*src+11); | 532 | pkt->flags = rm_get_uint8(*src+11); |
553 | 533 | ||
554 | if(pkt->version == 1) | 534 | if(pkt->version == 1) |
555 | unknown = get_uint8(*src+10); | 535 | unknown = rm_get_uint8(*src+10); |
556 | 536 | ||
557 | if (pkt->flags & 2) /* keyframe */ | 537 | if (pkt->flags & 2) /* keyframe */ |
558 | y = rmctx->sub_packet_cnt = 0; | 538 | y = rmctx->sub_packet_cnt = 0; |
@@ -571,12 +551,12 @@ int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt) | |||
571 | } | 551 | } |
572 | } | 552 | } |
573 | else if (rmctx->codec_type == CODEC_AAC) { | 553 | else if (rmctx->codec_type == CODEC_AAC) { |
574 | rmctx->sub_packet_cnt = (get_uint16be(*src) & 0xf0) >> 4; | 554 | rmctx->sub_packet_cnt = (rm_get_uint16be(*src) & 0xf0) >> 4; |
575 | advance_buffer(src, 2); | 555 | advance_buffer(src, 2); |
576 | consumed += 2; | 556 | consumed += 2; |
577 | if (rmctx->sub_packet_cnt) { | 557 | if (rmctx->sub_packet_cnt) { |
578 | for(x = 0; x < rmctx->sub_packet_cnt; x++) { | 558 | for(x = 0; x < rmctx->sub_packet_cnt; x++) { |
579 | rmctx->sub_packet_lengths[x] = get_uint16be(*src); | 559 | rmctx->sub_packet_lengths[x] = rm_get_uint16be(*src); |
580 | advance_buffer(src, 2); | 560 | advance_buffer(src, 2); |
581 | consumed += 2; | 561 | consumed += 2; |
582 | } | 562 | } |