Mercurial > libavcodec.hg
comparison wmv2.c @ 5882:51fc10d9fdff libavcodec
rename some msmpeg4 symbols and make them non-static
so that they can be used in standalone wmv2.c
author | aurel |
---|---|
date | Wed, 07 Nov 2007 23:23:35 +0000 |
parents | 9f8219a3b86f |
children | 02007962faf4 |
comparison
equal
deleted
inserted
replaced
5881:aa110f457c5a | 5882:51fc10d9fdff |
---|---|
139 if(w->j_type_bit) put_bits(&s->pb, 1, w->j_type); | 139 if(w->j_type_bit) put_bits(&s->pb, 1, w->j_type); |
140 | 140 |
141 if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table); | 141 if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table); |
142 | 142 |
143 if(!s->per_mb_rl_table){ | 143 if(!s->per_mb_rl_table){ |
144 ff_code012(&s->pb, s->rl_chroma_table_index); | 144 ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index); |
145 ff_code012(&s->pb, s->rl_table_index); | 145 ff_msmpeg4_code012(&s->pb, s->rl_table_index); |
146 } | 146 } |
147 | 147 |
148 put_bits(&s->pb, 1, s->dc_table_index); | 148 put_bits(&s->pb, 1, s->dc_table_index); |
149 | 149 |
150 s->inter_intra_pred= 0; | 150 s->inter_intra_pred= 0; |
151 }else{ | 151 }else{ |
152 int cbp_index; | 152 int cbp_index; |
153 | 153 |
154 put_bits(&s->pb, 2, SKIP_TYPE_NONE); | 154 put_bits(&s->pb, 2, SKIP_TYPE_NONE); |
155 | 155 |
156 ff_code012(&s->pb, cbp_index=0); | 156 ff_msmpeg4_code012(&s->pb, cbp_index=0); |
157 if(s->qscale <= 10){ | 157 if(s->qscale <= 10){ |
158 int map[3]= {0,2,1}; | 158 int map[3]= {0,2,1}; |
159 w->cbp_table_index= map[cbp_index]; | 159 w->cbp_table_index= map[cbp_index]; |
160 }else if(s->qscale <= 20){ | 160 }else if(s->qscale <= 20){ |
161 int map[3]= {1,0,2}; | 161 int map[3]= {1,0,2}; |
168 if(w->mspel_bit) put_bits(&s->pb, 1, s->mspel); | 168 if(w->mspel_bit) put_bits(&s->pb, 1, s->mspel); |
169 | 169 |
170 if(w->abt_flag){ | 170 if(w->abt_flag){ |
171 put_bits(&s->pb, 1, w->per_mb_abt^1); | 171 put_bits(&s->pb, 1, w->per_mb_abt^1); |
172 if(!w->per_mb_abt){ | 172 if(!w->per_mb_abt){ |
173 ff_code012(&s->pb, w->abt_type); | 173 ff_msmpeg4_code012(&s->pb, w->abt_type); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table); | 177 if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table); |
178 | 178 |
179 if(!s->per_mb_rl_table){ | 179 if(!s->per_mb_rl_table){ |
180 ff_code012(&s->pb, s->rl_table_index); | 180 ff_msmpeg4_code012(&s->pb, s->rl_table_index); |
181 s->rl_chroma_table_index = s->rl_table_index; | 181 s->rl_chroma_table_index = s->rl_table_index; |
182 } | 182 } |
183 put_bits(&s->pb, 1, s->dc_table_index); | 183 put_bits(&s->pb, 1, s->dc_table_index); |
184 put_bits(&s->pb, 1, s->mv_table_index); | 184 put_bits(&s->pb, 1, s->mv_table_index); |
185 | 185 |
201 Wmv2Context * const w= (Wmv2Context*)s; | 201 Wmv2Context * const w= (Wmv2Context*)s; |
202 int cbp, coded_cbp, i; | 202 int cbp, coded_cbp, i; |
203 int pred_x, pred_y; | 203 int pred_x, pred_y; |
204 uint8_t *coded_block; | 204 uint8_t *coded_block; |
205 | 205 |
206 handle_slices(s); | 206 ff_msmpeg4_handle_slices(s); |
207 | 207 |
208 if (!s->mb_intra) { | 208 if (!s->mb_intra) { |
209 /* compute cbp */ | 209 /* compute cbp */ |
210 cbp = 0; | 210 cbp = 0; |
211 for (i = 0; i < 6; i++) { | 211 for (i = 0; i < 6; i++) { |
217 wmv2_inter_table[w->cbp_table_index][cbp + 64][1], | 217 wmv2_inter_table[w->cbp_table_index][cbp + 64][1], |
218 wmv2_inter_table[w->cbp_table_index][cbp + 64][0]); | 218 wmv2_inter_table[w->cbp_table_index][cbp + 64][0]); |
219 | 219 |
220 /* motion vector */ | 220 /* motion vector */ |
221 h263_pred_motion(s, 0, 0, &pred_x, &pred_y); | 221 h263_pred_motion(s, 0, 0, &pred_x, &pred_y); |
222 msmpeg4_encode_motion(s, motion_x - pred_x, | 222 ff_msmpeg4_encode_motion(s, motion_x - pred_x, |
223 motion_y - pred_y); | 223 motion_y - pred_y); |
224 } else { | 224 } else { |
225 /* compute cbp */ | 225 /* compute cbp */ |
226 cbp = 0; | 226 cbp = 0; |
227 coded_cbp = 0; | 227 coded_cbp = 0; |
229 int val, pred; | 229 int val, pred; |
230 val = (s->block_last_index[i] >= 1); | 230 val = (s->block_last_index[i] >= 1); |
231 cbp |= val << (5 - i); | 231 cbp |= val << (5 - i); |
232 if (i < 4) { | 232 if (i < 4) { |
233 /* predict value for close blocks only for luma */ | 233 /* predict value for close blocks only for luma */ |
234 pred = coded_block_pred(s, i, &coded_block); | 234 pred = ff_msmpeg4_coded_block_pred(s, i, &coded_block); |
235 *coded_block = val; | 235 *coded_block = val; |
236 val = val ^ pred; | 236 val = val ^ pred; |
237 } | 237 } |
238 coded_cbp |= val << (5 - i); | 238 coded_cbp |= val << (5 - i); |
239 } | 239 } |
480 | 480 |
481 static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){ | 481 static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){ |
482 MpegEncContext * const s= &w->s; | 482 MpegEncContext * const s= &w->s; |
483 int ret; | 483 int ret; |
484 | 484 |
485 ret= msmpeg4_decode_motion(s, mx_ptr, my_ptr); | 485 ret= ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr); |
486 | 486 |
487 if(ret<0) return -1; | 487 if(ret<0) return -1; |
488 | 488 |
489 if((((*mx_ptr)|(*my_ptr)) & 1) && s->mspel) | 489 if((((*mx_ptr)|(*my_ptr)) & 1) && s->mspel) |
490 w->hshift= get_bits1(&s->gb); | 490 w->hshift= get_bits1(&s->gb); |
566 | 566 |
567 sub_cbp= sub_cbp_table[ decode012(&s->gb) ]; | 567 sub_cbp= sub_cbp_table[ decode012(&s->gb) ]; |
568 // printf("S%d", sub_cbp); | 568 // printf("S%d", sub_cbp); |
569 | 569 |
570 if(sub_cbp&1){ | 570 if(sub_cbp&1){ |
571 if (msmpeg4_decode_block(s, block, n, 1, scantable) < 0) | 571 if (ff_msmpeg4_decode_block(s, block, n, 1, scantable) < 0) |
572 return -1; | 572 return -1; |
573 } | 573 } |
574 | 574 |
575 if(sub_cbp&2){ | 575 if(sub_cbp&2){ |
576 if (msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable) < 0) | 576 if (ff_msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable) < 0) |
577 return -1; | 577 return -1; |
578 } | 578 } |
579 s->block_last_index[n] = 63; | 579 s->block_last_index[n] = 63; |
580 | 580 |
581 return 0; | 581 return 0; |
582 }else{ | 582 }else{ |
583 return msmpeg4_decode_block(s, block, n, 1, s->inter_scantable.permutated); | 583 return ff_msmpeg4_decode_block(s, block, n, 1, s->inter_scantable.permutated); |
584 } | 584 } |
585 } | 585 } |
586 | 586 |
587 static void wmv2_add_block(Wmv2Context *w, DCTELEM *block1, uint8_t *dst, int stride, int n){ | 587 static void wmv2_add_block(Wmv2Context *w, DCTELEM *block1, uint8_t *dst, int stride, int n){ |
588 MpegEncContext * const s= &w->s; | 588 MpegEncContext * const s= &w->s; |
709 } | 709 } |
710 pix_op[1][dxy](dest_cr, ptr, uvlinesize, h >> 1); | 710 pix_op[1][dxy](dest_cr, ptr, uvlinesize, h >> 1); |
711 } | 711 } |
712 | 712 |
713 | 713 |
714 static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) | 714 int ff_wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) |
715 { | 715 { |
716 Wmv2Context * const w= (Wmv2Context*)s; | 716 Wmv2Context * const w= (Wmv2Context*)s; |
717 int cbp, code, i; | 717 int cbp, code, i; |
718 uint8_t *coded_val; | 718 uint8_t *coded_val; |
719 | 719 |
732 s->mb_skipped = 1; | 732 s->mb_skipped = 1; |
733 w->hshift=0; | 733 w->hshift=0; |
734 return 0; | 734 return 0; |
735 } | 735 } |
736 | 736 |
737 code = get_vlc2(&s->gb, mb_non_intra_vlc[w->cbp_table_index].table, MB_NON_INTRA_VLC_BITS, 3); | 737 code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table, MB_NON_INTRA_VLC_BITS, 3); |
738 if (code < 0) | 738 if (code < 0) |
739 return -1; | 739 return -1; |
740 s->mb_intra = (~code & 0x40) >> 6; | 740 s->mb_intra = (~code & 0x40) >> 6; |
741 | 741 |
742 cbp = code & 0x3f; | 742 cbp = code & 0x3f; |
750 /* predict coded block pattern */ | 750 /* predict coded block pattern */ |
751 cbp = 0; | 751 cbp = 0; |
752 for(i=0;i<6;i++) { | 752 for(i=0;i<6;i++) { |
753 int val = ((code >> (5 - i)) & 1); | 753 int val = ((code >> (5 - i)) & 1); |
754 if (i < 4) { | 754 if (i < 4) { |
755 int pred = coded_block_pred(s, i, &coded_val); | 755 int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val); |
756 val = val ^ pred; | 756 val = val ^ pred; |
757 *coded_val = val; | 757 *coded_val = val; |
758 } | 758 } |
759 cbp |= val << (5 - i); | 759 cbp |= val << (5 - i); |
760 } | 760 } |
799 //if(s->pict_type==P_TYPE) | 799 //if(s->pict_type==P_TYPE) |
800 // printf("%d%d ", s->inter_intra_pred, cbp); | 800 // printf("%d%d ", s->inter_intra_pred, cbp); |
801 //printf("I at %d %d %d %06X\n", s->mb_x, s->mb_y, ((cbp&3)? 1 : 0) +((cbp&0x3C)? 2 : 0), show_bits(&s->gb, 24)); | 801 //printf("I at %d %d %d %06X\n", s->mb_x, s->mb_y, ((cbp&3)? 1 : 0) +((cbp&0x3C)? 2 : 0), show_bits(&s->gb, 24)); |
802 s->ac_pred = get_bits1(&s->gb); | 802 s->ac_pred = get_bits1(&s->gb); |
803 if(s->inter_intra_pred){ | 803 if(s->inter_intra_pred){ |
804 s->h263_aic_dir= get_vlc2(&s->gb, inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1); | 804 s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1); |
805 // printf("%d%d %d %d/", s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y); | 805 // printf("%d%d %d %d/", s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y); |
806 } | 806 } |
807 if(s->per_mb_rl_table && cbp){ | 807 if(s->per_mb_rl_table && cbp){ |
808 s->rl_table_index = decode012(&s->gb); | 808 s->rl_table_index = decode012(&s->gb); |
809 s->rl_chroma_table_index = s->rl_table_index; | 809 s->rl_chroma_table_index = s->rl_table_index; |
810 } | 810 } |
811 | 811 |
812 s->dsp.clear_blocks(s->block[0]); | 812 s->dsp.clear_blocks(s->block[0]); |
813 for (i = 0; i < 6; i++) { | 813 for (i = 0; i < 6; i++) { |
814 if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) | 814 if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) |
815 { | 815 { |
816 av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding intra block: %d x %d (%d)\n", s->mb_x, s->mb_y, i); | 816 av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding intra block: %d x %d (%d)\n", s->mb_x, s->mb_y, i); |
817 return -1; | 817 return -1; |
818 } | 818 } |
819 } | 819 } |