00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "libavutil/attributes.h"
00022 #include "libavutil/samplefmt.h"
00023 #include "flacdsp.h"
00024 #include "config.h"
00025
00026 #define SAMPLE_SIZE 16
00027 #define PLANAR 0
00028 #include "flacdsp_template.c"
00029
00030 #undef PLANAR
00031 #define PLANAR 1
00032 #include "flacdsp_template.c"
00033
00034 #undef SAMPLE_SIZE
00035 #undef PLANAR
00036 #define SAMPLE_SIZE 32
00037 #define PLANAR 0
00038 #include "flacdsp_template.c"
00039
00040 #undef PLANAR
00041 #define PLANAR 1
00042 #include "flacdsp_template.c"
00043
00044 static void flac_lpc_16_c(int32_t *decoded, const int coeffs[32],
00045 int pred_order, int qlevel, int len)
00046 {
00047 int i, j;
00048
00049 for (i = pred_order; i < len - 1; i += 2, decoded += 2) {
00050 int c = coeffs[0];
00051 int d = decoded[0];
00052 int s0 = 0, s1 = 0;
00053 for (j = 1; j < pred_order; j++) {
00054 s0 += c*d;
00055 d = decoded[j];
00056 s1 += c*d;
00057 c = coeffs[j];
00058 }
00059 s0 += c*d;
00060 d = decoded[j] += s0 >> qlevel;
00061 s1 += c*d;
00062 decoded[j + 1] += s1 >> qlevel;
00063 }
00064 if (i < len) {
00065 int sum = 0;
00066 for (j = 0; j < pred_order; j++)
00067 sum += coeffs[j] * decoded[j];
00068 decoded[j] += sum >> qlevel;
00069 }
00070 }
00071
00072 static void flac_lpc_32_c(int32_t *decoded, const int coeffs[32],
00073 int pred_order, int qlevel, int len)
00074 {
00075 int i, j;
00076
00077 for (i = pred_order; i < len; i++, decoded++) {
00078 int64_t sum = 0;
00079 for (j = 0; j < pred_order; j++)
00080 sum += (int64_t)coeffs[j] * decoded[j];
00081 decoded[j] += sum >> qlevel;
00082 }
00083
00084 }
00085
00086 av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt,
00087 int bps)
00088 {
00089 if (bps > 16)
00090 c->lpc = flac_lpc_32_c;
00091 else
00092 c->lpc = flac_lpc_16_c;
00093
00094 switch (fmt) {
00095 case AV_SAMPLE_FMT_S32:
00096 c->decorrelate[0] = flac_decorrelate_indep_c_32;
00097 c->decorrelate[1] = flac_decorrelate_ls_c_32;
00098 c->decorrelate[2] = flac_decorrelate_rs_c_32;
00099 c->decorrelate[3] = flac_decorrelate_ms_c_32;
00100 break;
00101
00102 case AV_SAMPLE_FMT_S32P:
00103 c->decorrelate[0] = flac_decorrelate_indep_c_32p;
00104 c->decorrelate[1] = flac_decorrelate_ls_c_32p;
00105 c->decorrelate[2] = flac_decorrelate_rs_c_32p;
00106 c->decorrelate[3] = flac_decorrelate_ms_c_32p;
00107 break;
00108
00109 case AV_SAMPLE_FMT_S16:
00110 c->decorrelate[0] = flac_decorrelate_indep_c_16;
00111 c->decorrelate[1] = flac_decorrelate_ls_c_16;
00112 c->decorrelate[2] = flac_decorrelate_rs_c_16;
00113 c->decorrelate[3] = flac_decorrelate_ms_c_16;
00114 break;
00115
00116 case AV_SAMPLE_FMT_S16P:
00117 c->decorrelate[0] = flac_decorrelate_indep_c_16p;
00118 c->decorrelate[1] = flac_decorrelate_ls_c_16p;
00119 c->decorrelate[2] = flac_decorrelate_rs_c_16p;
00120 c->decorrelate[3] = flac_decorrelate_ms_c_16p;
00121 break;
00122 }
00123
00124 if (ARCH_ARM)
00125 ff_flacdsp_init_arm(c, fmt, bps);
00126 }