On Wed, Jun 17, 2009 at 1:31 AM, Kostya<[email protected]> wrote: > On Tue, Jun 16, 2009 at 08:33:31PM -0400, Alex Converse wrote: >> This patch set reduces encoding time by 56% for me. >> >> I hope it's not premature. > > I'm pretty sure it won't work with CONFIG_HARDCODED_TABLES option > because you miss that hardcoded table, otherwise looks ok.
Yes, I forgot about CONFIG_HARDCODED_TABLES. I've also reevaluated the location of the tables.
commit 0dfb0358f5cc1537078ab5cc5c8fc4ee080ad23c Author: Alex Converse <[email protected]> Date: Thu Apr 23 23:21:15 2009 -0400 Make quantizer^0.75 a table diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 9901462..a708e9c 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -35,6 +35,7 @@ #include "aac.h" #include "aacenc.h" #include "aactab.h" +#include "aaccodertab.h" /** bits needed to code codebook run value for long windows */ static const uint8_t run_value_bits_long[64] = { @@ -105,7 +106,7 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, const { const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; - const float Q34 = pow(Q, 0.75); + const float Q34 = ff_aac_pow2sf_34_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; const float CLIPPED_ESCAPE = 165140.0f*IQ; int i, j, k; float cost = 0; @@ -220,7 +221,7 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, { const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; - const float Q34 = pow(Q, 0.75); + const float Q34 = ff_aac_pow2sf_34_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; const float CLIPPED_ESCAPE = 165140.0f*IQ; const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2; int i, j, k; @@ -1007,6 +1008,17 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe, const float lam } } +void ff_aaccoder_init() +{ +#if !CONFIG_HARDCODED_TABLES + int i; + for (i = 0; i < 428; i++) + { + ff_aac_pow2sf_34_tab[i] = pow(ff_aac_pow2sf_tab[i], 0.75); + } +#endif /* CONFIG_HARDCODED_TABLES */ +} + AACCoefficientsEncoder ff_aac_coders[] = { { search_for_quantizers_faac, diff --git a/libavcodec/aaccoder.h b/libavcodec/aaccoder.h new file mode 100644 index 0000000..44b2bea --- /dev/null +++ b/libavcodec/aaccoder.h @@ -0,0 +1,30 @@ +/* + * AAC coefficients encoder declarations + * Copyright (C) 2009 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/aaccoder.h + * AAC coefficients encoder declarations + */ + +#ifndef AVCODEC_AACCODER_H +void ff_aaccoder_init(); +#define AVCODEC_AACCODER_H +#endif /* AVCODEC_AACCODER_H */ diff --git a/libavcodec/aaccodertab.h b/libavcodec/aaccodertab.h new file mode 100644 index 0000000..4160178 --- /dev/null +++ b/libavcodec/aaccodertab.h @@ -0,0 +1,144 @@ +/* + * AAC coefficients encoder tables + * Copyright (c) 2009 Alex Converse ( alex.converse gmail com ) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/aaccodertab.h + * AAC coefficients encoder tables + */ + +#ifndef AVCODEC_AACCODERTAB_H +#define AVCODEC_AACCODERTAB_H + +#if CONFIG_HARDCODED_TABLES +static const float ff_aac_pow2sf_34_tab[428] = { + 5.14487888e-12, 5.85892966e-12, 6.67208259e-12, 7.59809143e-12, + 8.65262029e-12, 9.85350603e-12, 1.12210605e-11, 1.27784163e-11, + 1.45519152e-11, 1.65715549e-11, 1.88714998e-11, 2.14906495e-11, + 2.44733071e-11, 2.78699234e-11, 3.17379525e-11, 3.61428179e-11, + 4.11590310e-11, 4.68714373e-11, 5.33766607e-11, 6.07847314e-11, + 6.92209623e-11, 7.88280483e-11, 8.97684843e-11, 1.02227331e-10, + 1.16415322e-10, 1.32572439e-10, 1.50971999e-10, 1.71925196e-10, + 1.95786456e-10, 2.22959387e-10, 2.53903620e-10, 2.89142543e-10, + 3.29272248e-10, 3.74971498e-10, 4.27013286e-10, 4.86277851e-10, + 5.53767698e-10, 6.30624386e-10, 7.18147875e-10, 8.17818646e-10, + 9.31322575e-10, 1.06057951e-09, 1.20777599e-09, 1.37540157e-09, + 1.56629165e-09, 1.78367510e-09, 2.03122896e-09, 2.31314035e-09, + 2.63417799e-09, 2.99977199e-09, 3.41610629e-09, 3.89022281e-09, + 4.43014159e-09, 5.04499509e-09, 5.74518300e-09, 6.54254917e-09, + 7.45058060e-09, 8.48463610e-09, 9.66220792e-09, 1.10032126e-08, + 1.25303332e-08, 1.42694008e-08, 1.62498317e-08, 1.85051228e-08, + 2.10734239e-08, 2.39981759e-08, 2.73288503e-08, 3.11217825e-08, + 3.54411327e-08, 4.03599607e-08, 4.59614640e-08, 5.23403934e-08, + 5.96046448e-08, 6.78770888e-08, 7.72976634e-08, 8.80257005e-08, + 1.00242666e-07, 1.14155206e-07, 1.29998654e-07, 1.48040982e-07, + 1.68587391e-07, 1.91985407e-07, 2.18630802e-07, 2.48974260e-07, + 2.83529062e-07, 3.22879686e-07, 3.67691712e-07, 4.18723147e-07, + 4.76837158e-07, 5.43016711e-07, 6.18381307e-07, 7.04205604e-07, + 8.01941326e-07, 9.13241649e-07, 1.03998923e-06, 1.18432786e-06, + 1.34869913e-06, 1.53588326e-06, 1.74904642e-06, 1.99179408e-06, + 2.26823249e-06, 2.58303749e-06, 2.94153369e-06, 3.34978517e-06, + 3.81469727e-06, 4.34413369e-06, 4.94705046e-06, 5.63364483e-06, + 6.41553061e-06, 7.30593320e-06, 8.31991383e-06, 9.47462286e-06, + 1.07895930e-05, 1.22870661e-05, 1.39923714e-05, 1.59343526e-05, + 1.81458599e-05, 2.06642999e-05, 2.35322696e-05, 2.67982814e-05, + 3.05175781e-05, 3.47530695e-05, 3.95764037e-05, 4.50691587e-05, + 5.13242449e-05, 5.84474656e-05, 6.65593107e-05, 7.57969829e-05, + 8.63167443e-05, 9.82965284e-05, 1.11938971e-04, 1.27474821e-04, + 1.45166880e-04, 1.65314399e-04, 1.88258156e-04, 2.14386251e-04, + 2.44140625e-04, 2.78024556e-04, 3.16611229e-04, 3.60553269e-04, + 4.10593959e-04, 4.67579724e-04, 5.32474485e-04, 6.06375863e-04, + 6.90533954e-04, 7.86372228e-04, 8.95511766e-04, 1.01979857e-03, + 1.16133504e-03, 1.32251519e-03, 1.50606525e-03, 1.71509001e-03, + 1.95312500e-03, 2.22419645e-03, 2.53288983e-03, 2.88442615e-03, + 3.28475167e-03, 3.74063780e-03, 4.25979588e-03, 4.85100690e-03, + 5.52427163e-03, 6.29097782e-03, 7.16409413e-03, 8.15838855e-03, + 9.29068029e-03, 1.05801215e-02, 1.20485220e-02, 1.37207201e-02, + 1.56250000e-02, 1.77935716e-02, 2.02631187e-02, 2.30754092e-02, + 2.62780134e-02, 2.99251024e-02, 3.40783671e-02, 3.88080552e-02, + 4.41941731e-02, 5.03278226e-02, 5.73127531e-02, 6.52671084e-02, + 7.43254423e-02, 8.46409723e-02, 9.63881761e-02, 1.09765761e-01, + 1.25000000e-01, 1.42348573e-01, 1.62104949e-01, 1.84603274e-01, + 2.10224107e-01, 2.39400819e-01, 2.72626936e-01, 3.10464442e-01, + 3.53553385e-01, 4.02622581e-01, 4.58502024e-01, 5.22136867e-01, + 5.94603539e-01, 6.77127779e-01, 7.71105409e-01, 8.78126085e-01, + 1.00000000e+00, 1.13878858e+00, 1.29683959e+00, 1.47682619e+00, + 1.68179286e+00, 1.91520655e+00, 2.18101549e+00, 2.48371553e+00, + 2.82842708e+00, 3.22098064e+00, 3.66801620e+00, 4.17709494e+00, + 4.75682831e+00, 5.41702223e+00, 6.16884327e+00, 7.02500868e+00, + 8.00000000e+00, 9.11030865e+00, 1.03747168e+01, 1.18146095e+01, + 1.34543428e+01, 1.53216524e+01, 1.74481239e+01, 1.98697243e+01, + 2.26274166e+01, 2.57678452e+01, 2.93441296e+01, 3.34167595e+01, + 3.80546265e+01, 4.33361778e+01, 4.93507462e+01, 5.62000694e+01, + 6.40000000e+01, 7.28824692e+01, 8.29977341e+01, 9.45168762e+01, + 1.07634743e+02, 1.22573219e+02, 1.39584991e+02, 1.58957794e+02, + 1.81019333e+02, 2.06142761e+02, 2.34753036e+02, 2.67334076e+02, + 3.04437012e+02, 3.46689423e+02, 3.94805969e+02, 4.49600555e+02, + 5.12000000e+02, 5.83059753e+02, 6.63981873e+02, 7.56135010e+02, + 8.61077942e+02, 9.80585754e+02, 1.11667993e+03, 1.27166235e+03, + 1.44815466e+03, 1.64914209e+03, 1.87802429e+03, 2.13867261e+03, + 2.43549609e+03, 2.77351538e+03, 3.15844775e+03, 3.59680444e+03, + 4.09600000e+03, 4.66447803e+03, 5.31185498e+03, 6.04908008e+03, + 6.88862354e+03, 7.84468604e+03, 8.93343945e+03, 1.01732988e+04, + 1.15852373e+04, 1.31931367e+04, 1.50241943e+04, 1.71093809e+04, + 1.94839688e+04, 2.21881230e+04, 2.52675820e+04, 2.87744355e+04, + 3.27680000e+04, 3.73158242e+04, 4.24948398e+04, 4.83926406e+04, + 5.51089883e+04, 6.27574883e+04, 7.14675156e+04, 8.13863906e+04, + 9.26818984e+04, 1.05545094e+05, 1.20193555e+05, 1.36875047e+05, + 1.55871750e+05, 1.77504984e+05, 2.02140656e+05, 2.30195484e+05, + 2.62144000e+05, 2.98526594e+05, 3.39958719e+05, 3.87141125e+05, + 4.40871906e+05, 5.02059906e+05, 5.71740125e+05, 6.51091125e+05, + 7.41455188e+05, 8.44360750e+05, 9.61548438e+05, 1.09500038e+06, + 1.24697400e+06, 1.42003988e+06, 1.61712525e+06, 1.84156388e+06, + 2.09715200e+06, 2.38821275e+06, 2.71966975e+06, 3.09712900e+06, + 3.52697525e+06, 4.01647925e+06, 4.57392100e+06, 5.20872900e+06, + 5.93164150e+06, 6.75488600e+06, 7.69238750e+06, 8.76000300e+06, + 9.97579200e+06, 1.13603190e+07, 1.29370020e+07, 1.47325110e+07, + 1.67772160e+07, 1.91057020e+07, 2.17573580e+07, 2.47770320e+07, + 2.82158020e+07, 3.21318340e+07, 3.65913680e+07, 4.16698320e+07, + 4.74531320e+07, 5.40390880e+07, 6.15391000e+07, 7.00800240e+07, + 7.98063360e+07, 9.08825520e+07, 1.03496016e+08, 1.17860088e+08, + 1.34217728e+08, 1.52845616e+08, 1.74058864e+08, 1.98216256e+08, + 2.25726416e+08, 2.57054672e+08, 2.92730944e+08, 3.33358656e+08, + 3.79625056e+08, 4.32312704e+08, 4.92312800e+08, 5.60640192e+08, + 6.38450688e+08, 7.27060416e+08, 8.27968128e+08, 9.42880704e+08, + 1.07374182e+09, 1.22276493e+09, 1.39247091e+09, 1.58573005e+09, + 1.80581133e+09, 2.05643738e+09, 2.34184755e+09, 2.66686925e+09, + 3.03700045e+09, 3.45850163e+09, 3.93850240e+09, 4.48512154e+09, + 5.10760550e+09, 5.81648333e+09, 6.62374502e+09, 7.54304563e+09, + 8.58993459e+09, 9.78211942e+09, 1.11397673e+10, 1.26858404e+10, + 1.44464906e+10, 1.64514990e+10, 1.87347804e+10, 2.13349540e+10, + 2.42960036e+10, 2.76680131e+10, 3.15080192e+10, 3.58809723e+10, + 4.08608440e+10, 4.65318666e+10, 5.29899602e+10, 6.03443651e+10, + 6.87194767e+10, 7.82569554e+10, 8.91181384e+10, 1.01486723e+11, + 1.15571925e+11, 1.31611992e+11, 1.49878243e+11, 1.70679632e+11, + 1.94368029e+11, 2.21344104e+11, 2.52064154e+11, 2.87047778e+11, + 3.26886752e+11, 3.72254933e+11, 4.23919682e+11, 4.82754920e+11, + 5.49755814e+11, 6.26055643e+11, 7.12945107e+11, 8.11893785e+11, + 9.24575400e+11, 1.05289594e+12, 1.19902595e+12, 1.36543705e+12, + 1.55494423e+12, 1.77075284e+12, 2.01651323e+12, 2.29638223e+12, + 2.61509402e+12, 2.97803946e+12, 3.39135745e+12, 3.86203936e+12, + 4.39804651e+12, 5.00844515e+12, 5.70356086e+12, 6.49515028e+12, +}; +#else +static float ff_aac_pow2sf_34_tab[428]; +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AVCODEC_AACCODERTAB_H */ diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 430b800..fa8b3cb 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -38,6 +38,7 @@ #include "aac.h" #include "aactab.h" #include "aacenc.h" +#include "aaccoder.h" #include "psymodel.h" @@ -201,6 +202,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.); #endif /* CONFIG_HARDCODED_TABLES */ + ff_aaccoder_init(); return 0; }
_______________________________________________ FFmpeg-soc mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc
