~noskcaj/ubuntu/saucy/libav/merge0.8.7-1

« back to all changes in this revision

Viewing changes to libavcodec/svq3.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:30:00 UTC
  • mfrom: (1.2.8) (1.1.13 experimental)
  • Revision ID: package-import@ubuntu.com-20120112223000-cmfo7w78q13i2fd9
Tags: 4:0.8~beta2-1ubuntu1
* Merge from debian, remaining changes:
  - don't build against libdirac, lame, libopenjpeg, librtmp, 
    x264, and xvid  (all in universe)

Show diffs side-by-side

added added

removed removed

Lines of Context:
288
288
    }
289
289
 
290
290
    /* form component predictions */
291
 
    dest = s->current_picture.data[0] + x + y*s->linesize;
292
 
    src  = pic->data[0] + mx + my*s->linesize;
 
291
    dest = s->current_picture.f.data[0] + x + y*s->linesize;
 
292
    src  = pic->f.data[0] + mx + my*s->linesize;
293
293
 
294
294
    if (emu) {
295
295
        s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, (width + 1), (height + 1),
309
309
        blocksize++;
310
310
 
311
311
        for (i = 1; i < 3; i++) {
312
 
            dest = s->current_picture.data[i] + (x >> 1) + (y >> 1)*s->uvlinesize;
313
 
            src  = pic->data[i] + mx + my*s->uvlinesize;
 
312
            dest = s->current_picture.f.data[i] + (x >> 1) + (y >> 1) * s->uvlinesize;
 
313
            src  = pic->f.data[i] + mx + my * s->uvlinesize;
314
314
 
315
315
            if (emu) {
316
316
                s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->uvlinesize, (width + 1), (height + 1),
347
347
            if (mode != PREDICT_MODE) {
348
348
                pred_motion(h, k, (part_width >> 2), dir, 1, &mx, &my);
349
349
            } else {
350
 
                mx = s->next_picture.motion_val[0][b_xy][0]<<1;
351
 
                my = s->next_picture.motion_val[0][b_xy][1]<<1;
 
350
                mx = s->next_picture.f.motion_val[0][b_xy][0] << 1;
 
351
                my = s->next_picture.f.motion_val[0][b_xy][1] << 1;
352
352
 
353
353
                if (dir == 0) {
354
354
                    mx = ((mx * h->frame_num_offset) / h->prev_frame_num_offset + 1) >> 1;
425
425
            }
426
426
 
427
427
            /* write back motion vectors */
428
 
            fill_rectangle(s->current_picture.motion_val[dir][b_xy], part_width>>2, part_height>>2, h->b_stride, pack16to32(mx,my), 4);
 
428
            fill_rectangle(s->current_picture.f.motion_val[dir][b_xy],
 
429
                           part_width >> 2, part_height >> 2, h->b_stride,
 
430
                           pack16to32(mx, my), 4);
429
431
        }
430
432
    }
431
433
 
448
450
    h->topright_samples_available = 0xFFFF;
449
451
 
450
452
    if (mb_type == 0) {           /* SKIP */
451
 
        if (s->pict_type == AV_PICTURE_TYPE_P || s->next_picture.mb_type[mb_xy] == -1) {
 
453
        if (s->pict_type == AV_PICTURE_TYPE_P || s->next_picture.f.mb_type[mb_xy] == -1) {
452
454
            svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 0, 0);
453
455
 
454
456
            if (s->pict_type == AV_PICTURE_TYPE_B) {
457
459
 
458
460
            mb_type = MB_TYPE_SKIP;
459
461
        } else {
460
 
            mb_type = FFMIN(s->next_picture.mb_type[mb_xy], 6);
 
462
            mb_type = FFMIN(s->next_picture.f.mb_type[mb_xy], 6);
461
463
            if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 0, 0) < 0)
462
464
                return -1;
463
465
            if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 1, 1) < 0)
486
488
        for (m = 0; m < 2; m++) {
487
489
            if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) {
488
490
                for (i = 0; i < 4; i++) {
489
 
                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - 1 + i*h->b_stride];
 
491
                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - 1 + i*h->b_stride];
490
492
                }
491
493
            } else {
492
494
                for (i = 0; i < 4; i++) {
494
496
                }
495
497
            }
496
498
            if (s->mb_y > 0) {
497
 
                memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t));
 
499
                memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t));
498
500
                memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);
499
501
 
