~ubuntu-branches/ubuntu/trusty/gst-libav1.0/trusty-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/vp56.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-09-24 17:07:00 UTC
  • mfrom: (1.1.17) (7.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20130924170700-4dg62s3pwl0pdakz
Tags: 1.2.0-1
* New upstream stable release:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.2.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#include "avcodec.h"
27
27
#include "bytestream.h"
 
28
#include "internal.h"
28
29
 
29
30
#include "vp56.h"
30
31
#include "vp56data.h"
196
197
    s->macroblocks[row * s->mb_width + col].mv = s->mv[3];
197
198
 
198
199
    /* chroma vectors are average luma vectors */
199
 
    if (s->avctx->codec->id == CODEC_ID_VP5) {
 
200
    if (s->avctx->codec->id == AV_CODEC_ID_VP5) {
200
201
        s->mv[4].x = s->mv[5].x = RSHIFT(mv.x,2);
201
202
        s->mv[4].y = s->mv[5].y = RSHIFT(mv.y,2);
202
203
    } else {
268
269
 
269
270
    for (b=0; b<6; b++) {
270
271
        VP56RefDc *ab = &s->above_blocks[s->above_block_idx[b]];
271
 
        VP56RefDc *lb = &s->left_block[vp56_b6to4[b]];
 
272
        VP56RefDc *lb = &s->left_block[ff_vp56_b6to4[b]];
272
273
        int count = 0;
273
274
        int dc = 0;
274
275
        int i;
281
282
            dc += ab->dc_coeff;
282
283
            count++;
283
284
        }
284
 
        if (s->avctx->codec->id == CODEC_ID_VP5)
 
285
        if (s->avctx->codec->id == AV_CODEC_ID_VP5)
285
286
            for (i=0; i<2; i++)
286
287
                if (count < 2 && ref_frame == ab[-1+2*i].ref_frame) {
287
288
                    dc += ab[-1+2*i].dc_coeff;
288
289
                    count++;
289
290
                }
290
291
        if (count == 0)
291
 
            dc = s->prev_dc[vp56_b2p[b]][ref_frame];
 
292
            dc = s->prev_dc[ff_vp56_b2p[b]][ref_frame];
292
293
        else if (count == 2)
293
294
            dc /= 2;
294
295
 
295
296
        s->block_coeff[b][idx] += dc;
296
 
        s->prev_dc[vp56_b2p[b]][ref_frame] = s->block_coeff[b][idx];
 
297
        s->prev_dc[ff_vp56_b2p[b]][ref_frame] = s->block_coeff[b][idx];
297
298
        ab->dc_coeff = s->block_coeff[b][idx];
298
299
        ab->ref_frame = ref_frame;
299
300
        lb->dc_coeff = s->block_coeff[b][idx];
339
340
 
340
341
    if (x<0 || x+12>=s->plane_width[plane] ||
341
342
        y<0 || y+12>=s->plane_height[plane]) {
342
 
        s->dsp.emulated_edge_mc(s->edge_emu_buffer,
 
343
        s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
343
344
                            src + s->block_offset[b] + (dy-2)*stride + (dx-2),
344
345
                            stride, 12, 12, x, y,
345
346
                            s->plane_width[plane],
410
411
    switch (mb_type) {
411
412
        case VP56_MB_INTRA:
412
413
            for (b=0; b<b_max; b++) {
413
 
                plane = vp56_b2p[b+ab];
414
 
                s->dsp.idct_put(frame_current->data[plane] + s->block_offset[b],
 
414
                plane = ff_vp56_b2p[b+ab];
 
415
                s->vp3dsp.idct_put(frame_current->data[plane] + s->block_offset[b],
415
416
                                s->stride[plane], s->block_coeff[b]);
416
417
            }
417
418
            break;
419
420
        case VP56_MB_INTER_NOVEC_PF:
420
421
        case VP56_MB_INTER_NOVEC_GF:
421
422
            for (b=0; b<b_max; b++) {
422
 
                plane = vp56_b2p[b+ab];
 
423
                plane = ff_vp56_b2p[b+ab];
423
424
                off = s->block_offset[b];
424
425
                s->dsp.put_pixels_tab[1][0](frame_current->data[plane] + off,
425
426
                                            frame_ref->data[plane] + off,
426
427
                                            s->stride[plane], 8);
427
 
                s->dsp.idct_add(frame_current->data[plane] + off,
 
428
                s->vp3dsp.idct_add(frame_current->data[plane] + off,
428
429
                                s->stride[plane], s->block_coeff[b]);
429
430
            }
430
431
            break;
439
440
            for (b=0; b<b_max; b++) {
440
441
                int x_off = b==1 || b==3 ? 8 : 0;
441
442
                int y_off = b==2 || b==3 ? 8 : 0;
442
 
                plane = vp56_b2p[b+ab];
 
443
                plane = ff_vp56_b2p[b+ab];
443
444
                vp56_mc(s, b, plane, frame_ref->data[plane], s->stride[plane],
444
445
                        16*col+x_off, 16*row+y_off);
445
 
                s->dsp.idct_add(frame_current->data[plane] + s->block_offset[b],
 
446
                s->vp3dsp.idct_add(frame_current->data[plane] + s->block_offset[b],
446
447
                                s->stride[plane], s->block_coeff[b]);
447
448
            }
448
449
            break;
486
487
    return 0;
487
488
}
488
489
 
489
 
int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
 
490
int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
490
491
                         AVPacket *avpkt)
491
492
{
492
493
    const uint8_t *buf = avpkt->data;
536
537
 
537
538
        if (!is_alpha) {
538
539
            p->reference = 1;
539
 
            if (avctx->get_buffer(avctx, p) < 0) {
 
540
            if (ff_get_buffer(avctx, p) < 0) {
540
541
                av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
541
542
                return -1;
542
543
            }
659
660
    p->qscale_table = s->qscale_table;
660
661
    p->qscale_type = FF_QSCALE_TYPE_VP56;
661
662
    *(AVFrame*)data = *p;
662
 
    *data_size = sizeof(AVFrame);
 
663
    *got_frame = 1;
663
664
 
664
665
    return avpkt->size;
665
666
}
670
671
    int i;
671
672
 
672
673
    s->avctx = avctx;
673
 
    avctx->pix_fmt = has_alpha ? PIX_FMT_YUVA420P : PIX_FMT_YUV420P;
 
674
    avctx->pix_fmt = has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P;
674
675
 
675
 
    if (avctx->idct_algo == FF_IDCT_AUTO)
676
 
        avctx->idct_algo = FF_IDCT_VP3;
677
 
    dsputil_init(&s->dsp, avctx);
 
676
    ff_dsputil_init(&s->dsp, avctx);
 
677
    ff_videodsp_init(&s->vdsp, 8);
 
678
    ff_vp3dsp_init(&s->vp3dsp, avctx->flags);
678
679
    ff_vp56dsp_init(&s->vp56dsp, avctx->codec->id);
 
680
    ff_init_scantable_permutation(s->dsp.idct_permutation, s->vp3dsp.idct_perm);
679
681
    ff_init_scantable(s->dsp.idct_permutation, &s->scantable,ff_zigzag_direct);
680
682
 
681
683
    for (i=0; i<4; i++)