Skip to content

Commit

Permalink
rename header fileld.
Browse files Browse the repository at this point in the history
num_samples_per_block -> max_num_samples_per_block
  • Loading branch information
aikiriao committed Jan 29, 2023
1 parent 540d29a commit d50f7c4
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion include/srla.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct SRLAHeader {
uint32_t num_samples; /* 1チャンネルあたり総サンプル数 */
uint32_t sampling_rate; /* サンプリングレート */
uint16_t bits_per_sample; /* サンプルあたりビット数 */
uint32_t num_samples_per_block; /* ブロックあたりサンプル数 */
uint32_t max_num_samples_per_block; /* ブロックあたり最大サンプル数 */
uint8_t preset; /* パラメータプリセット */
};

Expand Down
2 changes: 1 addition & 1 deletion include/srla_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct SRLAEncodeParameter {
uint16_t num_channels; /* 入力波形のチャンネル数 */
uint16_t bits_per_sample; /* 入力波形のサンプルあたりビット数 */
uint32_t sampling_rate; /* 入力波形のサンプリングレート */
uint32_t num_samples_per_block; /* ブロックあたりサンプル数 */
uint32_t max_num_samples_per_block; /* ブロックあたり最大サンプル数 */
uint8_t preset; /* エンコードパラメータプリセット */
};

Expand Down
8 changes: 4 additions & 4 deletions libs/srla_decoder/src/srla_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ SRLAApiResult SRLADecoder_DecodeHeader(
/* サンプルあたりビット数 */
ByteArray_GetUint16BE(data_pos, &u16buf);
tmp_header.bits_per_sample = u16buf;
/* ブロックあたりサンプル数 */
/* ブロックあたり最大サンプル数 */
ByteArray_GetUint32BE(data_pos, &u32buf);
tmp_header.num_samples_per_block = u32buf;
tmp_header.max_num_samples_per_block = u32buf;
/* パラメータプリセット */
ByteArray_GetUint8(data_pos, &u8buf);
tmp_header.preset = u8buf;
Expand Down Expand Up @@ -156,8 +156,8 @@ static SRLAError SRLADecoder_CheckHeaderFormat(const struct SRLAHeader *header)
if (header->bits_per_sample == 0) {
return SRLA_ERROR_INVALID_FORMAT;
}
/* ブロックあたりサンプル数 */
if (header->num_samples_per_block == 0) {
/* ブロックあたり最大サンプル数 */
if (header->max_num_samples_per_block == 0) {
return SRLA_ERROR_INVALID_FORMAT;
}
/* パラメータプリセット */
Expand Down
20 changes: 10 additions & 10 deletions libs/srla_encoder/src/srla_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ SRLAApiResult SRLAEncoder_EncodeHeader(
if (header->bits_per_sample == 0) {
return SRLA_APIRESULT_INVALID_FORMAT;
}
/* ブロックあたりサンプル数 */
if (header->num_samples_per_block == 0) {
/* ブロックあたり最大サンプル数 */
if (header->max_num_samples_per_block == 0) {
return SRLA_APIRESULT_INVALID_FORMAT;
}
/* パラメータプリセット */
Expand Down Expand Up @@ -108,8 +108,8 @@ SRLAApiResult SRLAEncoder_EncodeHeader(
ByteArray_PutUint32BE(data_pos, header->sampling_rate);
/* サンプルあたりビット数 */
ByteArray_PutUint16BE(data_pos, header->bits_per_sample);
/* ブロックあたりサンプル数 */
ByteArray_PutUint32BE(data_pos, header->num_samples_per_block);
/* ブロックあたり最大サンプル数 */
ByteArray_PutUint32BE(data_pos, header->max_num_samples_per_block);
/* パラメータプリセット */
ByteArray_PutUint8(data_pos, header->preset);

Expand Down Expand Up @@ -154,7 +154,7 @@ static SRLAError SRLAEncoder_ConvertParameterToHeader(
tmp_header.sampling_rate = parameter->sampling_rate;
tmp_header.bits_per_sample = parameter->bits_per_sample;
tmp_header.preset = parameter->preset;
tmp_header.num_samples_per_block = parameter->num_samples_per_block;
tmp_header.max_num_samples_per_block = parameter->max_num_samples_per_block;

/* 成功終了 */
(*header) = tmp_header;
Expand Down Expand Up @@ -374,12 +374,12 @@ SRLAApiResult SRLAEncoder_SetEncodeParameter(
}

/* エンコーダの容量を越えてないかチェック */
if ((encoder->max_num_samples_per_block < parameter->num_samples_per_block)
if ((encoder->max_num_samples_per_block < parameter->max_num_samples_per_block)
|| (encoder->max_num_channels < parameter->num_channels)) {
return SRLA_APIRESULT_INSUFFICIENT_BUFFER;
}
/* ブロックあたりサンプル数のセット */
tmp_header.num_samples_per_block = parameter->num_samples_per_block;
/* ブロックあたり最大サンプル数のセット */
tmp_header.max_num_samples_per_block = parameter->max_num_samples_per_block;

/* ヘッダ設定 */
encoder->header = tmp_header;
Expand Down Expand Up @@ -890,7 +890,7 @@ SRLAApiResult SRLAEncoder_EncodeBlock(
}

/* エンコードサンプル数チェック */
if (num_samples > header->num_samples_per_block) {
if (num_samples > header->max_num_samples_per_block) {
return SRLA_APIRESULT_INSUFFICIENT_BUFFER;
}

Expand Down Expand Up @@ -1000,7 +1000,7 @@ SRLAApiResult SRLAEncoder_EncodeWhole(

/* エンコードサンプル数の確定 */
num_encode_samples
= SRLAUTILITY_MIN(header->num_samples_per_block, num_samples - progress);
= SRLAUTILITY_MIN(header->max_num_samples_per_block, num_samples - progress);

/* サンプル参照位置のセット */
for (ch = 0; ch < header->num_channels; ch++) {
Expand Down
Loading

0 comments on commit d50f7c4

Please sign in to comment.