summaryrefslogtreecommitdiff
path: root/apps/codecs/libatrac/atrac3.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libatrac/atrac3.c')
-rw-r--r--apps/codecs/libatrac/atrac3.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c
index 3c6ecc9197..2f4d44b6af 100644
--- a/apps/codecs/libatrac/atrac3.c
+++ b/apps/codecs/libatrac/atrac3.c
@@ -1074,17 +1074,17 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, int off)
1074 * @param rmctx pointer to the AVCodecContext 1074 * @param rmctx pointer to the AVCodecContext
1075 */ 1075 */
1076 1076
1077int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q, 1077int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q,
1078 int *data_size, const uint8_t *buf, int buf_size) { 1078 int *data_size, const uint8_t *buf, int buf_size) {
1079 int result = 0, off = 0; 1079 int result = 0, off = 0;
1080 const uint8_t* databuf; 1080 const uint8_t* databuf;
1081 1081
1082 if (buf_size < rmctx->block_align) 1082 if (buf_size < block_align)
1083 return buf_size; 1083 return buf_size;
1084 1084
1085 /* Check if we need to descramble and what buffer to pass on. */ 1085 /* Check if we need to descramble and what buffer to pass on. */
1086 if (q->scrambled_stream) { 1086 if (q->scrambled_stream) {
1087 off = decode_bytes(buf, q->decoded_bytes_buffer, rmctx->block_align); 1087 off = decode_bytes(buf, q->decoded_bytes_buffer, block_align);
1088 databuf = q->decoded_bytes_buffer; 1088 databuf = q->decoded_bytes_buffer;
1089 } else { 1089 } else {
1090 databuf = buf; 1090 databuf = buf;
@@ -1102,7 +1102,7 @@ int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q,
1102 else 1102 else
1103 *data_size = 2048 * sizeof(int32_t); 1103 *data_size = 2048 * sizeof(int32_t);
1104 1104
1105 return rmctx->block_align; 1105 return block_align;
1106} 1106}
1107 1107
1108 1108
@@ -1111,23 +1111,23 @@ int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q,
1111 * 1111 *
1112 * @param rmctx pointer to the RMContext 1112 * @param rmctx pointer to the RMContext
1113 */ 1113 */
1114 1114int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
1115int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
1116{ 1115{
1117 int i; 1116 int i;
1118 uint8_t *edata_ptr = rmctx->codec_extradata; 1117 uint8_t *edata_ptr = (uint8_t*)&id3->id3v2buf;
1119 static VLC_TYPE atrac3_vlc_table[4096][2]; 1118 static VLC_TYPE atrac3_vlc_table[4096][2];
1120 static int vlcs_initialized = 0; 1119 static int vlcs_initialized = 0;
1121 1120
1122 /* Take data from the AVCodecContext (RM container). */ 1121 /* Take data from the RM container. */
1123 q->sample_rate = rmctx->sample_rate; 1122 q->sample_rate = id3->frequency;
1124 q->channels = rmctx->nb_channels; 1123 q->channels = id3->channels;
1125 q->bit_rate = rmctx->bit_rate; 1124 q->bit_rate = id3->bitrate * 1000;
1126 q->bits_per_frame = rmctx->block_align * 8; 1125 q->bits_per_frame = id3->bytesperframe * 8;
1127 q->bytes_per_frame = rmctx->block_align; 1126 q->bytes_per_frame = id3->bytesperframe;
1128 1127
1129 /* Take care of the codec-specific extradata. */ 1128 /* Take care of the codec-specific extradata. */
1130 if (rmctx->extradata_size == 14) { 1129
1130 if (id3->extradata_size == 14) {
1131 /* Parse the extradata, WAV format */ 1131 /* Parse the extradata, WAV format */
1132 DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */ 1132 DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */
1133 q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]); 1133 q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]);
@@ -1152,7 +1152,7 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
1152 return -1; 1152 return -1;
1153 } 1153 }
1154 1154
1155 } else if (rmctx->extradata_size == 10) { 1155 } else if (id3->extradata_size == 10) {
1156 /* Parse the extradata, RM format. */ 1156 /* Parse the extradata, RM format. */
1157 q->atrac3version = rm_get_uint32be(&edata_ptr[0]); 1157 q->atrac3version = rm_get_uint32be(&edata_ptr[0]);
1158 q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]); 1158 q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]);
@@ -1163,7 +1163,7 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
1163 q->scrambled_stream = 1; 1163 q->scrambled_stream = 1;
1164 1164
1165 } else { 1165 } else {
1166 DEBUGF("Unknown extradata size %d.\n",rmctx->extradata_size); 1166 DEBUGF("Unknown extradata size %d.\n",id3->extradata_size);
1167 } 1167 }
1168 /* Check the extradata. */ 1168 /* Check the extradata. */
1169 1169
@@ -1191,13 +1191,13 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
1191 return -1; 1191 return -1;
1192 } 1192 }
1193 1193
1194 if (rmctx->nb_channels <= 0 || rmctx->nb_channels > 2 /*|| ((rmctx->channels * 1024) != q->samples_per_frame)*/) { 1194 if (id3->channels <= 0 || id3->channels > 2 ) {
1195 DEBUGF("Channel configuration error!\n"); 1195 DEBUGF("Channel configuration error!\n");
1196 return -1; 1196 return -1;
1197 } 1197 }
1198 1198
1199 1199
1200 if(rmctx->block_align >= UINT16_MAX/2) 1200 if(id3->bytesperframe >= UINT16_MAX/2)
1201 return -1; 1201 return -1;
1202 1202
1203 1203