comparison h261.c @ 2046:863ce5459aec libavcodec

simplify
author michael
date Sun, 30 May 2004 21:39:38 +0000
parents 9447bbd8a7e9
children 541686b38a5e
comparison
equal deleted inserted replaced
2045:9447bbd8a7e9 2046:863ce5459aec
56 int last_bits; //bits left of the following frame in the last byte in this frame 56 int last_bits; //bits left of the following frame in the last byte in this frame
57 }H261Context; 57 }H261Context;
58 58
59 void ff_h261_loop_filter(H261Context * h){ 59 void ff_h261_loop_filter(H261Context * h){
60 MpegEncContext * const s = &h->s; 60 MpegEncContext * const s = &h->s;
61 int i;
62 const int linesize = s->linesize; 61 const int linesize = s->linesize;
63 const int uvlinesize= s->uvlinesize; 62 const int uvlinesize= s->uvlinesize;
64 uint8_t *dest_y = s->dest[0]; 63 uint8_t *dest_y = s->dest[0];
65 uint8_t *dest_cb= s->dest[1]; 64 uint8_t *dest_cb= s->dest[1];
66 uint8_t *dest_cr= s->dest[2]; 65 uint8_t *dest_cr= s->dest[2];
227 s->mv[0][0][1] = 0; 226 s->mv[0][0][1] = 0;
228 s->mb_skiped = 1; 227 s->mb_skiped = 1;
229 return 0; 228 return 0;
230 } 229 }
231 230
231 static int decode_mv_component(GetBitContext *gb, int v){
232 int mv_diff = get_vlc2(gb, h261_mv_vlc.table, H261_MV_VLC_BITS, 2);
233 mv_diff = mvmap[mv_diff];
234
235 if(mv_diff && !get_bits1(gb))
236 mv_diff= -mv_diff;
237
238 v += mv_diff;
239 if (v <=-16) v+= 32;
240 else if(v >= 16) v-= 32;
241
242 return v;
243 }
244
232 static int h261_decode_mb(H261Context *h, 245 static int h261_decode_mb(H261Context *h,
233 DCTELEM block[6][64]) 246 DCTELEM block[6][64])
234 { 247 {
235 MpegEncContext * const s = &h->s; 248 MpegEncContext * const s = &h->s;
236 int i, cbp, mv_x_diff, mv_y_diff, sign, xy; 249 int i, cbp, xy;
237 250
238 cbp = 63; 251 cbp = 63;
239 // Read mba 252 // Read mba
240 do{ 253 do{
241 h->mba_diff = get_vlc2(&s->gb, h261_mba_vlc.table, H261_MBA_VLC_BITS, 2)+1; 254 h->mba_diff = get_vlc2(&s->gb, h261_mba_vlc.table, H261_MBA_VLC_BITS, 2)+1;
286 { 299 {
287 h->current_mv_x = 0; 300 h->current_mv_x = 0;
288 h->current_mv_y = 0; 301 h->current_mv_y = 0;
289 } 302 }
290 303
291 mv_x_diff = get_vlc2(&s->gb, h261_mv_vlc.table, H261_MV_VLC_BITS, 2); 304 h->current_mv_x= decode_mv_component(&s->gb, h->current_mv_x);
292 mv_x_diff = mvmap[mv_x_diff]; 305 h->current_mv_y= decode_mv_component(&s->gb, h->current_mv_y);
293
294 if(mv_x_diff != 0){
295 sign = get_bits1(&s->gb);
296
297 if(!sign)
298 mv_x_diff= -mv_x_diff;
299 }
300
301 mv_y_diff = get_vlc2(&s->gb, h261_mv_vlc.table, H261_MV_VLC_BITS, 2);
302 mv_y_diff = mvmap[mv_y_diff];
303
304 if(mv_y_diff != 0){
305 sign = get_bits1(&s->gb);
306
307 if(!sign)
308 mv_y_diff= -mv_y_diff;
309 }
310
311 //mv's are in the range -15...15
312 if((h->current_mv_x + mv_x_diff > -16) && (h->current_mv_x + mv_x_diff < 16) )
313 h->current_mv_x += mv_x_diff;
314 else
315 h->current_mv_x += (mv_x_diff + (mv_x_diff > 0 ? -32 : 32));
316
317 if((h->current_mv_y + mv_y_diff > -16) && (h->current_mv_y + mv_y_diff < 16) )
318 h->current_mv_y += mv_y_diff;
319 else
320 h->current_mv_y += (mv_y_diff + (mv_y_diff>0 ? -32 : 32));
321 } 306 }
322 307
323 // Read cbp 308 // Read cbp
324 if ( HAS_CBP( h->mtype ) ){ 309 if ( HAS_CBP( h->mtype ) ){
325 cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1; 310 cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1;