500
502
                if (s->mb_x < (s->mb_width - 1)) {
501
 
                    *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride + 4];
 
503
                    *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4];
502
504
                    h->ref_cache[m][scan8[0] + 4 - 1*8] =
503
505
                        (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 ||
504
506
                         h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride    ]  ] == -1) ? PART_NOT_AVAILABLE : 1;
505
507
                }else
506
508
                    h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE;
507
509
                if (s->mb_x > 0) {
508
 
                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride - 1];
 
510
                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1];
509
511
                    h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1;
510
512
                }else
511
513
                    h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE;
526
528
                    return -1;
527
529
            } else {
528
530
                for (i = 0; i < 4; i++) {
529
 
                    memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
 
531
                    memset(s->current_picture.f.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
530
532
                }
531
533
            }
532
534
            if (mb_type != 1) {
534
536
                    return -1;
535
537
            } else {
536
538
                for (i = 0; i < 4; i++) {
537
 
                    memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
 
539
                    memset(s->current_picture.f.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
538
540
                }
539
541
            }
540
542
        }
589
591
            }
590
592
        }
591
593
 
592
 
        ff_h264_write_back_intra_pred_mode(h);
 
594
        write_back_intra_pred_mode(h);
593
595
 
594
596
        if (mb_type == 8) {
595
597
            ff_h264_check_intra4x4_pred_mode(h);
621
623
 
622
624
    if (!IS_INTER(mb_type) && s->pict_type != AV_PICTURE_TYPE_I) {
623
625
        for (i = 0; i < 4; i++) {
624
 
            memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
 
626
            memset(s->current_picture.f.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
625
627
        }
626
628
        if (s->pict_type == AV_PICTURE_TYPE_B) {
627
629
            for (i = 0; i < 4; i++) {
628
 
                memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
 
630
                memset(s->current_picture.f.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
629
631
            }
630
632
        }
631
633
    }
706
708
    }
707
709
 
708
710
    h->cbp= cbp;
709
 
    s->current_picture.mb_type[mb_xy] = mb_type;
 
711
    s->current_picture.f.mb_type[mb_xy] = mb_type;
710
712
 
711
713
    if (IS_INTRA(mb_type)) {
712
714
        h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8);
922
924
 
923
925
        h->b_stride = 4*s->mb_width;
924
926
 
925
 
        ff_h264_alloc_tables(h);
 
927
        if (ff_h264_alloc_tables(h) < 0) {
 
928
            av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n");
 
929
            return AVERROR(ENOMEM);
 
930
        }
926
931
    }
927
932
 
928
933
    return 0;
966
971
    }
967
972
 
968
973
    /* for skipping the frame */
969
 
    s->current_picture.pict_type = s->pict_type;
970
 
    s->current_picture.key_frame = (s->pict_type == AV_PICTURE_TYPE_I);
 
974
    s->current_picture.f.pict_type = s->pict_type;
 
975
    s->current_picture.f.key_frame = (s->pict_type == AV_PICTURE_TYPE_I);
971
976
 
972
977
    /* Skip B-frames if we do not have reference frames. */
973
978
    if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B)
1051
1056
            }
1052
1057
 
1053
1058
            if (s->pict_type != AV_PICTURE_TYPE_B && !s->low_delay) {
1054
 
                s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
 
1059
                s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
1055
1060
                    (s->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;
1056
1061
            }
1057
1062
        }
1089
1094
}
1090
1095
 
1091
1096
AVCodec ff_svq3_decoder = {
1092
 
    "svq3",
1093
 
    AVMEDIA_TYPE_VIDEO,
1094
 
    CODEC_ID_SVQ3,
1095
 
    sizeof(SVQ3Context),
1096
 
    svq3_decode_init,
1097
 
    NULL,
1098
 
    svq3_decode_end,
1099
 
    svq3_decode_frame,
1100
 
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
 
1097
    .name           = "svq3",
 
1098
    .type           = AVMEDIA_TYPE_VIDEO,
 
1099
    .id             = CODEC_ID_SVQ3,
 
1100
    .priv_data_size = sizeof(SVQ3Context),
 
1101
    .init           = svq3_decode_init,
 
1102
    .close          = svq3_decode_end,
 
1103
    .decode         = svq3_decode_frame,
 
1104
    .capabilities   = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
1101
1105
    .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3"),
1102
1106
    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_NONE},
1103
1107
};