comparison mpegvideo.c @ 664:00a882f626bd libavcodec

interlaced mpeg4 b frame decoding
author michaelni
date Fri, 13 Sep 2002 09:45:32 +0000
parents a0901e38c564
children 3f2e5a282f61
comparison
equal deleted inserted replaced
663:76fef3b11680 664:00a882f626bd
257 CHECKED_ALLOCZ(s->mb_type , s->mb_num * sizeof(UINT8)) 257 CHECKED_ALLOCZ(s->mb_type , s->mb_num * sizeof(UINT8))
258 258
259 /* MV prediction */ 259 /* MV prediction */
260 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); 260 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
261 CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(INT16)); 261 CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(INT16));
262 262 }
263 /* 4mv direct mode decoding table */ 263
264 CHECKED_ALLOCZ(s->non_b_mv4_table, size * sizeof(UINT8)) 264 if(s->codec_id==CODEC_ID_MPEG4){
265 /* 4mv and interlaced direct mode decoding tables */
266 CHECKED_ALLOCZ(s->co_located_type_table, s->mb_num * sizeof(UINT8))
267 CHECKED_ALLOCZ(s->field_mv_table, s->mb_num*2*2 * sizeof(INT16))
268 CHECKED_ALLOCZ(s->field_select_table, s->mb_num*2* sizeof(INT8))
265 } 269 }
266 270
267 if (s->h263_pred || s->h263_plus) { 271 if (s->h263_pred || s->h263_plus) {
268 int y_size, c_size, i, size; 272 int y_size, c_size, i, size;
269 273
348 av_freep(&s->mbskip_table); 352 av_freep(&s->mbskip_table);
349 av_freep(&s->bitstream_buffer); 353 av_freep(&s->bitstream_buffer);
350 av_freep(&s->tex_pb_buffer); 354 av_freep(&s->tex_pb_buffer);
351 av_freep(&s->pb2_buffer); 355 av_freep(&s->pb2_buffer);
352 av_freep(&s->edge_emu_buffer); 356 av_freep(&s->edge_emu_buffer);
353 av_freep(&s->non_b_mv4_table); 357 av_freep(&s->co_located_type_table);
358 av_freep(&s->field_mv_table);
359 av_freep(&s->field_select_table);
354 av_freep(&s->avctx->stats_out); 360 av_freep(&s->avctx->stats_out);
355 av_freep(&s->ac_stats); 361 av_freep(&s->ac_stats);
356 362
357 for(i=0;i<3;i++) { 363 for(i=0;i<3;i++) {
358 int j; 364 int j;
1464 /* update motion predictor, not for B-frames as they need the motion_val from the last P/S-Frame */ 1470 /* update motion predictor, not for B-frames as they need the motion_val from the last P/S-Frame */
1465 if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE) { //FIXME move into h263.c if possible, format specific stuff shouldnt be here 1471 if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE) { //FIXME move into h263.c if possible, format specific stuff shouldnt be here
1466 1472
1467 const int wrap = s->block_wrap[0]; 1473 const int wrap = s->block_wrap[0];
1468 const int xy = s->block_index[0]; 1474 const int xy = s->block_index[0];
1475 const int mb_index= s->mb_x + s->mb_y*s->mb_width;
1469 if(s->mv_type == MV_TYPE_8X8){ 1476 if(s->mv_type == MV_TYPE_8X8){
1470 s->non_b_mv4_table[xy]=1; 1477 s->co_located_type_table[mb_index]= CO_LOCATED_TYPE_4MV;
1471 } else { 1478 } else {
1472 int motion_x, motion_y; 1479 int motion_x, motion_y;
1473 if (s->mb_intra) { 1480 if (s->mb_intra) {
1474 motion_x = 0; 1481 motion_x = 0;
1475 motion_y = 0; 1482 motion_y = 0;
1483 if(s->co_located_type_table)
1484 s->co_located_type_table[mb_index]= 0;
1476 } else if (s->mv_type == MV_TYPE_16X16) { 1485 } else if (s->mv_type == MV_TYPE_16X16) {
1477 motion_x = s->mv[0][0][0]; 1486 motion_x = s->mv[0][0][0];
1478 motion_y = s->mv[0][0][1]; 1487 motion_y = s->mv[0][0][1];
1488 if(s->co_located_type_table)
1489 s->co_located_type_table[mb_index]= 0;
1479 } else /*if (s->mv_type == MV_TYPE_FIELD)*/ { 1490 } else /*if (s->mv_type == MV_TYPE_FIELD)*/ {
1491 int i;
1480 motion_x = s->mv[0][0][0] + s->mv[0][1][0]; 1492 motion_x = s->mv[0][0][0] + s->mv[0][1][0];
1481 motion_y = s->mv[0][0][1] + s->mv[0][1][1]; 1493 motion_y = s->mv[0][0][1] + s->mv[0][1][1];
1482 motion_x = (motion_x>>1) | (motion_x&1); 1494 motion_x = (motion_x>>1) | (motion_x&1);
1495 for(i=0; i<2; i++){
1496 s->field_mv_table[mb_index][i][0]= s->mv[0][i][0];
1497 s->field_mv_table[mb_index][i][1]= s->mv[0][i][1];
1498 s->field_select_table[mb_index][i]= s->field_select[0][i];
1499 }
1500 s->co_located_type_table[mb_index]= CO_LOCATED_TYPE_FIELDMV;
1483 } 1501 }
1484 /* no update if 8X8 because it has been done during parsing */ 1502 /* no update if 8X8 because it has been done during parsing */
1485 s->motion_val[xy][0] = motion_x; 1503 s->motion_val[xy][0] = motion_x;
1486 s->motion_val[xy][1] = motion_y; 1504 s->motion_val[xy][1] = motion_y;
1487 s->motion_val[xy + 1][0] = motion_x; 1505 s->motion_val[xy + 1][0] = motion_x;
1488 s->motion_val[xy + 1][1] = motion_y; 1506 s->motion_val[xy + 1][1] = motion_y;
1489 s->motion_val[xy + wrap][0] = motion_x; 1507 s->motion_val[xy + wrap][0] = motion_x;
1490 s->motion_val[xy + wrap][1] = motion_y; 1508 s->motion_val[xy + wrap][1] = motion_y;
1491 s->motion_val[xy + 1 + wrap][0] = motion_x; 1509 s->motion_val[xy + 1 + wrap][0] = motion_x;
1492 s->motion_val[xy + 1 + wrap][1] = motion_y; 1510 s->motion_val[xy + 1 + wrap][1] = motion_y;
1493 s->non_b_mv4_table[xy]=0;
1494 } 1511 }
1495 } 1512 }
1496 1513
1497 if (!(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { 1514 if (!(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) {
1498 UINT8 *dest_y, *dest_cb, *dest_cr; 1515 UINT8 *dest_y, *dest_cb, *dest_cr;