Revision 356ab1da

View differences:

libavcodec/mpeg12.c
375 375

  
376 376
            /* motion vectors */
377 377
            s->mv_dir = 0;
378
            for(i=0;i<2;i++) {
379
                if (USES_LIST(mb_type, i)) {
380
                    s->mv_dir |= (MV_DIR_FORWARD >> i);
381
                    dprintf(s->avctx, "motion_type=%d\n", motion_type);
382
                    switch(motion_type) {
383
                    case MT_FRAME: /* or MT_16X8 */
378
            dprintf(s->avctx, "motion_type=%d\n", motion_type);
379
            switch(motion_type) {
380
            case MT_FRAME: /* or MT_16X8 */
381
                for(i=0;i<2;i++) {
382
                    if (USES_LIST(mb_type, i)) {
383
                        s->mv_dir |= (MV_DIR_FORWARD >> i);
384 384
                        if (s->picture_structure == PICT_FRAME) {
385 385
                            /* MT_FRAME */
386 386
                            mb_type |= MB_TYPE_16x16;
......
408 408
                                }
409 409
                            }
410 410
                        }
411
                        break;
412
                    case MT_FIELD:
413
                        s->mv_type = MV_TYPE_FIELD;
411
                    }
412
                }
413
                break;
414
            case MT_FIELD:
415
                s->mv_type = MV_TYPE_FIELD;
416
                for(i=0;i<2;i++) {
417
                    if (USES_LIST(mb_type, i)) {
418
                        s->mv_dir |= (MV_DIR_FORWARD >> i);
414 419
                        if (s->picture_structure == PICT_FRAME) {
415 420
                            mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
416 421
                            for(j=0;j<2;j++) {
......
437 442
                                s->mv[i][0][k] = val;
438 443
                            }
439 444
                        }
440
                        break;
441
                    case MT_DMV:
442
                        {
443
                            int dmx, dmy, mx, my, m;
444

  
445
                            mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
446
                                                    s->last_mv[i][0][0]);
447
                            s->last_mv[i][0][0] = mx;
448
                            s->last_mv[i][1][0] = mx;
449
                            dmx = get_dmv(s);
450
                            my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
451
                                                    s->last_mv[i][0][1] >> 1);
452
                            dmy = get_dmv(s);
453
                            s->mv_type = MV_TYPE_DMV;
454

  
455

  
456
                            s->last_mv[i][0][1] = my<<1;
457
                            s->last_mv[i][1][1] = my<<1;
458

  
459
                            s->mv[i][0][0] = mx;
460
                            s->mv[i][0][1] = my;
461
                            s->mv[i][1][0] = mx;//not used
462
                            s->mv[i][1][1] = my;//not used
463

  
464
                            if (s->picture_structure == PICT_FRAME) {
465
                                mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
466

  
467
                                //m = 1 + 2 * s->top_field_first;
468
                                m = s->top_field_first ? 1 : 3;
469

  
470
                                /* top -> top pred */
471
                                s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
472
                                s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
473
                                m = 4 - m;
474
                                s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
475
                                s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
476
                            } else {
477
                                mb_type |= MB_TYPE_16x16;
478

  
479
                                s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
480
                                s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
481
                                if(s->picture_structure == PICT_TOP_FIELD)
482
                                    s->mv[i][2][1]--;
483
                                else
484
                                    s->mv[i][2][1]++;
485
                            }
445
                    }
446
                }
447
                break;
448
            case MT_DMV:
449
                s->mv_type = MV_TYPE_DMV;
450
                for(i=0;i<2;i++) {
451
                    if (USES_LIST(mb_type, i)) {
452
                        int dmx, dmy, mx, my, m;
453
                        s->mv_dir |= (MV_DIR_FORWARD >> i);
454
                        mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
455
                                                s->last_mv[i][0][0]);
456
                        s->last_mv[i][0][0] = mx;
457
                        s->last_mv[i][1][0] = mx;
458
                        dmx = get_dmv(s);
459
                        my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
460
                                                s->last_mv[i][0][1] >> 1);
461
                        dmy = get_dmv(s);
462

  
463

  
464
                        s->last_mv[i][0][1] = my<<1;
465
                        s->last_mv[i][1][1] = my<<1;
466

  
467
                        s->mv[i][0][0] = mx;
468
                        s->mv[i][0][1] = my;
469
                        s->mv[i][1][0] = mx;//not used
470
                        s->mv[i][1][1] = my;//not used
471

  
472
                        if (s->picture_structure == PICT_FRAME) {
473
                            mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
474

  
475
                            //m = 1 + 2 * s->top_field_first;
476
                            m = s->top_field_first ? 1 : 3;
477

  
478
                            /* top -> top pred */
479
                            s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
480
                            s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
481
                            m = 4 - m;
482
                            s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
483
                            s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
484
                        } else {
485
                            mb_type |= MB_TYPE_16x16;
486

  
487
                            s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
488
                            s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
489
                            if(s->picture_structure == PICT_TOP_FIELD)
490
                                s->mv[i][2][1]--;
491
                            else
492
                                s->mv[i][2][1]++;
486 493
                        }
487
                        break;
488
                    default:
489
                        av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
490
                        return -1;
491 494
                    }
492 495
                }
496
                break;
497
            default:
498
                av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
499
                return -1;
493 500
            }
494 501
        }
495 502

  

Also available in: Unified diff