comparison mpeg12.c @ 520:19a5e2a81e1a libavcodec

new bitstream reader API (old get_bits() based one is emulated and will still be supported in the future cuz its simpler) minor optimizations to get_vlc
author michaelni
date Tue, 09 Jul 2002 10:35:10 +0000
parents 0b4450c15067
children 3c07cf9595de
comparison
equal deleted inserted replaced
519:55b4e2248a45 520:19a5e2a81e1a
959 s->last_dc[component] = dc; 959 s->last_dc[component] = dc;
960 block[0] = dc; 960 block[0] = dc;
961 dprintf("dc=%d diff=%d\n", dc, diff); 961 dprintf("dc=%d diff=%d\n", dc, diff);
962 i = 1; 962 i = 1;
963 } else { 963 } else {
964 int bit_cnt, v; 964 int v;
965 UINT32 bit_buf; 965 OPEN_READER(re, &s->gb);
966 UINT8 *buf_ptr;
967 i = 0; 966 i = 0;
968 /* special case for the first coef. no need to add a second vlc table */ 967 /* special case for the first coef. no need to add a second vlc table */
969 SAVE_BITS(&s->gb); 968 UPDATE_CACHE(re, &s->gb);
970 SHOW_BITS(&s->gb, v, 2); 969 v= SHOW_UBITS(re, &s->gb, 2);
971 if (v & 2) { 970 if (v & 2) {
972 run = 0; 971 run = 0;
973 level = 1 - ((v & 1) << 1); 972 level = 1 - ((v & 1) << 1);
974 FLUSH_BITS(2); 973 SKIP_BITS(re, &s->gb, 2);
975 RESTORE_BITS(&s->gb); 974 CLOSE_READER(re, &s->gb);
976 goto add_coef; 975 goto add_coef;
977 } 976 }
978 RESTORE_BITS(&s->gb); 977 CLOSE_READER(re, &s->gb);
979 } 978 }
980 979
981 /* now quantify & encode AC coefs */ 980 /* now quantify & encode AC coefs */
982 for(;;) { 981 for(;;) {
983 code = get_vlc(&s->gb, &rl->vlc); 982 code = get_vlc(&s->gb, &rl->vlc);
1033 else 1032 else
1034 scan_table = zigzag_direct; 1033 scan_table = zigzag_direct;
1035 mismatch = 1; 1034 mismatch = 1;
1036 1035
1037 { 1036 {
1038 int bit_cnt, v; 1037 int v;
1039 UINT32 bit_buf; 1038 OPEN_READER(re, &s->gb);
1040 UINT8 *buf_ptr;
1041 i = 0; 1039 i = 0;
1042 if (n < 4) 1040 if (n < 4)
1043 matrix = s->inter_matrix; 1041 matrix = s->inter_matrix;
1044 else 1042 else
1045 matrix = s->chroma_inter_matrix; 1043 matrix = s->chroma_inter_matrix;
1046 1044
1047 /* special case for the first coef. no need to add a second vlc table */ 1045 /* special case for the first coef. no need to add a second vlc table */
1048 SAVE_BITS(&s->gb); 1046 UPDATE_CACHE(re, &s->gb);
1049 SHOW_BITS(&s->gb, v, 2); 1047 v= SHOW_UBITS(re, &s->gb, 2);
1050 if (v & 2) { 1048 if (v & 2) {
1051 run = 0; 1049 run = 0;
1052 level = 1 - ((v & 1) << 1); 1050 level = 1 - ((v & 1) << 1);
1053 FLUSH_BITS(2); 1051 SKIP_BITS(re, &s->gb, 2);
1054 RESTORE_BITS(&s->gb); 1052 CLOSE_READER(re, &s->gb);
1055 goto add_coef; 1053 goto add_coef;
1056 } 1054 }
1057 RESTORE_BITS(&s->gb); 1055 CLOSE_READER(re, &s->gb);
1058 } 1056 }
1059 1057
1060 /* now quantify & encode AC coefs */ 1058 /* now quantify & encode AC coefs */
1061 for(;;) { 1059 for(;;) {
1062 code = get_vlc(&s->gb, &rl->vlc); 1060 code = get_vlc(&s->gb, &rl->vlc);