Skip to content

Commit

Permalink
reduce redundant memcpy.
Browse files Browse the repository at this point in the history
  • Loading branch information
aikiriao committed Jun 22, 2024
1 parent be5823e commit 6d65384
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libs/srla_encoder/src/srla_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,16 +1152,20 @@ static SRLAApiResult SRLAEncoder_EncodeCompressData(

/* 判定結果に応じてLRの結果を差し替える */
if (ch_process_method == SRLA_CH_PROCESS_METHOD_MS) {
int32_t *tmpp;
for (ch = 0; ch < 2; ch++) {
memcpy(encoder->pre_emphasis[ch], encoder->ms_pre_emphasis[ch],
sizeof(struct SRLAPreemphasisFilter) * SRLA_NUM_PREEMPHASIS_FILTERS);
encoder->coef_order[ch] = encoder->ms_coef_order[ch];
encoder->coef_rshifts[ch] = encoder->ms_coef_rshifts[ch];
memcpy(encoder->params_int[ch], encoder->ms_params_int[ch],
sizeof(int32_t) * encoder->ms_coef_order[ch]);
memcpy(encoder->residual[ch], encoder->ms_residual[ch], sizeof(int32_t) * num_samples);
tmpp = encoder->residual[ch];
encoder->residual[ch] = encoder->ms_residual[ch];
encoder->ms_residual[ch] = tmpp;
}
} else if ((ch_process_method == SRLA_CH_PROCESS_METHOD_LS) || (ch_process_method == SRLA_CH_PROCESS_METHOD_SR)) {
int32_t *tmpp;
const uint32_t src_ch = 1; /* S */
const uint32_t dst_ch = (ch_process_method == SRLA_CH_PROCESS_METHOD_LS) ? 1 : 0;
memcpy(encoder->pre_emphasis[dst_ch], encoder->ms_pre_emphasis[src_ch],
Expand All @@ -1170,7 +1174,9 @@ static SRLAApiResult SRLAEncoder_EncodeCompressData(
encoder->coef_rshifts[dst_ch] = encoder->ms_coef_rshifts[src_ch];
memcpy(encoder->params_int[dst_ch], encoder->ms_params_int[src_ch],
sizeof(int32_t) * encoder->ms_coef_order[src_ch]);
memcpy(encoder->residual[dst_ch], encoder->ms_residual[src_ch], sizeof(int32_t) * num_samples);
tmpp = encoder->residual[dst_ch];
encoder->residual[dst_ch] = encoder->ms_residual[src_ch];
encoder->ms_residual[src_ch] = tmpp;
}
}

Expand Down

0 comments on commit 6d65384

Please sign in to comment.