summaryrefslogtreecommitdiff
path: root/packages/mplayer/files/mplayer-1.0rc1-atmel.2.patch
blob: 800f43e8ebbc0af134b1d350b67e78a84030eb10 (plain)
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
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
 cfg-common.h                     |    4 +
 cfg-mencoder.h                   |    4 +
 cfg-mplayer.h                    |    4 +
 configure                        |   13 +-
 libaf/af_format.c                |    7 +
 libavcodec/Makefile              |    7 +
 libavcodec/avr32/dsputil_avr32.c | 2678 ++++++++++++++++++++++++++++++++++++++
 libavcodec/avr32/fdct.S          |  541 ++++++++
 libavcodec/avr32/h264idct.S      |  451 +++++++
 libavcodec/avr32/idct.S          |  829 ++++++++++++
 libavcodec/avr32/mc.S            |  434 ++++++
 libavcodec/avr32/pico.h          |  260 ++++
 libavcodec/bitstream.h           |   77 +-
 libavcodec/dsputil.c             |    3 +
 libavcodec/h264.c                |   15 +
 libavutil/common.h               |   16 +
 libavutil/internal.h             |    9 +
 libfaad2/common.h                |    2 +-
 libmpcodecs/ad_libmad.c          |    5 +
 libswscale/pico-avr32.h          |  137 ++
 libswscale/swscale_internal.h    |    2 +-
 libswscale/yuv2rgb.c             |   14 +
 libswscale/yuv2rgb_avr32.c       |  416 ++++++
 libvo/vo_fbdev2.c                |  101 ++-
 version.sh                       |    2 +-
 25 files changed, 6011 insertions(+), 20 deletions(-)
 create mode 100644 libavcodec/avr32/dsputil_avr32.c
 create mode 100644 libavcodec/avr32/fdct.S
 create mode 100644 libavcodec/avr32/h264idct.S
 create mode 100644 libavcodec/avr32/idct.S
 create mode 100644 libavcodec/avr32/mc.S
 create mode 100644 libavcodec/avr32/pico.h
 create mode 100644 libswscale/pico-avr32.h
 create mode 100644 libswscale/yuv2rgb_avr32.c

