Revision 326438643866 () - Diff

Link to this snippet: https://friendpaste.com/6JgZsbPEH80zirD88rTazL
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
diff -r mplayer-export-arch/libavcodec/Makefile mplayer-export-svn/libavcodec/Makefile
38a39
> OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacpsy.o aactab.o psymodel.o iirfilter.o mdct.o fft.o mpeg4audio.o
105c106
< OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += h263dec.o h263.o h263_parser.o mpeg12data.o mpegvideo.o error_resilience.o vaapi_mpeg4.o
---
> OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o
111d111
< OBJS-$(CONFIG_H264_VDPAU_DECODER) += h264.o h264idct.o h264pred.o h264_parser.o cabac.o mpegvideo.o error_resilience.o
143,144d142
< OBJS-$(CONFIG_MPEG_VDPAU_DECODER) += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
< OBJS-$(CONFIG_MPEG1_VDPAU_DECODER) += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
149c147
< OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o vaapi_mpeg2.o
---
> OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o
154c152
< OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += h263dec.o h263.o mpeg4video_parser.o mpeg12data.o mpegvideo.o error_resilience.o vaapi_mpeg4.o
---
> OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += vaapi_mpeg4.o
242,243c240
< OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vc1dec.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o vaapi_vc1.o
< OBJS-$(CONFIG_VC1_VDPAU_DECODER) += vc1dec.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o
---
> OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o
267,268c264
< OBJS-$(CONFIG_WMV3_VAAPI_HWACCEL) += vc1dec.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o vaapi_vc1.o
< OBJS-$(CONFIG_WMV3_VDPAU_DECODER) += vc1dec.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o
---
> OBJS-$(CONFIG_WMV3_VAAPI_HWACCEL) += vaapi_vc1.o
385,402c381,400
< OBJS-$(CONFIG_LIBAMR_NB) += libamr.o
< OBJS-$(CONFIG_LIBAMR_WB) += libamr.o
< OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o
< OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o
< OBJS-$(CONFIG_LIBFAAC) += libfaac.o
< OBJS-$(CONFIG_LIBFAAD) += libfaad.o
< OBJS-$(CONFIG_LIBGSM) += libgsm.o
< OBJS-$(CONFIG_LIBMP3LAME) += libmp3lame.o
< OBJS-$(CONFIG_LIBOPENCORE_AMRNB) += libopencore-amr.o
< OBJS-$(CONFIG_LIBOPENCORE_AMRWB) += libopencore-amr.o
< OBJS-$(CONFIG_LIBOPENJPEG) += libopenjpeg.o
< OBJS-$(CONFIG_LIBSCHROEDINGER_DECODER) += libschroedingerdec.o libschroedinger.o libdirac_libschro.o
< OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o libschroedinger.o libdirac_libschro.o
< OBJS-$(CONFIG_LIBSPEEX) += libspeexdec.o
< OBJS-$(CONFIG_LIBTHEORA) += libtheoraenc.o
< OBJS-$(CONFIG_LIBVORBIS) += libvorbis.o
< OBJS-$(CONFIG_LIBX264) += libx264.o
< OBJS-$(CONFIG_LIBXVID) += libxvidff.o libxvid_rc.o
---
> OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o
> OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o
> OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o
> OBJS-$(CONFIG_LIBFAAD_DECODER) += libfaad.o
> OBJS-$(CONFIG_LIBGSM_DECODER) += libgsm.o
> OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o
> OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsm.o
> OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsm.o
> OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o
> OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o
> OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o
> OBJS-$(CONFIG_LIBOPENCORE_AMRWB_ENCODER) += libopencore-amr.o
> OBJS-$(CONFIG_LIBOPENJPEG_DECODER) += libopenjpeg.o
> OBJS-$(CONFIG_LIBSCHROEDINGER_DECODER) += libschroedingerdec.o libschroedinger.o libdirac_libschro.o
> OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o libschroedinger.o libdirac_libschro.o
> OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o
> OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o
> OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o
> OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
> OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvidff.o libxvid_rc.o
diff -r mplayer-export-arch/libavcodec/aac.c mplayer-export-svn/libavcodec/aac.c
201a202,203
> ac->output_configured = 1;
>
448,453d449
< enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
< memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
< if(set_default_channel_config(ac, new_che_pos, avccontext->channels - (avccontext->channels == 8)))
< return -1;
< if(output_configure(ac, ac->che_pos, new_che_pos, 1))
< return -1;
1582c1578,1580
< if (hdr_info.chan_config)
---
> if (!ac->output_configured && hdr_info.chan_config) {
> enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
> memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
1583a1582,1586
> if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config))
> return -7;
> if (output_configure(ac, ac->che_pos, new_che_pos, 1))
> return -7;
> }
1658c1661,1665
< err = output_configure(ac, ac->che_pos, new_che_pos, 0);
---
> if (ac->output_configured)
> av_log(avccontext, AV_LOG_ERROR,
> "Not evaluating a further program_config_element as this construct is dubious at best.\n");
> else
> err = output_configure(ac, ac->che_pos, new_che_pos, 0);
diff -r mplayer-export-arch/libavcodec/aac.h mplayer-export-svn/libavcodec/aac.h
118a119,124
> #define SCALE_DIV_512 36 ///< scalefactor difference that corresponds to scale difference in 512 times
> #define SCALE_ONE_POS 140 ///< scalefactor index that corresponds to scale=1.0
> #define SCALE_MAX_POS 255 ///< scalefactor index maximum value
> #define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard
> #define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference
>
128a135
> const uint8_t *swb_sizes; ///< table of scalefactor band sizes for a particular window
167a175
> int start;
192c200,201
< enum BandType band_type[120]; ///< band types
---
> Pulse pulse;
> enum BandType band_type[128]; ///< band types
194a204,205
> int sf_idx[128]; ///< scalefactor indices (used by encoder)
> uint8_t zeroes[128]; ///< band is not coded (used by encoder)
196c207
< DECLARE_ALIGNED_16(float, saved[512]); ///< overlap
---
> DECLARE_ALIGNED_16(float, saved[1024]); ///< overlap
206c217,219
< uint8_t ms_mask[120]; ///< Set if mid/side stereo is used for each scalefactor window band
---
> int common_window; ///< Set if channels share a common 'IndividualChannelStream' in bitstream.
> int ms_mode; ///< Signals mid/side stereo flags coding mode (used by encoder)
> uint8_t ms_mask[128]; ///< Set if mid/side stereo is used for each scalefactor window band
263a277,278
>
> int output_configured;
Only in mplayer-export-svn/libavcodec: aaccoder.c
diff -r mplayer-export-arch/libavcodec/aacenc.c mplayer-export-svn/libavcodec/aacenc.c
29d28
< * psy model selection with some option
35c34
< #include "get_bits.h"
---
> #include "put_bits.h"
39d37
< #include "aacpsy.h"
41a40,42
> #include "aacenc.h"
>
> #include "psymodel.h"
86c87
< static const uint8_t * const swb_size_1024[] = {
---
> static const uint8_t *swb_size_1024[] = {
113c114
< static const uint8_t * const swb_size_128[] = {
---
> static const uint8_t *swb_size_128[] = {
122,138d122
< /** bits needed to code codebook run value for long windows */
< static const uint8_t run_value_bits_long[64] = {
< 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
< 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10,
< 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
< 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15
< };
<
< /** bits needed to code codebook run value for short windows */
< static const uint8_t run_value_bits_short[16] = {
< 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 9
< };
<
< static const uint8_t* const run_value_bits[2] = {
< run_value_bits_long, run_value_bits_short
< };
<
150,176d133
< * structure used in optimal codebook search
< */
< typedef struct BandCodingPath {
< int prev_idx; ///< pointer to the previous path point
< int codebook; ///< codebook for coding band run
< int bits; ///< number of bit needed to code given number of bands
< } BandCodingPath;
<
< /**
< * AAC encoder context
< */
< typedef struct {
< PutBitContext pb;
< MDCTContext mdct1024; ///< long (1024 samples) frame transform context
< MDCTContext mdct128; ///< short (128 samples) frame transform context
< DSPContext dsp;
< DECLARE_ALIGNED_16(FFTSample, output[2048]); ///< temporary buffer for MDCT input coefficients
< int16_t* samples; ///< saved preprocessed input
<
< int samplerate_index; ///< MPEG-4 samplerate index
<
< ChannelElement *cpe; ///< channel elements
< AACPsyContext psy; ///< psychoacoustic model context
< int last_frame;
< } AACEncContext;
<
< /**
199a157,158
> const uint8_t *sizes[2];
> int lengths[2];
203,204c162,163
< for(i = 0; i < 16; i++)
< if(avctx->sample_rate == ff_mpeg4audio_sample_rates[i])
---
> for (i = 0; i < 16; i++)
> if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i])
206c165
< if(i == 16){
---
> if (i == 16) {
210c169
< if(avctx->channels > 6){
---
> if (avctx->channels > 6) {
225,233c184,186
< s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0]));
< s->cpe = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]);
< if(ff_aac_psy_init(&s->psy, avctx, AAC_PSY_3GPP,
< aac_chan_configs[avctx->channels-1][0], 0,
< swb_size_1024[i], ff_aac_num_swb_1024[i], swb_size_128[i], ff_aac_num_swb_128[i]) < 0){
< av_log(avctx, AV_LOG_ERROR, "Cannot initialize selected model.\n");
< return -1;
< }
< avctx->extradata = av_malloc(2);
---
> s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0]));
> s->cpe = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]);
> avctx->extradata = av_malloc(2);
235a189,207
>
> sizes[0] = swb_size_1024[i];
> sizes[1] = swb_size_128[i];
> lengths[0] = ff_aac_num_swb_1024[i];
> lengths[1] = ff_aac_num_swb_128[i];
> ff_psy_init(&s->psy, avctx, 2, sizes, lengths);
> s->psypp = ff_psy_preprocess_init(avctx);
> s->coder = &ff_aac_coders[0];
>
> s->lambda = avctx->global_quality ? avctx->global_quality : 120;
> #if !CONFIG_HARDCODED_TABLES
> for (i = 0; i < 428; i++)
> ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.);
> #endif /* CONFIG_HARDCODED_TABLES */
>
> if (avctx->channels > 5)
> av_log(avctx, AV_LOG_ERROR, "This encoder does not yet enforce the restrictions on LFEs. "
> "The output will most likely be an illegal bitstream.\n");
>
238a211,262
> static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s,
> SingleChannelElement *sce, short *audio, int channel)
> {
> int i, j, k;
> const float * lwindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;
> const float * swindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
> const float * pwindow = sce->ics.use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
>
> if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
> memcpy(s->output, sce->saved, sizeof(float)*1024);
> if (sce->ics.window_sequence[0] == LONG_STOP_SEQUENCE) {
> memset(s->output, 0, sizeof(s->output[0]) * 448);
> for (i = 448; i < 576; i++)
> s->output[i] = sce->saved[i] * pwindow[i - 448];
> for (i = 576; i < 704; i++)
> s->output[i] = sce->saved[i];
> }
> if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) {
> j = channel;
> for (i = 0; i < 1024; i++, j += avctx->channels) {
> s->output[i+1024] = audio[j] * lwindow[1024 - i - 1];
> sce->saved[i] = audio[j] * lwindow[i];
> }
> } else {
> j = channel;
> for (i = 0; i < 448; i++, j += avctx->channels)
> s->output[i+1024] = audio[j];
> for (i = 448; i < 576; i++, j += avctx->channels)
> s->output[i+1024] = audio[j] * swindow[576 - i - 1];
> memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448);
> j = channel;
> for (i = 0; i < 1024; i++, j += avctx->channels)
> sce->saved[i] = audio[j];
> }
> ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output);
> } else {
> j = channel;
> for (k = 0; k < 1024; k += 128) {
> for (i = 448 + k; i < 448 + k + 256; i++)
> s->output[i - 448 - k] = (i < 1024)
> ? sce->saved[i]
> : audio[channel + (i-1024)*avctx->channels];
> s->dsp.vector_fmul (s->output, k ? swindow : pwindow, 128);
> s->dsp.vector_fmul_reverse(s->output+128, s->output+128, swindow, 128);
> ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output);
> }
> j = channel;
> for (i = 0; i < 1024; i++, j += avctx->channels)
> sce->saved[i] = audio[j];
> }
> }
>
245c269
< int i;
---
> int w;
250c274
< if(info->window_sequence[0] != EIGHT_SHORT_SEQUENCE){
---
> if (info->window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
253c277
< }else{
---
> } else {
255,256c279,342
< for(i = 1; i < info->num_windows; i++)
< put_bits(&s->pb, 1, info->group_len[i]);
---
> for (w = 1; w < 8; w++)
> put_bits(&s->pb, 1, !info->group_len[w]);
> }
> }
>
> /**
> * Encode MS data.
> * @see 4.6.8.1 "Joint Coding - M/S Stereo"
> */
> static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe)
> {
> int i, w;
>
> put_bits(pb, 2, cpe->ms_mode);
> if (cpe->ms_mode == 1)
> for (w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w])
> for (i = 0; i < cpe->ch[0].ics.max_sfb; i++)
> put_bits(pb, 1, cpe->ms_mask[w*16 + i]);
> }
>
> /**
> * Produce integer coefficients from scalefactors provided by the model.
> */
> static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, int chans)
> {
> int i, w, w2, g, ch;
> int start, sum, maxsfb, cmaxsfb;
>
> for (ch = 0; ch < chans; ch++) {
> IndividualChannelStream *ics = &cpe->ch[ch].ics;
> start = 0;
> maxsfb = 0;
> cpe->ch[ch].pulse.num_pulse = 0;
> for (w = 0; w < ics->num_windows*16; w += 16) {
> for (g = 0; g < ics->num_swb; g++) {
> sum = 0;
> //apply M/S
> if (!ch && cpe->ms_mask[w + g]) {
> for (i = 0; i < ics->swb_sizes[g]; i++) {
> cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;
> cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];
> }
> }
> start += ics->swb_sizes[g];
> }
> for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--)
> ;
> maxsfb = FFMAX(maxsfb, cmaxsfb);
> }
> ics->max_sfb = maxsfb;
>
> //adjust zero bands for window groups
> for (w = 0; w < ics->num_windows; w += ics->group_len[w]) {
> for (g = 0; g < ics->max_sfb; g++) {
> i = 1;
> for (w2 = w; w2 < w + ics->group_len[w]; w2++) {
> if (!cpe->ch[ch].zeroes[w2*16 + g]) {
> i = 0;
> break;
> }
> }
> cpe->ch[ch].zeroes[w*16 + g] = i;
> }
> }
257a344,370
>
> if (chans > 1 && cpe->common_window) {
> IndividualChannelStream *ics0 = &cpe->ch[0].ics;
> IndividualChannelStream *ics1 = &cpe->ch[1].ics;
> int msc = 0;
> ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb);
> ics1->max_sfb = ics0->max_sfb;
> for (w = 0; w < ics0->num_windows*16; w += 16)
> for (i = 0; i < ics0->max_sfb; i++)
> if (cpe->ms_mask[w+i])
> msc++;
> if (msc == 0 || ics0->max_sfb == 0)
> cpe->ms_mode = 0;
> else
> cpe->ms_mode = msc < ics0->max_sfb ? 1 : 2;
> }
> }
>
> /**
> * Encode scalefactor band coding type.
> */
> static void encode_band_info(AACEncContext *s, SingleChannelElement *sce)
> {
> int w;
>
> for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
> s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda);
261c374
< * Calculate the number of bits needed to code all coefficient signs in current band.
---
> * Encode scalefactors.
263,264c376,377
< static int calculate_band_sign_bits(AACEncContext *s, SingleChannelElement *sce,
< int group_len, int start, int size)
---
> static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s,
> SingleChannelElement *sce)
266c379
< int bits = 0;
---
> int off = sce->sf_idx[0], diff;
268,271c381,390
< for(w = 0; w < group_len; w++){
< for(i = 0; i < size; i++){
< if(sce->icoefs[start + i])
< bits++;
---
>
> for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
> for (i = 0; i < sce->ics.max_sfb; i++) {
> if (!sce->zeroes[w*16 + i]) {
> diff = sce->sf_idx[w*16 + i] - off + SCALE_DIFF_ZERO;
> if (diff < 0 || diff > 120)
> av_log(avctx, AV_LOG_ERROR, "Scalefactor difference is too big to be coded\n");
> off = sce->sf_idx[w*16 + i];
> put_bits(&s->pb, ff_aac_scalefactor_bits[diff], ff_aac_scalefactor_code[diff]);
> }
273d391
< start += 128;
275d392
< return bits;
286c403,404
< if(!pulse->num_pulse) return;
---
> if (!pulse->num_pulse)
> return;
290c408
< for(i = 0; i < pulse->num_pulse; i++){
---
> for (i = 0; i < pulse->num_pulse; i++) {
301c419
< int start, i, w, w2, wg;
---
> int start, i, w, w2;
303,304c421
< w = 0;
< for(wg = 0; wg < sce->ics.num_window_groups; wg++){
---
> for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
306,307c423,424
< for(i = 0; i < sce->ics.max_sfb; i++){
< if(sce->zeroes[w*16 + i]){
---
> for (i = 0; i < sce->ics.max_sfb; i++) {
> if (sce->zeroes[w*16 + i]) {
311,315c428,433
< for(w2 = w; w2 < w + sce->ics.group_len[wg]; w2++){
< encode_band_coeffs(s, sce, start + w2*128,
< sce->ics.swb_sizes[i],
< sce->band_type[w*16 + i]);
< }
---
> for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++)
> s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128,
> sce->ics.swb_sizes[i],
> sce->sf_idx[w*16 + i],
> sce->band_type[w*16 + i],
> s->lambda);
318d435
< w += sce->ics.group_len[wg];
322a440,458
> * Encode one channel of audio data.
> */
> static int encode_individual_channel(AVCodecContext *avctx, AACEncContext *s,
> SingleChannelElement *sce,
> int common_window)
> {
> put_bits(&s->pb, 8, sce->sf_idx[0]);
> if (!common_window)
> put_ics_info(s, &sce->ics);
> encode_band_info(s, sce);
> encode_scale_factors(avctx, s, sce);
> encode_pulses(s, &sce->pulse);
> put_bits(&s->pb, 1, 0); //tns
> put_bits(&s->pb, 1, 0); //ssr
> encode_spectral_coeffs(s, sce);
> return 0;
> }
>
> /**
325c461,462
< static void put_bitstream_info(AVCodecContext *avctx, AACEncContext *s, const char *name)
---
> static void put_bitstream_info(AVCodecContext *avctx, AACEncContext *s,
> const char *name)
332c469
< if(namelen >= 15)
---
> if (namelen >= 15)
337c474
< for(i = 0; i < namelen - 2; i++)
---
> for (i = 0; i < namelen - 2; i++)
341a479,616
> static int aac_encode_frame(AVCodecContext *avctx,
> uint8_t *frame, int buf_size, void *data)
> {
> AACEncContext *s = avctx->priv_data;
> int16_t *samples = s->samples, *samples2, *la;
> ChannelElement *cpe;
> int i, j, chans, tag, start_ch;
> const uint8_t *chan_map = aac_chan_configs[avctx->channels-1];
> int chan_el_counter[4];
> FFPsyWindowInfo windows[avctx->channels];
>
> if (s->last_frame)
> return 0;
> if (data) {
> if (!s->psypp) {
> memcpy(s->samples + 1024 * avctx->channels, data,
> 1024 * avctx->channels * sizeof(s->samples[0]));
> } else {
> start_ch = 0;
> samples2 = s->samples + 1024 * avctx->channels;
> for (i = 0; i < chan_map[0]; i++) {
> tag = chan_map[i+1];
> chans = tag == TYPE_CPE ? 2 : 1;
> ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch,
> samples2 + start_ch, start_ch, chans);
> start_ch += chans;
> }
> }
> }
> if (!avctx->frame_number) {
> memcpy(s->samples, s->samples + 1024 * avctx->channels,
> 1024 * avctx->channels * sizeof(s->samples[0]));
> return 0;
> }
>
> start_ch = 0;
> for (i = 0; i < chan_map[0]; i++) {
> FFPsyWindowInfo* wi = windows + start_ch;
> tag = chan_map[i+1];
> chans = tag == TYPE_CPE ? 2 : 1;
> cpe = &s->cpe[i];
> samples2 = samples + start_ch;
> la = samples2 + 1024 * avctx->channels + start_ch;
> if (!data)
> la = NULL;
> for (j = 0; j < chans; j++) {
> IndividualChannelStream *ics = &cpe->ch[j].ics;
> int k;
> wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]);
> ics->window_sequence[1] = ics->window_sequence[0];
> ics->window_sequence[0] = wi[j].window_type[0];
> ics->use_kb_window[1] = ics->use_kb_window[0];
> ics->use_kb_window[0] = wi[j].window_shape;
> ics->num_windows = wi[j].num_windows;
> ics->swb_sizes = s->psy.bands [ics->num_windows == 8];
> ics->num_swb = s->psy.num_bands[ics->num_windows == 8];
> for (k = 0; k < ics->num_windows; k++)
> ics->group_len[k] = wi[j].grouping[k];
>
> s->cur_channel = start_ch + j;
> apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j);
> }
> start_ch += chans;
> }
> do {
> int frame_bits;
> init_put_bits(&s->pb, frame, buf_size*8);
> if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
> put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
> start_ch = 0;
> memset(chan_el_counter, 0, sizeof(chan_el_counter));
> for (i = 0; i < chan_map[0]; i++) {
> FFPsyWindowInfo* wi = windows + start_ch;
> tag = chan_map[i+1];
> chans = tag == TYPE_CPE ? 2 : 1;
> cpe = &s->cpe[i];
> for (j = 0; j < chans; j++) {
> s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda);
> }
> cpe->common_window = 0;
> if (chans > 1
> && wi[0].window_type[0] == wi[1].window_type[0]
> && wi[0].window_shape == wi[1].window_shape) {
>
> cpe->common_window = 1;
> for (j = 0; j < wi[0].num_windows; j++) {
> if (wi[0].grouping[j] != wi[1].grouping[j]) {
> cpe->common_window = 0;
> break;
> }
> }
> }
> if (cpe->common_window && s->coder->search_for_ms)
> s->coder->search_for_ms(s, cpe, s->lambda);
> adjust_frame_information(s, cpe, chans);
> put_bits(&s->pb, 3, tag);
> put_bits(&s->pb, 4, chan_el_counter[tag]++);
> if (chans == 2) {
> put_bits(&s->pb, 1, cpe->common_window);
> if (cpe->common_window) {
> put_ics_info(s, &cpe->ch[0].ics);
> encode_ms_info(&s->pb, cpe);
> }
> }
> for (j = 0; j < chans; j++) {
> s->cur_channel = start_ch + j;
> ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]);
> encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window);
> }
> start_ch += chans;
> }
>
> frame_bits = put_bits_count(&s->pb);
> if (frame_bits <= 6144 * avctx->channels - 3)
> break;
>
> s->lambda *= avctx->bit_rate * 1024.0f / avctx->sample_rate / frame_bits;
>
> } while (1);
>
> put_bits(&s->pb, 3, TYPE_END);
> flush_put_bits(&s->pb);
> avctx->frame_bits = put_bits_count(&s->pb);
>
> // rate control stuff
> if (!(avctx->flags & CODEC_FLAG_QSCALE)) {
> float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits;
> s->lambda *= ratio;
> s->lambda = FFMIN(s->lambda, 65536.f);
> }
>
> if (!data)
> s->last_frame = 1;
> memcpy(s->samples, s->samples + 1024 * avctx->channels,
> 1024 * avctx->channels * sizeof(s->samples[0]));
> return put_bits_count(&s->pb)>>3;
> }
>
348c623,624
< ff_aac_psy_end(&s->psy);
---
> ff_psy_end(&s->psy);
> ff_psy_preprocess_end(s->psypp);
Only in mplayer-export-svn/libavcodec: aacenc.h
diff -r mplayer-export-arch/libavcodec/aacpsy.c mplayer-export-svn/libavcodec/aacpsy.c
28d27
< #include "aacpsy.h"
29a29
> #include "psymodel.h"
33,38d32
< * General:
< * better audio preprocessing (add DC highpass filter?)
< * more psy models
< * maybe improve coefficient quantization function in some way
< *
< * 3GPP-based psy model:
45,70d38
< * Quantize one coefficient.
< * @return absolute value of the quantized coefficient
< * @see 3GPP TS26.403 5.6.2 "Scalefactor determination"
< */
< static av_always_inline int quant(float coef, const float Q)
< {
< return av_clip((int)(pow(fabsf(coef) * Q, 0.75) + 0.4054), 0, 8191);
< }
<
< static inline float get_approximate_quant_error(float *c, int size, int scale_idx)
< {
< int i;
< int q;
< float coef, unquant, sum = 0.0f;
< const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
< const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
< for(i = 0; i < size; i++){
< coef = fabs(c[i]);
< q = quant(c[i], Q);
< unquant = (q * cbrt(q)) * IQ;
< sum += (coef - unquant) * (coef - unquant);
< }
< return sum;
< }
<
< /**
75a44,46
>
> #define PSY_3GPP_RPEMIN 0.01f
> #define PSY_3GPP_RPELEV 2.0f
85a57,59
> float thr; ///< energy threshold
> float min_snr; ///< minimal SNR
> float thr_quiet; ///< threshold in quiet
88a63,75
> * single/pair channel context for psychoacoustic model
> */
> typedef struct Psy3gppChannel{
> Psy3gppBand band[128]; ///< bands information
> Psy3gppBand prev_band[128]; ///< bands information from the previous frame
>
> float win_energy; ///< sliding average of channel energy
> float iir_state[2]; ///< hi-pass IIR filter state
> uint8_t next_grouping; ///< stored grouping scheme for the next frame (in case of 8 short window sequence)
> enum WindowSequence next_window_seq; ///< window sequence to be used in the next frame
> }Psy3gppChannel;
>
> /**
98a86,93
> * 3GPP TS26.403-inspired psychoacoustic model specific data
> */
> typedef struct Psy3gppContext{
> Psy3gppCoeffs psy_coef[2];
> Psy3gppChannel *ch;
> }Psy3gppContext;
>
> /**
101c96
< static inline float calc_bark(float f)
---
> static av_cold float calc_bark(float f)
104a100,318
>
> #define ATH_ADD 4
> /**
> * Calculate ATH value for given frequency.
> * Borrowed from Lame.
> */
> static av_cold float ath(float f, float add)
> {
> f /= 1000.0f;
> return 3.64 * pow(f, -0.8)
> - 6.8 * exp(-0.6 * (f - 3.4) * (f - 3.4))
> + 6.0 * exp(-0.15 * (f - 8.7) * (f - 8.7))
> + (0.6 + 0.04 * add) * 0.001 * f * f * f * f;
> }
>
> static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
> Psy3gppContext *pctx;
> float barks[1024];
> int i, j, g, start;
> float prev, minscale, minath;
>
> ctx->model_priv_data = av_mallocz(sizeof(Psy3gppContext));
> pctx = (Psy3gppContext*) ctx->model_priv_data;
>
> for (i = 0; i < 1024; i++)
> barks[i] = calc_bark(i * ctx->avctx->sample_rate / 2048.0);
> minath = ath(3410, ATH_ADD);
> for (j = 0; j < 2; j++) {
> Psy3gppCoeffs *coeffs = &pctx->psy_coef[j];
> i = 0;
> prev = 0.0;
> for (g = 0; g < ctx->num_bands[j]; g++) {
> i += ctx->bands[j][g];
> coeffs->barks[g] = (barks[i - 1] + prev) / 2.0;
> prev = barks[i - 1];
> }
> for (g = 0; g < ctx->num_bands[j] - 1; g++) {
> coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW);
> coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI);
> }
> start = 0;
> for (g = 0; g < ctx->num_bands[j]; g++) {
> minscale = ath(ctx->avctx->sample_rate * start / 1024.0, ATH_ADD);
> for (i = 1; i < ctx->bands[j][g]; i++)
> minscale = FFMIN(minscale, ath(ctx->avctx->sample_rate * (start + i) / 1024.0 / 2.0, ATH_ADD));
> coeffs->ath[g] = minscale - minath;
> start += ctx->bands[j][g];
> }
> }
>
> pctx->ch = av_mallocz(sizeof(Psy3gppChannel) * ctx->avctx->channels);
> return 0;
> }
>
> /**
> * IIR filter used in block switching decision
> */
> static float iir_filter(int in, float state[2])
> {
> float ret;
>
> ret = 0.7548f * (in - state[0]) + 0.5095f * state[1];
> state[0] = in;
> state[1] = ret;
> return ret;
> }
>
> /**
> * window grouping information stored as bits (0 - new group, 1 - group continues)
> */
> static const uint8_t window_grouping[9] = {
> 0xB6, 0x6C, 0xD8, 0xB2, 0x66, 0xC6, 0x96, 0x36, 0x36
> };
>
> /**
> * Tell encoder which window types to use.
> * @see 3GPP TS26.403 5.4.1 "Blockswitching"
> */
> static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
> const int16_t *audio, const int16_t *la,
> int channel, int prev_type)
> {
> int i, j;
> int br = ctx->avctx->bit_rate / ctx->avctx->channels;
> int attack_ratio = br <= 16000 ? 18 : 10;
> Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
> Psy3gppChannel *pch = &pctx->ch[channel];
> uint8_t grouping = 0;
> FFPsyWindowInfo wi;
>
> memset(&wi, 0, sizeof(wi));
> if (la) {
> float s[8], v;
> int switch_to_eight = 0;
> float sum = 0.0, sum2 = 0.0;
> int attack_n = 0;
> for (i = 0; i < 8; i++) {
> for (j = 0; j < 128; j++) {
> v = iir_filter(audio[(i*128+j)*ctx->avctx->channels], pch->iir_state);
> sum += v*v;
> }
> s[i] = sum;
> sum2 += sum;
> }
> for (i = 0; i < 8; i++) {
> if (s[i] > pch->win_energy * attack_ratio) {
> attack_n = i + 1;
> switch_to_eight = 1;
> break;
> }
> }
> pch->win_energy = pch->win_energy*7/8 + sum2/64;
>
> wi.window_type[1] = prev_type;
> switch (prev_type) {
> case ONLY_LONG_SEQUENCE:
> wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : ONLY_LONG_SEQUENCE;
> break;
> case LONG_START_SEQUENCE:
> wi.window_type[0] = EIGHT_SHORT_SEQUENCE;
> grouping = pch->next_grouping;
> break;
> case LONG_STOP_SEQUENCE:
> wi.window_type[0] = ONLY_LONG_SEQUENCE;
> break;
> case EIGHT_SHORT_SEQUENCE:
> wi.window_type[0] = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
> grouping = switch_to_eight ? pch->next_grouping : 0;
> break;
> }
> pch->next_grouping = window_grouping[attack_n];
> } else {
> for (i = 0; i < 3; i++)
> wi.window_type[i] = prev_type;
> grouping = (prev_type == EIGHT_SHORT_SEQUENCE) ? window_grouping[0] : 0;
> }
>
> wi.window_shape = 1;
> if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
> wi.num_windows = 1;
> wi.grouping[0] = 1;
> } else {
> int lastgrp = 0;
> wi.num_windows = 8;
> for (i = 0; i < 8; i++) {
> if (!((grouping >> i) & 1))
> lastgrp = i;
> wi.grouping[lastgrp]++;
> }
> }
>
> return wi;
> }
>
> /**
> * Calculate band thresholds as suggested in 3GPP TS26.403
> */
> static void psy_3gpp_analyze(FFPsyContext *ctx, int channel,
> const float *coefs, FFPsyWindowInfo *wi)
> {
> Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
> Psy3gppChannel *pch = &pctx->ch[channel];
> int start = 0;
> int i, w, g;
> const int num_bands = ctx->num_bands[wi->num_windows == 8];
> const uint8_t* band_sizes = ctx->bands[wi->num_windows == 8];
> Psy3gppCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];
>
> //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation"
> for (w = 0; w < wi->num_windows*16; w += 16) {
> for (g = 0; g < num_bands; g++) {
> Psy3gppBand *band = &pch->band[w+g];
> band->energy = 0.0f;
> for (i = 0; i < band_sizes[g]; i++)
> band->energy += coefs[start+i] * coefs[start+i];
> band->energy *= 1.0f / (512*512);
> band->thr = band->energy * 0.001258925f;
> start += band_sizes[g];
>
> ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].energy = band->energy;
> }
> }
> //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"
> for (w = 0; w < wi->num_windows*16; w += 16) {
> Psy3gppBand *band = &pch->band[w];
> for (g = 1; g < num_bands; g++)
> band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_low[g-1]);
> for (g = num_bands - 2; g >= 0; g--)
> band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_hi [g]);
> for (g = 0; g < num_bands; g++) {
> band[g].thr_quiet = FFMAX(band[g].thr, coeffs->ath[g]);
> if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE)
> band[g].thr_quiet = FFMAX(PSY_3GPP_RPEMIN*band[g].thr_quiet,
> FFMIN(band[g].thr_quiet,
> PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
> band[g].thr = FFMAX(band[g].thr, band[g].thr_quiet * 0.25);
>
> ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].threshold = band[g].thr;
> }
> }
> memcpy(pch->prev_band, pch->band, sizeof(pch->band));
> }
>
> static av_cold void psy_3gpp_end(FFPsyContext *apc)
> {
> Psy3gppContext *pctx = (Psy3gppContext*) apc->model_priv_data;
> av_freep(&pctx->ch);
> av_freep(&apc->model_priv_data);
> }
>
>
> const FFPsyModel ff_aac_psy_model =
> {
> .name = "3GPP TS 26.403-inspired model",
> .init = psy_3gpp_init,
> .window = psy_3gpp_window,
> .analyze = psy_3gpp_analyze,
> .end = psy_3gpp_end,
> };
diff -r mplayer-export-arch/libavcodec/allcodecs.c mplayer-export-svn/libavcodec/allcodecs.c
198c198
< REGISTER_DECODER (AAC, aac);
---
> REGISTER_ENCDEC (AAC, aac);
306,307d305
< REGISTER_ENCDEC (LIBAMR_NB, libamr_nb);
< REGISTER_ENCDEC (LIBAMR_WB, libamr_wb);
diff -r mplayer-export-arch/libavcodec/dvbsubdec.c mplayer-export-svn/libavcodec/dvbsubdec.c
1307a1308
> rect->type = SUBTITLE_BITMAP;
diff -r mplayer-export-arch/libavcodec/iirfilter.c mplayer-export-svn/libavcodec/iirfilter.c
28d27
< #include <complex.h>
51c50
< struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type,
---
> av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type,
56c55
< int i, j, size;
---
> int i, j;
59c58
< complex p[MAXORDER + 1];
---
> double p[MAXORDER + 1][2];
77c76,77
< p[0] = 1.0;
---
> p[0][0] = 1.0;
> p[0][1] = 0.0;
79c79
< p[i] = 0.0;
---
> p[i][0] = p[i][1] = 0.0;
81c81
< complex zp;
---
> double zp[2];
83,84c83,91
< zp = cexp(I*th) * wa;
< zp = (zp + 2.0) / (zp - 2.0);
---
> double a_re, a_im, c_re, c_im;
> zp[0] = cos(th) * wa;
> zp[1] = sin(th) * wa;
> a_re = zp[0] + 2.0;
> c_re = zp[0] - 2.0;
> a_im =
> c_im = zp[1];
> zp[0] = (a_re * c_re + a_im * c_im) / (c_re * c_re + c_im * c_im);
> zp[1] = (a_im * c_re - a_re * c_im) / (c_re * c_re + c_im * c_im);
87,88c94,102
< p[j] = zp*p[j] + p[j - 1];
< p[0] *= zp;
---
> {
> a_re = p[j][0];
> a_im = p[j][1];
> p[j][0] = a_re*zp[0] - a_im*zp[1] + p[j-1][0];
> p[j][1] = a_re*zp[1] + a_im*zp[0] + p[j-1][1];
> }
> a_re = p[0][0]*zp[0] - p[0][1]*zp[1];
> p[0][1] = p[0][0]*zp[1] + p[0][1]*zp[0];
> p[0][0] = a_re;
90c104
< c->gain = creal(p[order]);
---
> c->gain = p[order][0];
92,93c106,108
< c->gain += creal(p[i]);
< c->cy[i] = creal(-p[i] / p[order]);
---
> c->gain += p[i][0];
> c->cy[i] = (-p[i][0] * p[order][0] + -p[i][1] * p[order][1]) /
> (p[order][0] * p[order][0] + p[order][1] * p[order][1]);
100c115
< struct FFIIRFilterState* ff_iir_filter_init_state(int order)
---
> av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order)
151c166
< void ff_iir_filter_free_state(struct FFIIRFilterState *state)
---
> av_cold void ff_iir_filter_free_state(struct FFIIRFilterState *state)
156c171
< void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs)
---
> av_cold void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs)
diff -r mplayer-export-arch/libavcodec/indeo3.c mplayer-export-svn/libavcodec/indeo3.c
109a110
> av_freep(&s->buf);
145,147c146,148
< av_free(s->buf);
< av_free(s->ModPred);
< av_free(s->corrector_type);
---
> av_freep(&s->buf);
> av_freep(&s->ModPred);
> av_freep(&s->corrector_type);
978c979
< static int iv_decode_frame(Indeo3DecodeContext *s,
---
> static int iv_decode_frame(AVCodecContext *avctx,
980a982
> Indeo3DecodeContext *s = avctx->priv_data;
997c999
< if(avcodec_check_dimensions(NULL, image_width, image_height))
---
> if(avcodec_check_dimensions(avctx, image_width, image_height))
998a1001,1011
> if (image_width != avctx->width || image_height != avctx->height) {
> int ret;
> avcodec_set_dimensions(avctx, image_width, image_height);
> s->width = avctx->width;
> s->height = avctx->height;
> ret = iv_alloc_frames(s);
> if (ret < 0) {
> s->width = s->height = 0;
> return ret;
> }
> }
1073c1086
< if (iv_decode_frame(s, buf, buf_size) < 0)
---
> if (iv_decode_frame(avctx, buf, buf_size) < 0)
Only in mplayer-export-arch/libavcodec: libamr.c
diff -r mplayer-export-arch/libavcodec/libtheoraenc.c mplayer-export-svn/libavcodec/libtheoraenc.c
50c50
< char* message = NULL;
---
> const char* message = NULL;
152a153,157
> /* Clear up theora_comment struct before we reset the packet */
> theora_comment_clear( &t_comment );
> /* And despite documentation to the contrary, theora_comment_clear
> * does not release the packet */
> ogg_packet_clear(&o_packet);
160,162d164
< /* Clear up theora_comment struct */
< theora_comment_clear( &t_comment );
<
251a254,257
> av_freep(&avc_context->coded_frame);
> av_freep(&avc_context->extradata);
> avc_context->extradata_size = 0;
>
Only in mplayer-export-svn/libavcodec: psymodel.c
Only in mplayer-export-svn/libavcodec: psymodel.h
diff -r mplayer-export-arch/libavcodec/qpeg.c mplayer-export-svn/libavcodec/qpeg.c
291a292,295
> if (!avctx->palctrl) {
> av_log(avctx, AV_LOG_FATAL, "Missing required palette via palctrl\n");
> return -1;
> }
diff -r mplayer-export-arch/libavcodec/qtrleenc.c mplayer-export-svn/libavcodec/qtrleenc.c
76a77,79
> case PIX_FMT_ARGB:
> s->pixel_size = 4;
> break;
328c331
< .pix_fmts = (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_NONE},
---
> .pix_fmts = (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_ARGB, PIX_FMT_NONE},
diff -r mplayer-export-arch/libavcodec/vorbis.c mplayer-export-svn/libavcodec/vorbis.c
47a48,50
> // the two bits[p] > 32 checks should be redundant, all calling code should
> // already ensure that, but since it allows overwriting the stack it seems
> // reasonable to check redundantly.
65a69
> if (bits[p] > 32) return 1;
81a86
> if (bits[p] > 32) return 1;
diff -r mplayer-export-arch/libavcodec/vorbis_dec.c mplayer-export-svn/libavcodec/vorbis_dec.c
295c295
< for(;current_entry<used_entries;++current_length) {
---
> for(;current_entry<used_entries && current_length <= 32;++current_length) {
diff -r mplayer-export-arch/libavcodec/vp3.c mplayer-export-svn/libavcodec/vp3.c
519a520,521
> *
> * The filter_limit_values may not be larger than 127.
525a528
> int value;
532d534
< bounding_values[-x - filter_limit] = -filter_limit + x;
535d536
< bounding_values[x + filter_limit] = filter_limit - x;
536a538,543
> for (x = value = filter_limit; x < 128 && value; x++, value--) {
> bounding_values[ x] = value;
> bounding_values[-x] = -value;
> }
> if (value)
> bounding_values[128] = value;
1784c1791
< init_vlc(&s->dc_vlc[i], 5, 32,
---
> if (init_vlc(&s->dc_vlc[i], 5, 32,
1786c1793,1794
< &s->huffman_table[i][0][0], 4, 2, 0);
---
> &s->huffman_table[i][0][0], 4, 2, 0) < 0)
> goto vlc_fail;
1789c1797
< init_vlc(&s->ac_vlc_1[i], 5, 32,
---
> if (init_vlc(&s->ac_vlc_1[i], 5, 32,
1791c1799,1800
< &s->huffman_table[i+16][0][0], 4, 2, 0);
---
> &s->huffman_table[i+16][0][0], 4, 2, 0) < 0)
> goto vlc_fail;
1794c1803
< init_vlc(&s->ac_vlc_2[i], 5, 32,
---
> if (init_vlc(&s->ac_vlc_2[i], 5, 32,
1796c1805,1806
< &s->huffman_table[i+16*2][0][0], 4, 2, 0);
---
> &s->huffman_table[i+16*2][0][0], 4, 2, 0) < 0)
> goto vlc_fail;
1799c1809
< init_vlc(&s->ac_vlc_3[i], 5, 32,
---
> if (init_vlc(&s->ac_vlc_3[i], 5, 32,
1801c1811,1812
< &s->huffman_table[i+16*3][0][0], 4, 2, 0);
---
> &s->huffman_table[i+16*3][0][0], 4, 2, 0) < 0)
> goto vlc_fail;
1804c1815
< init_vlc(&s->ac_vlc_4[i], 5, 32,
---
> if (init_vlc(&s->ac_vlc_4[i], 5, 32,
1806c1817,1818
< &s->huffman_table[i+16*4][0][0], 4, 2, 0);
---
> &s->huffman_table[i+16*4][0][0], 4, 2, 0) < 0)
> goto vlc_fail;
1839a1852,1855
>
> vlc_fail:
> av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n");
> return -1;
2167c2183
< for (i = 0; i < 64; i++)
---
> for (i = 0; i < 64; i++) {
2168a2185,2189
> if (s->filter_limit_values[i] > 127) {
> av_log(avctx, AV_LOG_ERROR, "filter limit value too large (%i > 127), clamping\n", s->filter_limit_values[i]);
> s->filter_limit_values[i] = 127;
> }
> }
2325,2326c2346
< vp3_decode_init(avctx);
< return 0;
---
> return vp3_decode_init(avctx);
diff -r mplayer-export-arch/libavcodec/vp56.h mplayer-export-svn/libavcodec/vp56.h
52a53
> const uint8_t *end;
187a189
> c->end = buf + buf_size;
208c210
< if (--c->bits == 0) {
---
> if (--c->bits == 0 && c->buffer < c->end) {
231c233
< if (--c->bits == 0) {
---
> if (--c->bits == 0 && c->buffer < c->end) {
diff -r mplayer-export-arch/libavcodec/vp6.c mplayer-export-svn/libavcodec/vp6.c
374a375,376
> if (get_bits_count(&s->gb) >= s->gb.size_in_bits)
> return;
diff -r mplayer-export-arch/libavformat/Makefile mplayer-export-svn/libavformat/Makefile
23d22
< OBJS-$(CONFIG_ASF_STREAM_MUXER) += asfenc.o asf.o riff.o
81d79
< OBJS-$(CONFIG_IPOD_MUXER) += movenc.o riff.o isom.o avc.o
86d83
< OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += matroskaenc.o matroska.o riff.o isom.o avc.o flacenc.o
101d97
< OBJS-$(CONFIG_MP4_MUXER) += movenc.o riff.o isom.o avc.o
113d108
< OBJS-$(CONFIG_MPEGTSRAW_DEMUXER) += mpegts.o
122d116
< OBJS-$(CONFIG_MXF_D10_MUXER) += mxfenc.o mxf.o audiointerleave.o
178d171
< OBJS-$(CONFIG_PSP_MUXER) += movenc.o riff.o isom.o avc.o
212,213d204
< OBJS-$(CONFIG_TG2_MUXER) += movenc.o riff.o isom.o avc.o
< OBJS-$(CONFIG_TGP_MUXER) += movenc.o riff.o isom.o avc.o
diff -r mplayer-export-arch/libavformat/asfdec.c mplayer-export-svn/libavformat/asfdec.c
636c636
< if(packet_length >= (1U<<29)){
---
> if(!packet_length || packet_length >= (1U<<29)){
diff -r mplayer-export-arch/libavformat/flvdec.c mplayer-export-svn/libavformat/flvdec.c
26a27
> #include "libavutil/avstring.h"
221c222,223
< if(!strcmp(key, "stereo") && acodec) acodec->channels = num_val > 0 ? 2 : 1;
---
> av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
> av_metadata_set(&s->metadata, key, str_val);
222a225,226
> snprintf(str_val, sizeof(str_val), "%.f", num_val);
> av_metadata_set(&s->metadata, key, str_val);
224,225d227
< // else if(!strcmp(key, "width") && vcodec && num_val > 0) vcodec->width = num_val;
< // else if(!strcmp(key, "height") && vcodec && num_val > 0) vcodec->height = num_val;
228,250c230,231
< else if(!strcmp(key, "audiocodecid") && acodec && 0 <= (int)num_val)
< flv_set_audio_codec(s, astream, (int)num_val << FLV_AUDIO_CODECID_OFFSET);
< else if(!strcmp(key, "videocodecid") && vcodec && 0 <= (int)num_val)
< flv_set_video_codec(s, vstream, (int)num_val);
< else if(!strcmp(key, "audiosamplesize") && acodec && 0 < (int)num_val) {
< acodec->bits_per_coded_sample = num_val;
< //we may have to rewrite a previously read codecid because FLV only marks PCM endianness.
< if(num_val == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE))
< acodec->codec_id = CODEC_ID_PCM_S8;
< }
< else if(!strcmp(key, "audiosamplerate") && acodec && num_val >= 0) {
< //some tools, like FLVTool2, write consistently approximate metadata sample rates
< if (!acodec->sample_rate) {
< switch((int)num_val) {
< case 44000: acodec->sample_rate = 44100 ; break;
< case 22000: acodec->sample_rate = 22050 ; break;
< case 11000: acodec->sample_rate = 11025 ; break;
< case 5000 : acodec->sample_rate = 5512 ; break;
< default : acodec->sample_rate = num_val;
< }
< }
< }
< }
---
> } else if (amf_type == AMF_DATA_TYPE_STRING)
> av_metadata_set(&s->metadata, key, str_val);
378c359
< if (type == FLV_TAG_TYPE_META && size > 13+1+4 && 0)
---
> if (type == FLV_TAG_TYPE_META && size > 13+1+4)
diff -r mplayer-export-arch/libavformat/os_support.h mplayer-export-svn/libavformat/os_support.h
32c32
< #ifdef __MINGW32__
---
> #if defined(__MINGW32__) && !defined(__MINGW32CE__)
diff -r mplayer-export-arch/libavformat/soxdec.c mplayer-export-svn/libavformat/soxdec.c
114a115,116
> st->codec->block_align = st->codec->bits_per_coded_sample *
> st->codec->channels / 8;
121c123
< #define MAX_SIZE 4096
---
> #define SOX_SAMPLES 1024
126c128
< int ret;
---
> int ret, size;
131c133,134
< ret = av_get_packet(s->pb, pkt, MAX_SIZE);
---
> size = SOX_SAMPLES*s->streams[0]->codec->block_align;
> ret = av_get_packet(s->pb, pkt, size);
diff -r mplayer-export-arch/libavformat/tcp.c mplayer-export-svn/libavformat/tcp.c
133c133
< return AVERROR(errno);
---
> return AVERROR(ff_neterrno());
163c163
< return AVERROR(errno);
---
> return AVERROR(ff_neterrno());
diff -r mplayer-export-arch/libavformat/utils.c mplayer-export-svn/libavformat/utils.c
501a502,503
> if (ap && ap->prealloced_context)
> av_free(*ic_ptr);
diff -r mplayer-export-arch/libavutil/Makefile mplayer-export-svn/libavutil/Makefile
40c40
< sha1.o \
---
> sha.o \
44c44
< TESTPROGS = adler32 aes base64 crc des lls md5 pca sha1 softfloat tree
---
> TESTPROGS = adler32 aes base64 crc des lls md5 pca sha softfloat tree
diff -r mplayer-export-arch/libavutil/internal.h mplayer-export-svn/libavutil/internal.h
261,277d260
< #if defined(__ICC) || defined(__SUNPRO_C)
< #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
< #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
< #elif defined(__GNUC__)
< #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
< #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n)))
< #elif defined(_MSC_VER)
< #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
< #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
< #elif HAVE_INLINE_ASM
< #error The asm code needs alignment, but we do not know how to do it for this compiler.
< #else
< #define DECLARE_ALIGNED(n,t,v) t v
< #define DECLARE_ASM_CONST(n,t,v) static const t v
< #endif
<
<
284a268,274
> #if !HAVE_LOG2
> static av_always_inline av_const double log2(double x)
> {
> return log(x) * 1.44269504088896340736;
> }
> #endif /* HAVE_LOG2 */
>
diff -r mplayer-export-arch/libavutil/log.h mplayer-export-svn/libavutil/log.h
32,33c32
< typedef struct AVCLASS AVClass;
< struct AVCLASS {
---
> typedef struct {
52c51
< };
---
> } AVClass;
diff -r mplayer-export-arch/libavutil/mem.h mplayer-export-svn/libavutil/mem.h
30a31,45
> #if defined(__ICC) || defined(__SUNPRO_C)
> #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
> #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
> #elif defined(__GNUC__)
> #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
> #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n)))
> #elif defined(_MSC_VER)
> #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
> #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
> #else
> #define DECLARE_ALIGNED(n,t,v) t v
> #define DECLARE_ASM_CONST(n,t,v) static const t v
> #endif
>
>
Only in mplayer-export-svn/libavutil: sha.c
Only in mplayer-export-svn/libavutil: sha.h
Only in mplayer-export-arch/libavutil: sha1.c
diff -r mplayer-export-arch/libavutil/sha1.h mplayer-export-svn/libavutil/sha1.h
29a30,35
> /**
> * Initializes SHA-1 hashing.
> *
> * @param context pointer to the function context (of size av_sha_size)
> * @deprecated use av_sha_init() instead
> */
30a37,45
>
> /**
> * Updates hash value.
> *
> * @param context hash function context
> * @param data input data to update hash with
> * @param len input data length
> * @deprecated use av_sha_update() instead
> */
31a47,54
>
> /**
> * Finishes hashing and output digest value.
> *
> * @param context hash function context
> * @param digest buffer where output digest value is stored
> * @deprecated use av_sha_final() instead
> */