Mercurial > libavcodec.hg
comparison vp3.c @ 10696:a80851eebd2e libavcodec
Optimize unpack_vectors() by not shuffling around redundant vectors.
Inspired by guidance from Dark Shikari. On a Core 2 Duo 2.0 GHz, this
change decodes the 10-minute Big Buck Bunny 1080p short about 2 seconds
faster.
author | melanson |
---|---|
date | Sat, 19 Dec 2009 07:33:10 +0000 |
parents | b6116b343122 |
children | 7c0cc00cabc8 |
comparison
equal
deleted
inserted
replaced
10695:fe81255af588 | 10696:a80851eebd2e |
---|---|
887 motion_x[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)]; | 887 motion_x[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)]; |
888 motion_y[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)]; | 888 motion_y[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)]; |
889 } else { | 889 } else { |
890 motion_x[0] = fixed_motion_vector_table[get_bits(gb, 6)]; | 890 motion_x[0] = fixed_motion_vector_table[get_bits(gb, 6)]; |
891 motion_y[0] = fixed_motion_vector_table[get_bits(gb, 6)]; | 891 motion_y[0] = fixed_motion_vector_table[get_bits(gb, 6)]; |
892 } | |
893 | |
894 for (k = 1; k < 6; k++) { | |
895 motion_x[k] = motion_x[0]; | |
896 motion_y[k] = motion_y[0]; | |
897 } | 892 } |
898 | 893 |
899 /* vector maintenance, only on MODE_INTER_PLUS_MV */ | 894 /* vector maintenance, only on MODE_INTER_PLUS_MV */ |
900 if (s->macroblock_coding[current_macroblock] == | 895 if (s->macroblock_coding[current_macroblock] == |
901 MODE_INTER_PLUS_MV) { | 896 MODE_INTER_PLUS_MV) { |
944 | 939 |
945 case MODE_INTER_LAST_MV: | 940 case MODE_INTER_LAST_MV: |
946 /* all 6 fragments use the last motion vector */ | 941 /* all 6 fragments use the last motion vector */ |
947 motion_x[0] = last_motion_x; | 942 motion_x[0] = last_motion_x; |
948 motion_y[0] = last_motion_y; | 943 motion_y[0] = last_motion_y; |
949 for (k = 1; k < 6; k++) { | |
950 motion_x[k] = motion_x[0]; | |
951 motion_y[k] = motion_y[0]; | |
952 } | |
953 | 944 |
954 /* no vector maintenance (last vector remains the | 945 /* no vector maintenance (last vector remains the |
955 * last vector) */ | 946 * last vector) */ |
956 break; | 947 break; |
957 | 948 |
958 case MODE_INTER_PRIOR_LAST: | 949 case MODE_INTER_PRIOR_LAST: |
959 /* all 6 fragments use the motion vector prior to the | 950 /* all 6 fragments use the motion vector prior to the |
960 * last motion vector */ | 951 * last motion vector */ |
961 motion_x[0] = prior_last_motion_x; | 952 motion_x[0] = prior_last_motion_x; |
962 motion_y[0] = prior_last_motion_y; | 953 motion_y[0] = prior_last_motion_y; |
963 for (k = 1; k < 6; k++) { | |
964 motion_x[k] = motion_x[0]; | |
965 motion_y[k] = motion_y[0]; | |
966 } | |
967 | 954 |
968 /* vector maintenance */ | 955 /* vector maintenance */ |
969 prior_last_motion_x = last_motion_x; | 956 prior_last_motion_x = last_motion_x; |
970 prior_last_motion_y = last_motion_y; | 957 prior_last_motion_y = last_motion_y; |
971 last_motion_x = motion_x[0]; | 958 last_motion_x = motion_x[0]; |
972 last_motion_y = motion_y[0]; | 959 last_motion_y = motion_y[0]; |
973 break; | 960 break; |
974 | 961 |
975 default: | 962 default: |
976 /* covers intra, inter without MV, golden without MV */ | 963 /* covers intra, inter without MV, golden without MV */ |
977 memset(motion_x, 0, 6 * sizeof(int)); | 964 motion_x[0] = 0; |
978 memset(motion_y, 0, 6 * sizeof(int)); | 965 motion_y[0] = 0; |
979 | 966 |
980 /* no vector maintenance */ | 967 /* no vector maintenance */ |
981 break; | 968 break; |
982 } | 969 } |
983 | 970 |
990 if (current_fragment >= s->fragment_count) { | 977 if (current_fragment >= s->fragment_count) { |
991 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vectors(): bad fragment number (%d >= %d)\n", | 978 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vectors(): bad fragment number (%d >= %d)\n", |
992 current_fragment, s->fragment_count); | 979 current_fragment, s->fragment_count); |
993 return 1; | 980 return 1; |
994 } | 981 } |
982 if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) { | |
995 s->all_fragments[current_fragment].motion_x = motion_x[k]; | 983 s->all_fragments[current_fragment].motion_x = motion_x[k]; |
996 s->all_fragments[current_fragment].motion_y = motion_y[k]; | 984 s->all_fragments[current_fragment].motion_y = motion_y[k]; |
985 } else { | |
986 s->all_fragments[current_fragment].motion_x = motion_x[0]; | |
987 s->all_fragments[current_fragment].motion_y = motion_y[0]; | |
988 } | |
997 } | 989 } |
998 } | 990 } |
999 } | 991 } |
1000 | 992 |
1001 return 0; | 993 return 0; |