diff --git a/cfg-common.h b/cfg-common.h
index 780df38..7d878a8 100644
--- a/cfg-common.h
+++ b/cfg-common.h
@@ -235,6 +235,10 @@
 	{"tsprobe", &ts_probe, CONF_TYPE_POSITION, 0, 0, TS_MAX_PROBE_SIZE, NULL},
 	{"tskeepbroken", &ts_keep_broken, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 
+#ifdef ARCH_AVR32
+        {"use-pico", &avr32_use_pico, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+        {"nouse-pico", &avr32_use_pico, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+#endif
 	// draw by slices or whole frame (useful with libmpeg2/libavcodec)
 	{"slices", &vd_use_slices, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"noslices", &vd_use_slices, CONF_TYPE_FLAG, 0, 1, 0, NULL},
diff --git a/cfg-mencoder.h b/cfg-mencoder.h
index 411b748..addf791 100644
--- a/cfg-mencoder.h
+++ b/cfg-mencoder.h
@@ -5,6 +5,10 @@
 
 #include "cfg-common.h"
 
+#ifdef ARCH_AVR32
+extern int avr32_use_pico;
+#endif
+
 #ifdef USE_FAKE_MONO
 extern int fakemono; // defined in dec_audio.c
 #endif
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 62b6eac..31499c2 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -4,6 +4,10 @@
 
 #include "cfg-common.h"
 
+#ifdef ARCH_AVR32
+extern int avr32_use_pico;
+#endif
+
 extern int noconsolecontrols;
 
 #if defined(HAVE_FBDEV)||defined(HAVE_VESA)
diff --git a/configure b/configure
index 29002c8..56c6fe4 100755
--- a/configure
+++ b/configure
@@ -1203,6 +1203,15 @@ EOF
     _optimizing="$proc"
     ;;
 
+  avr32)
+    _def_arch='#define ARCH_AVR32'
+    _target_arch='TARGET_ARCH_AVR32 = yes'
+    iproc='avr32'
+    proc=''
+    _march=''
+    _mcpu=''
+    _optimizing=''
+    ;;
   arm|armv4l|armv5tel)
     _def_arch='#define ARCH_ARMV4L 1'
     _target_arch='TARGET_ARCH_ARMV4L = yes'
@@ -1533,7 +1542,7 @@ echores $_named_asm_args
 # Checking for CFLAGS
 _stripbinaries=yes
 if test "$_profile" != "" || test "$_debug" != "" ; then
-  CFLAGS="-W -Wall -O2 $_march $_mcpu $_debug $_profile"
+  CFLAGS="-W -Wall -O4 $_march $_mcpu $_debug $_profile"
   if test "$_cc_major" -ge "3" ; then
     CFLAGS=`echo "$CFLAGS" | sed -e 's/\(-Wall\)/\1 -Wno-unused-parameter/'`
   fi
@@ -3794,7 +3803,7 @@ fi
 
 
 echocheck "X11 headers presence"
-  for I in `echo $_inc_extra | sed s/-I//g` /usr/X11/include /usr/X11R6/include /usr/include/X11R6 /usr/include /usr/openwin/include ; do
+  for I in `echo $_inc_extra | sed s/-I//g`; do
     if test -f "$I/X11/Xlib.h" ; then
       _inc_x11="-I$I"
       _x11_headers="yes"
diff --git a/libaf/af_format.c b/libaf/af_format.c
index e5b7cc9..5d7ea6d 100644
--- a/libaf/af_format.c
+++ b/libaf/af_format.c
@@ -20,7 +20,14 @@
 // Integer to float conversion through lrintf()
 #ifdef HAVE_LRINTF
 #include <math.h>
+
+#ifdef ARCH_AVR32
+#define lrintf(x) rint(x)
+#define llrint(x) (long long)rint(x) 
+#else
 long int lrintf(float);
+#endif
+
 #else
 #define lrintf(x) ((int)(x))
 #endif
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 17b6c45..8e1dc96 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -360,6 +360,12 @@ OBJS-$(TARGET_ARCH_SPARC)              += sparc/dsputil_vis.o \
 
 sparc/dsputil_vis.o: CFLAGS += -mcpu=ultrasparc -mtune=ultrasparc
 
+# avr32 specific stuff
+ifeq ($(TARGET_ARCH_AVR32),yes)
+ASM_OBJS += avr32/idct.o avr32/fdct.o avr32/mc.o avr32/h264idct.o
+OBJS += avr32/dsputil_avr32.o
+endif
+
 # sun mediaLib specific stuff
 OBJS-$(HAVE_MLIB)                      += mlib/dsputil_mlib.o \
 
@@ -419,6 +425,7 @@ tests: apiexample $(TESTS)
 clean::
 	rm -f \
 	   i386/*.o i386/*~ \
+	   avr32/*.o avr32/*~ \
 	   armv4l/*.o armv4l/*~ \
 	   mlib/*.o mlib/*~ \
 	   alpha/*.o alpha/*~ \
diff --git a/libavcodec/avr32/dsputil_avr32.c b/libavcodec/avr32/dsputil_avr32.c
new file mode 100644
index 0000000..200284d
--- /dev/null
+++ b/libavcodec/avr32/dsputil_avr32.c
@@ -0,0 +1,2678 @@
+/*
+ * Copyright (c) 2007 Atmel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of ATMEL may not be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+#include "../dsputil.h"
+#include "pico.h"
+
+int avr32_use_pico = 1;
+
+//#define CHECK_DSP_FUNCS_AGAINST_C
+
+#ifdef CHECK_DSP_FUNCS_AGAINST_C
+#define DSP_FUNC_NAME(name) test_ ## name
+#else
+#define DSP_FUNC_NAME(name) name
+#endif
+
+union doubleword {
+  int64_t doubleword;
+  struct {
+    int32_t top;
+    int32_t bottom;
+  } words; 
+};
+
+#undef  LD16
+#undef  LD32
+#undef  LD64
+  
+#define LD16(a) (*((uint16_t*)(a)))
+#define LD32(a) (*((uint32_t*)(a)))
+#define LD64(a) (*((uint64_t*)(a)))
+#define LD64_UNALIGNED(a) \
+  ({ union doubleword __tmp__; \
+   __tmp__.words.top = LD32(a); \
+   __tmp__.words.bottom = LD32(a + 4); \
+   __tmp__.doubleword; }) 
+
+#undef  ST32
+#undef  ST16
+
+#define ST16(a, b) *((uint16_t*)(a)) = (b)
+#define ST32(a, b) *((uint32_t*)(a)) = (b)
+
+#undef rnd_avg32
+#define rnd_avg32(a, b) \
+  ({ uint32_t __tmp__;\
+     asm("pavg.ub\t%0, %1, %2" : "=r"(__tmp__) : "r"(a), "r"(b));\
+     __tmp__;})
+
+void idct_avr32(DCTELEM *data);
+void fdct_avr32(DCTELEM *data);
+
+void idct_put_avr32(uint8_t *dest, int line_size, DCTELEM *data);
+void idct_add_avr32(uint8_t *dest, int line_size, DCTELEM *data);
+
+void h264_idct_add_avr32(uint8_t *dest, DCTELEM *data, int stride);
+void h264_idct8_add_avr32(uint8_t *dest, DCTELEM *data, int stride);
+
+#define extern_dspfunc(PFX, NUM) \
+    void PFX ## _pixels ## NUM ## _avr32(uint8_t *dst, const uint8_t *pixels, int line_size, int h );     \
+    void PFX ## _pixels ## NUM ## _h_avr32(uint8_t *dst, const uint8_t *pixels, int line_size, int h );  \
+    void PFX ## _pixels ## NUM ## _v_avr32(uint8_t *dst, const uint8_t *pixels, int line_size, int h );  \
+    void PFX ## _pixels ## NUM ## _hv_avr32(uint8_t *dst, const uint8_t *pixels, int line_size, int h )
+
+extern_dspfunc(put, 8);
+extern_dspfunc(put_no_rnd, 8);
+extern_dspfunc(avg, 8);
+extern_dspfunc(avg_no_rnd, 8);
+#undef extern_dspfunc
+
+#ifdef CHECK_DSP_FUNCS_AGAINST_C
+#define extern_dspfunc(PFX, NUM)                                        \
+  void PFX ## _pixels ## NUM ## _c(uint8_t *dst, const uint8_t *pixels, int line_size, int h ); \
+  void PFX ## _pixels ## NUM ## _x2_c(uint8_t *dst, const uint8_t *pixels, int line_size, int h ); \
+  void PFX ## _pixels ## NUM ## _y2_c(uint8_t *dst, const uint8_t *pixels, int line_size, int h ); \
+  void PFX ## _pixels ## NUM ## _xy2_c(uint8_t *dst, const uint8_t *pixels, int line_size, int h )
+
+extern_dspfunc(put, 4);
+extern_dspfunc(put_no_rnd, 4);
+extern_dspfunc(put, 8);
+extern_dspfunc(put_no_rnd, 8);
+extern_dspfunc(put, 16);
+extern_dspfunc(put_no_rnd, 16);
+extern_dspfunc(avg, 8);
+extern_dspfunc(avg_no_rnd, 8);
+extern_dspfunc(avg, 16);
+extern_dspfunc(avg_no_rnd, 16);
+
+
+#undef extern_dspfunc
+#define extern_dspfunc(PFX, NUM) \
+void PFX ## NUM ## _mc00_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc10_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc20_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc30_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc01_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc11_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc21_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc31_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc02_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc12_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc22_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc32_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc03_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc13_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc23_c(uint8_t *dst, uint8_t *src, int stride);  \
+void PFX ## NUM ## _mc33_c(uint8_t *dst, uint8_t *src, int stride);  \
+
+extern_dspfunc(put_h264_qpel,  16);
+extern_dspfunc(put_h264_qpel,  8);
+extern_dspfunc(put_h264_qpel,  4);
+extern_dspfunc(avg_h264_qpel,  16);
+extern_dspfunc(avg_h264_qpel,  8);
+extern_dspfunc(avg_h264_qpel,  4);
+
+#undef extern_dspfunc
+
+void put_h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y);
+void put_h264_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y);
+void put_h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y);
+                         
+void avg_h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y);
+void avg_h264_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y);
+void avg_h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y);
+
+
+void dump_block8(uint8_t *block, int line_size, int h);
+void dump_block4(uint8_t *block, int line_size, int h);
+void dump_block(uint8_t *block, int line_size, int h, int w);
+
+void check_block8(uint8_t *test, uint8_t *correct, int line_size_test, int line_size_correct, 
+                  int h, char *name, int max_dev);
+void check_block4(uint8_t *test, uint8_t *correct, int line_size_test, int line_size_correct, 
+                  int h, char *name, int max_dev);
+void check_block(uint8_t *test, uint8_t *correct, int line_size_test, int line_size_correct, 
+                 int h, int width, char *name, int max_dev);
+
+#define PIXOP2( OPNAME, OP ) \
+void OPNAME ## _pixels4_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+    int i;\
+    for(i=0; i<h; i++){\
+        OP(*((uint32_t*)(block  )), LD32(pixels  ));\
+        pixels+=line_size;\
+        block +=line_size;\
+    }\
+}\
+void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
+                                                int src_stride1, int src_stride2, int h){\
+    int i;\
+    for(i=0; i<h; i++){\
+        uint32_t a,b;\
+        a= LD32(&src1[i*src_stride1  ]);\
+        b= LD32(&src2[i*src_stride2  ]);\
+        OP(*((uint32_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
+        a= LD32(&src1[i*src_stride1+4]);\
+        b= LD32(&src2[i*src_stride2+4]);\
+        OP(*((uint32_t*)&dst[i*dst_stride+4]), rnd_avg32(a, b));\
+    }\
+}\
+\
+void OPNAME ## _pixels4_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
+                                                int src_stride1, int src_stride2, int h){\
+    int i;\
+    for(i=0; i<h; i++){\
+        uint32_t a,b;\
+        a= LD32(&src1[i*src_stride1  ]);\
+        b= LD32(&src2[i*src_stride2  ]);\
+        OP(*((uint32_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
+    }\
+}\
+\
+void OPNAME ## _pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
+                                                int src_stride1, int src_stride2, int h){\
+    OPNAME ## _pixels8_l2(dst  , src1  , src2  , dst_stride, src_stride1, src_stride2, h);\
+    OPNAME ## _pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\
+}\
+
+#else
+#define PIXOP2( OPNAME, OP ) \
+static void OPNAME ## _pixels4_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+    int i;\
+    for(i=0; i<h; i++){\
+        OP(*((uint32_t*)(block  )), LD32(pixels  ));\
+        pixels+=line_size;\
+        block +=line_size;\
+    }\
+}\
+static void OPNAME ## _pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+    int i;\
+    for(i=0; i<h; i++){\
+        OP(*((uint32_t*)(block  )), LD32(pixels  ));\
+        OP(*((uint32_t*)(block+4)), LD32(pixels+4));\
+        pixels+=line_size;\
+        block +=line_size;\
+    }\
+}\
+static void OPNAME ## _pixels16_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+    int i;\
+    for(i=0; i<h; i++){\
+        OP(*((uint32_t*)(block  )), LD32(pixels  ));\
+        OP(*((uint32_t*)(block+4)), LD32(pixels+4));\
+        OP(*((uint32_t*)(block+8)), LD32(pixels+8));\
+        OP(*((uint32_t*)(block+12)), LD32(pixels+12));\
+        pixels+=line_size;\
+        block +=line_size;\
+    }\
+}\
+static void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
+                                                int src_stride1, int src_stride2, int h){\
+    int i;\
+    for(i=0; i<h; i++){\
+        uint32_t a,b;\
+        a= LD32(&src1[i*src_stride1  ]);\
+        b= LD32(&src2[i*src_stride2  ]);\
+        OP(*((uint32_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
+        a= LD32(&src1[i*src_stride1+4]);\
+        b= LD32(&src2[i*src_stride2+4]);\
+        OP(*((uint32_t*)&dst[i*dst_stride+4]), rnd_avg32(a, b));\
+    }\
+}\
+\
+static void OPNAME ## _pixels4_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
+                                                int src_stride1, int src_stride2, int h){\
+    int i;\
+    for(i=0; i<h; i++){\
+        uint32_t a,b;\
+        a= LD32(&src1[i*src_stride1  ]);\
+        b= LD32(&src2[i*src_stride2  ]);\
+        OP(*((uint32_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
+    }\
+}\
+\
+static void OPNAME ## _pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
+                                                int src_stride1, int src_stride2, int h){\
+    OPNAME ## _pixels8_l2(dst  , src1  , src2  , dst_stride, src_stride1, src_stride2, h);\
+    OPNAME ## _pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\
+}\
+
+#endif
+
+#define op_avg(a, b) a = rnd_avg32(a, b)
+#define op_put(a, b) a = b
+
+PIXOP2(avg, op_avg)
+PIXOP2(put, op_put)
+#undef op_avg
+#undef op_put
+
+
+
+static inline void copy_block4(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
+{
+  int i;
+  for(i=0; i<h; i++)
+    {
+      ST32(dst   , LD32(src   ));
+      dst+=dstStride;
+      src+=srcStride;
+    }
+}
+
+static void clear_blocks_avr32(DCTELEM *blocks)
+{
+  int n = 12;
+  uint64_t tmp1, tmp2;
+  blocks += 6*64;  
+  asm volatile ( "mov\t%1, 0\n" 
+                 "mov\t%m1, 0\n" 
+                 "mov\t%2, 0\n" 
+                 "mov\t%m2, 0\n" 
+                 "0:\n" 
+                 "stm\t--%3, %1, %m1, %2, %m2\n"
+                 "stm\t--%3, %1, %m1, %2, %m2\n"
+                 "stm\t--%3, %1, %m1, %2, %m2\n"
+                 "stm\t--%3, %1, %m1, %2, %m2\n"        
+                 "sub\t%0, 1\n"        
+                 "brne\t0b\n"        
+                 : "+r"(n), "=&r"(tmp1), "=&r"(tmp2), 
+                 "+r"(blocks));
+}
+
+
+static inline void copy_block8(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
+{
+  int i;
+  for(i=0; i<h; i++)
+    {
+      ST32(dst   , LD32(src   ));
+      ST32(dst+4 , LD32(src+4 ));
+      dst+=dstStride;
+      src+=srcStride;
+    }
+}
+
+static inline void copy_block16(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
+{
+  int i;
+  for(i=0; i<h; i++)
+    {
+      ST32(dst   , LD32(src   ));
+      ST32(dst+4 , LD32(src+4 ));
+      ST32(dst+8 , LD32(src+8 ));
+      ST32(dst+12, LD32(src+12));
+      dst+=dstStride;
+      src+=srcStride;
+    }
+}
+
+
+static void put_h264_chroma_mc2_pico(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+  const int A=(8-x)*(8-y);
+  const int B=(  x)*(8-y);
+  const int C=(8-x)*(  y);
+  const int D=(  x)*(  y);
+  int i;
+  
+  PICO_PUT_W(PICO_COEFF0_A, (A << 16) | (B & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF0_B, 32);
+  PICO_PUT_W(PICO_COEFF1_A, (C << 16) | (D & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF1_B, 0);
+  PICO_PUT_W(PICO_COEFF2_A, 0);
+  PICO_PUT_W(PICO_COEFF2_B, 0);
+  PICO_PUT_W(PICO_CONFIG, 
+             PICO_OUTPUT_MODE(PICO_PLANAR_MODE) 
+             | PICO_INPUT_MODE(PICO_HOR_FILTER_MODE) 
+             | PICO_COEFF_FRAC_BITS(6)
+             | PICO_OFFSET_FRAC_BITS(6));
+  
+  for(i=0; i<h; i++)
+    {
+      
+      int src0 = LD32(src);
+      int src1 = LD32(src + stride);
+
+      PICO_MVRC_W(PICO_INPIX0, src0);
+      PICO_MVRC_W(PICO_INPIX1, src1);
+      PICO_OP(PICO_SINGLE_VECTOR, 2, 0, 4, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 3, 1, 5, 0);
+      src += stride;
+      ST16(dst,(short)PICO_GET_W(PICO_OUTPIX0));
+      dst += stride;
+    }
+}
+
+
+static void put_h264_chroma_mc4_pico(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+  const int A=(8-x)*(8-y);\
+  const int B=(  x)*(8-y);
+  const int C=(8-x)*(  y);
+  const int D=(  x)*(  y);
+  int i;
+  
+  PICO_PUT_W(PICO_COEFF0_A, (A << 16) | (B & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF0_B, 32);
+  PICO_PUT_W(PICO_COEFF1_A, (C << 16) | (D & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF1_B, 0);
+  PICO_PUT_W(PICO_COEFF2_A, 0);
+  PICO_PUT_W(PICO_COEFF2_B, 0);
+  PICO_PUT_W(PICO_CONFIG, 
+             PICO_OUTPUT_MODE(PICO_PLANAR_MODE) 
+             | PICO_INPUT_MODE(PICO_HOR_FILTER_MODE) 
+             | PICO_COEFF_FRAC_BITS(6)
+             | PICO_OFFSET_FRAC_BITS(6));
+
+  for(i=0; i<h; i++)
+    {
+      /*
+        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));
+        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));
+        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));
+        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));
+        dst+= stride;
+        src+= stride;
+      */
+      
+      int src0 = LD32(src);
+      int src1 = (((int)src[4] << 24) | (int)src[stride]);
+      int src2 = LD32(src + stride + 1);
+      
+      PICO_MVRC_W(PICO_INPIX0, src0);
+      PICO_MVRC_W(PICO_INPIX1, src1);
+      PICO_MVRC_W(PICO_INPIX2, src2);
+      PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 7, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 8, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 9, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 10, 0);
+      src += stride;
+      ST32(dst, PICO_GET_W(PICO_OUTPIX0));
+
+      dst += stride;
+    }
+}
+
+static void put_h264_chroma_mc8_pico(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+  const int A=(8-x)*(8-y);
+  const int B=(  x)*(8-y);
+  const int C=(8-x)*(  y);
+  const int D=(  x)*(  y);
+  int i;
+  
+  PICO_PUT_W(PICO_COEFF0_A, (A << 16) | (B & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF0_B, 32);
+  PICO_PUT_W(PICO_COEFF1_A, (C << 16) | (D & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF1_B, 0);
+  PICO_PUT_W(PICO_COEFF2_A, 0);
+  PICO_PUT_W(PICO_COEFF2_B, 0);
+  PICO_PUT_W(PICO_CONFIG, 
+             PICO_OUTPUT_MODE(PICO_PLANAR_MODE) 
+             | PICO_INPUT_MODE(PICO_HOR_FILTER_MODE) 
+             | PICO_COEFF_FRAC_BITS(6)
+             | PICO_OFFSET_FRAC_BITS(6));
+
+  for(i=0; i<h; i++)
+    {
+      /*
+        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));
+        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));
+        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));
+        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));
+        OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));
+        OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));
+        OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));
+        OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));
+        dst+= stride;
+        src+= stride;
+      */  
+      int src0 = LD32(src);
+      int src1 = (((int)src[4] << 24) | (int)src[stride]);
+      int src2 = LD32(src + stride + 1);
+      
+      PICO_MVRC_W(PICO_INPIX0, src0);
+      PICO_MVRC_W(PICO_INPIX1, src1);
+      PICO_MVRC_W(PICO_INPIX2, src2);
+      PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 7, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 8, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 9, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 10, 0);
+      ST32(dst, PICO_GET_W(PICO_OUTPIX0));
+      
+      src0 = LD32(src + 4);
+      src1 = (src[8] << 24) | src[stride + 4];
+      src2 = LD32(src + stride + 5);
+      
+      PICO_MVRC_W(PICO_INPIX0, src0);
+      PICO_MVRC_W(PICO_INPIX1, src1);
+      PICO_MVRC_W(PICO_INPIX2, src2);
+      PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 7, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 8, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 9, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 10, 0);
+      src += stride;
+      ST32(dst + 4, PICO_GET_W(PICO_OUTPIX0));
+
+      dst += stride;
+    }
+}
+
+
+static void avg_h264_chroma_mc2_pico(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+  const int A=(8-x)*(8-y);
+  const int B=(  x)*(8-y);
+  const int C=(8-x)*(  y);
+  const int D=(  x)*(  y);
+  int i;
+  
+  PICO_PUT_W(PICO_COEFF0_A, (A << 16) | (B & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF0_B, 32);
+  PICO_PUT_W(PICO_COEFF1_A, (C << 16) | (D & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF1_B, 0);
+  PICO_PUT_W(PICO_COEFF2_A, 0);
+  PICO_PUT_W(PICO_COEFF2_B, 0);
+  PICO_PUT_W(PICO_CONFIG, 
+             PICO_OUTPUT_MODE(PICO_PLANAR_MODE) 
+             | PICO_INPUT_MODE(PICO_HOR_FILTER_MODE) 
+             | PICO_COEFF_FRAC_BITS(6)
+             | PICO_OFFSET_FRAC_BITS(6));
+  
+  for(i=0; i<h; i++)
+    {
+      int src0 = LD32(src);
+      int src1 = LD32(src + stride);
+      
+      PICO_MVRC_W(PICO_INPIX0, src0);
+      PICO_MVRC_W(PICO_INPIX1, src1);
+      PICO_OP(PICO_SINGLE_VECTOR, 2, 0, 4, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 3, 1, 5, 0);
+      src += stride;
+      ST16(dst, rnd_avg32(LD16(dst), PICO_GET_W(PICO_OUTPIX0)));
+      dst += stride;
+    }
+}
+
+
+static void avg_h264_chroma_mc4_pico(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+  const int A=(8-x)*(8-y);\
+  const int B=(  x)*(8-y);
+  const int C=(8-x)*(  y);
+  const int D=(  x)*(  y);
+  int i;
+  
+  PICO_PUT_W(PICO_COEFF0_A, (A << 16) | (B & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF0_B, 32);
+  PICO_PUT_W(PICO_COEFF1_A, (C << 16) | (D & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF1_B, 0);
+  PICO_PUT_W(PICO_COEFF2_A, 0);
+  PICO_PUT_W(PICO_COEFF2_B, 0);
+  PICO_PUT_W(PICO_CONFIG, 
+             PICO_OUTPUT_MODE(PICO_PLANAR_MODE) 
+             | PICO_INPUT_MODE(PICO_HOR_FILTER_MODE) 
+             | PICO_COEFF_FRAC_BITS(6)
+             | PICO_OFFSET_FRAC_BITS(6));
+
+  for(i=0; i<h; i++)
+    {
+      /*
+        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));
+        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));
+        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));
+        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));
+        dst+= stride;
+        src+= stride;
+      */
+      
+      int src0 = *((int *)src);
+      int src1 = (int)((src[4] << 24) | src[stride]);
+      int src2 = *((int *)(src + stride + 1));
+      
+      PICO_MVRC_W(PICO_INPIX0, src0);
+      PICO_MVRC_W(PICO_INPIX1, src1);
+      PICO_MVRC_W(PICO_INPIX2, src2);
+      PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 7, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 8, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 9, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 10, 0);
+      src += stride;
+      ST32(dst, rnd_avg32(LD32(dst), PICO_GET_W(PICO_OUTPIX0)));
+      dst += stride;
+    }
+}
+
+static void avg_h264_chroma_mc8_pico(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
+  const int A=(8-x)*(8-y);
+  const int B=(  x)*(8-y);
+  const int C=(8-x)*(  y);
+  const int D=(  x)*(  y);
+  int i;
+  
+  PICO_PUT_W(PICO_COEFF0_A, (A << 16) | (B & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF0_B, 32);
+  PICO_PUT_W(PICO_COEFF1_A, (C << 16) | (D & 0xFFFF));
+  PICO_PUT_W(PICO_COEFF1_B, 0);
+  PICO_PUT_W(PICO_COEFF2_A, 0);
+  PICO_PUT_W(PICO_COEFF2_B, 0);
+  PICO_PUT_W(PICO_CONFIG, 
+             PICO_OUTPUT_MODE(PICO_PLANAR_MODE) 
+             | PICO_INPUT_MODE(PICO_HOR_FILTER_MODE) 
+             | PICO_COEFF_FRAC_BITS(6)
+             | PICO_OFFSET_FRAC_BITS(6));
+
+  for(i=0; i<h; i++)
+    {
+      /*
+        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));
+        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));
+        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));
+        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));
+        OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));
+        OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));
+        OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));
+        OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));
+        dst+= stride;
+        src+= stride;
+      */  
+      int src0 = *((int *)src);
+      int src1 = (volatile int)((src[4] << 24) | src[stride]);
+      int src2 = *((int *)(src + stride + 1));
+
+      PICO_MVRC_W(PICO_INPIX0, src0);
+      PICO_MVRC_W(PICO_INPIX1, src1);
+      PICO_MVRC_W(PICO_INPIX2, src2);
+      PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 7, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 8, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 9, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 10, 0);
+      ST32(dst, rnd_avg32(LD32(dst), PICO_GET_W(PICO_OUTPIX0)));
+
+      src0 = *((int *)(src + 4));
+      src1 = (int)((src[8] << 24) | src[stride + 4]);
+      src2 = *((int *)(src + stride + 5));
+      
+      PICO_MVRC_W(PICO_INPIX0, src0);
+      PICO_MVRC_W(PICO_INPIX1, src1);
+      PICO_MVRC_W(PICO_INPIX2, src2);
+      PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 7, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 8, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 9, 0);
+      PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 10, 0);
+      src += stride;
+      ST32(dst + 4, rnd_avg32(LD32(dst + 4), PICO_GET_W(PICO_OUTPIX0)));
+      dst += stride;
+    }
+}
+
+static struct pico_config_t h264_qpel4_h_lowpass_config = { 
+  .input_mode = PICO_HOR_FILTER_MODE,
+  .output_mode = PICO_PLANAR_MODE,
+  .coeff_frac_bits = 5,
+  .offset_frac_bits = 5,
+  .coeff0_0 = 1,
+  .coeff0_1 = -5,
+  .coeff0_2 = 20,
+  .coeff0_3 = 16,
+  .coeff1_0 = 20,
+  .coeff1_1 = -5,
+  .coeff1_2 = 1,
+  .coeff1_3 = 0,
+  .coeff2_0 = 0,
+  .coeff2_1 = 0,
+  .coeff2_2 = 0,
+  .coeff2_3 = 0 
+};
+
+
+
+static void put_h264_qpel4_h_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  const int h=4;
+  int i;
+    
+  set_pico_config(&h264_qpel4_h_lowpass_config);
+
+  for(i=0; i<h; i++){
+    
+    /*
+      OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
+      OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
+      OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
+      OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
+      dst+=dstStride;\
+      src+=srcStride;\ */
+    PICO_MVRC_W(PICO_INPIX0, LD32(src - 2));
+    PICO_MVRC_D(PICO_INPIX2, LD64_UNALIGNED(src + 2));
+    PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 3, 6);
+    PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 4, 7);
+    PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 5, 8);
+    PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 6, 9);
+    src += srcStride;
+    ST32(dst, PICO_GET_W(PICO_OUTPIX0));
+    dst += dstStride;
+  }
+}
+
+static void avg_h264_qpel4_h_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  const int h=4;
+  int i;
+    
+  set_pico_config(&h264_qpel4_h_lowpass_config);
+  
+  for(i=0; i<h; i++){
+    
+    /*
+      OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
+      OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
+      OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
+      OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
+      dst+=dstStride;\
+      src+=srcStride;\ */
+        
+    PICO_MVRC_W(PICO_INPIX0, LD32(src - 2));
+    PICO_MVRC_D(PICO_INPIX2, LD64_UNALIGNED(src + 2));
+    PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 3, 6);
+    PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 4, 7);
+    PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 5, 8);
+    PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 6, 9);
+    src += srcStride;
+    ST32(dst, rnd_avg32(LD32(dst), PICO_GET_W(PICO_OUTPIX0)));
+    dst += dstStride;
+  }
+}
+
+static struct pico_config_t h264_qpel4_v_lowpass_config1 = { 
+  .input_mode = PICO_VERT_FILTER_MODE,
+  .output_mode = PICO_PACKED_MODE,
+  .coeff_frac_bits = 5,
+  .offset_frac_bits = 5,
+  .coeff0_0 = 1,
+  .coeff0_1 = -5,
+  .coeff0_2 = 20,
+  .coeff0_3 = 16,
+  .coeff1_0 = 1,
+  .coeff1_1 = -5,
+  .coeff1_2 = 20,
+  .coeff1_3 = 16,
+  .coeff2_0 = 1,
+  .coeff2_1 = -5,
+  .coeff2_2 = 20,
+  .coeff2_3 = 16 
+};
+
+
+
+static struct pico_config_t h264_qpel4_v_lowpass_config2 = { 
+  .input_mode = PICO_VERT_FILTER_MODE,
+  .output_mode = PICO_PLANAR_MODE,
+  .coeff_frac_bits = 5,
+  .offset_frac_bits = 5,
+  .coeff0_0 = 1,
+  .coeff0_1 = -5,
+  .coeff0_2 = 20,
+  .coeff0_3 = 16,
+  .coeff1_0 = 20,
+  .coeff1_1 = -5,
+  .coeff1_2 = 1,
+  .coeff1_3 = 0,
+  .coeff2_0 = 0,
+  .coeff2_1 = 0,
+  .coeff2_2 = 0,
+  .coeff2_3 = 0 
+};
+
+static void put_h264_qpel4_v_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+
+  /*
+    const int w=4;
+    uint8_t *cm = cropTbl + MAX_NEG_CROP;
+    int i;
+    for(i=0; i<w; i++)
+    {
+    const int srcB= src[-2*srcStride];\
+    const int srcA= src[-1*srcStride];\
+    const int src0= src[0 *srcStride];\
+    const int src1= src[1 *srcStride];\
+    const int src2= src[2 *srcStride];\
+    const int src3= src[3 *srcStride];\
+    const int src4= src[4 *srcStride];\
+    const int src5= src[5 *srcStride];\
+    const int src6= src[6 *srcStride];\
+    OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
+    OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
+    OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
+    OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
+    dst++;\
+    src++;\
+  */  
+  
+  set_pico_config(&h264_qpel4_v_lowpass_config1);
+  
+  {
+    int srcB= LD32(src - 2*srcStride);
+    int srcA= LD32(src - 1*srcStride);
+    int src0= LD32(src + 0 *srcStride);
+    int src1= LD32(src + 1 *srcStride);
+    int src2= LD32(src + 2 *srcStride);
+    int src3= LD32(src + 3 *srcStride);
+    int src4= LD32(src + 4 *srcStride);
+    int src5= LD32(src + 5 *srcStride);
+    int src6= LD32(src + 6 *srcStride);
+    
+    /* First compute the leftmost three colums */
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(0, 0, 0, 3, 6);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX0, src3);
+    PICO_OP(PICO_USE_ACC, 0, 0, 3, 6);
+    ST32(dst, PICO_GET_W(PICO_OUTPIX0));
+    dst += dstStride;
+    PICO_MVRC_W(PICO_INPIX0, srcA);
+    PICO_MVRC_W(PICO_INPIX1, src0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_OP(0, 0, 0, 3, 6);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_MVRC_W(PICO_INPIX1, src3);
+    PICO_MVRC_W(PICO_INPIX0, src4);
+    PICO_OP(PICO_USE_ACC, 0, 0, 3, 6);
+    ST32(dst, PICO_GET_W(PICO_OUTPIX0));
+    dst += dstStride;
+    PICO_MVRC_W(PICO_INPIX0, src0);
+    PICO_MVRC_W(PICO_INPIX1, src1);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_OP(0, 0, 0, 3, 6);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_MVRC_W(PICO_INPIX1, src4);
+    PICO_MVRC_W(PICO_INPIX0, src5);
+    PICO_OP(PICO_USE_ACC, 0, 0, 3, 6);
+    ST32(dst, PICO_GET_W(PICO_OUTPIX0));
+    dst += dstStride;
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_OP(0, 0, 0, 3, 6);
+    PICO_MVRC_W(PICO_INPIX2, src4);
+    PICO_MVRC_W(PICO_INPIX1, src5);
+    PICO_MVRC_W(PICO_INPIX0, src6);
+    PICO_OP(PICO_USE_ACC, 0, 0, 3, 6);
+    ST32(dst, PICO_GET_W(PICO_OUTPIX0));
+    /* Now compute the last column */
+ 
+    union wordbytes {
+      int word;
+      struct  {
+        unsigned int t:8;
+        unsigned int u:8;
+        unsigned int l:8;
+        unsigned int b:8; 
+      } bytes; } tmp1, tmp2, tmp3;
+    
+    
+    tmp1.bytes.t = srcB;
+    tmp1.bytes.u = src1;
+    tmp1.bytes.l = src4;
+    
+    tmp2.bytes.t = srcA;
+    tmp2.bytes.u = src2;
+    tmp2.bytes.l = src5;
+
+    tmp3.bytes.t = src0;
+    tmp3.bytes.u = src3;
+    tmp3.bytes.l = src6;
+    
+    PICO_MVRC_W(PICO_INPIX0, tmp1.word);
+    PICO_MVRC_W(PICO_INPIX1, tmp2.word);
+    PICO_MVRC_W(PICO_INPIX2, tmp3.word);
+    set_pico_config(&h264_qpel4_v_lowpass_config2);
+
+    
+    PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 3, 6);
+    PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 4, 7);
+    PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 5, 8);
+    PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 6, 9);
+    
+    PICO_MVCR_W(tmp1.word, PICO_OUTPIX0);
+    dst[3] = (char)(tmp1.bytes.b);
+    dst[3 - dstStride] = (char)(tmp1.bytes.l);
+    dst[3 - 2*dstStride] = (char)(tmp1.bytes.u);
+    dst[3 - 3*dstStride] = (char)(tmp1.bytes.t);
+    
+  }
+    /*}
+    
+
+    }*/
+}
+
+static void avg_h264_qpel4_v_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+
+  /*
+    const int w=4;
+    uint8_t *cm = cropTbl + MAX_NEG_CROP;
+    int i;
+    for(i=0; i<w; i++)
+    {
+    const int srcB= src[-2*srcStride];\
+    const int srcA= src[-1*srcStride];\
+    const int src0= src[0 *srcStride];\
+    const int src1= src[1 *srcStride];\
+    const int src2= src[2 *srcStride];\
+    const int src3= src[3 *srcStride];\
+    const int src4= src[4 *srcStride];\
+    const int src5= src[5 *srcStride];\
+    const int src6= src[6 *srcStride];\
+    OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
+    OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
+    OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
+    OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
+    dst++;\
+    src++;\
+  */  
+  uint8_t tmp_block[4*4];
+  
+  set_pico_config(&h264_qpel4_v_lowpass_config1);
+  
+  {
+    int srcB= LD32(src - 2*srcStride);
+    int srcA= LD32(src - 1*srcStride);
+    int src0= LD32(src + 0 *srcStride);
+    int src1= LD32(src + 1 *srcStride);
+    int src2= LD32(src + 2 *srcStride);
+    int src3= LD32(src + 3 *srcStride);
+    int src4= LD32(src + 4 *srcStride);
+    int src5= LD32(src + 5 *srcStride);
+    int src6= LD32(src + 6 *srcStride);
+    
+    /* First compute the leftmost three colums */
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(0, 0, 0, 3, 6);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX0, src3);
+    PICO_OP(PICO_USE_ACC, 0, 0, 3, 6);
+    ST32(tmp_block, PICO_GET_W(PICO_OUTPIX0));
+    PICO_MVRC_W(PICO_INPIX0, srcA);
+    PICO_MVRC_W(PICO_INPIX1, src0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_OP(0, 0, 0, 3, 6);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_MVRC_W(PICO_INPIX1, src3);
+    PICO_MVRC_W(PICO_INPIX0, src4);
+    PICO_OP(PICO_USE_ACC, 0, 0, 3, 6);
+    ST32(tmp_block + 4, PICO_GET_W(PICO_OUTPIX0));
+    PICO_MVRC_W(PICO_INPIX0, src0);
+    PICO_MVRC_W(PICO_INPIX1, src1);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_OP(0, 0, 0, 3, 6);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_MVRC_W(PICO_INPIX1, src4);
+    PICO_MVRC_W(PICO_INPIX0, src5);
+    PICO_OP(PICO_USE_ACC, 0, 0, 3, 6);
+    ST32(tmp_block + 8, PICO_GET_W(PICO_OUTPIX0));
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_OP(0, 0, 0, 3, 6);
+    PICO_MVRC_W(PICO_INPIX2, src4);
+    PICO_MVRC_W(PICO_INPIX1, src5);
+    PICO_MVRC_W(PICO_INPIX0, src6);
+    PICO_OP(PICO_USE_ACC, 0, 0, 3, 6);
+    ST32(tmp_block + 12, PICO_GET_W(PICO_OUTPIX0));
+    /* Now compute the last column */
+ 
+    union wordbytes {
+      int word;
+      struct  {
+        unsigned int t:8;
+        unsigned int u:8;
+        unsigned int l:8;
+        unsigned int b:8; 
+      } bytes; } tmp1, tmp2, tmp3;
+    
+    
+    tmp1.bytes.t = srcB;
+    tmp1.bytes.u = src1;
+    tmp1.bytes.l = src4;
+    
+    tmp2.bytes.t = srcA;
+    tmp2.bytes.u = src2;
+    tmp2.bytes.l = src5;
+
+    tmp3.bytes.t = src0;
+    tmp3.bytes.u = src3;
+    tmp3.bytes.l = src6;
+    
+    PICO_MVRC_W(PICO_INPIX0, tmp1.word);
+    PICO_MVRC_W(PICO_INPIX1, tmp2.word);
+    PICO_MVRC_W(PICO_INPIX2, tmp3.word);
+    set_pico_config(&h264_qpel4_v_lowpass_config2);
+
+    
+    PICO_OP(PICO_SINGLE_VECTOR, 0, 0, 3, 6);
+    PICO_OP(PICO_SINGLE_VECTOR, 1, 1, 4, 7);
+    PICO_OP(PICO_SINGLE_VECTOR, 2, 2, 5, 8);
+    PICO_OP(PICO_SINGLE_VECTOR, 3, 3, 6, 9);
+    
+    PICO_MVCR_W(tmp1.word, PICO_OUTPIX0);
+    tmp_block[3 + 3*4] = (char)(tmp1.bytes.b);
+    tmp_block[3 + 2*4] = (char)(tmp1.bytes.l);
+    tmp_block[3 + 1*4] = (char)(tmp1.bytes.u);
+    tmp_block[3] = (char)(tmp1.bytes.t);
+
+    /* Compute the average */
+    srcB= LD32(dst);
+    srcA= LD32(dst + dstStride);
+    src0= LD32(dst + dstStride*2);
+    src1= LD32(dst + dstStride*3);
+          
+    src2= LD32(tmp_block);
+    src3= LD32(tmp_block + 4);
+    src4= LD32(tmp_block + 8);
+    src5= LD32(tmp_block + 12);
+
+    ST32(dst, rnd_avg32(srcB, src2));
+    ST32(dst + dstStride, rnd_avg32(srcA, src3));
+    ST32(dst + 2*dstStride, rnd_avg32(src0, src4));
+    ST32(dst + 3*dstStride, rnd_avg32(src1, src5));    
+  }
+}
+
+static struct pico_config_t h264_qpel4_hv_lowpass_config = { 
+  .input_mode = PICO_HOR_FILTER_MODE,
+  .output_mode = PICO_PACKED_MODE,
+  .coeff_frac_bits = 10,
+  .offset_frac_bits = 10,
+  .coeff0_0 = 1,
+  .coeff0_1 = -5,
+  .coeff0_2 = 20,
+  .coeff0_3 = 512,
+  .coeff1_0 = -5,
+  .coeff1_1 = 25,
+  .coeff1_2 = -100,
+  .coeff1_3 = 0,
+  .coeff2_0 = 20,
+  .coeff2_1 = -100,
+  .coeff2_2 = 400,
+  .coeff2_3 = 0 
+};
+
+static void put_h264_qpel4_hv_lowpass_pico(uint8_t *dst,  uint8_t *src, int dstStride, int srcStride){
+
+  int32_t tmp_block[48];
+  int32_t *tmp = tmp_block;
+  int i;
+  
+  set_pico_config(&h264_qpel4_hv_lowpass_config);
+
+  src -= 2;
+  for ( i = 0; i < 2; i++ ){ 
+    int srcB= LD32(src - 2*srcStride);
+    int srcA= LD32(src - 1*srcStride);
+    int src0= LD32(src + 0 *srcStride);
+    int src1= LD32(src + 1 *srcStride);
+    int src2= LD32(src + 2 *srcStride);
+    int src3= LD32(src + 3 *srcStride);
+    int src4= LD32(src + 4 *srcStride);
+    int src5= LD32(src + 5 *srcStride);
+    int src6= LD32(src + 6 *srcStride);
+    
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(0, 0, 0, 4, 8);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX0, src3);
+    PICO_OP(PICO_USE_ACC, 0, 0, 4, 8);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_OP(0, 0, 1, 5, 9);
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(PICO_USE_ACC, 0, 1, 5, 9);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_OP(0, 0, 4, 8, 0);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_MVRC_W(PICO_INPIX1, src3);
+    PICO_MVRC_W(PICO_INPIX0, src4);
+    PICO_OP(PICO_USE_ACC, 0, 0, 4, 8);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_OP(0, 0, 1, 5, 9);
+    PICO_MVRC_W(PICO_INPIX0, srcA);
+    PICO_MVRC_W(PICO_INPIX1, src0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_OP(PICO_USE_ACC, 0, 1, 5, 9);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_MVRC_W(PICO_INPIX0, src2);
+    PICO_OP(0, 0, 4, 8, 0);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_MVRC_W(PICO_INPIX1, src4);
+    PICO_MVRC_W(PICO_INPIX0, src5);
+    PICO_OP(PICO_USE_ACC, 0, 0, 4, 8);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+
+    PICO_OP(0, 0, 1, 5, 9);
+    PICO_MVRC_W(PICO_INPIX0, src0);
+    PICO_MVRC_W(PICO_INPIX1, src1);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_OP(PICO_USE_ACC, 0, 1, 5, 9);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+
+    PICO_MVRC_W(PICO_INPIX0, src3);
+    PICO_OP(0, 0, 4, 8, 0);
+    PICO_MVRC_W(PICO_INPIX2, src4);
+    PICO_MVRC_W(PICO_INPIX1, src5);
+    PICO_MVRC_W(PICO_INPIX0, src6);
+    PICO_OP(PICO_USE_ACC, 0, 0, 4, 8); 
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_OP(0, 0, 1, 5, 9);
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_OP(PICO_USE_ACC, 0, 1, 5, 9);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;    
+    src += 2;
+  }
+
+  src -= 1;
+  tmp -= 48;
+
+  
+  PICO_PUT_W(PICO_CONFIG, 
+             PICO_OUTPUT_MODE(PICO_PLANAR_MODE)  
+             | PICO_INPUT_MODE(PICO_VERT_FILTER_MODE) 
+             | PICO_COEFF_FRAC_BITS(10)
+             | PICO_OFFSET_FRAC_BITS(10));
+
+  for ( i = 0; i < 2; i++ ){ 
+    int srcB= LD32(src - 2*srcStride);
+    int srcA= LD32(src - 1*srcStride);
+    int src0= LD32(src + 0 *srcStride);
+    int src1= LD32(src + 1 *srcStride);
+    int src2= LD32(src + 2 *srcStride);
+    int src3= LD32(src + 3 *srcStride);
+    int src4= LD32(src + 4 *srcStride);
+    int src5= LD32(src + 5 *srcStride);
+    int src6= LD32(src + 6 *srcStride);
+    
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(PICO_USE_ACC, 0, 6, 3, 0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX0, src3);
+    PICO_OP(PICO_USE_ACC | PICO_SINGLE_VECTOR, 0, 6, 3, 0);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_OP(PICO_USE_ACC, 1, 9, 6, 3);
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(PICO_USE_ACC | PICO_SINGLE_VECTOR, 1, 9, 6, 3);
+    
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_MVRC_W(PICO_INPIX0, srcA);
+    PICO_MVRC_W(PICO_INPIX1, src0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_OP(PICO_USE_ACC, 2, 6, 3, 0);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_MVRC_W(PICO_INPIX1, src3);
+    PICO_MVRC_W(PICO_INPIX0, src4);
+    PICO_OP(PICO_USE_ACC | PICO_SINGLE_VECTOR, 2, 6, 3, 0);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_OP(PICO_USE_ACC, 3, 9, 6, 3);
+    PICO_MVRC_W(PICO_INPIX0, srcA);
+    PICO_MVRC_W(PICO_INPIX1, src0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_OP(PICO_USE_ACC | PICO_SINGLE_VECTOR, 3, 9, 6, 3);
+    
+    ST16(dst + 0*dstStride, (short)(PICO_GET_W(PICO_OUTPIX0) >> 16)); 
+    ST16(dst + 1*dstStride, (short)PICO_GET_W(PICO_OUTPIX0)); 
+    
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_MVRC_W(PICO_INPIX0, src0);
+    PICO_MVRC_W(PICO_INPIX1, src1);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_OP(PICO_USE_ACC, 0, 6, 3, 0);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_MVRC_W(PICO_INPIX1, src4);
+    PICO_MVRC_W(PICO_INPIX0, src5);
+    PICO_OP(PICO_USE_ACC| PICO_SINGLE_VECTOR, 0, 6, 3, 0);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_OP(PICO_USE_ACC, 1, 9, 6, 3);
+    PICO_MVRC_W(PICO_INPIX0, src0);
+    PICO_MVRC_W(PICO_INPIX1, src1);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_OP(PICO_USE_ACC| PICO_SINGLE_VECTOR, 1, 9, 6, 3);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_OP(PICO_USE_ACC, 2, 6, 3, 0);
+    PICO_MVRC_W(PICO_INPIX2, src4);
+    PICO_MVRC_W(PICO_INPIX1, src5);
+    PICO_MVRC_W(PICO_INPIX0, src6);
+    PICO_OP(PICO_USE_ACC| PICO_SINGLE_VECTOR, 2, 6, 3, 0);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_OP(PICO_USE_ACC, 3, 9, 6, 3);
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_OP(PICO_USE_ACC| PICO_SINGLE_VECTOR, 3, 9, 6, 3);
+
+    ST16(dst + 2*dstStride, (short)(PICO_GET_W(PICO_OUTPIX0) >> 16)); 
+    ST16(dst + 3*dstStride, (short)PICO_GET_W(PICO_OUTPIX0)); 
+
+    dst += 2;
+    src += 2;
+  }
+}
+
+
+
+
+static void avg_h264_qpel4_hv_lowpass_pico(uint8_t *dst,  uint8_t *src, int dstStride, int srcStride){
+
+  int32_t tmp_block[48];
+  int32_t *tmp = tmp_block;
+  int i;
+  
+  set_pico_config(&h264_qpel4_hv_lowpass_config);
+
+  src -= 2;
+  for ( i = 0; i < 2; i++ ){ 
+    int srcB= LD32(src - 2*srcStride);
+    int srcA= LD32(src - 1*srcStride);
+    int src0= LD32(src + 0 *srcStride);
+    int src1= LD32(src + 1 *srcStride);
+    int src2= LD32(src + 2 *srcStride);
+    int src3= LD32(src + 3 *srcStride);
+    int src4= LD32(src + 4 *srcStride);
+    int src5= LD32(src + 5 *srcStride);
+    int src6= LD32(src + 6 *srcStride);
+    
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(0, 0, 0, 4, 8);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX0, src3);
+    PICO_OP(PICO_USE_ACC, 0, 0, 4, 8);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_OP(0, 0, 1, 5, 9);
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(PICO_USE_ACC, 0, 1, 5, 9);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_OP(0, 0, 4, 8, 0);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_MVRC_W(PICO_INPIX1, src3);
+    PICO_MVRC_W(PICO_INPIX0, src4);
+    PICO_OP(PICO_USE_ACC, 0, 0, 4, 8);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_OP(0, 0, 1, 5, 9);
+    PICO_MVRC_W(PICO_INPIX0, srcA);
+    PICO_MVRC_W(PICO_INPIX1, src0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_OP(PICO_USE_ACC, 0, 1, 5, 9);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_MVRC_W(PICO_INPIX0, src2);
+    PICO_OP(0, 0, 4, 8, 0);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_MVRC_W(PICO_INPIX1, src4);
+    PICO_MVRC_W(PICO_INPIX0, src5);
+    PICO_OP(PICO_USE_ACC, 0, 0, 4, 8);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+
+    PICO_OP(0, 0, 1, 5, 9);
+    PICO_MVRC_W(PICO_INPIX0, src0);
+    PICO_MVRC_W(PICO_INPIX1, src1);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_OP(PICO_USE_ACC, 0, 1, 5, 9);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+
+    PICO_MVRC_W(PICO_INPIX0, src3);
+    PICO_OP(0, 0, 4, 8, 0);
+    PICO_MVRC_W(PICO_INPIX2, src4);
+    PICO_MVRC_W(PICO_INPIX1, src5);
+    PICO_MVRC_W(PICO_INPIX0, src6);
+    PICO_OP(PICO_USE_ACC, 0, 0, 4, 8); 
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;
+    
+    PICO_OP(0, 0, 1, 5, 9);
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_OP(PICO_USE_ACC, 0, 1, 5, 9);
+    PICO_STCM_W(tmp, 
+                PICO_REGVECT_VMU0_OUT, 
+                PICO_REGVECT_VMU1_OUT, 
+                PICO_REGVECT_VMU2_OUT);
+    tmp += 3;    
+    src += 2;
+  }
+
+  src -= 1;
+  tmp -= 48;
+
+  
+  PICO_PUT_W(PICO_CONFIG, 
+             PICO_OUTPUT_MODE(PICO_PLANAR_MODE)  
+             | PICO_INPUT_MODE(PICO_VERT_FILTER_MODE) 
+             | PICO_COEFF_FRAC_BITS(10)
+             | PICO_OFFSET_FRAC_BITS(10));
+
+  for ( i = 0; i < 2; i++ ){ 
+    int srcB= LD32(src - 2*srcStride);
+    int srcA= LD32(src - 1*srcStride);
+    int src0= LD32(src + 0 *srcStride);
+    int src1= LD32(src + 1 *srcStride);
+    int src2= LD32(src + 2 *srcStride);
+    int src3= LD32(src + 3 *srcStride);
+    int src4= LD32(src + 4 *srcStride);
+    int src5= LD32(src + 5 *srcStride);
+    int src6= LD32(src + 6 *srcStride);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(PICO_USE_ACC, 0, 6, 3, 0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX0, src3);
+    PICO_OP(PICO_USE_ACC | PICO_SINGLE_VECTOR, 0, 6, 3, 0);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_OP(PICO_USE_ACC, 1, 9, 6, 3);
+    PICO_MVRC_W(PICO_INPIX0, srcB);
+    PICO_MVRC_W(PICO_INPIX1, srcA);
+    PICO_MVRC_W(PICO_INPIX2, src0);
+    PICO_OP(PICO_USE_ACC | PICO_SINGLE_VECTOR, 1, 9, 6, 3);
+    
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_MVRC_W(PICO_INPIX0, srcA);
+    PICO_MVRC_W(PICO_INPIX1, src0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_OP(PICO_USE_ACC, 2, 6, 3, 0);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_MVRC_W(PICO_INPIX1, src3);
+    PICO_MVRC_W(PICO_INPIX0, src4);
+    PICO_OP(PICO_USE_ACC | PICO_SINGLE_VECTOR, 2, 6, 3, 0);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_OP(PICO_USE_ACC, 3, 9, 6, 3);
+    PICO_MVRC_W(PICO_INPIX0, srcA);
+    PICO_MVRC_W(PICO_INPIX1, src0);
+    PICO_MVRC_W(PICO_INPIX2, src1);
+    PICO_OP(PICO_USE_ACC | PICO_SINGLE_VECTOR, 3, 9, 6, 3);
+    
+    ST16(dst + 0*dstStride, rnd_avg32(LD16(dst + 0*dstStride), PICO_GET_W(PICO_OUTPIX0) >> 16)); 
+    ST16(dst + 1*dstStride, rnd_avg32(LD16(dst + 1*dstStride), PICO_GET_W(PICO_OUTPIX0))); 
+    
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_MVRC_W(PICO_INPIX0, src0);
+    PICO_MVRC_W(PICO_INPIX1, src1);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_OP(PICO_USE_ACC, 0, 6, 3, 0);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_MVRC_W(PICO_INPIX1, src4);
+    PICO_MVRC_W(PICO_INPIX0, src5);
+    PICO_OP(PICO_USE_ACC| PICO_SINGLE_VECTOR, 0, 6, 3, 0);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_OP(PICO_USE_ACC, 1, 9, 6, 3);
+    PICO_MVRC_W(PICO_INPIX0, src0);
+    PICO_MVRC_W(PICO_INPIX1, src1);
+    PICO_MVRC_W(PICO_INPIX2, src2);
+    PICO_OP(PICO_USE_ACC| PICO_SINGLE_VECTOR, 1, 9, 6, 3);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_OP(PICO_USE_ACC, 2, 6, 3, 0);
+    PICO_MVRC_W(PICO_INPIX2, src4);
+    PICO_MVRC_W(PICO_INPIX1, src5);
+    PICO_MVRC_W(PICO_INPIX0, src6);
+    PICO_OP(PICO_USE_ACC| PICO_SINGLE_VECTOR, 2, 6, 3, 0);
+
+    PICO_LDCM_W_INC(tmp, 
+                    PICO_REGVECT_VMU0_OUT, 
+                    PICO_REGVECT_VMU1_OUT, 
+                    PICO_REGVECT_VMU2_OUT);
+    PICO_OP(PICO_USE_ACC, 3, 9, 6, 3);
+    PICO_MVRC_W(PICO_INPIX0, src1);
+    PICO_MVRC_W(PICO_INPIX1, src2);
+    PICO_MVRC_W(PICO_INPIX2, src3);
+    PICO_OP(PICO_USE_ACC| PICO_SINGLE_VECTOR, 3, 9, 6, 3);
+
+    ST16(dst + 2*dstStride, rnd_avg32(LD16(dst + 2*dstStride), PICO_GET_W(PICO_OUTPIX0) >> 16)); 
+    ST16(dst + 3*dstStride, rnd_avg32(LD16(dst + 3*dstStride), PICO_GET_W(PICO_OUTPIX0))); 
+
+    dst += 2;
+    src += 2;
+  }
+}
+
+
+static void put_h264_qpel8_v_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  put_h264_qpel4_v_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel4_v_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+  src += 4*srcStride;
+  dst += 4*dstStride;
+  put_h264_qpel4_v_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel4_v_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+}
+
+static void avg_h264_qpel8_v_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  avg_h264_qpel4_v_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel4_v_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+  src += 4*srcStride;
+  dst += 4*dstStride;
+  avg_h264_qpel4_v_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel4_v_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+}
+
+static void put_h264_qpel8_h_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  put_h264_qpel4_h_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel4_h_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+  src += 4*srcStride;
+  dst += 4*dstStride;
+  put_h264_qpel4_h_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel4_h_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+}
+
+static void avg_h264_qpel8_h_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  avg_h264_qpel4_h_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel4_h_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+  src += 4*srcStride;
+  dst += 4*dstStride;
+  avg_h264_qpel4_h_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel4_h_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+}
+
+static void put_h264_qpel8_hv_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  put_h264_qpel4_hv_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel4_hv_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+  src += 4*srcStride;
+  dst += 4*dstStride;
+  put_h264_qpel4_hv_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel4_hv_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+}
+
+static void avg_h264_qpel8_hv_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  avg_h264_qpel4_hv_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel4_hv_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+  src += 4*srcStride;
+  dst += 4*dstStride;
+  avg_h264_qpel4_hv_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel4_hv_lowpass_pico(dst+4, src+4, dstStride, srcStride);
+}
+
+static void put_h264_qpel16_v_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  put_h264_qpel8_v_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel8_v_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+  src += 8*srcStride;
+  dst += 8*dstStride;
+  put_h264_qpel8_v_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel8_v_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+}
+
+static void avg_h264_qpel16_v_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  avg_h264_qpel8_v_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel8_v_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+  src += 8*srcStride;
+  dst += 8*dstStride;
+  avg_h264_qpel8_v_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel8_v_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+}
+
+static void put_h264_qpel16_h_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  put_h264_qpel8_h_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel8_h_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+  src += 8*srcStride;
+  dst += 8*dstStride;
+  put_h264_qpel8_h_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel8_h_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+}
+
+static void avg_h264_qpel16_h_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  avg_h264_qpel8_h_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel8_h_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+  src += 8*srcStride;
+  dst += 8*dstStride;
+  avg_h264_qpel8_h_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel8_h_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+}
+
+static void put_h264_qpel16_hv_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  put_h264_qpel8_hv_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel8_hv_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+  src += 8*srcStride;
+  dst += 8*dstStride;
+  put_h264_qpel8_hv_lowpass_pico(dst  , src  , dstStride, srcStride);
+  put_h264_qpel8_hv_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+}
+
+static void avg_h264_qpel16_hv_lowpass_pico(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){
+  avg_h264_qpel8_hv_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel8_hv_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+  src += 8*srcStride;
+  dst += 8*dstStride;
+  avg_h264_qpel8_hv_lowpass_pico(dst  , src  , dstStride, srcStride);
+  avg_h264_qpel8_hv_lowpass_pico(dst+8, src+8, dstStride, srcStride);
+}
+
+
+#define H264_MC(OPNAME, SIZE) \
+static void OPNAME ## h264_qpel ## SIZE ## _mc00_pico (uint8_t *dst, uint8_t *src, int stride){\
+    OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc10_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t half[SIZE*SIZE];\
+    put_h264_qpel ## SIZE ## _h_lowpass_pico(half, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, src, half, stride, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc20_pico(uint8_t *dst, uint8_t *src, int stride){\
+    OPNAME ## h264_qpel ## SIZE ## _h_lowpass_pico(dst, src, stride, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc30_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t half[SIZE*SIZE];\
+    put_h264_qpel ## SIZE ## _h_lowpass_pico(half, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, src+1, half, stride, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc01_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    uint8_t half[SIZE*SIZE];\
+    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
+    put_h264_qpel ## SIZE ## _v_lowpass_pico(half, full_mid, SIZE, SIZE);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, full_mid, half, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc02_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
+    OPNAME ## h264_qpel ## SIZE ## _v_lowpass_pico(dst, full_mid, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc03_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    uint8_t half[SIZE*SIZE];\
+    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
+    put_h264_qpel ## SIZE ## _v_lowpass_pico(half, full_mid, SIZE, SIZE);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, full_mid+SIZE, half, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc11_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    uint8_t halfH[SIZE*SIZE];\
+    uint8_t halfV[SIZE*SIZE];\
+    put_h264_qpel ## SIZE ## _h_lowpass_pico(halfH, src, SIZE, stride);\
+    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
+    put_h264_qpel ## SIZE ## _v_lowpass_pico(halfV, full_mid, SIZE, SIZE);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc31_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    uint8_t halfH[SIZE*SIZE];\
+    uint8_t halfV[SIZE*SIZE];\
+    put_h264_qpel ## SIZE ## _h_lowpass_pico(halfH, src, SIZE, stride);\
+    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
+    put_h264_qpel ## SIZE ## _v_lowpass_pico(halfV, full_mid, SIZE, SIZE);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc13_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    uint8_t halfH[SIZE*SIZE];\
+    uint8_t halfV[SIZE*SIZE];\
+    put_h264_qpel ## SIZE ## _h_lowpass_pico(halfH, src + stride, SIZE, stride);\
+    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
+    put_h264_qpel ## SIZE ## _v_lowpass_pico(halfV, full_mid, SIZE, SIZE);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc33_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    uint8_t halfH[SIZE*SIZE];\
+    uint8_t halfV[SIZE*SIZE];\
+    put_h264_qpel ## SIZE ## _h_lowpass_pico(halfH, src + stride, SIZE, stride);\
+    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
+    put_h264_qpel ## SIZE ## _v_lowpass_pico(halfV, full_mid, SIZE, SIZE);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc22_pico(uint8_t *dst, uint8_t *src, int stride){\
+    OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_pico(dst, src, stride, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc21_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t halfH[SIZE*SIZE];\
+    uint8_t halfHV[SIZE*SIZE];\
+    put_h264_qpel ## SIZE ## _h_lowpass_pico(halfH, src, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _hv_lowpass_pico(halfHV, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc23_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t halfH[SIZE*SIZE];\
+    uint8_t halfHV[SIZE*SIZE];\
+    put_h264_qpel ## SIZE ## _h_lowpass_pico(halfH, src + stride, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _hv_lowpass_pico(halfHV, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc12_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    uint8_t halfV[SIZE*SIZE];\
+    uint8_t halfHV[SIZE*SIZE];\
+    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
+    put_h264_qpel ## SIZE ## _v_lowpass_pico(halfV, full_mid, SIZE, SIZE);\
+    put_h264_qpel ## SIZE ## _hv_lowpass_pico(halfHV, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc32_pico(uint8_t *dst, uint8_t *src, int stride){\
+    uint8_t full[SIZE*(SIZE+5)];\
+    uint8_t * const full_mid= full + SIZE*2;\
+    uint8_t halfV[SIZE*SIZE];\
+    uint8_t halfHV[SIZE*SIZE];\
+    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
+    put_h264_qpel ## SIZE ## _v_lowpass_pico(halfV, full_mid, SIZE, SIZE);\
+    put_h264_qpel ## SIZE ## _hv_lowpass_pico(halfHV, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
+}\
+
+H264_MC(put_, 4)
+H264_MC(put_, 8)
+H264_MC(put_, 16)
+H264_MC(avg_, 4)
+H264_MC(avg_, 8)
+H264_MC(avg_, 16)
+
+
+
+#define dspfunc16(PFX) \
+    void PFX ## _pixels16_avr32(uint8_t *dst, const uint8_t *pixels, int line_size, int h ){ \
+          PFX ## _pixels8_avr32(dst, pixels, line_size, h);\
+          PFX ## _pixels8_avr32(dst + 8, pixels + 8, line_size, h);\
+    }\
+    void PFX ## _pixels16_h_avr32(uint8_t *dst, const uint8_t *pixels, int line_size, int h ){ \
+          PFX ## _pixels8_h_avr32(dst, pixels, line_size, h);\
+          PFX ## _pixels8_h_avr32(dst + 8, pixels + 8, line_size, h);\
+    }\
+    void PFX ## _pixels16_v_avr32(uint8_t *dst, const uint8_t *pixels, int line_size, int h ){ \
+          PFX ## _pixels8_v_avr32(dst, pixels, line_size, h);\
+          PFX ## _pixels8_v_avr32(dst + 8, pixels + 8, line_size, h);\
+    }\
+    void PFX ## _pixels16_hv_avr32(uint8_t *dst, const uint8_t *pixels, int line_size, int h ){ \
+          PFX ## _pixels8_hv_avr32(dst, pixels, line_size, h);\
+          PFX ## _pixels8_hv_avr32(dst + 8, pixels + 8, line_size, h);\
+    }\
+
+
+dspfunc16(put)
+dspfunc16(put_no_rnd)
+dspfunc16(avg)
+dspfunc16(avg_no_rnd)
+#undef dspfunc16
+
+static int pix_sum_avr32(uint8_t * pix, int line_size)
+{
+    int s, i;
+
+    s = 0;
+    for (i = 0; i < 16; i++) {
+      int tmp1,tmp2,tmp3,tmp4,tmp5;
+      __asm__ volatile ( "ld.w\t%0, %6[0]\n\t"
+                         "ld.w\t%1, %6[4]\n\t"
+                         "ld.w\t%2, %6[8]\n\t"
+                         "ld.w\t%3, %6[12]\n\t"
+                         "punpckub.h\t%4, %0:t\n\t"
+                         "padd.h\t%5, %5, %4\n\t"
+                         "punpckub.h\t%4, %0:b\n\t"
+                         "padd.h\t%5, %5, %4\n\t"
+                         "punpckub.h\t%4, %1:t\n\t"
+                         "padd.h\t%5, %5, %4\n\t"
+                         "punpckub.h\t%4, %1:b\n\t"
+                         "padd.h\t%5, %5, %4\n\t"
+                         "punpckub.h\t%4, %2:t\n\t"
+                         "padd.h\t%5, %5, %4\n\t"
+                         "punpckub.h\t%4, %2:b\n\t"
+                         "padd.h\t%5, %5, %4\n\t"
+                         "punpckub.h\t%4, %3:t\n\t"
+                         "padd.h\t%5, %5, %4\n\t"
+                         "punpckub.h\t%4, %3:b\n\t"
+                         "padd.h\t%5, %5, %4\n\t"
+                         : "=&r"(tmp1),"=&r"(tmp2),"=&r"(tmp3),"=&r"(tmp4),"=&r"(tmp5),"=&r"(s)
+                         : "r"(pix));
+      pix += line_size;
+    }
+    __asm__ volatile ( "addhh.w\t%0, %0:t, %0:b" : "=&r" (s) );
+
+    return s;
+}
+
+
+//#define op_scale1(x)  block[x] = clip_uint8( (block[x]*weight + offset) >> log2_denom )
+//#define op_scale2(x)  dst[x] = clip_uint8( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
+//#define H264_WEIGHT(W,H) \
+//static void weight_h264_pixels ## W ## x ## H ## _c(uint8_t *block, int stride, int log2_denom, int weight, int offset){ \
+//    int attribute_unused x, y; \
+//    offset <<= log2_denom; \
+//    if(log2_denom) offset += 1<<(log2_denom-1); \
+//    for(y=0; y<H; y++, block += stride){ \
+//      uint32_t tmp0, tmp1;
+//      if(W==2) { \
+//        asm volatile ( "ld.ub\t%[tmp0], %[block][0]\n" \
+//                       "ld.ub\t%[tmp1], %[block][1]\n" \
+//                       "mulhh.w\t%[tmp0], %[tmp0]:b, %[weight]:b\n" \
+//                       "mulhh.w\t%[tmp1], %[tmp1]:b, %[weight]:b\n" \
+//                       "asr\t%[tmp0], %[log2_denom]\n" \
+//                       "asr\t%[tmp1], %[log2_denom]\n" \
+//                       "satu\t%[tmp0] >> 0, 8\n" \
+//                       "satu\t%[tmp1] >> 0, 8\n" \
+//                       "st.b\t%[block][0], %[tmp0]\n" \
+//                       "st.b\t%[block][1], %[tmp1]\n" \
+//                       : [tmp0] "=&r"(tmp0), [tmp1] "=&r"(tmp1) \
+//                       : [block] "r"(block), [weight]"r"(weight), [log2_denom]"r"(log2denom) ); \     
+//      } else if ( W==4 ) { \
+//        asm volatile ( "ld.w\t%[tmp0], %[block][0]\n" \
+//                       "punpckub.h\t%[tmp1], %[tmp0]:t\n" \
+//                       "punpckub.h\t%[tmp0], %[tmp0]:b\n" \
+//                       "mulhh.w\t%[tmp2], %[tmp1]:t, %[weight]:b\n" \
+//                       "mulhh.w\t%[tmp1], %[tmp1]:b, %[weight]:b\n" \
+//                       "asr\t%[tmp0], %[log2_denom]\n" \
+//                       "asr\t%[tmp1], %[log2_denom]\n" \
+//                       "satu\t%[tmp0] >> 0, 8\n" \
+//                       "satu\t%[tmp1] >> 0, 8\n" \
+//                       "st.b\t%[block][0], %[tmp0]\n" \
+//                       "st.b\t%[block][1], %[tmp1]\n" \
+//                       : [tmp0] "=&r"(tmp0), [tmp1] "=&r"(tmp1) \
+//                       : [block] "r"(block), [weight]"r"(weight), [log2_denom]"r"(log2denom) ); \     
+//
+//
+//
+//        if(W==4) continue; \
+//        op_scale1(4); \
+//        op_scale1(5); \
+//        op_scale1(6); \
+//        op_scale1(7); \
+//        if(W==8) continue; \
+//        op_scale1(8); \
+//        op_scale1(9); \
+//        op_scale1(10); \
+//        op_scale1(11); \
+//        op_scale1(12); \
+//        op_scale1(13); \
+//        op_scale1(14); \
+//        op_scale1(15); \
+//    } \
+//} \
+//static void biweight_h264_pixels ## W ## x ## H ## _c(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offsetd, int offsets){ \
+//    int attribute_unused x, y; \
+//    int offset = (offsets + offsetd + 1) >> 1; \
+//    offset = ((offset << 1) + 1) << log2_denom; \
+//    for(y=0; y<H; y++, dst += stride, src += stride){ \
+//        op_scale2(0); \
+//        op_scale2(1); \
+//        if(W==2) continue; \
+//        op_scale2(2); \
+//        op_scale2(3); \
+//        if(W==4) continue; \
+//        op_scale2(4); \
+//        op_scale2(5); \
+//        op_scale2(6); \
+//        op_scale2(7); \
+//        if(W==8) continue; \
+//        op_scale2(8); \
+//        op_scale2(9); \
+//        op_scale2(10); \
+//        op_scale2(11); \
+//        op_scale2(12); \
+//        op_scale2(13); \
+//        op_scale2(14); \
+//        op_scale2(15); \
+//    } \
+//}
+
+
+
+/* Returns zero in each byte where the absolute difference between <a> and <b>
+   is not less than <compare> */
+#define PABS_DIFF_LESS_THAN( a, b, compare) \
+  ({  uint32_t __tmp__, __tmp2__, __mask__; \
+      asm ( \
+      /* Check ABS( a - b ) < compare */  \
+        "psubs.ub\t%[tmp], %[opa], %[opb]\n"  \
+        "psubs.ub\t%[tmp2], %[opb], %[opa]\n" \
+        "or\t%[tmp], %[tmp2]\n" /* ABS ( a - b ) */ \
+        /* This produces 0 for all bytes where the comparison is not true */ \
+        "psubs.ub\t%[mask], %[cmp], %[tmp]\n" \
+        : [tmp] "=&r"(__tmp__), [tmp2] "=&r"(__tmp2__), [mask] "=&r"(__mask__)  \
+        : [opa] "r"(a), [opb] "r"(b), [cmp] "r"(compare)  ); \
+      __mask__; })
+
+/* 
+   Set all bytes containing zero in <value> to 255 and the rest to zero.
+   
+   Add with saturation 254 to all bytes making all bytes different from 
+   zero become 255. Then add one without saturation to make all bytes 
+   originally containing zero 255 and the rest 0. */ 
+#define SET_ALL_BITS_IN_ZERO_BYTES(value) \
+  ({  uint32_t __tmp__; \
+      asm ( \
+        "padds.ub\t%[tmp], %[val], %[max_minus_one]\n"  \
+        "padd.b\t%[tmp], %[tmp], %[all_ones]\n" \
+        : [tmp] "=r"(__tmp__) \
+        : [val] "r"(value), [max_minus_one] "r"(0xFEFEFEFE), [all_ones] "r"(0x01010101) ); \
+      __tmp__; })
+
+#define  PACKW_SH(upper, lower) \
+  ({  uint32_t __tmp__; \
+      asm ( \
+        "packw.sh\t%[tmp], %[u], %[l]\n"  \
+        : [tmp] "=r"(__tmp__) \
+        : [u] "r"(upper), [l] "r"(lower) ); \
+      __tmp__; })
+
+#define  PACKSH_UB(upper, lower) \
+  ({  uint32_t __tmp__; \
+      asm ( \
+        "packsh.sb\t%[tmp], %[u], %[l]\n"  \
+        : [tmp] "=r"(__tmp__) \
+        : [u] "r"(upper), [l] "r"(lower) ); \
+      __tmp__; })
+
+static  void h264_v_loop_filter_luma_avr32(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
+{
+  int i;
+  
+  if ( alpha == 0 )
+    return;
+  
+  alpha = PACKW_SH(alpha, alpha);
+  alpha = PACKSH_UB(alpha, alpha);
+  beta = PACKW_SH(beta, beta);
+  beta = PACKSH_UB(beta, beta);
+
+  for( i = 0; i < 4; i++ ) {
+    uint32_t p0, p1, p2, q0, q1, q2;
+    uint32_t mask, mask2;
+    uint32_t tmp, tmp2, tmp3, tmp4;
+
+    if( tc0[i] < 0 ) {
+      pix += 4;
+      continue;
+    }
+
+/*    for( d = 0; d < 4; d++ ) {
+       const int p0 = pix[-1*stride];
+       const int p1 = pix[-2*stride];
+       const int p2 = pix[-3*stride];
+       const int q0 = pix[0];
+       const int q1 = pix[1*stride];
+       const int q2 = pix[2*stride];
+      
+       if( ABS( p0 - q0 ) < alpha &&
+           ABS( p1 - p0 ) < beta &&
+           ABS( q1 - q0 ) < beta ) { */
+
+    p0 = LD32(pix - stride);
+    p1 = LD32(pix - 2*stride);
+    q0 = LD32(pix);
+    q1 = LD32(pix + stride);
+    
+    /* Check which of the columns should be filtered, if any. */
+    mask = PABS_DIFF_LESS_THAN(p0, q0, alpha);
+    mask |= PABS_DIFF_LESS_THAN(p1, p0, beta);
+    mask |= PABS_DIFF_LESS_THAN(q1, q0, beta);
+        
+    if ( !mask )
+      continue;
+        
+    mask = SET_ALL_BITS_IN_ZERO_BYTES(mask);
+    
+
+    int tc =  PACKW_SH(tc0[i], tc0[i]);
+    int tc0_p = tc;
+    int tc0_m = PACKW_SH(-tc0[i], -tc0[i]);
+
+    /*
+      int i_delta;
+      if( ABS( p2 - p0 ) < beta ) {
+      pix[-2*stride] = p1 + clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] );
+      tc++;
+      }*/ 
+
+    p2 = LD32(pix - 3*stride);
+    mask2 = PABS_DIFF_LESS_THAN(p2, p0, beta) & ~mask;
+    
+    if ( mask2 ){
+      mask2 = SET_ALL_BITS_IN_ZERO_BYTES(mask2);
+      asm ("pavg.ub\t%[tmp], %[p0], %[q0]\n"
+           "paddh.ub\t%[tmp], %[tmp], %[p2]\n"
+           "punpckub.h\t%[tmp2], %[tmp]:t\n"
+           "punpckub.h\t%[tmp], %[tmp]:b\n"
+           "punpckub.h\t%[tmp3], %[p1]:t\n"
+           "punpckub.h\t%[tmp4], %[p1]:b\n"
+           "psub.h\t%[tmp2], %[tmp2], %[tmp3]\n"
+           "psub.h\t%[tmp], %[tmp], %[tmp4]\n"
+           "pmin.sh\t%[tmp2], %[tmp2], %[tc0_p]\n"
+           "pmin.sh\t%[tmp], %[tmp], %[tc0_p]\n"
+           "pmax.sh\t%[tmp2], %[tmp2], %[tc0_m]\n"
+           "pmax.sh\t%[tmp], %[tmp], %[tc0_m]\n"
+           "padd.h\t%[tmp2], %[tmp2], %[tmp3]\n"
+           "padd.h\t%[tmp], %[tmp], %[tmp4]\n"
+           "packsh.ub\t%[tmp], %[tmp2], %[tmp]\n"
+           "andn\t%[tmp], %[mask2]\n"
+           "and\t%[tmp2], %[q1], %[mask2]\n"
+           "or\t%[tmp], %[tmp2]\n"
+           : [tmp]"=&r"(tmp), [tmp2]"=&r"(tmp2), [tmp3]"=&r"(tmp3),
+           [tmp4]"=&r"(tmp4)
+           : [q0]"r"(q0), [p2]"r"(p2), [p1]"r"(p1), [p0]"r"(p0), [q1]"r"(q1), [tc0_p]"r"(tc0_p),
+           [tc0_m]"r"(tc0_m), [mask2]"r"(mask2));
+      ST32(pix - 2*stride, tmp);      
+      tc += 0x00010001;
+    }
+
+        
+    q2 = LD32(pix + 2*stride);
+
+    /*
+      if( ABS( q2 - q0 ) < beta ) {
+      pix[   stride] = q1 + clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] );
+      tc++;
+      }
+    */
+    mask2 = PABS_DIFF_LESS_THAN(q2, q0, beta) & ~mask;
+
+    if ( mask2 ){
+      mask2 = SET_ALL_BITS_IN_ZERO_BYTES(mask2);
+      asm ("pavg.ub\t%[tmp], %[p0], %[q0]\n"
+           "paddh.ub\t%[tmp], %[tmp], %[q2]\n"
+           "punpckub.h\t%[tmp2], %[tmp]:t\n"
+           "punpckub.h\t%[tmp], %[tmp]:b\n"
+           "punpckub.h\t%[tmp3], %[q1]:t\n"
+           "punpckub.h\t%[tmp4], %[q1]:b\n"
+           "psub.h\t%[tmp2], %[tmp2], %[tmp3]\n"
+           "psub.h\t%[tmp], %[tmp], %[tmp4]\n"
+           "pmin.sh\t%[tmp2], %[tmp2], %[tc0_p]\n"
+           "pmin.sh\t%[tmp], %[tmp], %[tc0_p]\n"
+           "pmax.sh\t%[tmp2], %[tmp2], %[tc0_m]\n"
+           "pmax.sh\t%[tmp], %[tmp], %[tc0_m]\n"
+           "padd.h\t%[tmp2], %[tmp2], %[tmp3]\n"
+           "padd.h\t%[tmp], %[tmp], %[tmp4]\n"
+           "packsh.ub\t%[tmp], %[tmp2], %[tmp]\n"
+           "andn\t%[tmp], %[mask2]\n"
+           "and\t%[tmp2], %[q1], %[mask2]\n"
+           "or\t%[tmp], %[tmp2]\n"
+           : [tmp]"=&r"(tmp), [tmp2]"=&r"(tmp2), [tmp3]"=&r"(tmp3),
+           [tmp4]"=&r"(tmp4)
+           : [q0]"r"(q0), [q2]"r"(q2), [q1]"r"(q1), [p0]"r"(p0), [tc0_p]"r"(tc0_p),
+           [tc0_m]"r"(tc0_m), [mask2]"r"(mask2));
+      ST32(pix + stride, tmp); 
+      tc += 0x00010001;
+    }
+
+    uint32_t old_p0 = p0;
+    uint32_t old_q0 = q0;
+    
+    /* i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
+       pix[-stride] = clip_uint8( p0 + i_delta );   
+       pix[0]        = clip_uint8( q0 - i_delta );  */ 
+    
+    asm (
+         /* Check if the two upper pixels should be filtered */
+         "lsr\t%[tmp], %[inv_mask], 16\n"
+         "breq\t0f\n"
+
+         "punpckub.h\t%[tmp], %[p1]:t\n"
+         "punpckub.h\t%[tmp2], %[q1]:t\n"
+         
+         /* p1 - q1 */
+         "psub.h\t%[tmp], %[tmp], %[tmp2]\n"
+
+         "punpckub.h\t%[tmp3], %[q0]:t\n"
+         "punpckub.h\t%[tmp4], %[p0]:t\n"
+
+         /* q0 - p0 */
+         "psub.h\t%[tmp2], %[tmp3], %[tmp4]\n"
+         
+         /* (q0 - p0) << 2 */
+         "plsl.h\t%[tmp2], %[tmp2], 2\n"
+
+         /* ((q0 - p0) << 2) + (p1 - q1) */
+         "padd.h\t%[tmp2], %[tmp2], %[tmp]\n"
+
+         "mov\t%[tmp], 0x00040004\n"
+         /* ((q0 - p0) << 2) + (p1 - q1) + 4*/
+         "padd.h\t%[tmp2], %[tmp2], %[tmp]\n"
+
+         /* (((q0 - p0) << 2) + (p1 - q1) + 4) >> 3*/
+         "pasr.h\t%[tmp2], %[tmp2], 3\n"
+
+         "mov\t%[tmp], 0\n"
+         "psub.h\t%[tmp], %[tmp], %[tc]\n"
+
+         /* i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); */
+         "pmin.sh\t%[tmp2], %[tmp2], %[tc]\n"
+         "pmax.sh\t%[tmp2], %[tmp2], %[tmp]\n"
+
+
+         /* pix[-stride] = clip_uint8( p0 + i_delta ); */
+         "padd.h\t%[tmp4], %[tmp4], %[tmp2]\n"
+
+         
+         /* pix[0]        = clip_uint8( q0 - i_delta ); */
+         "psub.h\t%[tmp3], %[tmp3], %[tmp2]\n"
+
+         /* Check if the two lower pixels should be filtered */
+         "lsl\t%[tmp2], %[inv_mask], 16\n"
+         "breq\t1f\n"
+
+         "0:\n"
+         "punpckub.h\t%[p1], %[p1]:b\n"
+         "punpckub.h\t%[q1], %[q1]:b\n"
+
+         /* p1 - q1 */
+         "psub.h\t%[p1], %[p1], %[q1]\n"
+
+         "punpckub.h\t%[q0], %[q0]:b\n"
+         "punpckub.h\t%[p0], %[p0]:b\n"
+
+         /* q0 - p0 */
+         "psub.h\t%[tmp2], %[q0], %[p0]\n"
+
+         /* (q0 - p0) << 2 */
+         "plsl.h\t%[tmp2], %[tmp2], 2\n"
+
+         /* ((q0 - p0) << 2) + (p1 - q1) */
+         "padd.h\t%[tmp2], %[tmp2], %[p1]\n"
+
+         "mov\t%[q1], 0x00040004\n"
+         /* ((q0 - p0) << 2) + (p1 - q1) + 4*/
+         "padd.h\t%[tmp2], %[tmp2], %[q1]\n"
+
+         /* (((q0 - p0) << 2) + (p1 - q1) + 4) >> 3*/
+         "pasr.h\t%[tmp2], %[tmp2], 3\n"
+ 
+         /* i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); */
+         "pmin.sh\t%[tmp2], %[tmp2], %[tc]\n"
+         "pmax.sh\t%[tmp2], %[tmp2], %[tmp]\n"
+
+         /* pix[-stride] = clip_uint8( p0 + i_delta ); */
+         "padd.h\t%[p0], %[p0], %[tmp2]\n"
+
+         /* pix[0]        = clip_uint8( q0 - i_delta ); */
+         "psub.h\t%[q0], %[q0], %[tmp2]\n"
+
+         "1:\n"
+         "packsh.ub\t%[p0], %[tmp4], %[p0]\n"
+         "packsh.ub\t%[q0], %[tmp3], %[tmp4]\n"
+
+         : [tmp]"=&r"(tmp), [tmp2]"=&r"(tmp2), [tmp3]"=&r"(tmp3),
+         [tmp4]"=&r"(tmp4), [q0]"=&r"(q0), [q1]"=&r"(q1), [p0]"=&r"(p0), [p1]"=&r"(p1)
+         : [tc]"r"(tc), [inv_mask]"r"(~mask));
+    
+    ST32(pix - stride, (mask & old_p0) | (p0 & ~mask));
+    ST32(pix, (mask & old_q0) | (q0 & ~mask));
+    
+  }
+  pix += 1;
+}
+
+
+
+
+#ifdef CHECK_DSP_FUNCS_AGAINST_C
+
+void dump_block8(uint8_t *block, int line_size, int h){
+  int i, j;
+
+  for ( i = 0; i < h ; i++ ){
+    av_log(NULL, AV_LOG_ERROR, "\t"); 
+    for ( j = 0; j < 8 ; j++ ){
+      av_log(NULL, AV_LOG_ERROR, "%d ", block[j + i*line_size]); 
+    }
+    av_log(NULL, AV_LOG_ERROR, "\n"); 
+  }
+}
+
+void dump_block4(uint8_t *block, int line_size, int h){
+  int i, j;
+
+  for ( i = 0; i < h ; i++ ){
+    av_log(NULL, AV_LOG_ERROR, "\t"); 
+    for ( j = 0; j < 4 ; j++ ){
+      av_log(NULL, AV_LOG_ERROR, "%d ", block[j + i*line_size]); 
+    }
+    av_log(NULL, AV_LOG_ERROR, "\n"); 
+  }
+}
+
+void dump_block(uint8_t *block, int line_size, int h, int w){
+  int i, j;
+
+  for ( i = 0; i < h ; i++ ){
+    av_log(NULL, AV_LOG_ERROR, "\t"); 
+    for ( j = 0; j < w ; j++ ){
+      av_log(NULL, AV_LOG_ERROR, "%d ", block[j + i*line_size]); 
+    }
+    av_log(NULL, AV_LOG_ERROR, "\n"); 
+  }
+}
+
+void check_block8(uint8_t *test, uint8_t *correct, int line_size_test, int line_size_correct, 
+                  int h, char *name, int max_dev){
+  int i,j;
+  for ( i = 0; i < 8 ; i++ ){
+    for ( j = 0; j < h ; j++ ){
+      int diff = test[i + line_size_test*j] - correct[i + line_size_correct*j];
+      diff = diff < 0 ? -diff : diff;
+      if ( diff > max_dev ){
+        av_log(NULL, AV_LOG_ERROR, "Error pixel x=%i, y=%i differs. Is 0x%x should be 0x%x\n", 
+               i, j, test[i + line_size_test*j], correct[i + j*line_size_correct]);        
+        av_log(NULL, AV_LOG_ERROR, "Error resulting block from %s is:\n", name);
+        dump_block8(test, line_size_test, h); 
+        av_log(NULL, AV_LOG_ERROR, "But should be equal to:\n");
+        dump_block8(correct, line_size_correct, h);         
+        exit(1);
+      }
+    }
+  }  
+}
+
+void check_block4(uint8_t *test, uint8_t *correct, int line_size_test, int line_size_correct, 
+                  int h, char *name, int max_dev){
+  int i,j;
+  for ( i = 0; i < 4 ; i++ ){
+    for ( j = 0; j < h ; j++ ){
+      int diff = test[i + line_size_test*j] - correct[i + line_size_correct*j];
+      diff = diff < 0 ? -diff : diff;
+      if ( diff > max_dev ){
+        av_log(NULL, AV_LOG_ERROR, "Error pixel x=%i, y=%i differs. Is 0x%x should be 0x%x\n", 
+               i, j, test[i + line_size_test*j], correct[i + j*line_size_correct]);        
+        av_log(NULL, AV_LOG_ERROR, "Error resulting block from %s is:\n", name);
+        dump_block8(test, line_size_test, h); 
+        av_log(NULL, AV_LOG_ERROR, "But should be equal to:\n");
+        dump_block4(correct, line_size_correct, h);         
+        exit(1);
+      }
+    }
+  }  
+}
+
+void check_block(uint8_t *test, uint8_t *correct, int line_size_test, int line_size_correct, 
+                 int h, int width, char *name, int max_dev){
+  int i,j;
+  for ( i = 0; i < width ; i++ ){
+    for ( j = 0; j < h ; j++ ){
+      int diff = test[i + line_size_test*j] - correct[i + line_size_correct*j];
+      diff = diff < 0 ? -diff : diff;
+      if ( diff > max_dev ){
+        av_log(NULL, AV_LOG_ERROR, "Error pixel x=%i, y=%i differs. Is 0x%x should be 0x%x\n", 
+               i, j, test[i + line_size_test*j], correct[i + j*line_size_correct]);        
+        av_log(NULL, AV_LOG_ERROR, "Error resulting block from %s is:\n", name);
+        dump_block(test, line_size_test, h, width); 
+        av_log(NULL, AV_LOG_ERROR, "But should be equal to:\n");
+        dump_block(correct, line_size_correct, h, width);         
+        exit(1);
+      }
+    }
+  }  
+}
+
+void dump_dct_block(DCTELEM *block){
+  int i, j;
+
+  for ( i = 0; i < 8 ; i++ ){
+    av_log(NULL, AV_LOG_ERROR, "\t"); 
+    for ( j = 0; j < 8 ; j++ ){
+      av_log(NULL, AV_LOG_ERROR, "0x%x ", block[j + i*8]); 
+    }
+    av_log(NULL, AV_LOG_ERROR, "\n"); 
+  }
+}
+
+void test_idct_avr32(DCTELEM *block){
+  DCTELEM testBlock[64];
+  int i, j;
+
+  /* Copy transposed block to testBlock */ 
+  for ( i = 0; i < 8 ; i++ ){
+    for ( j = 0; j < 8 ; j++ ){
+      testBlock[i + 8*j] = block[j + i*8]; 
+    }
+  }
+  
+  idct_avr32(block);
+  simple_idct(&testBlock);
+  
+  for ( i = 0; i < 64 ; i++ ){
+    if ( block[i] != testBlock[i] ){
+      av_log(NULL, AV_LOG_ERROR, "Error resulting block from idct is:\n");
+      dump_dct_block(block); 
+      av_log(NULL, AV_LOG_ERROR, "But should be equal to the transposed of:\n");
+      dump_dct_block(testBlock);         
+      exit(1);
+    }
+  }
+}
+
+void test_idct_put_avr32(uint8_t *dest, int line_size, DCTELEM *block){
+  uint8_t testBlock[64];
+  DCTELEM blockCopy[64];
+  int i, j;
+
+  /* Copy transposed block to blockCopy */ 
+  for ( i = 0; i < 8 ; i++ ){
+    for ( j = 0; j < 8 ; j++ ){
+      blockCopy[i + 8*j] = block[j + i*8]; 
+    }
+  }
+
+  idct_put_avr32(dest, line_size, block);
+  simple_idct_put(&testBlock, 8, blockCopy);
+  
+  check_block8(dest, testBlock, line_size, 8, 8, "idct_put", 1);
+}
+
+
+void test_idct_add_avr32(uint8_t *dest, int line_size, DCTELEM *block){
+  uint8_t testBlock[64];
+  DCTELEM blockCopy[64];
+  int i, j;
+  
+  /* Copy dest to testBlock */ 
+  for ( i = 0; i < 8 ; i++ ){
+    for ( j = 0; j < 8 ; j++ ){
+      testBlock[i + 8*j] = dest[i + j*line_size]; 
+    }
+  }
+
+  /* Copy transposed block to blockCopy */ 
+  for ( i = 0; i < 8 ; i++ ){
+    for ( j = 0; j < 8 ; j++ ){
+      blockCopy[i + 8*j] = block[j + i*8]; 
+    }
+  }
+
+  idct_add_avr32(dest, line_size, block);
+  simple_idct_add(&testBlock, 8, blockCopy);
+  
+  check_block8(dest, testBlock, line_size, 8, 8, "idct_add", 1);
+}
+
+void test_h264_idct_add_avr32(uint8_t *dest, DCTELEM *block, int stride){
+  uint8_t testBlock[16];
+  DCTELEM blockCopy[16];
+  int i, j;
+  
+  /* Copy dest to testBlock */ 
+  for ( i = 0; i < 4 ; i++ ){
+    for ( j = 0; j < 4 ; j++ ){
+      testBlock[i + 4*j] = dest[i + j*stride]; 
+    }
+  }
+
+  /* Copy transposed block to blockCopy */ 
+  for ( i = 0; i < 16 ; i++ ){
+    blockCopy[i] = block[i]; 
+  }
+
+  ff_h264_idct_add_c(dest, block, stride);
+  
+  h264_idct_add_avr32(testBlock, blockCopy, 4);
+  
+  check_block(dest, testBlock, stride, 4, 4, 4, "h264_idct_add", 0);
+}
+
+void test_h264_idct8_add_avr32(uint8_t *dest, DCTELEM *block, int stride){
+  uint8_t testBlock[8*8];
+  DCTELEM blockCopy[8*8];
+  int i, j;
+  
+  /* Copy dest to testBlock */ 
+  for ( i = 0; i < 8 ; i++ ){
+    for ( j = 0; j < 8 ; j++ ){
+      testBlock[i + 8*j] = dest[i + j*stride]; 
+    }
+  }
+
+  /* Copy source block to blockCopy */ 
+  for ( i = 0; i < 8*8 ; i++ ){
+    blockCopy[i] = block[i]; 
+  }
+
+  ff_h264_idct8_add_c(dest, block, stride);
+  h264_idct8_add_avr32(testBlock, blockCopy, 8);
+  
+  check_block(dest, testBlock, stride, 8, 8, 8, "h264_idct8_add", 0);
+}
+
+void test_put_pixels_funcs8(op_pixels_func test, op_pixels_func correct, uint8_t *block, 
+                       const uint8_t *pixels, int line_size, int h, char *name, int in_h_size, int in_v_size){
+  uint8_t *testBlock, *testBlock2;
+  int i, j;
+  int input_v_size = h + in_v_size;
+  int input_h_size = 8 + in_h_size;
+
+  testBlock = alloca(input_h_size*input_v_size);
+  testBlock2 = alloca(input_h_size*input_v_size);
+
+  for ( i = 0; i < input_h_size ; i++ ){
+    for ( j = 0; j < input_v_size ; j++ ){
+      testBlock[i + input_h_size*j] = pixels[i + j*line_size]; 
+    }
+  }
+
+  test(block, pixels, line_size, h);
+  correct(testBlock2, testBlock, input_h_size, h);
+  
+  check_block8(block, testBlock2, line_size, input_h_size, h, name, 0);
+
+} 
+
+void test_h264_chroma_mc_funcs(h264_chroma_mc_func test, h264_chroma_mc_func correct, uint8_t *dst, 
+                               uint8_t *src, int stride, int h, int w, int x, int y, char *name){
+  uint8_t *testBlock, *testBlock2;
+  int i, j;
+  int input_v_size = h + 1;
+  int input_h_size = ((w + 1) + 3) & ~3;
+
+  testBlock = alloca(input_h_size*input_v_size);
+  testBlock2 = alloca(input_h_size*input_v_size);
+
+  for ( i = 0; i < w + 1 ; i++ ){
+    for ( j = 0; j < h + 1 ; j++ ){
+      testBlock[i + input_h_size*j] = src[i + j*stride]; 
+    }
+  }
+
+  for ( i = 0; i < w ; i++ ){
+    for ( j = 0; j < h ; j++ ){
+      testBlock2[i + input_h_size*j] = dst[i + j*stride]; 
+    }
+  }
+
+  test(dst, src, stride, h, x, y);
+  correct(testBlock2, testBlock, input_h_size, h, x, y);
+  
+  check_block(dst, testBlock2, stride, input_h_size, h, w, name, 0);
+
+} 
+
+void test_qpel_mc_funcs(qpel_mc_func test, qpel_mc_func correct, uint8_t *dst, 
+                        uint8_t *src, int stride, int size, char *name){
+  uint8_t *testBlock, *testBlock2;
+  int i, j;
+  int test_stride = size + 8;
+
+  testBlock = alloca(test_stride*(size+8)) + 4 + test_stride*4;
+  testBlock2 = alloca(test_stride*size);
+  
+  for ( i = -4; i < size+4 ; i++ ){
+    for ( j = -4; j < size+4 ; j++ ){
+      testBlock[i + test_stride*j] = src[i + j*stride]; 
+    }
+  }
+  
+  for ( i = 0; i < size ; i++ ){
+    for ( j = 0; j < size ; j++ ){
+      testBlock2[i + test_stride*j] = dst[i + j*stride]; 
+    }
+  }
+
+  correct(dst, src, stride);
+  test(testBlock2, testBlock, test_stride);
+  
+  check_block(testBlock2, dst, test_stride, stride, size, size, name, 0);
+
+} 
+
+
+#define test_pixels_funcs(PFX, NUM ) \
+void test_ ## PFX ## _pixels ## NUM ## _avr32( uint8_t *block, const uint8_t *pixels, int line_size, int h){ \
+  test_put_pixels_funcs8(PFX ## _pixels ## NUM ## _avr32, PFX ## _pixels ## NUM ## _c, \
+                         block, pixels, line_size, h, "test_" #PFX "_pixels", 0, 0); } \
+void test_ ## PFX ## _pixels ## NUM ## _h_avr32( uint8_t *block, const uint8_t *pixels, int line_size, int h){ \
+  test_put_pixels_funcs8(PFX ## _pixels ## NUM ## _h_avr32, PFX ## _pixels ## NUM ## _x2_c, \
+                         block, pixels, line_size, h, "test_" #PFX "_pixels_h", 1, 0); } \
+void test_ ## PFX ## _pixels ## NUM ## _v_avr32( uint8_t *block, const uint8_t *pixels, int line_size, int h){ \
+  test_put_pixels_funcs8(PFX ## _pixels ## NUM ## _v_avr32, PFX ## _pixels ## NUM ## _y2_c, \
+                         block, pixels, line_size, h, "test_" #PFX "_pixels_v", 0, 1); } \
+void test_ ## PFX ## _pixels ## NUM ## _hv_avr32( uint8_t *block, const uint8_t *pixels, int line_size, int h){ \
+  test_put_pixels_funcs8(PFX ## _pixels ## NUM ## _hv_avr32, PFX ## _pixels ## NUM ## _xy2_c, \
+                         block, pixels, line_size, h, "test_" #PFX "_pixels_hv", 1, 1); }
+
+test_pixels_funcs(put, 8);
+test_pixels_funcs(put_no_rnd, 8);
+test_pixels_funcs(put, 16);
+test_pixels_funcs(put_no_rnd, 16);
+
+test_pixels_funcs(avg, 8);
+test_pixels_funcs(avg_no_rnd, 8);
+test_pixels_funcs(avg, 16);
+test_pixels_funcs(avg_no_rnd, 16);
+
+#define test_h264_chroma_mc_funcs(PFX, NUM ) \
+void test_ ## PFX ## _h264_chroma_mc ## NUM ## _pico( uint8_t *dst, uint8_t *src, int stride, int h, int x, int y){ \
+  test_h264_chroma_mc_funcs(PFX ## _h264_chroma_mc ## NUM ## _pico, PFX ## _h264_chroma_mc ## NUM ## _c, \
+                         dst, src, stride, h, NUM, x, y, "test_" #PFX "_h264_chroma_mc" #NUM "_pico"); } \
+
+test_h264_chroma_mc_funcs(put, 2);
+test_h264_chroma_mc_funcs(put, 4);
+test_h264_chroma_mc_funcs(put, 8);
+test_h264_chroma_mc_funcs(avg, 2);
+test_h264_chroma_mc_funcs(avg, 4);
+test_h264_chroma_mc_funcs(avg, 8);
+
+#define test_qpel_mc_funcs_type(PFX, NUM, TYPE ) \
+void test_ ## PFX ## NUM ## _ ## TYPE ## _pico( uint8_t *dst, uint8_t *src, int stride){ \
+  test_qpel_mc_funcs(PFX ## NUM ## _ ## TYPE ## _pico, PFX ## NUM ## _ ## TYPE ## _c, \
+                         dst, src, stride, NUM, "test_" #PFX #NUM "_" #TYPE "_pico"); } 
+
+#define test_qpel_mc_funcs(PFX, NUM) \
+  test_qpel_mc_funcs_type(PFX, NUM, mc00);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc10);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc20);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc30);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc01);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc11);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc21);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc31);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc02);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc12);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc22);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc32);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc03);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc13);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc23);\
+  test_qpel_mc_funcs_type(PFX, NUM, mc33)
+
+test_qpel_mc_funcs(put_h264_qpel, 4);
+test_qpel_mc_funcs(put_h264_qpel, 8);
+test_qpel_mc_funcs(put_h264_qpel, 16);
+test_qpel_mc_funcs(avg_h264_qpel, 4);
+test_qpel_mc_funcs(avg_h264_qpel, 8);
+test_qpel_mc_funcs(avg_h264_qpel, 16);
+
+
+#define dspfunc(PFX, IDX, NUM) \
+    c->PFX ## _pixels_tab[IDX][ 0] = DSP_FUNC_NAME( PFX ## NUM ## _mc00_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 1] = DSP_FUNC_NAME( PFX ## NUM ## _mc10_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 2] = DSP_FUNC_NAME( PFX ## NUM ## _mc20_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 3] = DSP_FUNC_NAME( PFX ## NUM ## _mc30_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 4] = DSP_FUNC_NAME( PFX ## NUM ## _mc01_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 5] = DSP_FUNC_NAME( PFX ## NUM ## _mc11_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 6] = DSP_FUNC_NAME( PFX ## NUM ## _mc21_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 7] = DSP_FUNC_NAME( PFX ## NUM ## _mc31_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 8] = DSP_FUNC_NAME( PFX ## NUM ## _mc02_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 9] = DSP_FUNC_NAME( PFX ## NUM ## _mc12_pico ); \
+    c->PFX ## _pixels_tab[IDX][10] = DSP_FUNC_NAME( PFX ## NUM ## _mc22_pico ); \
+    c->PFX ## _pixels_tab[IDX][11] = DSP_FUNC_NAME( PFX ## NUM ## _mc32_pico ); \
+    c->PFX ## _pixels_tab[IDX][12] = DSP_FUNC_NAME( PFX ## NUM ## _mc03_pico ); \
+    c->PFX ## _pixels_tab[IDX][13] = DSP_FUNC_NAME( PFX ## NUM ## _mc13_pico ); \
+    c->PFX ## _pixels_tab[IDX][14] = DSP_FUNC_NAME( PFX ## NUM ## _mc23_pico ); \
+    c->PFX ## _pixels_tab[IDX][15] = DSP_FUNC_NAME( PFX ## NUM ## _mc33_pico )
+
+#endif
+
+void dsputil_init_avr32(DSPContext* c, AVCodecContext *avctx)
+{
+
+  /* H264 */
+
+  if ( 0 /*avr32_use_pico*/ ){
+    c->put_h264_chroma_pixels_tab[0]= DSP_FUNC_NAME(put_h264_chroma_mc8_pico);
+    c->put_h264_chroma_pixels_tab[1]= DSP_FUNC_NAME(put_h264_chroma_mc4_pico);
+    c->put_h264_chroma_pixels_tab[2]= DSP_FUNC_NAME(put_h264_chroma_mc2_pico);
+    
+    c->avg_h264_chroma_pixels_tab[0]= DSP_FUNC_NAME(avg_h264_chroma_mc8_pico);
+    c->avg_h264_chroma_pixels_tab[1]= DSP_FUNC_NAME(avg_h264_chroma_mc4_pico);
+    c->avg_h264_chroma_pixels_tab[2]= DSP_FUNC_NAME(avg_h264_chroma_mc2_pico);
+  }
+
+#define dspfunc(PFX, IDX, NUM) \
+    c->PFX ## _pixels_tab[IDX][ 0] = DSP_FUNC_NAME( PFX ## NUM ## _mc00_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 1] = DSP_FUNC_NAME( PFX ## NUM ## _mc10_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 2] = DSP_FUNC_NAME( PFX ## NUM ## _mc20_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 3] = DSP_FUNC_NAME( PFX ## NUM ## _mc30_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 4] = DSP_FUNC_NAME( PFX ## NUM ## _mc01_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 5] = DSP_FUNC_NAME( PFX ## NUM ## _mc11_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 6] = DSP_FUNC_NAME( PFX ## NUM ## _mc21_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 7] = DSP_FUNC_NAME( PFX ## NUM ## _mc31_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 8] = DSP_FUNC_NAME( PFX ## NUM ## _mc02_pico ); \
+    c->PFX ## _pixels_tab[IDX][ 9] = DSP_FUNC_NAME( PFX ## NUM ## _mc12_pico ); \
+    c->PFX ## _pixels_tab[IDX][10] = DSP_FUNC_NAME( PFX ## NUM ## _mc22_pico ); \
+    c->PFX ## _pixels_tab[IDX][11] = DSP_FUNC_NAME( PFX ## NUM ## _mc32_pico ); \
+    c->PFX ## _pixels_tab[IDX][12] = DSP_FUNC_NAME( PFX ## NUM ## _mc03_pico ); \
+    c->PFX ## _pixels_tab[IDX][13] = DSP_FUNC_NAME( PFX ## NUM ## _mc13_pico ); \
+    c->PFX ## _pixels_tab[IDX][14] = DSP_FUNC_NAME( PFX ## NUM ## _mc23_pico ); \
+    c->PFX ## _pixels_tab[IDX][15] = DSP_FUNC_NAME( PFX ## NUM ## _mc33_pico )
+
+  if ( avr32_use_pico ){
+    dspfunc(put_h264_qpel, 0, 16);
+    dspfunc(put_h264_qpel, 1, 8);
+    dspfunc(put_h264_qpel, 2, 4);
+    dspfunc(avg_h264_qpel, 0, 16);
+    dspfunc(avg_h264_qpel, 1, 8);
+    dspfunc(avg_h264_qpel, 2, 4);
+  }
+
+  c->idct_put= DSP_FUNC_NAME(idct_put_avr32);
+  c->idct_add= DSP_FUNC_NAME(idct_add_avr32);
+  c->idct    = DSP_FUNC_NAME(idct_avr32);
+  c->h264_idct_add = DSP_FUNC_NAME(h264_idct_add_avr32);
+  c->h264_idct8_add = DSP_FUNC_NAME(h264_idct8_add_avr32);
+
+  /*c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_avr32;*/
+  
+  c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
+  
+  c->fdct = fdct_avr32;
+
+  c->clear_blocks = clear_blocks_avr32;
+  
+#undef dspfunc  
+#define dspfunc(PFX, IDX, NUM) \
+    c->PFX ## _pixels_tab[IDX][0] = DSP_FUNC_NAME( PFX ## _pixels ## NUM ## _avr32 );     \
+    c->PFX ## _pixels_tab[IDX][1] = DSP_FUNC_NAME( PFX ## _pixels ## NUM ## _h_avr32);  \
+    c->PFX ## _pixels_tab[IDX][2] = DSP_FUNC_NAME( PFX ## _pixels ## NUM ## _v_avr32);  \
+    c->PFX ## _pixels_tab[IDX][3] = DSP_FUNC_NAME( PFX ## _pixels ## NUM ## _hv_avr32)
+
+    dspfunc(put, 0, 16);
+    dspfunc(put_no_rnd, 0, 16);
+    dspfunc(put, 1, 8);
+    dspfunc(put_no_rnd, 1, 8);
+
+    dspfunc(avg, 1, 8);
+    dspfunc(avg_no_rnd, 1, 8);
+    dspfunc(avg, 0, 16);
+    dspfunc(avg_no_rnd, 0, 16);
+#undef dspfunc
+
+}
+
+
+
+#if 0
+int main(int argc, char *argv[]){
+  
+
+}
+#endif
+
diff --git a/libavcodec/avr32/fdct.S b/libavcodec/avr32/fdct.S
new file mode 100644
index 0000000..be45b86
--- /dev/null
+++ b/libavcodec/avr32/fdct.S
@@ -0,0 +1,541 @@
+/*
+ * Copyright (c) 2007 Atmel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of ATMEL may not be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+//********************************************************** 
+//* 2-D fDCT, Based on: 		          		  *
+//* C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical *
+//* Fast 1-D DCT Algorithms with 11 Multiplications",      *
+//* Proc. Int'l. Conf. on Acoustics, Speech, and Signal    *
+//* Processing 1989 (ICASSP '89), pp. 988-991.             *
+//*							  *
+//* Fixed point implementation optimized for the AVR-II	  *	
+//* instruction set. If a table is used for the 		  *
+//* coeffisients we can load two and two of them from      *
+//* This will give a reduction of 
+//*							  *
+//*							  *
+//**********************************************************
+
+
+/* This routine is a slow-but-accurate integer implementation of the
+ * forward DCT (Discrete Cosine Transform). Taken from the IJG software
+ *
+ * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
+ * on each column.  Direct algorithms are also available, but they are
+ * much more complex and seem not to be any faster when reduced to code.
+ *
+ * This implementation is based on an algorithm described in
+ *   C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
+ *   Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
+ *   Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
+ * The primary algorithm described there uses 11 multiplies and 29 adds.
+ * We use their alternate method with 12 multiplies and 32 adds.
+ * The advantage of this method is that no data path contains more than one
+ * multiplication; this allows a very simple and accurate implementation in
+ * scaled fixed-point arithmetic, with a minimal number of shifts.
+ *
+ * The poop on this scaling stuff is as follows:
+ *
+ * Each 1-D DCT step produces outputs which are a factor of sqrt(N)
+ * larger than the true DCT outputs.  The final outputs are therefore
+ * a factor of N larger than desired; since N=8 this can be cured by
+ * a simple right shift at the end of the algorithm.  The advantage of
+ * this arrangement is that we save two multiplications per 1-D DCT,
+ * because the y0 and y4 outputs need not be divided by sqrt(N).
+ * In the IJG code, this factor of 8 is removed by the quantization step
+ * (in jcdctmgr.c), here it is removed.
+ *
+ * We have to do addition and subtraction of the integer inputs, which
+ * is no problem, and multiplication by fractional constants, which is
+ * a problem to do in integer arithmetic.  We multiply all the constants
+ * by CONST_SCALE and convert them to integer constants (thus retaining
+ * CONST_BITS bits of precision in the constants).  After doing a
+ * multiplication we have to divide the product by CONST_SCALE, with proper
+ * rounding, to produce the correct output.  This division can be done
+ * cheaply as a right shift of CONST_BITS bits.  We postpone shifting
+ * as long as possible so that partial sums can be added together with
+ * full fractional precision.
+ *
+ * The outputs of the first pass are scaled up by PASS1_BITS bits so that
+ * they are represented to better-than-integral precision.  These outputs
+ * require 8 + PASS1_BITS + 3 bits; this fits in a 16-bit word
+ * with the recommended scaling.  (For 12-bit sample data, the intermediate
+ * array is INT32 anyway.)
+ *
+ * To avoid overflow of the 32-bit intermediate results in pass 2, we must
+ * have 8 + CONST_BITS + PASS1_BITS <= 26.  Error analysis
+ * shows that the values given below are the most effective.
+ *
+ * We can gain a little more speed, with a further compromise in accuracy,
+ * by omitting the addition in a descaling shift.  This yields an incorrectly
+ * rounded result half the time...
+ */
+
+	.global		fdct_avr32
+
+
+
+#define CONST_BITS  13
+#define PASS1_BITS  2
+
+#define FIX_0_298631336  2446	/* FIX(0.298631336) */
+#define FIX_0_390180644  3196	/* FIX(0.390180644) */
+#define FIX_0_541196100  4433	/* FIX(0.541196100) */
+#define FIX_0_765366865  6270	/* FIX(0.765366865) */
+#define FIX_0_899976223  7373	/* FIX(0.899976223) */
+#define FIX_1_175875602  9633	/* FIX(1.175875602) */
+#define FIX_1_501321110  12299	/* FIX(1.501321110) */
+#define FIX_1_847759065  15137	/* FIX(1.847759065) */
+#define FIX_1_961570560  16069	/* FIX(1.961570560) */
+#define FIX_2_053119869  16819	/* FIX(2.053119869) */
+#define FIX_2_562915447  20995	/* FIX(2.562915447) */
+#define FIX_3_072711026  25172	/* FIX(3.072711026) */
+
+
+/*
+ * Perform an integer forward DCT on one block of samples.
+ */
+
+//void
+//fdct_int32(short *const block)
+//{
+//	int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+//	int tmp10, tmp11, tmp12, tmp13;
+//	int z1, z2, z3, z4, z5;
+//	short *blkptr;
+//	int *dataptr;
+//	int data[64];
+//	int i;
+//
+//       /* Pass 1: process rows. */
+//       /* Note results are scaled up by sqrt(8) compared to a true DCT; */
+//       /* furthermore, we scale the results by 2**PASS1_BITS. */
+//
+//	dataptr = data;
+//	blkptr = block;
+
+	.text
+fdct_avr32:
+	pushm		r0-r3, r4-r7, lr
+#define		loop_ctr	r0
+#define		blkptr		r12
+#define		x0		r1
+#define		x1		r2
+#define		x2		r3
+#define		x3		r4
+#define		x4		r5
+#define		x5		r6
+#define		x6		r7
+#define		x7		r8
+#define		tmp0		r5
+#define		tmp7		r2
+#define		tmp1		r3
+#define		tmp6		r4
+#define		tmp2		r9
+#define		tmp5		r8
+#define		tmp3		r7
+#define		tmp4		r6
+
+
+	mov		loop_ctr, 8
+//	for (i = 0; i < 8; i++) {
+ROW_LOOP:
+
+	ldm		blkptr, r1, r2, r3, r4 
+
+//		tmp2 = blkptr[2] + blkptr[5];
+//		tmp3 = blkptr[3] + blkptr[4];
+	paddx.h		r5, r3, r2  
+//		tmp5 = blkptr[2] - blkptr[5];
+//		tmp4 = blkptr[3] - blkptr[4];
+	psubx.h		r6, r3, r2 
+//		tmp0 = blkptr[0] + blkptr[7];
+//		tmp1 = blkptr[1] + blkptr[6];
+	paddx.h		r2, r4, r1
+//		tmp7 = blkptr[0] - blkptr[7];
+//		tmp6 = blkptr[1] - blkptr[6];
+	psubx.h		r3, r4, r1
+
+//		/* Even part per LL&M figure 1 --- note that published figure is faulty;
+//		 * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
+//		 */
+
+#define		tmp10		r1
+#define		tmp13		r5
+#define		tmp11		r7
+#define		tmp12		r3
+#define		z1		r9
+
+//		tmp10 = tmp0 + tmp3;
+//		tmp13 = tmp0 - tmp3;
+	paddsub.h	r1, r2:t, r5:b	
+//		tmp11 = tmp1 + tmp2;
+//		tmp12 = tmp1 - tmp2;
+	paddsub.h	r4, r2:b, r5:t	
+	
+
+//		dataptr[0] = (tmp10 + tmp11) << PASS1_BITS;
+//		dataptr[4] = (tmp10 - tmp11) << PASS1_BITS;
+	paddsub.h	r7, r1:t, r4:t
+	ld.w		r10, pc[const_table - .] 
+	plsl.h		r7, r7, PASS1_BITS
+	
+//		z1 = (tmp12 + tmp13) * FIX_0_541196100;
+	addhh.w		r8, r4:b, r1:b
+	mulhh.w		r8, r8:b, r10:t		
+	
+//		dataptr[2] =
+//			DESCALE(z1 + tmp13 * FIX_0_765366865, CONST_BITS - PASS1_BITS);
+//		dataptr[6] =
+//			DESCALE(z1 + tmp12 * (-FIX_1_847759065), CONST_BITS - PASS1_BITS);
+	mulhh.w		r9, r1:b, r10:b
+	ld.w		r10, pc[const_table - . + 4]	
+	add		r1, r8, r9	
+	satrnds		r1 >> (CONST_BITS - PASS1_BITS), 31	
+
+	mulhh.w		r9, r4:b, r10:t
+	add		r4, r8, r9
+	satrnds		r4 >> (CONST_BITS - PASS1_BITS), 31	
+		
+
+//		/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
+//		 * cK represents cos(K*pi/16).
+//		 * i0..i3 in the paper are tmp4..tmp7 here.
+//		 */
+
+#define		z2		r5
+#define		z3		r6
+#define		z4		r7
+#define		z5		r8
+
+//		z4 = tmp5 + tmp7;
+//		z3 = tmp4 + tmp6;
+	padd.h		r2, r6, r3 
+//		z2 = tmp5 + tmp6;
+//		z1 = tmp4 + tmp7;
+	paddx.h		r5, r6, r3 	
+
+	lddpc		r9, pc[const_table - . + 8]
+//		z5 = (z3 + z4) * FIX_1_175875602;	/* sqrt(2) * c3 */
+	addhh.w		r8, r2:t, r2:b
+	mulhh.w		r8, r8:b, r10:b
+	lddpc		r10, pc[const_table - . + 12]
+	
+
+//		tmp4 *= FIX_0_298631336;	/* sqrt(2) * (-c1+c3+c5-c7) */
+	mulhh.w		r11, r6:b, r9:t
+	
+//		tmp5 *= FIX_2_053119869;	/* sqrt(2) * ( c1+c3-c5+c7) */
+	mulhh.w		r6, r6:t, r9:b
+
+//		tmp6 *= FIX_3_072711026;	/* sqrt(2) * ( c1+c3+c5-c7) */
+	lddpc		r9, pc[const_table - . + 20]
+	mulhh.w		lr, r3:b, r10:t
+	
+//		tmp7 *= FIX_1_501321110;	/* sqrt(2) * ( c1+c3-c5-c7) */
+	mulhh.w		r3, r3:t, r10:b
+
+//		z3 *= -FIX_1_961570560;	/* sqrt(2) * (-c3-c5) */
+	mulhh.w		r10, r2:b, r9:t
+
+//		z4 *= -FIX_0_390180644;	/* sqrt(2) * (c5-c3) */
+	mulhh.w		r2, r2:t, r9:b
+	lddpc		r9, pc[const_table - . + 16]
+//		z3 += z5;
+//		z4 += z5;
+	add		r10, r8
+	add		r2, r8
+	
+//		z1 *= -FIX_0_899976223;	/* sqrt(2) * (c7-c3) */
+	mulhh.w		r8, r5:b, r9:t
+
+//		z2 *= -FIX_2_562915447;	/* sqrt(2) * (-c1-c3) */
+	mulhh.w		r5, r5:t, r9:b
+	
+//		dataptr[7] = DESCALE(tmp4 + z1 + z3, CONST_BITS - PASS1_BITS);
+	add		r11, r8
+	add		r11, r10
+	satrnds		r11 >> (CONST_BITS - PASS1_BITS), 31	
+	
+//		dataptr[5] = DESCALE(tmp5 + z2 + z4, CONST_BITS - PASS1_BITS);
+	add		r6, r5
+
+	sthh.w		blkptr[6*2], r4:b, r11:b  	
+	add		r6, r2
+	satrnds		r6 >> (CONST_BITS - PASS1_BITS), 31	
+
+//		dataptr[3] = DESCALE(tmp6 + z2 + z3, CONST_BITS - PASS1_BITS);
+	add		lr, r5
+	sthh.w		blkptr[4*2], r7:b, r6:b	
+	add		lr, r10
+	satrnds		lr >> (CONST_BITS - PASS1_BITS), 31	
+	
+//		dataptr[1] = DESCALE(tmp7 + z1 + z4, CONST_BITS - PASS1_BITS);
+	add		r3, r8
+	sthh.w		blkptr[2*2], r1:b, lr:b
+	add		r3, r2
+	satrnds		r3 >> (CONST_BITS - PASS1_BITS), 31	
+
+		
+
+//		dataptr += 8;			/* advance pointer to next row */
+//		blkptr += 8;
+	sthh.w		blkptr[0], r7:t, r3:b	
+	sub		blkptr, -16
+	sub		loop_ctr, 1
+	brne		ROW_LOOP
+
+//	}
+
+	/* Pass 2: process columns.
+	 * We remove the PASS1_BITS scaling, but leave the results scaled up
+	 * by an overall factor of 8.
+	 */
+
+//	dataptr = data;
+	sub		blkptr, 128
+
+	mov		loop_ctr, 4
+//	for (i = 0; i < 8; i++) {
+COLOUMN_LOOP:
+	ld.w		r1, blkptr[0]
+	ld.w		r2, blkptr[1*8*2]
+	ld.w		r3, blkptr[2*8*2]
+	ld.w		r4, blkptr[3*8*2]
+	ld.w		r5, blkptr[4*8*2]
+	ld.w		r6, blkptr[5*8*2]
+	ld.w		r7, blkptr[6*8*2]
+	ld.w		r8, blkptr[7*8*2]
+	
+//		tmp0 = blkptr[0] + blkptr[7*8];
+	padds.sh	r9, r1, r8 
+//		tmp7 = blkptr[0] - blkptr[7*8];
+	psubs.sh	r1, r1, r8 
+//		tmp1 = blkptr[1*8] + blkptr[6*8];
+	padds.sh	r8, r2, r7 
+//		tmp6 = blkptr[1*8] - blkptr[6*8];
+	psubs.sh	r2, r2, r7 
+//		tmp2 = blkptr[2*8] + blkptr[5*8];
+	padds.sh	r7, r3, r6 
+//		tmp5 = blkptr[2*8] - blkptr[5*8];
+	psubs.sh	r3, r3, r6 
+//		tmp3 = blkptr[3*8] + blkptr[4*8];
+	padds.sh	r6, r4, r5 
+//		tmp4 = blkptr[3*8] - blkptr[4*8];
+	psubs.sh	r4, r4, r5 
+
+//		/* even part per ll&m figure 1 --- note that published figure is faulty;
+//		 * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
+//		 */
+//
+//		tmp10 = tmp0 + tmp3;
+	padds.sh	r5, r9, r6 
+//		tmp13 = tmp0 - tmp3;
+	psubs.sh	r9, r9, r6 
+//		tmp11 = tmp1 + tmp2;
+	padds.sh	r6, r8, r7 
+//		tmp12 = tmp1 - tmp2;
+	psubs.sh	r8, r8, r7 
+
+//		dataptr[0] = DESCALE(tmp10 + tmp11, PASS1_BITS);
+//		dataptr[32] = DESCALE(tmp10 - tmp11, PASS1_BITS);
+//Might get an overflow here
+	padds.sh	r7, r5, r6
+	psubs.sh	r5, r5, r6
+
+	//Rounding	
+	mov		lr,  (1 << (PASS1_BITS + 2))
+	orh		lr, hi(1 << (16 + PASS1_BITS + 2))	
+	padds.sh	r7, r7, lr
+	padds.sh	r5, r5, lr
+	
+	pasr.h		r7, r7, PASS1_BITS + 3
+	pasr.h		r5, r5, PASS1_BITS + 3
+	st.w		r12[0], r7
+	st.w		r12[4*8*2], r5
+				 
+	lddpc		r10, const_table2
+
+
+//		z1 = (tmp12 + tmp13) * FIX_0_541196100;
+	padds.sh	r5, r8, r9
+	mulhh.w		r6, r5:t, r10:t
+	mulhh.w		r7, r5:b, r10:t
+
+//		dataptr[16] =
+//			DESCALE(z1 + tmp13 * FIX_0_765366865, CONST_BITS + PASS1_BITS);
+	lddpc		r11, const_table2 + 4
+	mulhh.w		lr, r9:t, r10:b
+	mulhh.w		r9, r9:b, r10:b
+	add		lr, r6
+	add		r9, r7
+	satrnds		lr >> (CONST_BITS + PASS1_BITS + 3), 31
+	satrnds		r9 >> (CONST_BITS + PASS1_BITS + 3), 31
+	sthh.w		r12[2*8*2], lr:b, r9:b
+			
+//		dataptr[48] =
+//			DESCALE(z1 + tmp12 * (-FIX_1_847759065), CONST_BITS + PASS1_BITS);
+	mulhh.w		lr, r8:t, r11:t
+	mulhh.w		r8, r8:b, r11:t
+	add		lr, r6
+	add		r8, r7
+	satrnds		lr >> (CONST_BITS + PASS1_BITS + 3), 31
+	satrnds		r8 >> (CONST_BITS + PASS1_BITS + 3), 31
+	sthh.w		r12[6*8*2], lr:b, r8:b
+
+//		/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
+//		 * cK represents cos(K*pi/16).
+//		 * i0..i3 in the paper are tmp4..tmp7 here.
+//		 */
+//
+//		z2 = tmp5 + tmp6;
+//		z3 = tmp4 + tmp6;
+//		z4 = tmp5 + tmp7;
+	padds.sh	r5, r3, r2
+	padds.sh	r6, r4, r2
+	padds.sh	r7, r3, r1
+	
+//		z5 = (z3 + z4) * FIX_1_175875602;	/* sqrt(2) * c3 */
+	padds.sh	r8, r6, r7
+	mulhh.w		r9, r8:t, r11:b
+	mulhh.w		r8, r8:b, r11:b
+	
+//		z3 *= -FIX_1_961570560;	/* sqrt(2) * (-c3-c5) */
+//		z3 += z5;
+	lddpc		r11, const_table2 + 8
+	mulhh.w		r10, r6:t, r11:t
+	mulhh.w		r6, r6:b, r11:t
+	add		r10, r9
+	add		r6, r8
+	
+//		z4 *= -FIX_0_390180644;	/* sqrt(2) * (c5-c3) */
+//		z4 += z5;
+	mulhh.w		lr, r7:t, r11:b
+	mulhh.w		r7, r7:b, r11:b
+	lddpc		r11, const_table2 + 12
+	st.w		--sp,r0
+	add		lr, r9
+	add		r7, r8
+
+//		tmp6 *= FIX_3_072711026;	/* sqrt(2) * ( c1+c3+c5-c7) */
+	mulhh.w		r0, r2:t, r11:t	  
+	machh.w		r0, r5:t, r11:b
+	mulhh.w		r2, r2:b, r11:t	  
+	machh.w		r2, r5:b, r11:b
+
+//		z2 *= -FIX_2_562915447;	/* sqrt(2) * (-c1-c3) */
+//		dataptr[24] = DESCALE(tmp6 + z2 + z3, CONST_BITS + PASS1_BITS);
+	add		r0, r10
+	lddpc		r11, const_table2 + 16
+	add		r2, r6
+	satrnds		r0 >> (CONST_BITS + PASS1_BITS + 3), 31	
+	satrnds		r2 >> (CONST_BITS + PASS1_BITS + 3), 31	
+	sthh.w		r12[3*8*2], r0:b, r2:b		
+//		tmp5 *= FIX_2_053119869;	/* sqrt(2) * ( c1+c3-c5+c7) */
+	mulhh.w		r0, r3:t, r11:t	  
+	machh.w		r0, r5:t, r11:b
+	mulhh.w		r2, r3:b, r11:t	  
+	machh.w		r2, r5:b, r11:b
+	add		r0, lr
+	lddpc		r11, const_table2 + 20
+	add		r2, r7
+	
+//		dataptr[40] = DESCALE(tmp5 + z2 + z4, CONST_BITS + PASS1_BITS);
+	satrnds		r0 >> (CONST_BITS + PASS1_BITS + 3), 31	
+	satrnds		r2 >> (CONST_BITS + PASS1_BITS + 3), 31	
+	sthh.w		r12[5*8*2], r0:b, r2:b		
+
+
+//		z1 = tmp4 + tmp7;
+	padds.sh	r2, r4, r1
+
+//		tmp4 *= FIX_0_298631336;	/* sqrt(2) * (-c1+c3+c5-c7) */
+	mulhh.w		r3, r4:t, r11:t
+	machh.w		r3, r2:t, r11:b
+	mulhh.w		r4, r4:b, r11:t
+	machh.w		r4, r2:b, r11:b
+	add		r3, r10
+	lddpc		r11, const_table2 + 24
+	add		r4, r6
+	
+//		z1 *= -FIX_0_899976223;	/* sqrt(2) * (c7-c3) */
+//		dataptr[56] = DESCALE(tmp4 + z1 + z3, CONST_BITS + PASS1_BITS);
+	satrnds		r3 >> (CONST_BITS + PASS1_BITS + 3), 31	
+	satrnds		r4 >> (CONST_BITS + PASS1_BITS + 3), 31	
+	sthh.w		r12[7*8*2], r3:b, r4:b		
+
+
+//		tmp7 *= FIX_1_501321110;	/* sqrt(2) * ( c1+c3-c5-c7) */
+	mulhh.w		r3, r1:t, r11:t
+	machh.w		r3, r2:t, r11:b
+	mulhh.w		r4, r1:b, r11:t
+	machh.w		r4, r2:b, r11:b
+	add		r3, lr
+	add		r4, r7
+
+//		dataptr[8] = DESCALE(tmp7 + z1 + z4, CONST_BITS + PASS1_BITS);
+	satrnds		r3 >> (CONST_BITS + PASS1_BITS + 3), 31	
+	satrnds		r4 >> (CONST_BITS + PASS1_BITS + 3), 31	
+	sthh.w		r12[1*8*2], r3:b, r4:b		
+	ld.w		r0, sp++ 
+	
+//		dataptr++;				/* advance pointer to next column */
+	sub		blkptr, -4
+	sub		loop_ctr, 1
+	brne		COLOUMN_LOOP
+
+//	}
+
+	popm		r0-r3, r4-r7, pc
+	
+//	/* descale */
+//	for (i = 0; i < 64; i++)
+//		block[i] = (short int) DESCALE(data[i], 3);
+
+
+//}
+
+
+	.align	2
+const_table:	.short	FIX_0_541196100, FIX_0_765366865, -FIX_1_847759065, FIX_1_175875602
+		.short	FIX_0_298631336, FIX_2_053119869, FIX_3_072711026, FIX_1_501321110
+		.short	-FIX_0_899976223,-FIX_2_562915447, -FIX_1_961570560, -FIX_0_390180644
+	
+const_table2:	.short	FIX_0_541196100, FIX_0_765366865, -FIX_1_847759065, FIX_1_175875602
+		.short	-FIX_1_961570560, -FIX_0_390180644, FIX_3_072711026, -FIX_2_562915447
+		.short	FIX_2_053119869, -FIX_2_562915447, FIX_0_298631336,  -FIX_0_899976223 
+		.short	FIX_1_501321110, -FIX_0_899976223
+	
+
+
+
diff --git a/libavcodec/avr32/h264idct.S b/libavcodec/avr32/h264idct.S
new file mode 100644
index 0000000..4b23e2d
--- /dev/null
+++ b/libavcodec/avr32/h264idct.S
@@ -0,0 +1,451 @@
+/*
+ * Copyright (c) 2007 Atmel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of ATMEL may not be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+	.global	h264_idct_add_avr32
+
+	/* Macro for performing the 1-D transform on one row line. 
+
+	   The register 'w01' should contain the first two pixels,
+	   and the register 'w23' should contain the last two pixels
+	   in the line. The resulting line is placed in p01 and p23
+	   so that { w01, w23 } = { x0, x1, x3, x2 }.
+	   'tmp' and 'tmp2' should be scratchpad registers. */ 
+	.macro	transform_row 	w01, w23, tmp, tmp2 
+	add		\tmp, \w23, \w01 << 1   /* tmp = { xxxx, 2*w1 + w3 } */
+	sub		\tmp2, \w01, \w23 << 1  /* tmp2 = { xxxx, w1 - 2*w3 } */ 
+	bfins		\tmp2, \tmp, 16, 16     /* tmp2 = { 2*w1 + w3, w1 - 2*w3 } */
+	pasr.h		\tmp2, \tmp2, 1	        /* tmp2 = { w1 + w3/2, w1/2 - w3 } */
+	paddsub.h	\tmp, \w01:t, \w23:t    /* tmp =  { w0 + w2, w0 - w2 }  */
+	padd.h		\w01, \tmp, \tmp2	/* w01 =  { w0 + w2 + w1 + w3/2, w0 - w2 + w1/2 - w3 } */
+	psub.h		\w23, \tmp, \tmp2	/* w23 =  { w0 + w2 - w1 - w3/2, w0 - w2 - w1/2 + w3 } */
+	.endm			        	
+
+	/* Macro for performing the 1-D transform on two columns. 
+	   
+	   The registers w0, w1, w2, w3 should each contain two 
+	   packed samples from the two colomns to transform.
+	   tmp and tmp2 are scratchpad registers. 
+	  
+	   The resulting transformed columns are placed in the
+	   same positions as the input columns. 
+	*/ 
+	.macro	transform_2columns	w0, w1, w2, w3, tmp, tmp2
+	padd.h		\tmp, \w0, \w2  /* tmp = z0 = w0 + w2 */
+	psub.h		\w0, \w0, \w2   /* w0 = z1 = w0 - w2 */
+	pasr.h		\w2, \w1, 1	/* w2 = w1/2 */
+	pasr.h		\tmp2, \w3, 1	/* tmp2 = w3/2 */
+	psub.h		\w3, \w2, \w3	/* w3 = z2 = w1/2 - w3 */
+	padd.h		\tmp2, \w1, \tmp2/* tmp2 = z3 = w1 + w3/2 */
+	padd.h		\w1, \w0, \w3	/* w1 = x1 = z1 + z2 */
+	psub.h		\w2, \w0, \w3	/* w2 = x2 = z1 - z2 */
+	padd.h		\w0, \tmp, \tmp2/* w0 = x0 = z0 + z3 */
+	psub.h		\w3, \tmp, \tmp2/* w3 = x3 = z0 - z3 */
+	/* Scale down result. */
+	pasr.h		\w0, \w0, 6
+	pasr.h		\w1, \w1, 6
+	pasr.h		\w2, \w2, 6
+	pasr.h		\w3, \w3, 6
+	.endm			        	
+	
+/*void h264_idct_add_avr32(uint8_t *dst, DCTELEM *block, int stride)*/
+
+h264_idct_add_avr32:
+		
+	stm	--sp,r0-r3,r4-r7, lr 
+
+	/* Setup rounding factor. */
+	mov	r0, (1 << 5)
+	lsl	r0, 16	
+
+	/* Load block */
+        ldm	r11,r2-r9 
+        /* r9 = { w00, w01 }, 
+           r8 = { w02, w03 }, 
+           r7 = { w10, w11 }, 
+           r6 = { w12, w13 }, 
+           r5 = { w20, w21 }, 
+           r4 = { w22, w23 }, 
+           r3 = { w30, w31 }, 
+           r2 = { w32, w33 } */
+
+	
+	/* Add the rounding factor to w00. */
+	add			r9, r0
+	
+	/* Transform rows */
+	transform_row	        r9, r8, r0, r1
+	transform_row	        r7, r6, r0, r1
+	transform_row	        r5, r4, r0, r1
+	transform_row	        r3, r2, r0, r1
+
+	/* Transform columns */
+	transform_2columns	r9, r7, r5, r3, r0, r1
+	transform_2columns	r8, r6, r4, r2, r0, r1
+
+	/* Load predicted pixels.*/
+	ld.w			lr, r12[0]
+        ld.w			r11, r12[r10]
+
+	/* Unpack to halwords. */
+        punpckub.h		r0, lr:t
+        punpckub.h		r1, lr:b
+
+	/* Add with transformed row. */
+        padd.h			r0, r0, r9
+        paddx.h			r1, r1, r8
+	/* Pack and saturate back to 8-bit pixels. */
+        packsh.ub		r0, r0, r1
+
+	/* Unpack to halwords. */
+        punpckub.h		lr, r11:t
+        punpckub.h		r11, r11:b
+
+	/* Add with transformed row. */
+        padd.h			lr, lr, r7
+        paddx.h			r11, r11, r6
+	/* Pack and saturate back to 8-bit pixels. */
+        packsh.ub		r1, lr, r11
+
+	/* Store back to frame. */
+	st.w			r12[0], r0
+	st.w			r12[r10], r1
+
+	add			r12, r12, r10 << 1
+
+	/* Load predicted pixels.*/
+	ld.w			lr, r12[0]
+        ld.w			r11, r12[r10]
+
+	/* Unpack to halwords. */
+        punpckub.h		r0, lr:t
+        punpckub.h		r1, lr:b
+
+	/* Add with transformed row. */
+        padd.h			r0, r0, r5
+        paddx.h			r1, r1, r4
+	/* Pack and saturate back to 8-bit pixels. */
+        packsh.ub		r0, r0, r1
+
+	/* Unpack to halwords. */
+        punpckub.h		lr, r11:t
+        punpckub.h		r11, r11:b
+
+	/* Add with transformed row. */
+        padd.h			lr, lr, r3
+        paddx.h			r11, r11, r2
+	/* Pack and saturate back to 8-bit pixels. */
+        packsh.ub		r1, lr, r11
+
+	/* Store back to frame. */
+	st.w			r12[0], r0
+	st.w			r12[r10], r1
+	
+	ldm			sp++,r0-r3,r4-r7, pc 
+
+
+	.global	h264_idct8_add_avr32
+//void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride){
+
+h264_idct8_add_avr32:		
+	stm         --sp,r0-r3,r4-r7, lr 
+
+	/* Push dst and stride on stack */
+	stm         --sp,r10,r12 
+
+//    int i;
+//    DCTELEM (*src)[8] = (DCTELEM(*)[8])block;
+//    uint8_t *cm = cropTbl + MAX_NEG_CROP;
+
+//    block[0] += 32;
+
+
+//    for( i = 0; i < 8; i++ )
+//    {
+	mov		lr, 4
+0:
+	ld.w		r7, r11[0*(8*2)]
+	ld.w		r6, r11[1*(8*2)]
+	ld.w		r5, r11[2*(8*2)]	
+	ld.w		r4, r11[3*(8*2)]	
+	ld.w		r3, r11[4*(8*2)]	
+	ld.w		r2, r11[5*(8*2)]	
+	ld.w		r1, r11[6*(8*2)]	
+	ld.w		r0, r11[7*(8*2)]	
+	
+/*	
+
+        const int a0 =  src[0][i] + src[4][i];
+        const int a2 =  src[0][i] - src[4][i];
+        const int a4 = (src[2][i]>>1) - src[6][i];
+        const int a6 = (src[6][i]>>1) + src[2][i]; 
+*/
+	padd.h		r8, r7, r3	/* r8 = a0 */	
+	psub.h		r7, r7, r3	/* r7 = a2 */	
+	pasr.h		r3, r5, 1	/* r3 = src[2][i] >> 1 */
+	pasr.h		r9, r1, 1	/* r9 = src[6][i] >> 1 */
+	psub.h		r3, r3, r1	/* r3 = a4 */
+	padd.h		r9, r9, r5	/* r9 = a6 */
+
+/*
+        const int b0 = a0 + a6;
+        const int b2 = a2 + a4;
+        const int b4 = a2 - a4;
+        const int b6 = a0 - a6; 
+*/
+	padd.h		r1, r8, r9	/* r1 = b0 */
+	psub.h		r8, r8, r9	/* r8 = b6 */
+	padd.h		r5, r7, r3	/* r5 = b2 */
+	psub.h		r7, r7, r3	/* r7 = b4 */
+	
+/*	
+        const int a1 = -src[3][i] + src[5][i] - src[7][i] - (src[7][i]>>1);
+        const int a3 =  src[1][i] + src[7][i] - src[3][i] - (src[3][i]>>1);
+        const int a5 = -src[1][i] + src[7][i] + src[5][i] + (src[5][i]>>1);
+        const int a7 =  src[3][i] + src[5][i] + src[1][i] + (src[1][i]>>1);
+*/
+	pasr.h		r3, r0, 1
+	padd.h		r3, r3, r0
+	psub.h		r3, r2, r3
+	psub.h		r3, r3, r4 /* r3 = a1 */
+	
+	pasr.h		r9, r4, 1
+	padd.h		r9, r9, r4
+	psub.h		r9, r0, r9
+	padd.h		r9, r6, r9 /* r9 = a3 */
+	
+	pasr.h		r10, r2, 1
+	padd.h		r10, r10, r2
+	padd.h		r10, r10, r0
+	psub.h		r10, r10, r6 /* r10 = a5 */
+	
+	pasr.h		r0, r6, 1
+	padd.h		r0, r0, r6
+	padd.h		r0, r0, r2
+	padd.h		r0, r0, r4 /* r0 = a7 */
+/*
+        const int b1 = (a7>>2) + a1;
+        const int b3 =  a3 + (a5>>2);
+        const int b5 = (a3>>2) - a5;
+        const int b7 =  a7 - (a1>>2);
+*/
+	pasr.h		r2, r0, 2
+	padd.h		r2, r2, r3 /* r2 = b1 */
+	pasr.h		r3, r3, 2
+	psub.h		r3, r0, r3 /* r3 = b7 */
+
+	pasr.h		r0, r10, 2
+	padd.h		r0, r0, r9 /* r0 = b3 */
+	pasr.h		r9, r9, 2
+	psub.h		r9, r9, r10 /* r9 = b5 */
+	
+	
+/*	
+        src[0][i] = b0 + b7;
+        src[7][i] = b0 - b7;
+        src[1][i] = b2 + b5;
+        src[6][i] = b2 - b5;
+        src[2][i] = b4 + b3;
+        src[5][i] = b4 - b3;
+        src[3][i] = b6 + b1;
+        src[4][i] = b6 - b1; */
+
+	padd.h		r4, r1, r3
+	psub.h		r1, r1, r3
+	st.w		r11[0*(8*2)], r4
+	st.w		r11[7*(8*2)], r1
+		
+	padd.h		r3, r5, r9
+	psub.h		r5, r5, r9
+	st.w		r11[1*(8*2)], r3
+	st.w		r11[6*(8*2)], r5
+	
+	padd.h		r9, r7, r0
+	psub.h		r7, r7, r0
+	st.w		r11[2*(8*2)], r9
+	st.w		r11[5*(8*2)], r7
+
+	padd.h		r0, r8, r2
+	psub.h		r8, r8, r2
+	st.w		r11[3*(8*2)], r0
+	st.w		r11[4*(8*2)], r8
+
+	sub		r11, -4
+	sub		lr, 1
+	brne		0b
+	
+//    }
+
+	lddsp		r12, sp[0]	/* r12 = dst */ 
+	sub		r11, 4*4
+	ldm		r11++, r4-r7
+	mov		lr, 8
+	/* Push dst and stride on stack */
+	
+1:		
+//    for( i = 0; i < 8; i++ )
+//    {
+
+	/* r7 = {src[i][0], src[i][1]}  
+           r6 = {src[i][2], src[i][3]}
+	   r5 = {src[i][4], src[i][5]}
+           r4 = {src[i][6], src[i][7]}	*/	
+
+/*
+        const int a0 =  src[i][0] + src[i][4];
+        const int a2 =  src[i][0] - src[i][4];
+        const int a4 = (src[i][2]>>1) - src[i][6];
+        const int a6 = (src[i][6]>>1) + src[i][2]; 
+*/
+	pasr.h		r8, r6, 1
+	pasr.h		r9, r4, 1
+	addhh.w		r0, r7:t, r5:t	/* r0 = a0 */
+	subhh.w		r1, r7:t, r5:t	/* r1 = a2 */
+	subhh.w		r2, r8:t, r4:t	/* r2 = a4 */
+	addhh.w		r3, r9:t, r6:t	/* r3 = a6 */		
+		
+/*
+        const int b0 = a0 + a6;
+        const int b2 = a2 + a4;
+        const int b4 = a2 - a4;
+        const int b6 = a0 - a6;	
+*/
+	add		r10, r0, r3	/* r10 = b0 */ 
+	sub		r0, r3		/* r0 = b6 */
+	add		r3, r1, r2	/* r3 = b2 */
+	sub		r1, r2		/* r1 = b4 */		
+/*
+	
+
+          const int a7 =  src[i][5] + src[i][3] + src[i][1] + (src[i][1]>>1);
+          const int a1 =  src[i][5] - src[i][3] - src[i][7] - (src[i][7]>>1);
+          const int a3 =  src[i][7] + src[i][1] - src[i][3] - (src[i][3]>>1);
+          const int a5 =  src[i][7] - src[i][1] + src[i][5] + (src[i][5]>>1); */
+	addhh.w		r8, r8:b, r6:b
+	addhh.w		r2, r4:b, r7:b
+	sub		r2, r8		/* r2 = a3 */	
+
+	addhh.w		r9, r9:b, r4:b
+	subhh.w		r8, r5:b, r6:b
+	sub		r8, r9		/* r8 = a1 */	
+
+	pasr.h		r9, r7, 1
+	addhh.w		r9, r9:b, r7:b
+	addhh.w		r6, r5:b, r6:b
+	add		r6, r9		/* r6 = a7 */	
+		
+	pasr.h		r9, r5, 1
+	addhh.w		r9, r9:b, r5:b
+	subhh.w		r5, r4:b, r7:b
+	add		r5, r9		/* r5 = a5 */	
+			
+/*        const int b1 = (a7>>2) + a1;
+          const int b3 = (a5>>2) + a3;
+          const int b5 = (a3>>2) - a5;
+          const int b7 = -(a1>>2) + a7  ;  */
+	asr		r4, r6, 2
+	add		r4, r8		/* r4 = b1 */
+	asr		r8, 2
+	rsub		r8, r6		/* r8 = b7 */
+	
+	asr		r6, r5, 2
+	add		r6, r2		/* r6 = b3 */
+	asr		r2, 2
+	sub		r2, r5		/* r2 = b5 */
+	
+/*
+        dst[i*stride + 0] = cm[ dst[i*stride + 0] + ((b0 + b7) >> 6) ];
+        dst[i*stride + 1] = cm[ dst[i*stride + 1] + ((b2 + b5) >> 6) ];
+        dst[i*stride + 2] = cm[ dst[i*stride + 2] + ((b4 + b3) >> 6) ];
+        dst[i*stride + 3] = cm[ dst[i*stride + 3] + ((b6 + b1) >> 6) ];
+        dst[i*stride + 4] = cm[ dst[i*stride + 4] + ((b6 - b1) >> 6) ];
+        dst[i*stride + 5] = cm[ dst[i*stride + 5] + ((b4 - b3) >> 6) ];
+        dst[i*stride + 6] = cm[ dst[i*stride + 6] + ((b2 - b5) >> 6) ];
+        dst[i*stride + 7] = cm[ dst[i*stride + 7] + ((b0 - b7) >> 6) ];
+*/
+	add		r5, r10, r8
+	satrnds		r5 >> 6, 0	/* r5 = (b0 + b7) >> 6 */
+	sub		r10, r8
+	satrnds		r10 >> 6, 0	/* r10 = (b0 - b7) >> 6 */
+	add		r8, r3, r2
+	satrnds		r8 >> 6, 0	/* r8 = (b2 + b5) >> 6 */
+	sub		r3, r2
+	satrnds		r3 >> 6, 0	/* r3 = (b2 - b5) >> 6 */
+	
+	add		r2, r1, r6	
+	satrnds		r2 >> 6, 0	/* r2 = (b4 + b3) >> 6 */
+	sub		r1, r6	
+	satrnds		r1 >> 6, 0	/* r1 = (b4 - b3) >> 6 */
+				
+	add		r6, r0, r4	
+	satrnds		r6 >> 6, 0	/* r6 = (b6 + b1) >> 6 */
+	sub		r0, r4	
+	satrnds		r0 >> 6, 0	/* r0 = (b6 - b1) >> 6 */
+
+	ld.w		r4, r12[0]
+	
+	packw.sh	r8, r5, r8
+	packw.sh	r7, r2, r6
+	ld.w		r9, r12[4]
+	packw.sh	r6, r0, r1
+	packw.sh	r5, r3, r10
+	
+	punpckub.h	r10, r4:t
+	punpckub.h	r4, r4:b
+	punpckub.h	r3, r9:t
+	punpckub.h	r9, r9:b
+
+	padd.h		r8, r8, r10
+	padd.h		r7, r7, r4
+	padd.h		r6, r6, r3
+	padd.h		r5, r5, r9
+	
+	lddsp		r10, sp[4]	/* r10 = stride */
+	packsh.ub	r0, r8, r7
+	packsh.ub	r1, r6, r5
+
+	st.w		r12[0], r0
+	st.w		r12[4], r1
+	
+	ldm		r11++, r4-r7
+	add		r12, r10	/* dst += stride */
+	
+	sub		lr, 1
+	brne		1b			
+			
+	sub		sp, -8
+	ldm		sp++,r0-r3,r4-r7, pc
+
+
+		
+//    }
+//}
diff --git a/libavcodec/avr32/idct.S b/libavcodec/avr32/idct.S
new file mode 100644
index 0000000..e7551ec
--- /dev/null
+++ b/libavcodec/avr32/idct.S
@@ -0,0 +1,829 @@
+/*
+ * Copyright (c) 2007 Atmel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of ATMEL may not be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+	.global idct_add_avr32
+	.global idct_put_avr32
+	.global idct_avr32
+	
+
+#define CONST_BITS  13
+#define PASS1_BITS  2
+
+#define ONE	((INT32) 1)
+
+#define CONST_SCALE (ONE << CONST_BITS)
+
+#define	LINE_SIZE	32
+
+#define FIX_0_298631336  (2446)	/* FIX(0.298631336) */
+#define FIX_0_390180644  (3196)	/* FIX(0.390180644) */
+#define FIX_0_541196100  (4433)	/* FIX(0.541196100) */
+#define FIX_0_765366865  (6270)	/* FIX(0.765366865) */
+#define FIX_0_899976223  (7373)	/* FIX(0.899976223) */
+#define FIX_1_175875602  (9633)	/* FIX(1.175875602) */
+#define FIX_1_501321110  (12299)/* FIX(1.501321110) */
+#define FIX_1_847759065  (15137)/* FIX(1.847759065) */
+#define FIX_1_961570560  (16069)/* FIX(1.961570560) */
+#define FIX_2_053119869  (16819)/* FIX(2.053119869) */
+#define FIX_2_562915447  (20995)/* FIX(2.562915447) */
+#define FIX_3_072711026  (25172)/* FIX(3.072711026) */
+
+
+#define loop_cnt	r11	
+	
+	.text
+	
+idct_add_avr32:
+	pushm		r0-r3, r4-r7, lr	//Free up registers to use for local variables
+
+	// Give room for some variables on the stack
+	sub		sp, 8
+	stdsp		SP[0], r12 // rfp
+	stdsp		SP[4], r11 // iinc
+		
+	mov 		loop_cnt, 8		//Initialize loop counter
+
+FOR_ROW:
+
+	ldm		r10, r0, r1, r2, r3	//Load 8 DCT-coeffisients from the current row in the DCT-block
+	mov		r6, 0
+#ifdef USE_PREFETCH
+	pref		r10[LINE_SIZE]		//Prefetch next line 
+#endif
+	or		r4, r2, r3 << 16 
+	or		r4, r1			//Check if all DCT-coeffisients except the DC is zero
+	or		r4, r0
+	brne 		AC_ROW			//If there are non-zero AC coeffisients perform row-transform
+
+	paddsub.h	r5, r3:t, r6:b		//Extract the DC-coeff from r5			
+	plsl.h		r5, r5, PASS1_BITS
+	mov		r4, r5
+	st.d		r10++, r4
+	st.d		r10++, r4
+	
+	sub		loop_cnt, 1		//Decrement loop counter
+	brne		FOR_ROW			//Perform loop one more time if loop_cnt is not zero 
+
+	bral		COLOUMN_TRANSFORM	//Perform coloumn transform after row transform is computed 
+		
+		
+AC_ROW:	
+
+
+	ld.w		r12, pc[coef_table - .]
+	ld.w		r9, pc[coef_table - . + 4]
+
+	padd.h		r4, r2, r0 // r4:t = dataptr[2] + dataptr[6],r4:b = dataptr[3] + dataptr[7] 
+	mulhh.w		r5, r4:t, r12:t
+	mulhh.w		r6, r0:t, r12:b
+	ld.w		r12, pc[coef_table - . + 8]
+	mulhh.w		r7, r2:t, r9:t
+	add		r6, r5	// tmp2
+	satrnds		r6 >> (CONST_BITS - PASS1_BITS), 31
+	add		r7, r5	// tmp3
+	satrnds		r7 >> (CONST_BITS - PASS1_BITS), 31
+
+	paddsub.h	r5, r3:t, r1:t
+	plsl.h		r5, r5, PASS1_BITS // r5:t = tmp0, r5:b = tmp1
+	
+	paddsub.h	r7, r5:t, r7:b // r7:t = tmp10, r7:b = tmp13
+	paddsub.h	r6, r5:b, r6:b // r6:t = tmp11, r6:b = tmp12
+	
+	    
+	addhh.w		lr, r3:b, r1:b // lr = z4	
+	addhh.w		r5, r4:b, lr:b
+	mulhh.w		r5, r5:b, r9:b // r5 = z5
+	
+	ld.w		r9, pc[coef_table - . + 12]
+	mulhh.w		r4, r4:b, r12:t // r4 = z3
+	mulhh.w		lr, lr:b, r12:b // lr = z4
+	
+	add		r4, r5	
+	add		lr, r5	
+	
+	addhh.w		r5, r2:b, r1:b // r5 = z2	
+	addhh.w		r8, r3:b, r0:b // r8 = z1	
+
+	    
+	mulhh.w		r0, r0:b, r9:t // r0 = tmp0
+	ld.w		r12, pc[coef_table - . + 16]
+	mulhh.w		r1, r1:b, r9:b // r1 = tmp1
+	ld.w		r9, pc[coef_table - . + 20]
+	mulhh.w		r2, r2:b, r12:t // r2 = tmp2
+	mulhh.w		r3, r3:b, r12:b // r3 = tmp3
+	mulhh.w		r8, r8:b, r9:t // r8 = z1	
+	mulhh.w		r5, r5:b, r9:b // r5 = z2	
+    
+    
+	add		r0, r8
+	add		r0, r4
+	add		r1, r5
+	add		r1, lr
+	add		r2, r5
+	add		r2, r4	 
+	add		r3, r8
+	add		r3, lr	 
+
+	satrnds		r0 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r1 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r2 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r3 >> (CONST_BITS - PASS1_BITS), 31
+	
+	paddsub.h	r5, r6:t, r2:b // r5:t = dataptr[1], r5:b = dataptr[6]
+	paddsub.h	r4, r7:t, r3:b // r4:t = dataptr[0], r4:b = dataptr[7]
+	paddsub.h	r3, r6:b, r1:b // r3:t = dataptr[2], r3:b = dataptr[5]
+	paddsub.h	r2, r7:b, r0:b // r2:t = dataptr[3], r2:b = dataptr[4]
+
+	sthh.w		r10[0], r4:t, r5:t
+	sthh.w		r10[4], r3:t, r2:t
+	sthh.w		r10[8], r2:b, r3:b
+	sthh.w		r10[12], r5:b, r4:b
+	
+	
+
+	sub		r10, -16 
+	sub		loop_cnt, 1
+	brne		FOR_ROW, e
+
+COLOUMN_TRANSFORM:
+
+	sub		r10, 128	//Set pointer to start of DCT block
+
+
+	mov		loop_cnt, 8
+FOR_COLOUMN:	
+	ldins.h		r3:t,r10[0]    // r3:t = dataptr[0]  
+	ldins.h		r1:t,r10[1*8*2]// r1:t = dataptr[1] 
+	ldins.h		r2:t,r10[2*8*2]// r2:t = dataptr[2] 
+	ldins.h		r0:t,r10[5*8*2]// r0:t = dataptr[5] 
+	ldins.h		r3:b,r10[4*8*2]// r3:b = dataptr[4] 
+	ldins.h		r1:b,r10[3*8*2]// r1:b = dataptr[3] 
+	ldins.h		r2:b,r10[6*8*2]// r2:b = dataptr[6] 
+	ldins.h		r0:b,r10[7*8*2]// r0:b = dataptr[7] 
+		
+	or		r4, r1, r3 << 16
+	or		r4, r2	
+	or		r4, r0
+	brne 		AC_COLOUMN			//If there are non-zero AC coeffisients perform row-transform
+
+	lddsp		r12, SP[0]       // rfp
+	lddsp		r9, SP[4]	// iinc
+	satrnds		r3 >> ( PASS1_BITS + 3 + 16 ), 9	
+	ld.d		r0, r12[0]
+	sub		r10, -2	// Increment the dataptr
+	bfins		r3, r3, 16, 16
+	punpckub.h	r2, r1:t
+	padd.h		r2, r2, r3
+	punpckub.h	r1, r1:b
+	padd.h		r1, r1, r3
+	packsh.ub	r1, r2, r1
+	punpckub.h	r2, r0:t
+	padd.h		r2, r2, r3
+	punpckub.h	r0, r0:b
+	padd.h		r0, r0, r3
+	packsh.ub	r0, r2, r0
+	st.d		r12[0], r0
+	add		r12, r9	// increment rfp
+	stdsp		SP[0], r12		
+			
+	sub		loop_cnt, 1//Decrement loop counter
+	brne		FOR_COLOUMN//Perform loop one more time if loop_cnt is not zero 
+
+	sub		sp, -8	
+	popm		r0-r3, r4-r7, pc//Pop back registers and PC 
+
+AC_COLOUMN:
+	
+	ld.w		r12, pc[coef_table - .]
+	ld.w		r9, pc[coef_table - . + 4]
+
+	addhh.w		r4, r2:t, r2:b
+	mulhh.w		r4, r4:b, r12:t	// r4 = z1
+	mulhh.w		r5, r2:b, r12:b
+	ld.w		r12, pc[coef_table - . + 8]
+	mulhh.w		r6, r2:t, r9:t
+	add		r5, r4	// r5 = tmp2
+	add		r6, r4	// r6 = tmp3
+
+	addhh.w		r7, r3:t, r3:b
+	subhh.w		r8, r3:t, r3:b
+
+	lsl		r7, CONST_BITS
+	lsl		r8, CONST_BITS
+			
+	add		r2, r7, r6 // r2 = tmp10
+	sub		r3, r7, r6 // r3 = tmp13
+	add		r4, r8, r5 // r4 = tmp11
+	sub		r5, r8, r5 // r5 = tmp12
+	   
+	padd.h		r6, r0, r1 // r6:t = z4, r6:b = z3
+	addhh.w		r7, r6:t, r6:b
+	mulhh.w		r7, r7:b, r9:b // r7 = z5
+	
+	ld.w		r9, pc[coef_table - . + 12]
+	mulhh.w		r8, r6:b, r12:t // r8 = z3
+	mulhh.w		r6, r6:t, r12:b // r6 = z4
+	
+	add		r8, r7	
+	add		r6, r7	
+	
+	paddx.h		r7, r0, r1 // r7:t = z2, r7:b = z1
+
+	mulhh.w		r12, r0:b, r9:t // r12 = tmp0
+	mulhh.w		r0, r0:t, r9:b // r0 = tmp1
+	ld.w		r9, pc[coef_table - . + 16]
+	add		r12, r8
+	add		r0, r6
+		
+	ld.w		lr, pc[coef_table - . + 20]
+	machh.w		r8, r1:b, r9:t // r8 = tmp2
+	machh.w		r6, r1:t, r9:b // r6 = tmp3
+	mulhh.w		r9, r7:b, lr:t // r9 = z1	
+	mulhh.w		r7, r7:t, lr:b // r7 = z2	
+    
+    
+	add		r12, r9
+	add		r0, r7
+	add		r8, r7
+	add		r6, r9
+
+	add		r1, r2, r6 // r1 = dataptr[DCTSIZE*0]
+	sub		r2, r2, r6 // r2 = dataptr[DCTSIZE*7]
+	add		r6, r4, r8 // r6 = dataptr[DCTSIZE*1]
+	sub		r4, r4, r8 // r4 = dataptr[DCTSIZE*6]
+	add		r8, r5, r0 // r8 = dataptr[DCTSIZE*2]
+	sub		r5, r5, r0 // r5 = dataptr[DCTSIZE*5]
+	add		r0, r3, r12 // r0 = dataptr[DCTSIZE*3]
+	sub		r3, r3, r12 // r3 = dataptr[DCTSIZE*4]
+	
+	satrnds		r1 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r2 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r6 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r4 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r8 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r5 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r0 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r3 >> (CONST_BITS+PASS1_BITS+3), 9
+
+	packw.sh	r1, r1, r6
+	packw.sh	r8, r8, r0
+	packw.sh	r3, r3, r5
+	packw.sh	r4, r4, r2
+		
+	lddsp		r12, SP[0]       // rfp
+	lddsp		r9, SP[4]	// iinc
+	ld.d		r6, r12[0]
+	sub		r10, -2	// Increment the dataptr
+	punpckub.h	r0, r7:t
+	padd.h		r1, r1, r0
+	punpckub.h	r0, r7:b
+	padd.h		r8, r8, r0
+	packsh.ub	r7, r1, r8
+	punpckub.h	r0, r6:t
+	padd.h		r3, r3, r0
+	punpckub.h	r0, r6:b
+	padd.h		r4, r4, r0
+	packsh.ub	r6, r3, r4
+	st.d		r12[0], r6
+	add		r12, r9	// increment rfp
+	stdsp		SP[0], r12		
+				
+	sub		loop_cnt, 1		//Decrement loop counter
+	brne		FOR_COLOUMN			//Perform loop one more time if loop_cnt is not zero 
+	
+	sub		sp, -8	
+	popm		r0-r3, r4-r7, pc	//Pop back registers and PC 
+	
+
+
+//Coeffisient Table:
+	.align	2
+coef_table:	
+	.short	FIX_0_541196100, -FIX_1_847759065, FIX_0_765366865, FIX_1_175875602 
+	.short	- FIX_1_961570560, - FIX_0_390180644, FIX_0_298631336, FIX_2_053119869
+	.short	FIX_3_072711026, FIX_1_501321110, - FIX_0_899976223, - FIX_2_562915447
+
+
+idct_put_avr32:
+	pushm		r0-r3, r4-r7, lr	//Free up registers to use for local variables
+
+		//; Give room for some variables on the stack
+	sub		sp, 8
+	stdsp		SP[0], r12 // rfp
+	stdsp		SP[4], r11 // iinc
+		
+	mov 		loop_cnt, 8		//Initialize loop counter
+
+0:
+
+	ldm		r10, r0, r1, r2, r3	//Load 8 DCT-coeffisients from the current row in the DCT-block
+	mov		r6, 0
+#ifdef USE_PREFETCH
+	pref		r10[LINE_SIZE]		//Prefetch next line 
+#endif
+	or		r4, r2, r3 << 16 
+	or		r4, r1			//Check if all DCT-coeffisients except the DC is zero
+	or		r4, r0
+	brne 		1f			//If there are non-zero AC coeffisients perform row-transform
+
+	paddsub.h	r5, r3:t, r6:b		//Extract the DC-coeff from r5			
+	plsl.h		r5, r5, PASS1_BITS
+	mov		r4, r5
+	st.d		r10++, r4
+	st.d		r10++, r4
+	
+	sub		loop_cnt, 1		//Decrement loop counter
+	brne		0b			//Perform loop one more time if loop_cnt is not zero 
+
+	bral		2f	                //Perform coloumn transform after row transform is computed 
+		
+1:	
+
+	ld.w		r12, pc[coef_table_copy - .]
+	ld.w		r9, pc[coef_table_copy - . + 4]
+
+	padd.h		r4, r2, r0 // r4:t = dataptr[2] + dataptr[6],r4:b = dataptr[3] + dataptr[7] 
+	mulhh.w		r5, r4:t, r12:t
+	mulhh.w		r6, r0:t, r12:b
+	ld.w		r12, pc[coef_table_copy - . + 8]
+	mulhh.w		r7, r2:t, r9:t
+	add		r6, r5	// tmp2
+	satrnds		r6 >> (CONST_BITS - PASS1_BITS), 31
+	add		r7, r5	// tmp3
+	satrnds		r7 >> (CONST_BITS - PASS1_BITS), 31
+
+	paddsub.h	r5, r3:t, r1:t
+	plsl.h		r5, r5, PASS1_BITS // r5:t = tmp0, r5:b = tmp1
+	
+	paddsub.h	r7, r5:t, r7:b // r7:t = tmp10, r7:b = tmp13
+	paddsub.h	r6, r5:b, r6:b // r6:t = tmp11, r6:b = tmp12
+	
+	    
+
+	addhh.w		lr, r3:b, r1:b // lr = z4	
+	addhh.w		r5, r4:b, lr:b
+	mulhh.w		r5, r5:b, r9:b // r5 = z5
+	
+	ld.w		r9, pc[coef_table_copy - . + 12]
+	mulhh.w		r4, r4:b, r12:t // r4 = z3
+	mulhh.w		lr, lr:b, r12:b // lr = z4
+	
+	add		r4, r5	
+	add		lr, r5	
+	
+	addhh.w		r5, r2:b, r1:b // r5 = z2	
+	addhh.w		r8, r3:b, r0:b // r8 = z1	
+
+	    
+	mulhh.w		r0, r0:b, r9:t // r0 = tmp0
+	ld.w		r12, pc[coef_table_copy - . + 16]
+	mulhh.w		r1, r1:b, r9:b // r1 = tmp1
+	ld.w		r9, pc[coef_table_copy - . + 20]
+	mulhh.w		r2, r2:b, r12:t // r2 = tmp2
+	mulhh.w		r3, r3:b, r12:b // r3 = tmp3
+	mulhh.w		r8, r8:b, r9:t // r8 = z1	
+	mulhh.w		r5, r5:b, r9:b // r5 = z2	
+    
+    
+	add		r0, r8
+	add		r0, r4
+	add		r1, r5
+	add		r1, lr
+	add		r2, r5
+	add		r2, r4	 
+	add		r3, r8
+	add		r3, lr	 
+
+	satrnds		r0 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r1 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r2 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r3 >> (CONST_BITS - PASS1_BITS), 31
+	
+	paddsub.h	r5, r6:t, r2:b // r5:t = dataptr[1], r5:b = dataptr[6]
+	paddsub.h	r4, r7:t, r3:b // r4:t = dataptr[0], r4:b = dataptr[7]
+	paddsub.h	r3, r6:b, r1:b // r3:t = dataptr[2], r3:b = dataptr[5]
+	paddsub.h	r2, r7:b, r0:b // r2:t = dataptr[3], r2:b = dataptr[4]
+
+	sthh.w		r10[0], r4:t, r5:t
+	sthh.w		r10[4], r3:t, r2:t
+	sthh.w		r10[8], r2:b, r3:b
+	sthh.w		r10[12], r5:b, r4:b
+	
+	
+
+	sub		r10, -16 
+	sub		loop_cnt, 1
+	brne		0b
+
+2:
+
+	sub		r10, 128	//Set pointer to start of DCT block
+
+	mov		loop_cnt, 8
+
+0:	
+	ldins.h		r3:t,r10[0]    // r3:t = dataptr[0]  
+	ldins.h		r1:t,r10[1*8*2]// r1:t = dataptr[1] 
+	ldins.h		r2:t,r10[2*8*2]// r2:t = dataptr[2] 
+	ldins.h		r0:t,r10[5*8*2]// r0:t = dataptr[5] 
+	ldins.h		r3:b,r10[4*8*2]// r3:b = dataptr[4] 
+	ldins.h		r1:b,r10[3*8*2]// r1:b = dataptr[3] 
+	ldins.h		r2:b,r10[6*8*2]// r2:b = dataptr[6] 
+	ldins.h		r0:b,r10[7*8*2]// r0:b = dataptr[7] 
+		
+	or		r4, r1, r3 << 16
+	or		r4, r2	
+	or		r4, r0
+	brne 		1f			//If there are non-zero AC coeffisients perform row-transform
+
+	lddsp		r12, SP[0]       // rfp
+	lddsp		r9, SP[4]	// iinc
+	satrnds		r3 >> ( PASS1_BITS + 3 + 16 ), 31	
+	packw.sh	r3, r3, r3
+	packsh.ub	r3, r3, r3
+	mov		r2, r3
+	st.d		r12[0], r2
+	add		r12, r9	// increment rfp
+	sub		r10, -2	// Increment the dataptr
+	stdsp		SP[0], r12		
+			
+	sub		loop_cnt, 1//Decrement loop counter
+	brne		0b         //Perform loop one more time if loop_cnt is not zero 
+
+	sub		sp, -8	
+	popm		r0-r3, r4-r7, pc//Pop back registers and PC 
+
+1:
+	
+	ld.w		r12, pc[coef_table_copy - .]
+	ld.w		r9, pc[coef_table_copy - . + 4]
+
+	addhh.w		r4, r2:t, r2:b
+	mulhh.w		r4, r4:b, r12:t	// r4 = z1
+	mulhh.w		r5, r2:b, r12:b
+	ld.w		r12, pc[coef_table_copy - . + 8]
+	mulhh.w		r6, r2:t, r9:t
+	add		r5, r4	// r5 = tmp2
+	add		r6, r4	// r6 = tmp3
+
+	addhh.w		r7, r3:t, r3:b
+	subhh.w		r8, r3:t, r3:b
+
+	lsl		r7, CONST_BITS
+	lsl		r8, CONST_BITS
+			
+	add		r2, r7, r6 // r2 = tmp10
+	sub		r3, r7, r6 // r3 = tmp13
+	add		r4, r8, r5 // r4 = tmp11
+	sub		r5, r8, r5 // r5 = tmp12
+	   
+
+	padd.h		r6, r0, r1 // r6:t = z4, r6:b = z3
+	addhh.w		r7, r6:t, r6:b
+	mulhh.w		r7, r7:b, r9:b // r7 = z5
+	
+	ld.w		r9, pc[coef_table_copy - . + 12]
+	mulhh.w		r8, r6:b, r12:t // r8 = z3
+	mulhh.w		r6, r6:t, r12:b // r6 = z4
+	
+	add		r8, r7	
+	add		r6, r7	
+	
+	paddx.h		r7, r0, r1 // r7:t = z2, r7:b = z1
+
+	mulhh.w		r12, r0:b, r9:t // r12 = tmp0
+	mulhh.w		r0, r0:t, r9:b // r0 = tmp1
+	ld.w		r9, pc[coef_table_copy - . + 16]
+	add		r12, r8
+	add		r0, r6
+		
+	ld.w		lr, pc[coef_table_copy - . + 20]
+	machh.w		r8, r1:b, r9:t // r8 = tmp2
+	machh.w		r6, r1:t, r9:b // r6 = tmp3
+	mulhh.w		r9, r7:b, lr:t // r9 = z1	
+	mulhh.w		r7, r7:t, lr:b // r7 = z2	
+    
+    
+	add		r12, r9
+	add		r0, r7
+	add		r8, r7
+	add		r6, r9
+
+	add		r1, r2, r6 // r1 = dataptr[DCTSIZE*0]
+	sub		r2, r2, r6 // r2 = dataptr[DCTSIZE*7]
+	add		r6, r4, r8 // r6 = dataptr[DCTSIZE*1]
+	sub		r4, r4, r8 // r4 = dataptr[DCTSIZE*6]
+	add		r8, r5, r0 // r8 = dataptr[DCTSIZE*2]
+	sub		r5, r5, r0 // r5 = dataptr[DCTSIZE*5]
+	add		r0, r3, r12 // r0 = dataptr[DCTSIZE*3]
+	sub		r3, r3, r12 // r3 = dataptr[DCTSIZE*4]
+	
+	satrnds		r1 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r2 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r6 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r4 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r8 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r5 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r0 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r3 >> (CONST_BITS+PASS1_BITS+3), 9
+
+	packw.sh	r1, r1, r6
+	packw.sh	r8, r8, r0
+	packw.sh	r3, r3, r5
+	packw.sh	r4, r4, r2
+
+	packsh.ub	r1, r1, r8
+	packsh.ub	r0, r3, r4		
+	lddsp		r12, SP[0]       // rfp
+	lddsp		r9, SP[4]	// iinc
+	st.d		r12[0], r0
+	sub		r10, -2	// Increment the dataptr
+	add		r12, r9	// increment rfp
+	stdsp		SP[0], r12		
+				
+	sub		loop_cnt, 1		//Decrement loop counter
+	brne		0b			//Perform loop one more time if loop_cnt is not zero 
+	
+	sub		sp, -8	
+	popm		r0-r3, r4-r7, pc	//Pop back registers and PC 
+	
+
+
+	.align 2
+coef_table_copy:	
+	.short	FIX_0_541196100, -FIX_1_847759065, FIX_0_765366865, FIX_1_175875602 
+	.short	- FIX_1_961570560, - FIX_0_390180644, FIX_0_298631336, FIX_2_053119869
+	.short	FIX_3_072711026, FIX_1_501321110, - FIX_0_899976223, - FIX_2_562915447
+	
+
+idct_avr32:
+	pushm		r0-r3, r4-r7, lr	//Free up registers to use for local variables
+
+		//; Give room for a temporary block on the stack
+	sub		sp, 8*8*2
+		
+	mov 		loop_cnt, 8		//Initialize loop counter
+
+0:
+
+	ldm		r12++, r0, r1, r2, r3	//Load 8 DCT-coeffisients from the current row in the DCT-block
+	mov		r6, 0
+#ifdef USE_PREFETCH
+	pref		r12[LINE_SIZE]		//Prefetch next line 
+#endif
+	or		r4, r2, r3 << 16 
+	or		r4, r1			//Check if all DCT-coeffisients except the DC is zero
+	or		r4, r0
+	brne 		1f			//If there are non-zero AC coeffisients perform row-transform
+
+	paddsub.h	r5, r3:t, r6:b		//Extract the DC-coeff from r5			
+	plsl.h		r5, r5, PASS1_BITS
+	mov		r4, r5
+	st.d		sp++, r4
+	st.d		sp++, r4
+	
+	sub		loop_cnt, 1		//Decrement loop counter
+	brne		0b			//Perform loop one more time if loop_cnt is not zero 
+
+	bral		2f	                //Perform coloumn transform after row transform is computed 
+		
+1:	
+
+	ld.w		r10, pc[coef_table_idct - .]
+	ld.w		r9, pc[coef_table_idct - . + 4]
+
+	padd.h		r4, r2, r0 // r4:t = dataptr[2] + dataptr[6],r4:b = dataptr[3] + dataptr[7] 
+	mulhh.w		r5, r4:t, r10:t
+	mulhh.w		r6, r0:t, r10:b
+	ld.w		r10, pc[coef_table_idct - . + 8]
+	mulhh.w		r7, r2:t, r9:t
+	add		r6, r5	// tmp2
+	satrnds		r6 >> (CONST_BITS - PASS1_BITS), 31
+	add		r7, r5	// tmp3
+	satrnds		r7 >> (CONST_BITS - PASS1_BITS), 31
+
+	paddsub.h	r5, r3:t, r1:t
+	plsl.h		r5, r5, PASS1_BITS // r5:t = tmp0, r5:b = tmp1
+	
+	paddsub.h	r7, r5:t, r7:b // r7:t = tmp10, r7:b = tmp13
+	paddsub.h	r6, r5:b, r6:b // r6:t = tmp11, r6:b = tmp12
+	
+	    
+
+	addhh.w		lr, r3:b, r1:b // lr = z4	
+	addhh.w		r5, r4:b, lr:b
+	mulhh.w		r5, r5:b, r9:b // r5 = z5
+	
+	ld.w		r9, pc[coef_table_idct - . + 12]
+	mulhh.w		r4, r4:b, r10:t // r4 = z3
+	mulhh.w		lr, lr:b, r10:b // lr = z4
+	
+	add		r4, r5	
+	add		lr, r5	
+	
+	addhh.w		r5, r2:b, r1:b // r5 = z2	
+	addhh.w		r8, r3:b, r0:b // r8 = z1	
+
+	    
+	mulhh.w		r0, r0:b, r9:t // r0 = tmp0
+	ld.w		r10, pc[coef_table_idct - . + 16]
+	mulhh.w		r1, r1:b, r9:b // r1 = tmp1
+	ld.w		r9, pc[coef_table_idct - . + 20]
+	mulhh.w		r2, r2:b, r10:t // r2 = tmp2
+	mulhh.w		r3, r3:b, r10:b // r3 = tmp3
+	mulhh.w		r8, r8:b, r9:t // r8 = z1	
+	mulhh.w		r5, r5:b, r9:b // r5 = z2	
+    
+    
+	add		r0, r8
+	add		r0, r4
+	add		r1, r5
+	add		r1, lr
+	add		r2, r5
+	add		r2, r4	 
+	add		r3, r8
+	add		r3, lr	 
+
+	satrnds		r0 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r1 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r2 >> (CONST_BITS - PASS1_BITS), 31
+	satrnds		r3 >> (CONST_BITS - PASS1_BITS), 31
+	
+	paddsub.h	r5, r6:t, r2:b // r5:t = dataptr[1], r5:b = dataptr[6]
+	paddsub.h	r4, r7:t, r3:b // r4:t = dataptr[0], r4:b = dataptr[7]
+	paddsub.h	r3, r6:b, r1:b // r3:t = dataptr[2], r3:b = dataptr[5]
+	paddsub.h	r2, r7:b, r0:b // r2:t = dataptr[3], r2:b = dataptr[4]
+
+	sthh.w		sp[0], r4:t, r5:t
+	sthh.w		sp[4], r3:t, r2:t
+	sthh.w		sp[8], r2:b, r3:b
+	sthh.w		sp[12], r5:b, r4:b
+	
+	
+
+	sub		sp, -16 
+	sub		loop_cnt, 1
+	brne		0b
+
+2:
+
+	sub		sp, 8*8*2	//Set pointer to start of DCT block
+	sub		r12, 8*8*2	//Set pointer to start of DCT block
+
+	mov		loop_cnt, 8
+
+0:	
+	ldins.h		r3:t,sp[0]    // r3:t = dataptr[0]  
+	ldins.h		r1:t,sp[1*8*2]// r1:t = dataptr[1] 
+	ldins.h		r2:t,sp[2*8*2]// r2:t = dataptr[2] 
+	ldins.h		r0:t,sp[5*8*2]// r0:t = dataptr[5] 
+	ldins.h		r3:b,sp[4*8*2]// r3:b = dataptr[4] 
+	ldins.h		r1:b,sp[3*8*2]// r1:b = dataptr[3] 
+	ldins.h		r2:b,sp[6*8*2]// r2:b = dataptr[6] 
+	ldins.h		r0:b,sp[7*8*2]// r0:b = dataptr[7] 
+		
+	or		r4, r1, r3 << 16
+	or		r4, r2	
+	or		r4, r0
+	brne 		1f			//If there are non-zero AC coeffisients perform row-transform
+
+	satrnds		r3 >> ( PASS1_BITS + 3 + 16 ), 31	
+	packw.sh	r3, r3, r3
+	mov		r2, r3
+	st.d		r12++, r2
+	st.d		r12++, r2
+	sub		sp, -2	// Increment the dataptr
+			
+	sub		loop_cnt, 1//Decrement loop counter
+	brne		0b         //Perform loop one more time if loop_cnt is not zero 
+
+	sub		sp, -(8*8*2 - 8)	
+	popm		r0-r3, r4-r7, pc//Pop back registers and PC 
+
+1:
+	
+	ld.w		r10, pc[coef_table_idct - .]
+	ld.w		r9, pc[coef_table_idct - . + 4]
+
+	addhh.w		r4, r2:t, r2:b
+	mulhh.w		r4, r4:b, r10:t	// r4 = z1
+	mulhh.w		r5, r2:b, r10:b
+	ld.w		r10, pc[coef_table_idct - . + 8]
+	mulhh.w		r6, r2:t, r9:t
+	add		r5, r4	// r5 = tmp2
+	add		r6, r4	// r6 = tmp3
+
+	addhh.w		r7, r3:t, r3:b
+	subhh.w		r8, r3:t, r3:b
+
+	lsl		r7, CONST_BITS
+	lsl		r8, CONST_BITS
+			
+	add		r2, r7, r6 // r2 = tmp10
+	sub		r3, r7, r6 // r3 = tmp13
+	add		r4, r8, r5 // r4 = tmp11
+	sub		r5, r8, r5 // r5 = tmp12
+	   
+
+	padd.h		r6, r0, r1 // r6:t = z4, r6:b = z3
+	addhh.w		r7, r6:t, r6:b
+	mulhh.w		r7, r7:b, r9:b // r7 = z5
+	
+	ld.w		r9, pc[coef_table_idct - . + 12]
+	mulhh.w		r8, r6:b, r10:t // r8 = z3
+	mulhh.w		r6, r6:t, r10:b // r6 = z4
+	
+	add		r8, r7	
+	add		r6, r7	
+	
+	paddx.h		r7, r0, r1 // r7:t = z2, r7:b = z1
+
+	mulhh.w		r10, r0:b, r9:t // r10 = tmp0
+	mulhh.w		r0, r0:t, r9:b // r0 = tmp1
+	ld.w		r9, pc[coef_table_idct - . + 16]
+	add		r10, r8
+	add		r0, r6
+		
+	ld.w		lr, pc[coef_table_idct - . + 20]
+	machh.w		r8, r1:b, r9:t // r8 = tmp2
+	machh.w		r6, r1:t, r9:b // r6 = tmp3
+	mulhh.w		r9, r7:b, lr:t // r9 = z1	
+	mulhh.w		r7, r7:t, lr:b // r7 = z2	
+    
+    
+	add		r10, r9
+	add		r0, r7
+	add		r8, r7
+	add		r6, r9
+
+	add		r1, r2, r6 // r1 = dataptr[DCTSIZE*0]
+	sub		r2, r2, r6 // r2 = dataptr[DCTSIZE*7]
+	add		r6, r4, r8 // r6 = dataptr[DCTSIZE*1]
+	sub		r4, r4, r8 // r4 = dataptr[DCTSIZE*6]
+	add		r8, r5, r0 // r8 = dataptr[DCTSIZE*2]
+	sub		r5, r5, r0 // r5 = dataptr[DCTSIZE*5]
+	add		r0, r3, r10 // r0 = dataptr[DCTSIZE*3]
+	sub		r3, r3, r10 // r3 = dataptr[DCTSIZE*4]
+	
+	satrnds		r1 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r2 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r6 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r4 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r8 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r5 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r0 >> (CONST_BITS+PASS1_BITS+3), 9
+	satrnds		r3 >> (CONST_BITS+PASS1_BITS+3), 9
+
+	packw.sh	r7, r1, r6
+	packw.sh	r6, r8, r0
+	packw.sh	r5, r3, r5
+	packw.sh	r4, r4, r2
+
+	stm		r12, r4-r7
+	sub		sp, -2	// Increment the dataptr
+	sub		r12, -16
+					
+	sub		loop_cnt, 1		//Decrement loop counter
+	brne		0b			//Perform loop one more time if loop_cnt is not zero 
+	
+	sub		sp, -(8*8*2 - 8)	
+	popm		r0-r3, r4-r7, pc	//Pop back registers and PC 
+	
+
+
+	.align 2
+coef_table_idct:	
+	.short	FIX_0_541196100, -FIX_1_847759065, FIX_0_765366865, FIX_1_175875602 
+	.short	- FIX_1_961570560, - FIX_0_390180644, FIX_0_298631336, FIX_2_053119869
+	.short	FIX_3_072711026, FIX_1_501321110, - FIX_0_899976223, - FIX_2_562915447
+	
diff --git a/libavcodec/avr32/mc.S b/libavcodec/avr32/mc.S
new file mode 100644
index 0000000..07a002d
--- /dev/null
+++ b/libavcodec/avr32/mc.S
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 2007 Atmel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of ATMEL may not be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+		
+	
+	/* Macro for masking the lowest bit of each byte in a
+	   packed word */
+	.macro	packedmask1	reg, round
+	.if	\round
+	and	\reg, \reg, r8 >> 1
+	.else
+	and	\reg, r8
+	.endif
+	.endm		
+
+	/* Macro for 8 pixel wide horizontal and vertical interpolation functions */	
+	.macro	pixels8_hv	round, put		
+
+
+	pushm	r0-r7, lr
+
+	/* R12 = uint8_t *block, R11 = uint8_t pixels, R10 = int line_size, R9 = int h */
+	
+	/* Rounding immediate */
+	.if	\round
+	mov	r8, lo(0x02020202)
+	orh	r8, hi(0x02020202) 
+	.else
+	mov	r8, lo(0x01010101)
+	orh	r8, hi(0x01010101) 
+	.endif
+	mov	r7, 2
+	
+	/* Pixel naming convention :	 
+	
+		|-----------------------------------------------------|
+		| s00 | s01 | s02 | s03 | s04 | s05 | s06 | s07 | s08 |
+		|----d00---d01---d02---d03---d04---d05---d06---d07----|
+		| s10 | s11 | s12 | s13 | s14 | s15 | s16 | s17 | s18 |
+		|-----------------------------------------------------|
+	*/
+1:	
+	ld.w	r0, r11[0]		// r0 = { s00, s01, s02, s03 } 
+	ld.w	r1, r11[1]		// r1 = { s01, s02, s03, s04 }
+	mov	lr, r9
+	eor	r2, r0, r1	 	
+	packedmask1	r2, \round		 	 
+	add	r2, r8
+
+	paddh.ub	r0, r0, r1	// r0 = {(s00+s01)/2,(s01+s02)/2,(s02+s03)/2,(s03+s04)/2}
+	
+	add		r11, r10	// pixels += line_size
+	ld.w	r1, r11[0]		// r1 = { s10, s11, s12, s13 } 
+	ld.w	r3, r11[1]		// r3 = { s11, s12, s13, s14 }
+0:
+	eor	r5, r1, r3	 	
+	packedmask1	r5, \round		 	 
+	add	r2, r5
+	
+	paddh.ub	r1, r1, r3	// r1 = {(s10+s11)/2,(s11+s12)/2,(s12+s13)/2,(s13+s14)/2}
+	eor	r6, r0, r1		
+	packedmask1	r6, \round		 	 
+	add	r2, r2, r6 << 1	
+						
+	ld.w	r3, r11[r10]		// r3 = { s00, s01, s02, s03 } 
+	add	r11, r10		// pixels += line_size
+	ld.w	r4, r11[1]		// r4 = { s01, s02, s03, s04 }
+
+	paddh.ub	r0, r0, r1
+	plsr.b		r2, r2, 2
+	padd.b		r0, r0, r2	// r0 = { d00, d01, d02, d03 }
+	
+	/* Next row */
+	.if	\put
+	eor	r2, r3, r4	 	
+	packedmask1	r2, \round		 	 
+	add	r2, r8
+	.else
+	ld.w	r6, r12[0]
+	eor	r2, r3, r4	 	
+	packedmask1	r2, \round		 	 
+	add	r2, r8
+	pavg.ub	r0, r0, r6
+	.endif
+	st.w	r12[0], r0		// Put data into the block
+		
+	add	r5, r2
+	paddh.ub	r0, r3, r4	// r0 = {(s00+s01)/2,(s01+s02)/2,(s02+s03)/2,(s03+s04)/2}
+				
+	eor	r6, r0, r1		
+	packedmask1	r6, \round		 	 
+	add	r5, r5, r6 << 1	
+
+	.if	\put
+	paddh.ub	r1, r0, r1
+	plsr.b		r5, r5, 2
+	padd.b		r1, r1, r5	// r1 = { d10, d11, d12, d13 }
+	.else
+	ld.w		r3, r12[r10]
+	paddh.ub	r1, r0, r1
+	plsr.b		r5, r5, 2
+	padd.b		r1, r1, r5	// r1 = { d10, d11, d12, d13 }
+	pavg.ub		r1, r1, r3
+	.endif
+		
+	st.w	r12[r10], r1		// Put data into the block
+	
+	
+	ld.w	r1, r11[r10]		// r1 = { s10, s11, s12, s13 } 
+	add	r11, r10		// pixels += line_size
+	ld.w	r3, r11[1]		// r3 = { s11, s12, s13, s14 }
+	add	r12, r12, r10 << 1	// block += 2*line_size
+	sub	lr, 2
+	brne	0b
+
+	mul	r0, r10, r9		// r0 = line_size * h
+	rsub	r0, r0, 4		// r0 = 4 - (line_size * h)  
+	add	r11, r0
+	sub	r11, r10		// pixels += 4 - (line_size * (h+1))
+	add	r12, r0			// pixels += 4 - (line_size * (h))
+	sub	r7, 1
+	brne	1b
+	
+	popm	r0-r7, pc
+	.endm
+
+
+	/* Macro for 8 pixel wide vertical interpolation functions */	
+
+	.macro	pixels8_v	round, put		
+	pushm	r4-r7,lr	
+	/* R12 = uint8_t *block, R11 = uint8_t pixels, R10 = int line_size, R9 = int h */
+
+	/* 
+		Pixel Naming Convention :	
+		|-----------------------------------------------|
+		| s00 | s01 | s02 | s03 | s04 | s05 | s06 | s07 |
+		|-d00---d01---d02---d03---d04---d05---d06---d07-|
+		| s10 | s11 | s12 | s13 | s14 | s15 | s16 | s17 |
+		|-----------------------------------------------|
+	*/
+	ld.w	r8, r11[r10]		// r8 = { s10, s11, s12, s13 }
+	ld.w	lr, r11++		// lr = { s00, s01, s02, s03 }, src += 4
+	ld.w	r7, r11[0]		// r7 = { s04, s05, s06, s07 }
+	ld.w	r6, r11[r10]		// r6 = { s14, s15, s16, s17 }
+	sub	r10, 4			// stride -= 4 
+	add	r11, r11, r10 << 1	// src += 2*stride 
+	sub	r11, -4			// src += 4                               
+	
+0:	
+	.if	\round
+	pavg.ub r5, r8, lr		// r5 = {(s10+s00)/2,(s11+s01)/2,(s12+s02)/2,(s13+s03)/2}
+	pavg.ub r4, r6, r7		// r4 = {(s14+s04)/2,(s15+s05)/2,(s16+s06)/2,(s17+s07)/2}
+	.else
+	paddh.ub r5, r8, lr		// r5 = {(s10+s00)/2,(s11+s01)/2,(s12+s02)/2,(s13+s03)/2}
+	paddh.ub r4, r6, r7		// r4 = {(s14+s04)/2,(s15+s05)/2,(s16+s06)/2,(s17+s07)/2}
+	.endif
+
+	.if	\put
+	st.w	r12++, r5		// *dst++ = { d00, d01, d02, d03 } 
+	ld.w	lr, r11++		// lr = { s10, s11, s12, s13 }, src += 4 
+	st.w	r12[0], r4		// *dst = { d04, d05, d06, d07 }
+	ld.w	r7, r11[0]		// r7 = { s14, s15, s16, s17 }
+	.else
+	ld.w	lr, r12[0]		
+	ld.w	r7, r12[4]	
+	pavg.ub	r5, r5, lr	 
+	pavg.ub	r4, r4, r7	 
+	st.w	r12++, r5		// *dst++ = { d00, d01, d02, d03 } 
+	ld.w	lr, r11++		// lr = { s10, s11, s12, s13 }, src += 4 
+	st.w	r12[0], r4		// *dst = { d04, d05, d06, d07 }
+	ld.w	r7, r11[0]		// r7 = { s14, s15, s16, s17 }
+	.endif
+	add	r11, r10		// src += stride							
+#ifdef USE_PREFETCH
+	pref		r11[0]
+#endif		
+	add	r12, r10		// dst += stride
+
+	.if	\round
+	pavg.ub r5, r8, lr		// r5 = {(s10+s00)/2,(s11+s01)/2,(s12+s02)/2,(s13+s03)/2}
+	pavg.ub r4, r6, r7		// r4 = {(s14+s04)/2,(s15+s05)/2,(s16+s06)/2,(s17+s07)/2}
+	.else
+	paddh.ub r5, r8, lr		// r5 = {(s10+s00)/2,(s11+s01)/2,(s12+s02)/2,(s13+s03)/2}
+	paddh.ub r4, r6, r7		// r4 = {(s14+s04)/2,(s15+s05)/2,(s16+s06)/2,(s17+s07)/2}
+	.endif
+	.if	\put
+	st.w	r12++, r5		// *dst++ = { d00, d01, d02, d03 }                       
+	ld.w	r8, r11++		// r8 = { s10, s11, s12, s13 }, src += 4                 
+	st.w	r12[0], r4		// *dst = { d04, d05, d06, d07 }                         
+	ld.w	r6, r11[0]		// r6 = { s14, s15, s16, s17 }                           
+	.else
+	ld.w	r8, r12[0]		
+	ld.w	r6, r12[4]	
+	pavg.ub	r5, r5, r8	 
+	pavg.ub	r4, r4, r6	 
+	st.w	r12++, r5		// *dst++ = { d00, d01, d02, d03 }                       
+	ld.w	r8, r11++		// r8 = { s10, s11, s12, s13 }, src += 4                 
+	st.w	r12[0], r4		// *dst = { d04, d05, d06, d07 }                         
+	ld.w	r6, r11[0]		// r6 = { s14, s15, s16, s17 }                           
+	.endif
+	
+	add	r11, r10		// src += stride                                         
+#ifdef USE_PREFETCH
+	pref		r11[0]
+#endif		
+	add	r12, r10		// dst += stride                                         
+	sub	r9, 2
+	brne	0b
+		
+	popm	r4-r7,pc
+	.endm
+
+	/* Macro for 8 pixel wide horizontal interpolation functions */	
+
+	.macro	pixels8_h	round, put
+	pushm	r4-r7, lr	
+
+	/* R12 = uint8_t *block, R11 = uint8_t pixels, R10 = int line_size, R9 = int h */
+	/*
+		 Pixel Naming Convention:	
+		|--------------------------------------------------------------------|
+		| s00 d00 s01 d01 s02 d02 s03 d03 s04 d04 s05 d05 s06 d06 s07 d07 s08|
+		|------|-------|-------|-------|-------|-------|-------|-------|-----|
+		| s10 d10 s11 d11 s12 d12 s13 d13 s14 d14 s15 d15 s16 d16 s17 d17 s18|
+		|--------------------------------------------------------------------|
+	*/
+
+	ld.w	lr, r11[0]	// lr = { s00, s01, s02, s03 }
+	ld.w	r8, r11[1]	// r8 = { s01, s02, s03, s04 }
+	ld.w	r7, r11[4]	// r7 = { s04, s05, s06, s07 }
+	ld.w	r6, r11[5]	// r6 = { s05, s06, s07, s08 }
+	add	r11, r10	// src += stride			
+
+0:	
+	.if	\round
+	pavg.ub lr, r8, lr	// lr = {(s00+s01)/2,(s01+s02)/2,(s02+s03)/2,(s03+s04)/2}
+	pavg.ub r7, r6, r7	// r7 = {(s04+s05)/2,(s05+s06)/2,(s06+s07)/2,(s07+s08)/2}
+	.else
+	paddh.ub lr, r8, lr	// lr = {(s00+s01)/2,(s01+s02)/2,(s02+s03)/2,(s03+s04)/2}
+	paddh.ub r7, r6, r7	// r7 = {(s04+s05)/2,(s05+s06)/2,(s06+s07)/2,(s07+s08)/2}
+	.endif
+	.if	\put
+	ld.w	r5, r11[0]	// r5 = { s00, s01, s02, s03 }
+	ld.w	r4, r11[1]	// r4 = { s01, s02, s03, s04 }
+	.else
+	ld.w	r8, r12[0]
+	ld.w	r6, r12[4]
+	ld.w	r5, r11[0]	// r5 = { s00, s01, s02, s03 }
+	ld.w	r4, r11[1]	// r4 = { s01, s02, s03, s04 }
+	pavg.ub	lr, lr, r8
+	pavg.ub	r7, r7, r6
+	.endif
+	st.w	r12[0], lr	// dst = { d00, d01, d02, d03 }
+	st.w	r12[4], r7	// dst = { d04, d05, d06, d07 }
+	ld.w	r8, r11[4]	// r8 = { s04, s05, s06, s07 }
+	ld.w	r6, r11[5]	// r6 = { s05, s06, s07, s08 }
+	add	r11, r10	// src += stride						
+#ifdef USE_PREFETCH
+	pref		r11[0]
+#endif		
+	add	r12, r10	// dst += stride
+
+	.if	\round
+	pavg.ub r5, r4, r5	// r5 = {(s00+s01)/2,(s01+s02)/2,(s02+s03)/2,(s03+s04)/2}
+	pavg.ub r4, r6, r8	// r4 = {(s04+s05)/2,(s05+s06)/2,(s06+s07)/2,(s07+s08)/2}
+	.else
+	paddh.ub r5, r4, r5	// r5 = {(s00+s01)/2,(s01+s02)/2,(s02+s03)/2,(s03+s04)/2}
+	paddh.ub r4, r6, r8	// r4 = {(s04+s05)/2,(s05+s06)/2,(s06+s07)/2,(s07+s08)/2}
+	.endif
+	.if	\put
+	ld.w	lr, r11[0]	// lr = { s00, s01, s02, s03 }                           
+	ld.w	r8, r11[1]	// r8 = { s01, s02, s03, s04 }                           
+	.else
+	ld.w	r7, r12[0]
+	ld.w	r6, r12[4]
+	ld.w	lr, r11[0]	// lr = { s00, s01, s02, s03 }                           
+	ld.w	r8, r11[1]	// r8 = { s01, s02, s03, s04 }                           
+	pavg.ub	r5, r5, r7
+	pavg.ub	r4, r4, r6
+	.endif
+	st.w	r12[0], r5	// dst = { d00, d01, d02, d03 }                          
+	st.w	r12[4], r4	// dst = { d04, d05, d06, d07 }                          
+	ld.w	r7, r11[4]	// r7 = { s04, s05, s06, s07 }                           
+	ld.w	r6, r11[5]	// r6 = { s05, s06, s07, s08 }                           
+	add	r11, r10	// src += stride						                                         
+#ifdef USE_PREFETCH
+	pref		r11[0]
+#endif		
+	add	r12, r10	// dst += stride                                         
+	sub	r9, 2
+	brne	0b
+		
+	popm	r4-r7, pc
+	.endm
+	
+	/* Macro for 8 pixel wide copy functions */	
+	.macro	pixels8	put
+	stm		--sp, r3-r7,lr
+	/* R12 = uint8_t *block, R11 = uint8_t pixels, R10 = int line_size, R9 = int h */
+	mov		lr, r9
+	sub		r3, r10, 2	        // stride2 = stride - 2 
+0:	
+	.if	\put
+	ld.w		r9, r11[r10]	        // r9 = { s10, s11, s12, s13 }
+	ld.w		r7, r11++	        // r7 = { s00, s01, s02, s03 }, src += 4
+	ld.w		r6, r11[0]	        // r6 = { s04, s05, s06, s07 }
+	ld.w		r8, r11[r10]	        // r8 = { s14, s15, s16, s17 }
+	.else
+	ld.w		r9, r11[r10]	        // r9 = { s10, s11, s12, s13 }
+	ld.d		r4, r12[0]
+	ld.w		r7, r11++	        // r7 = { s00, s01, s02, s03 }, src += 4
+	ld.w		r6, r11[0]	        // r6 = { s04, s05, s06, s07 }
+	ld.w		r8, r11[r10]	        // r8 = { s14, s15, s16, s17 }
+	pavg.ub		r6, r6, r4
+	pavg.ub		r7, r7, r5
+	ld.d		r4, r12[r10]
+	.endif
+	st.d		r12, r6			// *dst = { s00, s01, s02, s03, s04, s05, s06, s07 }   
+	add		r11, r11, r3 << 1	// src += stride2 * 2
+	.ifeq	\put
+	pavg.ub		r8, r8, r4
+	pavg.ub		r9, r9, r5	
+	.endif	
+	st.d		r12[r10 << 0], r8	// *(dst + stride) = { s10, s11, s12, s13, s14, s15, s16, s17 } 
+	add		r12, r12, r10 << 1	// dst += 2*stride
+	sub		lr, 2
+	brne		0b
+	ldm		sp++, r3-r7,pc
+
+	.endm	
+	
+	.global	put_no_rnd_pixels8_hv_avr32
+	.text
+put_no_rnd_pixels8_hv_avr32:
+	pixels8_hv	0, 1	
+
+	.global	put_pixels8_hv_avr32
+	.text
+put_pixels8_hv_avr32:
+	pixels8_hv	1, 1	
+
+	.global	avg_no_rnd_pixels8_hv_avr32
+	.text
+avg_no_rnd_pixels8_hv_avr32:
+	pixels8_hv	0, 0	
+
+	.global	avg_pixels8_hv_avr32
+	.text
+avg_pixels8_hv_avr32:
+	pixels8_hv	1, 0	
+
+	.global	put_no_rnd_pixels8_v_avr32
+	.text
+put_no_rnd_pixels8_v_avr32:
+	pixels8_v	0, 1	
+
+	.global	put_pixels8_v_avr32
+	.text
+put_pixels8_v_avr32:
+	pixels8_v	1, 1	
+
+	.global	avg_no_rnd_pixels8_v_avr32
+	.text
+avg_no_rnd_pixels8_v_avr32:
+	pixels8_v	0, 0	
+
+	.global	avg_pixels8_v_avr32
+	.text
+avg_pixels8_v_avr32:
+	pixels8_v	1, 0	
+
+	.global	put_no_rnd_pixels8_h_avr32
+	.text
+put_no_rnd_pixels8_h_avr32:
+	pixels8_h	0, 1	
+
+	.global	put_pixels8_h_avr32
+	.text
+put_pixels8_h_avr32:
+	pixels8_h	1, 1	
+
+	.global	avg_no_rnd_pixels8_h_avr32
+	.text
+avg_no_rnd_pixels8_h_avr32:
+	pixels8_h	0, 0	
+
+	.global	avg_pixels8_h_avr32
+	.text
+avg_pixels8_h_avr32:
+	pixels8_h	1, 0	
+
+	.global	put_pixels8_avr32
+	.global	put_no_rnd_pixels8_avr32
+	.text
+put_pixels8_avr32:
+put_no_rnd_pixels8_avr32:
+	pixels8	1	
+
+	.global	avg_no_rnd_pixels8_avr32
+	.global	avg_pixels8_avr32
+	.text
+avg_pixels8_avr32:
+avg_no_rnd_pixels8_avr32:
+	pixels8	0	
diff --git a/libavcodec/avr32/pico.h b/libavcodec/avr32/pico.h
new file mode 100644
index 0000000..32201ba
--- /dev/null
+++ b/libavcodec/avr32/pico.h
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2007 Atmel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of ATMEL may not be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+#ifndef __PICO_H__
+#define __PICO_H__
+
+
+
+/* Coprocessor Number */
+#define PICO_CPNO  1
+
+/* Pixel Coprocessor Register file */
+#define PICO_REGVECT_INPIX2  cr0
+#define PICO_REGVECT_INPIX1  cr1
+#define PICO_REGVECT_INPIX0  cr2
+#define PICO_REGVECT_OUTPIX2 cr3
+#define PICO_REGVECT_OUTPIX1 cr4
+#define PICO_REGVECT_OUTPIX0 cr5
+#define PICO_REGVECT_COEFF0_A cr6
+#define PICO_REGVECT_COEFF0_B cr7
+#define PICO_REGVECT_COEFF1_A cr8
+#define PICO_REGVECT_COEFF1_B cr9
+#define PICO_REGVECT_COEFF2_A cr10
+#define PICO_REGVECT_COEFF2_B cr11
+#define PICO_REGVECT_VMU0_OUT cr12
+#define PICO_REGVECT_VMU1_OUT cr13
+#define PICO_REGVECT_VMU2_OUT cr14
+#define PICO_REGVECT_CONFIG   cr15
+
+#define PICO_INPIX2  0
+#define PICO_INPIX1  1
+#define PICO_INPIX0  2
+#define PICO_OUTPIX2 3
+#define PICO_OUTPIX1 4
+#define PICO_OUTPIX0 5
+#define PICO_COEFF0_A 6
+#define PICO_COEFF0_B 7
+#define PICO_COEFF1_A 8
+#define PICO_COEFF1_B 9
+#define PICO_COEFF2_A 10
+#define PICO_COEFF2_B 11
+#define PICO_VMU0_OUT 12
+#define PICO_VMU1_OUT 13
+#define PICO_VMU2_OUT 14
+#define PICO_CONFIG   15
+
+/* Config Register */
+#define PICO_COEFF_FRAC_BITS_OFFSET  0
+#define PICO_COEFF_FRAC_BITS_SIZE  4
+#define PICO_OFFSET_FRAC_BITS_OFFSET  4
+#define PICO_OFFSET_FRAC_BITS_SIZE  4
+#define PICO_INPUT_MODE_OFFSET  8
+#define PICO_INPUT_MODE_SIZE  2
+#define PICO_OUTPUT_MODE_OFFSET 10
+#define PICO_OUTPUT_MODE_SIZE 1
+
+struct pico_config_t {
+  unsigned int          : 32 - PICO_OUTPUT_MODE_OFFSET - PICO_OUTPUT_MODE_SIZE;
+  unsigned int          output_mode : PICO_OUTPUT_MODE_SIZE;
+  unsigned int          input_mode : PICO_INPUT_MODE_SIZE;
+  unsigned int          offset_frac_bits : PICO_OFFSET_FRAC_BITS_SIZE;
+  unsigned int          coeff_frac_bits : PICO_COEFF_FRAC_BITS_SIZE;
+  int                   vmu2_out;
+  int                   vmu1_out;
+  int                   vmu0_out;
+  short                 coeff2_2;
+  short                 coeff2_3;
+  short                 coeff2_0;
+  short                 coeff2_1;
+  short                 coeff1_2;
+  short                 coeff1_3;
+  short                 coeff1_0;
+  short                 coeff1_1;
+  short                 coeff0_2;
+  short                 coeff0_3;
+  short                 coeff0_0;
+  short                 coeff0_1;
+};
+
+
+#define PICO_COEFF_FRAC_BITS(x) (x << PICO_COEFF_FRAC_BITS_OFFSET)
+#define PICO_OFFSET_FRAC_BITS(x) (x << PICO_OFFSET_FRAC_BITS_OFFSET)
+#define PICO_INPUT_MODE(x) (x << PICO_INPUT_MODE_OFFSET)
+#define PICO_OUTPUT_MODE(x) (x << PICO_OUTPUT_MODE_OFFSET)
+
+#define GET_PICO_COEFF_FRAC_BITS(x) ((x >> PICO_COEFF_FRAC_BITS_OFFSET)&((1 << PICO_COEFF_FRAC_BITS_SIZE)-1))
+#define GET_PICO_OFFSET_FRAC_BITS(x) ((x >> PICO_OFFSET_FRAC_BITS_OFFSET)&((1 << PICO_OFFSET_FRAC_BITS_SIZE)-1))
+#define GET_PICO_INPUT_MODE(x) ((x >> PICO_INPUT_MODE_OFFSET)&((1 << PICO_INPUT_MODE_SIZE)-1))
+#define GET_PICO_OUTPUT_MODE(x) ((x >> PICO_OUTPUT_MODE_OFFSET)&((1 << PICO_OUTPUT_MODE_SIZE)-1))
+
+enum pico_input_mode { PICO_TRANSFORMATION_MODE,
+                       PICO_HOR_FILTER_MODE,
+                       PICO_VERT_FILTER_MODE };
+
+enum pico_output_mode { PICO_PACKED_MODE,
+                        PICO_PLANAR_MODE };
+
+/* Bits in coefficients */
+#define PICO_COEFF_BITS 12
+
+/* Operation bits */
+#define PICO_MATRIX (0)
+#define PICO_USE_ACC (1 << 2)
+#define PICO_SINGLE_VECTOR (1 << 3)
+
+
+#define __str(x...) #x
+#define __xstr(x...) __str(x)
+
+#define PICO_PUT_W(pico_reg, x) \
+  __builtin_mvrc_w(PICO_CPNO, pico_reg, x);
+#define PICO_GET_W(pico_reg) \
+  __builtin_mvcr_w(PICO_CPNO, pico_reg)
+
+#define PICO_MVCR_W(x, pico_reg) \
+  asm ("mvcr.w\tcp" __xstr(PICO_CPNO) ", %0, cr" __xstr(pico_reg) : "=r"(x));
+
+#define PICO_MVRC_W(pico_reg, x) \
+  asm  ("mvrc.w\tcp" __xstr(PICO_CPNO) ", cr" __xstr(pico_reg) ", %0" :: "r"(x));
+
+#define PICO_PUT_D(pico_reg, x) \
+  __builtin_mvrc_d(PICO_CPNO, pico_reg, x);
+#define PICO_GET_D(pico_reg) \
+  __builtin_mvcr_d(PICO_CPNO, pico_reg)
+
+#define PICO_MVCR_D(x, pico_reg) \
+  asm volatile ("mvcr.d\tcp" __xstr(PICO_CPNO) ", %0, cr" __xstr(pico_reg) : "=r"(x));
+#define PICO_MVRC_D(pico_reg, x) \
+  asm volatile ("mvrc.d\tcp" __xstr(PICO_CPNO) ", cr" __xstr(pico_reg) ", %0" :: "r"(x));
+
+#define PICO_STCM_W(ptr, pico_regs...) \
+  asm volatile ("stcm.w\tcp" __xstr(PICO_CPNO) ", %0," __xstr(pico_regs)  :: "r"(ptr)); 
+#define PICO_STCM_D(ptr, pico_regs...) \
+  asm volatile ("stcm.d\tcp" __xstr(PICO_CPNO) ", %0," __xstr(pico_regs)  :: "r"(ptr)); 
+
+#define PICO_STCM_W_DEC(ptr, pico_regs...) \
+  asm volatile ("stcm.w\tcp" __xstr(PICO_CPNO) ", --%0," __xstr(pico_regs)  : "+r"(ptr)); 
+#define PICO_STCM_D_DEC(ptr, pico_regs...) \
+  asm volatile ("stcm.d\tcp" __xstr(PICO_CPNO) ", --%0," __xstr(pico_regs)  : "+r"(ptr)); 
+
+#define PICO_LDCM_W(ptr, pico_regs...) \
+  asm volatile ("ldcm.w\tcp" __xstr(PICO_CPNO) ", %0," __xstr(pico_regs)  :: "r"(ptr)); 
+#define PICO_LDCM_D(ptr, pico_regs...) \
+  asm volatile ("ldcm.d\tcp" __xstr(PICO_CPNO) ", %0," __xstr(pico_regs)  :: "r"(ptr)); 
+
+#define PICO_LDCM_W_INC(ptr, pico_regs...) \
+  asm volatile ("ldcm.w\tcp" __xstr(PICO_CPNO) ", %0++," __xstr(pico_regs)  : "+r"(ptr)); 
+#define PICO_LDCM_D_INC(ptr, pico_regs...) \
+  asm volatile ("ldcm.d\tcp" __xstr(PICO_CPNO) ", %0++," __xstr(pico_regs)  : "+r"(ptr)); 
+
+#define PICO_OP(op, dst_addr, addr0, addr1, addr2) \
+  __builtin_cop(PICO_CPNO, addr0, addr1, addr2, op | dst_addr);
+
+static inline void set_pico_config(struct pico_config_t *config){
+  PICO_LDCM_D(config, 
+              PICO_REGVECT_COEFF0_A, PICO_REGVECT_COEFF0_B, 
+              PICO_REGVECT_COEFF1_A, PICO_REGVECT_COEFF1_B,
+              PICO_REGVECT_COEFF2_A, PICO_REGVECT_COEFF2_B,
+              PICO_REGVECT_VMU0_OUT, PICO_REGVECT_VMU1_OUT,
+              PICO_REGVECT_VMU2_OUT, PICO_REGVECT_CONFIG);              
+}
+
+static inline void get_pico_config(struct pico_config_t *config){
+  PICO_STCM_D(config, 
+              PICO_REGVECT_COEFF0_A, PICO_REGVECT_COEFF0_B, 
+              PICO_REGVECT_COEFF1_A, PICO_REGVECT_COEFF1_B,
+              PICO_REGVECT_COEFF2_A, PICO_REGVECT_COEFF2_B,
+              PICO_REGVECT_VMU0_OUT, PICO_REGVECT_VMU1_OUT,
+              PICO_REGVECT_VMU2_OUT, PICO_REGVECT_CONFIG);              
+}
+
+static inline void dump_pico_config(){
+  struct pico_config_t pico_config;
+  char *input_mode, *output_mode;
+  get_pico_config(&pico_config);
+
+  
+  av_log(NULL, AV_LOG_INFO, "Dumping pico configuration:\n\n"); 
+  av_log(NULL, AV_LOG_INFO, "\tcoeff_frac_bits = %d\n", pico_config.coeff_frac_bits); 
+  av_log(NULL, AV_LOG_INFO, "\toffset_frac_bits = %d\n", pico_config.offset_frac_bits); 
+
+  switch ( pico_config.input_mode ){
+  case PICO_TRANSFORMATION_MODE:
+    input_mode = "Transformation Mode"; 
+    break;
+  case PICO_HOR_FILTER_MODE:
+    input_mode = "Horisontal Filter Mode"; 
+    break;
+  case PICO_VERT_FILTER_MODE:
+    input_mode = "Vertical Filter Mode"; 
+    break;
+  default:
+    input_mode = "Unknown Mode!!"; 
+    break;    
+  }
+  av_log(NULL, AV_LOG_INFO, "\tinput_mode = %s\n", input_mode); 
+
+  switch ( pico_config.output_mode ){
+  case PICO_PLANAR_MODE:
+    output_mode = "Planar Mode"; 
+    break;
+  case PICO_PACKED_MODE:
+    output_mode = "Packed Mode"; 
+    break;
+  default:
+    output_mode = "Unknown Mode!!"; 
+    break;    
+  }
+
+  av_log(NULL, AV_LOG_INFO, "\toutput_mode = %s\n", output_mode); 
+
+  av_log(NULL, AV_LOG_INFO, "\tCoeff0_0 = %f\n", (float)pico_config.coeff0_0/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff0_1 = %f\n", (float)pico_config.coeff0_1/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff0_2 = %f\n", (float)pico_config.coeff0_2/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff0_3 = %f\n", (float)pico_config.coeff0_3/(float)(1 << pico_config.offset_frac_bits)); 
+                                   
+  av_log(NULL, AV_LOG_INFO, "\tCoeff1_0 = %f\n", (float)pico_config.coeff1_0/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff1_1 = %f\n", (float)pico_config.coeff1_1/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff1_2 = %f\n", (float)pico_config.coeff1_2/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff1_3 = %f\n", (float)pico_config.coeff1_3/(float)(1 << pico_config.offset_frac_bits)); 
+                                   
+  av_log(NULL, AV_LOG_INFO, "\tCoeff2_0 = %f\n", (float)pico_config.coeff2_0/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff2_1 = %f\n", (float)pico_config.coeff2_1/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff2_2 = %f\n", (float)pico_config.coeff2_2/(float)(1 << pico_config.coeff_frac_bits)); 
+  av_log(NULL, AV_LOG_INFO, "\tCoeff2_3 = %f\n", (float)pico_config.coeff2_3/(float)(1 << pico_config.offset_frac_bits)); 
+}
+
+
+
+#endif
+
diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
index 26b4f8d..1f8fabf 100644
--- a/libavcodec/bitstream.h
+++ b/libavcodec/bitstream.h
@@ -171,7 +171,7 @@ typedef struct RL_VLC_ELEM {
 #endif
 
 /* used to avoid missaligned exceptions on some archs (alpha, ...) */
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if defined(ARCH_X86) || defined(ARCH_X86_64) || defined(ARCH_AVR32)
 #    define unaligned16(a) (*(const uint16_t*)(a))
 #    define unaligned32(a) (*(const uint32_t*)(a))
 #    define unaligned64(a) (*(const uint64_t*)(a))
@@ -813,6 +813,44 @@ void free_vlc(VLC *vlc);
  * if the vlc code is invalid and max_depth>1 than the number of bits removed
  * is undefined
  */
+
+#if defined(ARCH_AVR32)
+#define GET_VLC(code, name, gb, table, bits, max_depth)\
+{\
+    int n, index, nb_bits;\
+    union { VLC_TYPE vlc[2];\
+            uint32_t u32; } table_elem;\
+\
+    index= SHOW_UBITS(name, gb, bits);\
+    table_elem.u32 = unaligned32(&table[index]); \
+    code = table_elem.vlc[0];\
+    n    = table_elem.vlc[1];\
+\
+    if(max_depth > 1 && n < 0 ){\
+        LAST_SKIP_BITS(name, gb, bits)\
+        UPDATE_CACHE(name, gb)\
+\
+        nb_bits = -n;\
+\
+        index= SHOW_UBITS(name, gb, nb_bits) + code;\
+        table_elem.u32 = unaligned32(&table[index]); \
+        code = table_elem.vlc[0];\
+        n    = table_elem.vlc[1];\
+        if(max_depth > 2 && n < 0){\
+            LAST_SKIP_BITS(name, gb, nb_bits)\
+            UPDATE_CACHE(name, gb)\
+\
+            nb_bits = -n;\
+\
+            index= SHOW_UBITS(name, gb, nb_bits) + code;\
+            code = table[index][0];\
+            n    = table[index][1];\
+        }\
+    }\
+    SKIP_BITS(name, gb, n)\
+}
+
+#else
 #define GET_VLC(code, name, gb, table, bits, max_depth)\
 {\
     int n, index, nb_bits;\
@@ -821,7 +859,7 @@ void free_vlc(VLC *vlc);
     code = table[index][0];\
     n    = table[index][1];\
 \
-    if(max_depth > 1 && n < 0){\
+    if(max_depth > 1 && n < 0 ){\
         LAST_SKIP_BITS(name, gb, bits)\
         UPDATE_CACHE(name, gb)\
 \
@@ -843,7 +881,38 @@ void free_vlc(VLC *vlc);
     }\
     SKIP_BITS(name, gb, n)\
 }
+#endif
 
+#if defined(ARCH_AVR32)
+#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
+{\
+    int n, index, nb_bits;\
+    union { RL_VLC_ELEM vlc;\
+            uint32_t u32; } table_elem;\
+\
+    index= SHOW_UBITS(name, gb, bits);\
+    table_elem.u32 = unaligned32(&table[index]); \
+    level = table_elem.vlc.level;\
+    n     = table_elem.vlc.len;\
+\
+    if(max_depth > 1 && n < 0 ){\
+        SKIP_BITS(name, gb, bits)\
+        if(need_update){\
+            UPDATE_CACHE(name, gb)\
+        }\
+\
+        nb_bits = -n;\
+\
+        index= SHOW_UBITS(name, gb, nb_bits) + level;\
+        table_elem.u32 = unaligned32(&table[index]); \
+        level = table_elem.vlc.level;\
+        n     = table_elem.vlc.len;\
+    }\
+    run= table_elem.vlc.run;\
+    SKIP_BITS(name, gb, n)\
+}
+
+#else
 #define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
 {\
     int n, index, nb_bits;\
@@ -852,7 +921,7 @@ void free_vlc(VLC *vlc);
     level = table[index].level;\
     n     = table[index].len;\
 \
-    if(max_depth > 1 && n < 0){\
+    if(max_depth > 1 && n < 0 ){\
         SKIP_BITS(name, gb, bits)\
         if(need_update){\
             UPDATE_CACHE(name, gb)\
@@ -867,7 +936,7 @@ void free_vlc(VLC *vlc);
     run= table[index].run;\
     SKIP_BITS(name, gb, n)\
 }
-
+#endif
 
 /**
  * parses a vlc code, faster then get_vlc()
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index 56c42b9..8fc10c6 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -4197,6 +4197,9 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
 #ifdef ARCH_BFIN
     dsputil_init_bfin(c,avctx);
 #endif
+#ifdef ARCH_AVR32
+    dsputil_init_avr32(c,avctx);
+#endif
 
     for(i=0; i<64; i++){
         if(!c->put_2tap_qpel_pixels_tab[0][i])
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 865e80a..8f7c3f1 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3258,7 +3258,12 @@ static void free_tables(H264Context *h){
 
 static void init_dequant8_coeff_table(H264Context *h){
     int i,q,x;
+#ifdef ARCH_AVR32
+    const int transpose = 0;
+#else
     const int transpose = (h->s.dsp.h264_idct8_add != ff_h264_idct8_add_c); //FIXME ugly
+#endif
+
     h->dequant8_coeff[0] = h->dequant8_buffer[0];
     h->dequant8_coeff[1] = h->dequant8_buffer[1];
 
@@ -3281,7 +3286,13 @@ static void init_dequant8_coeff_table(H264Context *h){
 
 static void init_dequant4_coeff_table(H264Context *h){
     int i,j,q,x;
+    // Yes this is ugly as hell....
+#ifdef ARCH_AVR32
+    const int transpose = 0;
+#else
     const int transpose = (h->s.dsp.h264_idct_add != ff_h264_idct_add_c); //FIXME ugly
+#endif
+
     for(i=0; i<6; i++ ){
         h->dequant4_coeff[i] = h->dequant4_buffer[i];
         for(j=0; j<i; j++){
@@ -4663,7 +4674,11 @@ static int decode_slice_header(H264Context *h){
         if (MPV_common_init(s) < 0)
             return -1;
 
+#ifdef ARCH_AVR32
+        if ( 1 ){
+#else
         if(s->dsp.h264_idct_add == ff_h264_idct_add_c){ //FIXME little ugly
+#endif
             memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));
             memcpy(h-> field_scan,  field_scan, 16*sizeof(uint8_t));
         }else{
diff --git a/libavutil/common.h b/libavutil/common.h
index 3ae5971..7e52b90 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -283,23 +283,39 @@ static inline int mid_pred(int a, int b, int c)
  * @param amax maximum value of the clip range
  * @return cliped value
  */
+#if defined(ARCH_AVR32)
+#define clip(a, amin, amax) \
+  ({ int __tmp__; \
+     asm ("min\t%0, %1, %2\n" \
+          "max\t%0, %0, %3\n" \
+          : "=&r"(__tmp__) : "r"(a), "r"(amax), "r"(amin)); \
+     __tmp__; })
+#else
 static inline int clip(int a, int amin, int amax)
 {
     if (a < amin)      return amin;
     else if (a > amax) return amax;
     else               return a;
 }
+#endif
 
 /**
  * clip a signed integer value into the 0-255 range
  * @param a value to clip
  * @return cliped value
  */
+#if defined(ARCH_AVR32)
+#define clip_uint8(a) \
+  ({ int __tmp__ = a; \
+     asm ("satu\t%0 >> 0, 8" : "+r"(__tmp__)); \
+     __tmp__; })
+#else
 static inline uint8_t clip_uint8(int a)
 {
     if (a&(~255)) return (-a)>>31;
     else          return a;
 }
+#endif
 
 /* math */
 int64_t ff_gcd(int64_t a, int64_t b);
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 285d304..a8b0718 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -210,6 +210,15 @@ if((y)<(x)){\
     }\
 }
 
+/* XXX: Hack for uclibc which declares lrintf but does not implement it... */
+#ifdef ARCH_AVR32
+#undef HAVE_LRINTF
+#define HAVE_LRINTF 1
+#define lrintf(x) rint(x)
+#define llrint(x) (long long)rint(x) 
+#endif
+ 
+
 #ifndef HAVE_LRINTF
 /* XXX: add ISOC specific test to avoid specific BSD testing. */
 /* better than nothing implementation. */
diff --git a/libfaad2/common.h b/libfaad2/common.h
index f809042..6c5fb21 100644
--- a/libfaad2/common.h
+++ b/libfaad2/common.h
@@ -67,7 +67,7 @@ extern "C" {
 /* Use if target platform has address generators with autoincrement */
 //#define PREFER_POINTERS
 
-#if defined(_WIN32_WCE) || defined(__arm__)
+#if defined(_WIN32_WCE) || defined(__arm__) || defined(__avr32__)
 #define FIXED_POINT
 #endif
 
diff --git a/libmpcodecs/ad_libmad.c b/libmpcodecs/ad_libmad.c
index 076359a..51b77fe 100644
--- a/libmpcodecs/ad_libmad.c
+++ b/libmpcodecs/ad_libmad.c
@@ -86,6 +86,11 @@ static int init(sh_audio_t *sh){
   sh->channels=(this->frame.header.mode == MAD_MODE_SINGLE_CHANNEL) ? 1 : 2;
   sh->samplerate=this->frame.header.samplerate;
   sh->i_bps=this->frame.header.bitrate/8;
+#ifdef WORDS_BIGENDIAN
+  sh->sample_format = AF_FORMAT_S16_BE;
+#else
+  sh->sample_format = AF_FORMAT_S16_LE;
+#endif
   sh->samplesize=2;
   
   return 1;
diff --git a/libswscale/pico-avr32.h b/libswscale/pico-avr32.h
new file mode 100644
index 0000000..7ac6200
--- /dev/null
+++ b/libswscale/pico-avr32.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2007 Atmel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of ATMEL may not be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+#ifndef __PICO_H__
+#define __PICO_H__
+
+/* Coprocessor Number */
+#define PICO_CPNO  1
+
+/* Pixel Coprocessor Register file */
+#define PICO_REGVECT_INPIX2  cr0
+#define PICO_REGVECT_INPIX1  cr1
+#define PICO_REGVECT_INPIX0  cr2
+#define PICO_REGVECT_OUTPIX2 cr3
+#define PICO_REGVECT_OUTPIX1 cr4
+#define PICO_REGVECT_OUTPIX0 cr5
+#define PICO_REGVECT_COEFF0_A cr6
+#define PICO_REGVECT_COEFF0_B cr7
+#define PICO_REGVECT_COEFF1_A cr8
+#define PICO_REGVECT_COEFF1_B cr9
+#define PICO_REGVECT_COEFF2_A cr10
+#define PICO_REGVECT_COEFF2_B cr11
+#define PICO_REGVECT_VMU0_OUT cr12
+#define PICO_REGVECT_VMU1_OUT cr13
+#define PICO_REGVECT_VMU2_OUT cr14
+#define PICO_REGVECT_CONFIG   cr15
+
+#define PICO_INPIX2  0
+#define PICO_INPIX1  1
+#define PICO_INPIX0  2
+#define PICO_OUTPIX2 3
+#define PICO_OUTPIX1 4
+#define PICO_OUTPIX0 5
+#define PICO_COEFF0_A 6
+#define PICO_COEFF0_B 7
+#define PICO_COEFF1_A 8
+#define PICO_COEFF1_B 9
+#define PICO_COEFF2_A 10
+#define PICO_COEFF2_B 11
+#define PICO_VMU0_OUT 12
+#define PICO_VMU1_OUT 13
+#define PICO_VMU2_OUT 14
+#define PICO_CONFIG   15
+
+/* Config Register */
+#define PICO_COEFF_FRAC_BITS  0
+#define PICO_COEFF_FRAC_BITS_WIDTH  4
+#define PICO_OFFSET_FRAC_BITS  4
+#define PICO_OFFSET_FRAC_BITS_WIDTH  4
+#define PICO_INPUT_MODE  8
+#define PICO_INPUT_MODE_WIDTH  2
+#define PICO_OUTPUT_MODE 10
+
+#define PICO_TRANSFORMATION_MODE 0 
+#define PICO_HOR_FILTER_MODE 1 
+#define PICO_VERT_FILTER_MODE 2 
+
+#define PICO_PLANAR_MODE 1
+#define PICO_PACKED_MODE 0
+
+/* Bits in coefficients */
+#define PICO_COEFF_BITS 12
+
+/* Operation bits */
+#define PICO_USE_ACC (1 << 2)
+#define PICO_SINGLE_VECTOR (1 << 3)
+
+
+#define __str(x...) #x
+#define __xstr(x...) __str(x)
+
+#define PICO_PUT_W(pico_reg, x) \
+  __builtin_mvrc_w(PICO_CPNO, pico_reg, x);
+#define PICO_GET_W(pico_reg) \
+  __builtin_mvcr_w(PICO_CPNO, pico_reg)
+
+#define PICO_PUT_D(pico_reg, x) \
+  __builtin_mvrc_d(PICO_CPNO, pico_reg, x);
+#define PICO_GET_D(pico_reg) \
+  __builtin_mvcr_d(PICO_CPNO, pico_reg)
+
+
+#define PICO_STCM_W(ptr, pico_regs...) \
+  asm volatile ("stcm.w\tcp" __xstr(PICO_CPNO) ", %0," __xstr(pico_regs)  :: "r"(ptr)); 
+#define PICO_STCM_D(ptr, pico_regs...) \
+  asm volatile ("stcm.d\tcp" __xstr(PICO_CPNO) ", %0," __xstr(pico_regs)  :: "r"(ptr)); 
+
+#define PICO_STCM_W_DEC(ptr, pico_regs...) \
+  asm volatile ("stcm.w\tcp" __xstr(PICO_CPNO) ", --%0," __xstr(pico_regs)  : "+r"(ptr)); 
+#define PICO_STCM_D_DEC(ptr, pico_regs...) \
+  asm volatile ("stcm.d\tcp" __xstr(PICO_CPNO) ", --%0," __xstr(pico_regs)  : "+r"(ptr)); 
+
+#define PICO_LDCM_W(ptr, pico_regs...) \
+  asm volatile ("ldcm.w\tcp" __xstr(PICO_CPNO) ", %0," __xstr(pico_regs)  :: "r"(ptr)); 
+#define PICO_LDCM_D(ptr, pico_regs...) \
+  asm volatile ("ldcm.d\tcp" __xstr(PICO_CPNO) ", %0," __xstr(pico_regs)  :: "r"(ptr)); 
+
+#define PICO_LDCM_W_INC(ptr, pico_regs...) \
+  asm volatile ("ldcm.w\tcp" __xstr(PICO_CPNO) ", %0++," __xstr(pico_regs)  : "+r"(ptr)); 
+#define PICO_LDCM_D_INC(ptr, pico_regs...) \
+  asm volatile ("ldcm.d\tcp" __xstr(PICO_CPNO) ", %0++," __xstr(pico_regs)  : "+r"(ptr)); 
+
+#define PICO_OP(op, dst_addr, addr0, addr1, addr2) \
+  __builtin_cop(PICO_CPNO, addr0, addr1, addr2, op | dst_addr);
+
+
+#endif
+
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index ecd28f5..3221d0c 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -173,7 +173,7 @@ typedef struct SwsContext{
 SwsFunc yuv2rgb_get_func_ptr (SwsContext *c);
 int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
 
-char *sws_format_name(int format);
+char *sws_format_name(enum PixelFormat format);
 
 //FIXME replace this with something faster
 #define isPlanarYUV(x) ((x)==PIX_FMT_YUV410P || (x)==PIX_FMT_YUV420P	\
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index 71759bc..fa83985 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -44,6 +44,10 @@
 #include "yuv2rgb_mlib.c"
 #endif
 
+#ifdef ARCH_AVR32
+#include "yuv2rgb_avr32.c"
+#endif
+
 #define DITHER1XBPP // only for mmx
 
 const uint8_t  __attribute__((aligned(8))) dither_2x2_4[2][8]={
@@ -601,6 +605,12 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c)
 	if(t) return t;
     }
 #endif
+#ifdef ARCH_AVR32
+    {
+      SwsFunc t= yuv2rgb_init_avr32(c);
+      if(t) return t;
+    }
+#endif
 #ifdef HAVE_ALTIVEC
     if (c->flags & SWS_CPU_CAPS_ALTIVEC)
     {
@@ -678,6 +688,10 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
 //printf("%lld %lld %lld %lld %lld\n", cy, crv, cbu, cgu, cgv);
     oy -= 256*brightness;
 
+#ifdef ARCH_AVR32
+    yuv2rgb_c_init_tables_avr32 (c, inv_table, fullRange, brightness, contrast, saturation);
+#endif
+
     for (i = 0; i < 1024; i++) {
 	int j;
 
diff --git a/libswscale/yuv2rgb_avr32.c b/libswscale/yuv2rgb_avr32.c
new file mode 100644
index 0000000..4a8341e
--- /dev/null
+++ b/libswscale/yuv2rgb_avr32.c
@@ -0,0 +1,416 @@
+/*
+ * Copyright (c) 2007 Atmel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of ATMEL may not be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+#include "pico-avr32.h"
+
+
+#define RGB(uv_part)  \
+      __asm__ volatile (        \
+                        "ld.w\t%0, %3[%7:" uv_part " << 2]\n\t" /* tmp = c->table_gV[V] */ \
+                        "ld.w\t%1, %4[%8:" uv_part "  << 2]\n\t" /* g = c->table_gU[U] */  \
+                        "ld.w\t%2, %5[%8:" uv_part "  << 2]\n\t" /* b = c->table_bU[U] */  \
+                        "add\t%1, %0\n\t" /* g += tmp */\
+                        "ld.w\t%0, %6[%7:" uv_part "  << 2]" /* r = c->table_rV[V] */ \
+                        : "=&r" (r), "=&r" (g), "=&r" (b) \
+                        : "r" (&c->table_gV[0]), "r" (&c->table_gU[0]),"r" (&c->table_bU[0]), \
+                        "r" (&c->table_rV[0]), "r" (V), "r" (U));
+
+                        
+#undef YUV2RGB1
+#define YUV2RGB1(dst, src, y, idx) \
+  { int tmp2;    __asm__ volatile (      \
+                        "ld.ub\t%0, %3[2*%8]\n\t" /* Y = ((uint32_t*)py_1)[0] */ \
+                        "ld.ub\t%1, %4[%0]\n\t" /* tmp = r[(Y >> 24) & 0xFF] */ \
+                        "ld.ub\t%2, %5[%0]\n\t" /* tmp = g[(Y >> 24) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 0], %1\n\t"         /* dst_1[2] = tmp; */   \
+                        "st.b\t%7[6*%8 + 1], %2\n\t"         /* dst_1[1] = tmp; */   \
+                        "ld.ub\t%1, %6[%0]\n\t" /* tmp = b[(Y >> 24) & 0xFF] */ \
+                        "ld.ub\t%0, %3[2*%8 + 1]\n\t" /* Y = ((uint32_t*)py_1)[0] */ \
+                        "st.b\t%7[6*%8 + 2], %1\n\t"         /* dst_1[0] = tmp; */   \
+                        "ld.ub\t%1, %4[%0]\n\t" /* tmp = r[(Y >> 16) & 0xFF] */ \
+                        "ld.ub\t%2, %5[%0]\n\t" /* tmp = g[(Y >> 16) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 3], %1\n\t"         /* dst_1[5] = tmp; */   \
+                        "ld.ub\t%1, %6[%0]\n\t" /* tmp = b[(Y >> 16) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 4], %2\n\t"         /* dst_1[4] = tmp; */   \
+                        "st.b\t%7[6*%8 + 5], %1"         /* dst_1[3] = tmp; */   \
+                        : "=&r" (y), "=&r" (tmp), "=&r" (tmp2) \
+                        : "r" (src), "r" (r), "r" (g), "r" (b), "r" (dst), "i" (idx)); }
+                        
+#undef YUV2RGB2
+#define YUV2RGB2(dst, src, y, idx) \
+  { int tmp2;    __asm__ volatile (      \
+                        "ld.ub\t%0, %3[2*%8]\n\t" /* Y = ((uint32_t*)py_1)[0] */ \
+                        "ld.ub\t%1, %4[%0]\n\t" /* tmp = r[(Y >> 24) & 0xFF] */ \
+                        "ld.ub\t%2, %5[%0]\n\t" /* tmp = g[(Y >> 24) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 0], %1\n\t"         /* dst_1[2] = tmp; */   \
+                        "st.b\t%7[6*%8 + 1], %2\n\t"         /* dst_1[1] = tmp; */   \
+                        "ld.ub\t%1, %6[%0]\n\t" /* tmp = b[(Y >> 24) & 0xFF] */ \
+                        "ld.ub\t%0, %3[2*%8 + 1]\n\t" /* Y = ((uint32_t*)py_1)[0] */ \
+                        "st.b\t%7[6*%8 + 2], %1\n\t"         /* dst_1[0] = tmp; */   \
+                        "ld.ub\t%1, %4[%0]\n\t" /* tmp = r[(Y >> 16) & 0xFF] */ \
+                        "ld.ub\t%2, %5[%0]\n\t" /* tmp = g[(Y >> 16) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 3], %1\n\t"         /* dst_1[5] = tmp; */   \
+                        "ld.ub\t%1, %6[%0]\n\t" /* tmp = b[(Y >> 16) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 4], %2\n\t"         /* dst_1[4] = tmp; */   \
+                        "st.b\t%7[6*%8 + 5], %1"         /* dst_1[3] = tmp; */   \
+                        : "=&r" (y), "=&r" (tmp), "=&r" (tmp2) \
+                        : "r" (src), "r" (r), "r" (g), "r" (b), "r" (dst), "i" (idx)); }
+
+
+#undef YUV2BGR1
+#define YUV2BGR1(dst, src, y, idx) \
+  { int tmp2;    __asm__ volatile (      \
+                        "ld.ub\t%0, %3[2*%8]\n\t" /* Y = ((uint32_t*)py_1)[0] */ \
+                        "ld.ub\t%1, %4[%0]\n\t" /* tmp = r[(Y >> 24) & 0xFF] */ \
+                        "ld.ub\t%2, %5[%0]\n\t" /* tmp = g[(Y >> 24) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 2], %1\n\t"         /* dst_1[2] = tmp; */   \
+                        "st.b\t%7[6*%8 + 1], %2\n\t"         /* dst_1[1] = tmp; */   \
+                        "ld.ub\t%1, %6[%0]\n\t" /* tmp = b[(Y >> 24) & 0xFF] */ \
+                        "ld.ub\t%0, %3[2*%8 + 1]\n\t" /* Y = ((uint32_t*)py_1)[0] */ \
+                        "st.b\t%7[6*%8 + 0], %1\n\t"         /* dst_1[0] = tmp; */   \
+                        "ld.ub\t%1, %4[%0]\n\t" /* tmp = r[(Y >> 16) & 0xFF] */ \
+                        "ld.ub\t%2, %5[%0]\n\t" /* tmp = g[(Y >> 16) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 5], %1\n\t"         /* dst_1[5] = tmp; */   \
+                        "ld.ub\t%1, %6[%0]\n\t" /* tmp = b[(Y >> 16) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 4], %2\n\t"         /* dst_1[4] = tmp; */   \
+                        "st.b\t%7[6*%8 + 3], %1"         /* dst_1[3] = tmp; */   \
+                        : "=&r" (y), "=&r" (tmp), "=&r" (tmp2) \
+                        : "r" (src), "r" (r), "r" (g), "r" (b), "r" (dst), "i" (idx)); }
+                        
+#undef YUV2BGR2
+#define YUV2BGR2(dst, src, y, idx) \
+  { int tmp2;    __asm__ volatile (      \
+                        "ld.ub\t%0, %3[2*%8]\n\t" /* Y = ((uint32_t*)py_1)[0] */ \
+                        "ld.ub\t%1, %4[%0]\n\t" /* tmp = r[(Y >> 24) & 0xFF] */ \
+                        "ld.ub\t%2, %5[%0]\n\t" /* tmp = g[(Y >> 24) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 2], %1\n\t"         /* dst_1[2] = tmp; */   \
+                        "st.b\t%7[6*%8 + 1], %2\n\t"         /* dst_1[1] = tmp; */   \
+                        "ld.ub\t%1, %6[%0]\n\t" /* tmp = b[(Y >> 24) & 0xFF] */ \
+                        "ld.ub\t%0, %3[2*%8 + 1]\n\t" /* Y = ((uint32_t*)py_1)[0] */ \
+                        "st.b\t%7[6*%8 + 0], %1\n\t"         /* dst_1[0] = tmp; */   \
+                        "ld.ub\t%1, %4[%0]\n\t" /* tmp = r[(Y >> 16) & 0xFF] */ \
+                        "ld.ub\t%2, %5[%0]\n\t" /* tmp = g[(Y >> 16) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 5], %1\n\t"         /* dst_1[5] = tmp; */   \
+                        "ld.ub\t%1, %6[%0]\n\t" /* tmp = b[(Y >> 16) & 0xFF] */ \
+                        "st.b\t%7[6*%8 + 4], %2\n\t"         /* dst_1[4] = tmp; */   \
+                        "st.b\t%7[6*%8 + 3], %1"         /* dst_1[3] = tmp; */   \
+                        : "=&r" (y), "=&r" (tmp), "=&r" (tmp2) \
+                        : "r" (src), "r" (r), "r" (g), "r" (b), "r" (dst), "i" (idx)); }
+
+
+
+int yuv2bgr24_avr32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
+                    int srcSliceH, uint8_t* dst[], int dstStride[]){
+  int y;
+  
+  if(c->srcFormat == PIX_FMT_YUV422P){
+    srcStride[1] *= 2;    
+    srcStride[2] *= 2;
+  }
+
+
+  for(y=0; y<srcSliceH; y+=2){
+    uint8_t *dst_1= (uint8_t*)(dst[0] + (y+srcSliceY  )*dstStride[0]);
+    uint8_t *dst_2= (uint8_t*)(dst[0] + (y+srcSliceY+1)*dstStride[0]);
+    uint32_t *r, *g, *b;
+    uint8_t *py_1= src[0] + y*srcStride[0];
+    uint8_t *py_2= py_1 + srcStride[0];
+    uint8_t *pu= src[1] + (y>>1)*srcStride[1];
+    uint8_t *pv= src[2] + (y>>1)*srcStride[2];
+    unsigned int h_size= c->dstW>>3;
+    while (h_size--) {
+      uint32_t U, V, Y1, Y2, tmp;
+      U = ((uint32_t*)pu)[0];
+      V = ((uint32_t*)pv)[0];
+      
+      RGB("t")
+        YUV2BGR1(dst_1, py_1, Y1, 0) 
+        YUV2BGR1(dst_2, py_2, Y2, 0) 
+
+      RGB("u")
+        YUV2BGR2(dst_1, py_1, Y1, 1) 
+        YUV2BGR2(dst_2, py_2, Y2, 1)
+
+      RGB("l")
+        YUV2BGR1(dst_1, py_1, Y1, 2) 
+        YUV2BGR1(dst_2, py_2, Y2, 2)
+
+      RGB("b")
+        YUV2BGR2(dst_1, py_1, Y1, 3) 
+        YUV2BGR2(dst_2, py_2, Y2, 3)
+ 
+                        
+
+      pu += 4;
+      pv += 4;
+      py_1 += 8;
+      py_2 += 8;
+      dst_1 += 24;
+      dst_2 += 24;
+    }
+  }
+  return srcSliceH;
+}
+
+
+
+static int yuv2rgb24_avr32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
+                             int srcSliceH, uint8_t* dst[], int dstStride[]){
+  int y;
+  
+  if(c->srcFormat == PIX_FMT_YUV422P){
+    srcStride[1] *= 2;
+    srcStride[2] *= 2;
+  }
+  for(y=0; y<srcSliceH; y+=2){
+    uint8_t *dst_1= (uint8_t*)(dst[0] + (y+srcSliceY  )*dstStride[0]);
+    uint8_t *dst_2= (uint8_t*)(dst[0] + (y+srcSliceY+1)*dstStride[0]);
+    uint8_t *r, *g, *b;
+    uint8_t *py_1= src[0] + y*srcStride[0];
+    uint8_t *py_2= py_1 + srcStride[0];
+    uint8_t *pu= src[1] + (y>>1)*srcStride[1];
+    uint8_t *pv= src[2] + (y>>1)*srcStride[2];
+    unsigned int h_size= c->dstW>>3;
+    while (h_size--) {
+      uint32_t U, V, Y1, Y2, tmp;
+      U = ((uint32_t*)pu)[0];
+      V = ((uint32_t*)pv)[0];
+      
+      RGB("t")
+        YUV2RGB1(dst_1, py_1, Y1, 0) 
+        YUV2RGB1(dst_2, py_2, Y2, 0) 
+
+      RGB("u")
+        YUV2RGB2(dst_1, py_1, Y1, 1) 
+        YUV2RGB2(dst_2, py_2, Y2, 1)
+
+      RGB("l")
+        YUV2RGB1(dst_1, py_1, Y1, 2) 
+        YUV2RGB1(dst_2, py_2, Y2, 2)
+
+      RGB("b")
+        YUV2RGB2(dst_1, py_1, Y1, 3) 
+        YUV2RGB2(dst_2, py_2, Y2, 3)
+ 
+      pu += 4;
+      pv += 4;
+      py_1 += 8;
+      py_2 += 8;
+      dst_1 += 24;
+      dst_2 += 24;
+    }
+  }
+  return srcSliceH;
+}
+
+#define SCALE(x, bits) (((x) + ( 1 << (bits - 1))) >> bits)
+#define COEFF_FRAC_BITS  9
+#define OFFSET_FRAC_BITS  2
+
+/* Coefficients used in the pico */
+static struct {
+  short coeff2_2;
+  short coeff2_3;
+  short coeff2_0;
+  short coeff2_1;
+  short coeff1_2;
+  short coeff1_3;
+  short coeff1_0;
+  short coeff1_1;
+  short coeff0_2;
+  short coeff0_3;
+  short coeff0_0;
+  short coeff0_1;
+} pico_coeff;
+
+
+static int yuv2bgr24_avr32_pico(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
+                                int srcSliceH, uint8_t* dst[], int dstStride[]){
+  int y;
+  static int first_time = 1;
+
+  /* Initialize pico */
+  PICO_LDCM_D(&pico_coeff, 
+              PICO_REGVECT_COEFF0_A, PICO_REGVECT_COEFF0_B, 
+              PICO_REGVECT_COEFF1_A, PICO_REGVECT_COEFF1_B,
+              PICO_REGVECT_COEFF2_A, PICO_REGVECT_COEFF2_B);              
+  
+  PICO_PUT_W(PICO_CONFIG, 
+             (PICO_PACKED_MODE << PICO_OUTPUT_MODE 
+              | PICO_TRANSFORMATION_MODE << PICO_INPUT_MODE 
+              | OFFSET_FRAC_BITS << PICO_OFFSET_FRAC_BITS
+              | COEFF_FRAC_BITS << PICO_COEFF_FRAC_BITS));
+
+
+  if(c->srcFormat == PIX_FMT_YUV422P){
+    srcStride[1] *= 2;
+    srcStride[2] *= 2;
+  }
+
+  for(y=0; y<srcSliceH; y+=2){
+    uint8_t *dst_1= (uint8_t*)(dst[0] + (y+srcSliceY  )*dstStride[0]);
+    uint8_t *dst_2= (uint8_t*)(dst[0] + (y+srcSliceY+1)*dstStride[0]);
+    uint8_t *r, *g, *b;
+    uint8_t *py_1= src[0] + y*srcStride[0];
+    uint8_t *py_2= py_1 + srcStride[0];
+    uint8_t *pu= src[1] + (y>>1)*srcStride[1];
+    uint8_t *pv= src[2] + (y>>1)*srcStride[2];
+    unsigned int h_size= c->dstW>>3;
+    int *py_1_int = (int *)py_1;
+    int *py_2_int = (int *)py_2;
+    int *pu_int = (int *)pu;
+    int *pv_int = (int *)pv;
+    while (h_size--) {
+      PICO_PUT_W(PICO_INPIX0, *py_1_int++);
+      PICO_PUT_W(PICO_INPIX1, *pu_int++);
+      PICO_PUT_W(PICO_INPIX2, *pv_int++);
+      PICO_OP(0, 0, 0, 4, 8);
+      PICO_OP(0, 1, 1, 4, 8);
+      PICO_OP(0, 2, 2, 5, 9);
+      PICO_OP(0, 3, 3, 5, 9);
+      PICO_PUT_W(PICO_INPIX0, *py_1_int++);
+      PICO_STCM_W(dst_1, PICO_REGVECT_OUTPIX2, PICO_REGVECT_OUTPIX1, PICO_REGVECT_OUTPIX0);
+      PICO_OP(0, 0, 0, 6, 10);
+      PICO_OP(0, 1, 1, 6, 10);
+      PICO_OP(0, 2, 2, 7, 11);
+      PICO_OP(0, 3, 3, 7, 11);
+      PICO_PUT_W(PICO_INPIX0, *py_2_int++);
+      PICO_STCM_W(dst_1 + 12, PICO_REGVECT_OUTPIX2, PICO_REGVECT_OUTPIX1, PICO_REGVECT_OUTPIX0);
+      
+      PICO_OP(0, 0, 0, 4, 8);
+      PICO_OP(0, 1, 1, 4, 8);
+      PICO_OP(0, 2, 2, 5, 9);
+      PICO_OP(0, 3, 3, 5, 9);
+      PICO_PUT_W(PICO_INPIX0, *py_2_int++);
+      PICO_STCM_W(dst_2, PICO_REGVECT_OUTPIX2, PICO_REGVECT_OUTPIX1, PICO_REGVECT_OUTPIX0);
+      PICO_OP(0, 0, 0, 6, 10);
+      PICO_OP(0, 1, 1, 6, 10);
+      PICO_OP(0, 2, 2, 7, 11);
+      PICO_OP(0, 3, 3, 7, 11);
+      PICO_STCM_W(dst_2 + 12, PICO_REGVECT_OUTPIX2, PICO_REGVECT_OUTPIX1, PICO_REGVECT_OUTPIX0);
+
+      dst_1 += 24;
+      dst_2 += 24;
+    }
+  }
+  return srcSliceH;
+}
+
+extern int avr32_use_pico;
+
+SwsFunc yuv2rgb_init_avr32 (SwsContext *c){
+  switch(c->dstFormat){
+  case PIX_FMT_BGR24:
+    {
+      if ( avr32_use_pico ){
+        MSG_ERR("AVR32 BGR24: Using PICO for color space conversion\n");
+        return yuv2bgr24_avr32_pico;
+      } else {
+        MSG_ERR("AVR32 BGR24: Using optimized color space conversion\n");
+        return yuv2bgr24_avr32;
+      }
+    }
+    break;
+  case PIX_FMT_RGB24:
+    {      
+      if ( avr32_use_pico ){
+        MSG_ERR("AVR32 RGB24: Using PICO for color space conversion\n");
+        return yuv2bgr24_avr32_pico;
+      } else {
+        MSG_ERR("AVR32 RGB24: Using optimized color space conversion\n");
+        return yuv2rgb24_avr32;
+      }  
+    }
+  }
+  return NULL;
+}
+
+
+int yuv2rgb_c_init_tables_avr32 (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation){
+  const int isRgb = (c->dstFormat == PIX_FMT_RGB24);
+ 
+  int64_t crv =  inv_table[0];
+  int64_t cbu =  inv_table[1];
+  int64_t cgu = -inv_table[2];
+  int64_t cgv = -inv_table[3];
+  int64_t cy  = 1<<16;
+  int64_t oy  = 0;
+  
+  if(!fullRange){
+    cy= (cy*255) / 219;
+    oy= 16<<16;
+  }
+  
+  cy = (cy *contrast             )>>16;
+  crv= (crv*contrast * saturation)>>32;
+  cbu= (cbu*contrast * saturation)>>32;
+  cgu= (cgu*contrast * saturation)>>32;
+  cgv= (cgv*contrast * saturation)>>32;
+
+  oy -= 256*brightness;
+  
+  pico_coeff.coeff1_0 = SCALE(cy, 16 - COEFF_FRAC_BITS); /* G <- Y */
+  pico_coeff.coeff1_1 = SCALE(cgu, 16 - COEFF_FRAC_BITS); /* G <- U */
+  pico_coeff.coeff1_2 = SCALE(cgv, 16 - COEFF_FRAC_BITS); /* G <- V */ 
+  pico_coeff.coeff1_3 = (SCALE(-128*cgu - 128*cgv - 16*cy, 16 - OFFSET_FRAC_BITS)
+                         + /*0.5*/(1 << (OFFSET_FRAC_BITS-1))); /* G offset */ 
+  
+  if ( isRgb ){
+    pico_coeff.coeff0_0 = SCALE(cy, 16 - COEFF_FRAC_BITS); /* R <- Y */
+    pico_coeff.coeff0_1 = 0; /* R <- U */
+    pico_coeff.coeff0_2 = SCALE(crv, 16 - COEFF_FRAC_BITS); /* R <- V */ 
+    pico_coeff.coeff0_3 = (SCALE(-128*crv - 16*cy, 16 - OFFSET_FRAC_BITS)
+                           + /*0.5*/(1 << (OFFSET_FRAC_BITS-1))); /* R offset */ 
+    
+    pico_coeff.coeff2_0 = SCALE(cy, 16 - COEFF_FRAC_BITS); /* B <- Y */
+    pico_coeff.coeff2_1 = SCALE(cbu, 16 - COEFF_FRAC_BITS); /* B <- U */
+    pico_coeff.coeff2_2 = 0; /* B <- V */ 
+    pico_coeff.coeff2_3 = (SCALE(-128*cbu - 16*cy, 16 - OFFSET_FRAC_BITS) 
+                           + /*0.5*/(1 << (OFFSET_FRAC_BITS-1)));/* B offset */       
+  } else {
+    pico_coeff.coeff2_0 = SCALE(cy, 16 - COEFF_FRAC_BITS); /* R <- Y */
+    pico_coeff.coeff2_1 = 0; /* R <- U */
+    pico_coeff.coeff2_2 = SCALE(crv, 16 - COEFF_FRAC_BITS); /* R <- V */ 
+    pico_coeff.coeff2_3 = (SCALE(-128*crv - 16*cy, 16 - OFFSET_FRAC_BITS)
+                           + /*0.5*/(1 << (OFFSET_FRAC_BITS-1))); /* R offset */ 
+    
+    pico_coeff.coeff0_0 = SCALE(cy, 16 - COEFF_FRAC_BITS); /* B <- Y */
+    pico_coeff.coeff0_1 = SCALE(cbu, 16 - COEFF_FRAC_BITS); /* B <- U */
+    pico_coeff.coeff0_2 = 0; /* B <- V */ 
+    pico_coeff.coeff0_3 = (SCALE(-128*cbu - 16*cy, 16 - OFFSET_FRAC_BITS)
+                           + /*0.5*/(1 << (OFFSET_FRAC_BITS-1))); /* B offset */       
+  }
+
+}
+
+
+#undef RGB
diff --git a/libvo/vo_fbdev2.c b/libvo/vo_fbdev2.c
index 053c193..7017770 100644
--- a/libvo/vo_fbdev2.c
+++ b/libvo/vo_fbdev2.c
@@ -22,6 +22,9 @@
 #include "sub.h"
 #include "mp_msg.h"
 
+/* Draw directly to framebuffer */
+#define USE_CONVERT2FB
+
 static vo_info_t info = {
 	"Framebuffer Device",
 	"fbdev2",
@@ -178,6 +181,15 @@ static int fb_preinit(int reset)
 	}
 	fb_orig_vinfo = fb_vinfo;
 
+	/* Reset panning offset */
+	fb_vinfo.yoffset = 0;
+	if (ioctl(fb_dev_fd, FBIOPAN_DISPLAY, &fb_vinfo)) {
+		mp_msg(MSGT_VO, MSGL_ERR,
+		       "[fbdev2] FBIOPAN_DISPLAY failed: %s\n",
+		       strerror(errno));
+		return 0;
+	}
+
 	fb_bpp = fb_vinfo.bits_per_pixel;
 
 	/* 16 and 15 bpp is reported as 16 bpp */
@@ -289,6 +301,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
 		mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't malloc next_frame: %s\n", strerror(errno));
 		return 1;
 	}
+#else
+	if ((fb_line_len * fb_vinfo.yres) <= (fb_finfo.smem_len / 2)
+	    && fb_vinfo.yoffset == 0)
+		center += fb_line_len * fb_vinfo.yres;
 #endif
 	if (fs) memset(frame_buffer, '\0', fb_line_len * fb_vinfo.yres);
 
@@ -299,14 +315,22 @@ static int query_format(uint32_t format)
 {
 	// open the device, etc.
 	if (fb_preinit(0)) return 0;
-	if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) {
+	if ((format & IMGFMT_RGB_MASK) == IMGFMT_RGB) {
 		int fb_target_bpp = format & 0xff;
 		set_bpp(&fb_vinfo, fb_target_bpp);
 		fb_vinfo.xres_virtual = fb_vinfo.xres;
-		fb_vinfo.yres_virtual = fb_vinfo.yres;
+		fb_vinfo.yres_virtual = fb_vinfo.yres * 2;
 		if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) {
-			mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't put VSCREENINFO: %s\n", strerror(errno));
-			return 0;
+			mp_msg(MSGT_VO, MSGL_WARN,
+			       "[fbdev2] Can't double virtual y resolution: %s\n",
+			       strerror(errno));
+			fb_vinfo.yres_virtual = fb_vinfo.yres;
+			if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) {
+				mp_msg(MSGT_VO, MSGL_ERR,
+				       "[fbdev2] Can't put VSCREENINFO: %s\n",
+				       strerror(errno));
+				return -1;
+			}
 		}
 		fb_pixel_size = fb_vinfo.bits_per_pixel / 8;
 		fb_bpp = fb_vinfo.red.length + fb_vinfo.green.length +
@@ -367,16 +391,67 @@ static void check_events(void)
 
 static void flip_page(void)
 {
-#ifndef USE_CONVERT2FB
 	int i, out_offset = 0, in_offset = 0;
 
-	for (i = 0; i < in_height; i++) {
-		memcpy(center + out_offset, next_frame + in_offset,
-				in_width * fb_pixel_size);
-		out_offset += fb_line_len;
-		in_offset += in_width * fb_pixel_size;
-	}
+#ifndef USE_CONVERT2FB
+	if (1) {
+#else
+	if (fb_vinfo.yres_virtual == fb_vinfo.yres) {
 #endif
+		for (i = 0; i < in_height; i++) {
+			memcpy(center + out_offset, next_frame + in_offset,
+			       in_width * fb_pixel_size);
+			out_offset += fb_line_len;
+			in_offset += in_width * fb_pixel_size;
+		}
+	} else {
+		if (fb_vinfo.yoffset == 0) {
+			fb_vinfo.yoffset += fb_vinfo.yres;
+			center -= fb_line_len * fb_vinfo.yres;
+		} else {
+			fb_vinfo.yoffset = 0;
+			center += fb_line_len * fb_vinfo.yres;
+		}
+
+		if (ioctl(fb_dev_fd, FBIOPAN_DISPLAY, &fb_vinfo)) {
+			mp_msg(MSGT_VO, MSGL_ERR,
+			       "[fbdev2] Can't FBIOPAN_DISPLAY: %s\n",
+			       strerror(errno));
+		}
+	}
+}
+
+static uint32_t get_image(mp_image_t *mpi)
+{
+	if(mpi->flags&MP_IMGFLAG_READABLE)
+		return VO_FALSE; // slow video ram 
+	if(mpi->type==MP_IMGTYPE_STATIC)
+		return VO_FALSE; // it is not static
+  
+	if (mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH)) {
+		// we're lucky or codec accepts stride => ok, let's go!
+
+		//YUY2 and RGB formats
+		mpi->planes[0] = center;
+		mpi->width = in_width;
+		mpi->stride[0] = fb_line_len;
+
+		// center image
+
+		mpi->flags |= MP_IMGFLAG_DIRECT;
+
+		return VO_TRUE;
+	}
+
+	return VO_FALSE;
+}
+
+static uint32_t put_image(mp_image_t *mpi)
+{
+	// already out?
+	if ((mpi->flags & (MP_IMGFLAG_DIRECT | MP_IMGFLAG_DRAW_CALLBACK)))
+		return VO_TRUE;
+	return VO_FALSE;
 }
 
 static void uninit(void)
@@ -403,6 +478,10 @@ static int control(uint32_t request, void *data, ...)
   switch (request) {
   case VOCTRL_QUERY_FORMAT:
     return query_format(*((uint32_t*)data));
+  case VOCTRL_GET_IMAGE:
+    return get_image(data);
+  case VOCTRL_DRAW_IMAGE:
+    return put_image(data);
   }
   return VO_NOTIMPL;
 }
diff --git a/version.sh b/version.sh
index 44b5c5d..cf22a68 100755
--- a/version.sh
+++ b/version.sh
@@ -1,2 +1,2 @@
 #!/bin/sh
-echo "#define VERSION \"1.0rc1-$1\"" > version.h
+echo "#define VERSION \"1.0rc1.atmel.2-$1\"" > version.h