[FFmpeg-soc] [soc]: r2477 - in aacenc: aacenc.c aacpsy.h
kostya
subversion at mplayerhq.hu
Wed Jun 18 15:17:39 CEST 2008
Author: kostya
Date: Wed Jun 18 15:17:39 2008
New Revision: 2477
Log:
Temporal noise shaping support
Modified:
aacenc/aacenc.c
aacenc/aacpsy.h
Modified: aacenc/aacenc.c
==============================================================================
--- aacenc/aacenc.c (original)
+++ aacenc/aacenc.c Wed Jun 18 15:17:39 2008
@@ -490,6 +490,43 @@ static void encode_pulse_data(AVCodecCon
}
}
+static void encode_tns_data(AVCodecContext *avctx, AACEncContext *s, cpe_struct *cpe, int channel)
+{
+ int i, w;
+
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.present);
+ if(!cpe->ch[channel].tns.present) return;
+ if(cpe->ch[channel].ics.window_sequence == EIGHT_SHORT_SEQUENCE){
+ for(w = 0; w < cpe->ch[channel].ics.num_windows; w++){
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.n_filt[w]);
+ if(!cpe->ch[channel].tns.n_filt[w]) continue;
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.coef_res[w] - 3);
+ put_bits(&s->pb, 4, cpe->ch[channel].tns.length[w][0]);
+ put_bits(&s->pb, 3, cpe->ch[channel].tns.order[w][0]);
+ if(cpe->ch[channel].tns.order[w][0]){
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.direction[w][0]);
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.coef_compress[w][0]);
+ for(i = 0; i < cpe->ch[channel].tns.order[w][0]; i++)
+ put_bits(&s->pb, cpe->ch[channel].tns.coef_len[w][0], cpe->ch[channel].tns.coef[w][0][i]);
+ }
+ }
+ }else{
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.n_filt[0]);
+ if(!cpe->ch[channel].tns.n_filt[0]) return;
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.coef_res[0] - 3);
+ for(w = 0; w < cpe->ch[channel].tns.n_filt[0]; w++){
+ put_bits(&s->pb, 6, cpe->ch[channel].tns.length[0][w]);
+ put_bits(&s->pb, 5, cpe->ch[channel].tns.order[0][w]);
+ if(cpe->ch[channel].tns.order[0][w]){
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.direction[0][w]);
+ put_bits(&s->pb, 1, cpe->ch[channel].tns.coef_compress[0][w]);
+ for(i = 0; i < cpe->ch[channel].tns.order[0][w]; i++)
+ put_bits(&s->pb, cpe->ch[channel].tns.coef_len[0][w], cpe->ch[channel].tns.coef[0][w][i]);
+ }
+ }
+ }
+}
+
static void encode_spectral_data(AVCodecContext *avctx, AACEncContext *s, cpe_struct *cpe, int channel)
{
int start, i, w, w2;
@@ -535,7 +572,7 @@ static int encode_individual_channel(AVC
encode_section_data(avctx, s, cpe, channel);
encode_scale_factor_data(avctx, s, cpe, channel);
encode_pulse_data(avctx, s, cpe, channel);
- put_bits(&s->pb, 1, 0); //tns
+ encode_tns_data(avctx, s, cpe, channel);
put_bits(&s->pb, 1, 0); //ssr
encode_spectral_data(avctx, s, cpe, channel);
return 0;
Modified: aacenc/aacpsy.h
==============================================================================
--- aacenc/aacpsy.h (original)
+++ aacenc/aacpsy.h Wed Jun 18 15:17:39 2008
@@ -72,6 +72,23 @@ typedef struct {
int tns_max_bands;
} ics_struct;
+#define TNS_MAX_ORDER 20
+/**
+ * Temporal Noise Shaping
+ */
+typedef struct {
+ int present;
+ int n_filt[8];
+ int length[8][4];
+ int direction[8][4];
+ int order[8][4];
+ int coef_res[8];
+ int coef_compress[8][4];
+ int coef_len[8][4];
+ const float *tmp2_map[8][4];
+ int coef[8][4][TNS_MAX_ORDER];
+} tns_struct;
+
/**
* M/S joint channel coding
*/
@@ -91,6 +108,7 @@ typedef struct {
*/
ics_struct ics;
pulse_struct pulse;
+ tns_struct tns;
int zeroes[8][64];
int sf_idx[8][64];
int cb[8][64]; ///< Codebooks
More information about the FFmpeg-soc
mailing list