~ubuntu-branches/debian/experimental/libav/experimental

« back to all changes in this revision

Viewing changes to libavcodec/vc1dec.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2014-08-10 09:45:02 UTC
  • mfrom: (1.1.28) (2.1.45 sid)
  • Revision ID: package-import@ubuntu.com-20140810094502-p8pds4kq0zpig5oq
Tags: 6:11~alpha1-1
* New upstream Release v11
  - Fixes Unchecked conversion from double to enum (Closes: #749164)
* Add some post v11_alpha1 patches from upstream
* All SONAMEs bumped because of internal changes, but external API is
  promised to have not changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "internal.h"
30
30
#include "avcodec.h"
31
31
#include "error_resilience.h"
 
32
#include "mpeg_er.h"
 
33
#include "mpegutils.h"
32
34
#include "mpegvideo.h"
33
35
#include "h263.h"
34
36
#include "h264chroma.h"
 
37
#include "qpeldsp.h"
35
38
#include "vc1.h"
36
39
#include "vc1data.h"
37
40
#include "vc1acdata.h"
77
80
    MpegEncContext *s = &v->s;
78
81
    ff_init_block_index(s);
79
82
    if (v->field_mode && !(v->second_field ^ v->tff)) {
80
 
        s->dest[0] += s->current_picture_ptr->f.linesize[0];
81
 
        s->dest[1] += s->current_picture_ptr->f.linesize[1];
82
 
        s->dest[2] += s->current_picture_ptr->f.linesize[2];
 
83
        s->dest[0] += s->current_picture_ptr->f->linesize[0];
 
84
        s->dest[1] += s->current_picture_ptr->f->linesize[1];
 
85
        s->dest[2] += s->current_picture_ptr->f->linesize[2];
83
86
    }
84
87
}
85
88
 
106
109
                fieldtx = v->fieldtx_plane[topleft_mb_pos];
107
110
            stride_y       = s->linesize << fieldtx;
108
111
            v_dist         = (16 - fieldtx) >> (fieldtx == 0);
109
 
            s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],
110
 
                                             s->dest[0] - 16 * s->linesize - 16,
111
 
                                             stride_y);
112
 
            s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1],
113
 
                                             s->dest[0] - 16 * s->linesize - 8,
114
 
                                             stride_y);
115
 
            s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2],
116
 
                                             s->dest[0] - v_dist * s->linesize - 16,
117
 
                                             stride_y);
118
 
            s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3],
119
 
                                             s->dest[0] - v_dist * s->linesize - 8,
120
 
                                             stride_y);
121
 
            s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4],
122
 
                                             s->dest[1] - 8 * s->uvlinesize - 8,
123
 
                                             s->uvlinesize);
124
 
            s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][5],
125
 
                                             s->dest[2] - 8 * s->uvlinesize - 8,
126
 
                                             s->uvlinesize);
 
112
            s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],
 
113
                                              s->dest[0] - 16 * s->linesize - 16,
 
114
                                              stride_y);
 
115
            s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1],
 
116
                                              s->dest[0] - 16 * s->linesize - 8,
 
117
                                              stride_y);
 
118
            s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2],
 
119
                                              s->dest[0] - v_dist * s->linesize - 16,
 
120
                                              stride_y);
 
121
            s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3],
 
122
                                              s->dest[0] - v_dist * s->linesize - 8,
 
123
                                              stride_y);
 
124
            s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4],
 
125
                                              s->dest[1] - 8 * s->uvlinesize - 8,
 
126
                                              s->uvlinesize);
 
127
            s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][5],
 
128
                                              s->dest[2] - 8 * s->uvlinesize - 8,
 
129
                                              s->uvlinesize);
127
130
        }
128
131
        if (s->mb_x == s->mb_width - 1) {
129
132
            top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x;
131
134
                fieldtx = v->fieldtx_plane[top_mb_pos];
132
135
            stride_y   = s->linesize << fieldtx;
133
136
            v_dist     = fieldtx ? 15 : 8;
134
 
            s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0],
135
 
                                             s->dest[0] - 16 * s->linesize,
136
 
                                             stride_y);
137
 
            s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1],
138
 
                                             s->dest[0] - 16 * s->linesize + 8,
139
 
                                             stride_y);
140
 
            s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2],
141
 
                                             s->dest[0] - v_dist * s->linesize,
142
 
                                             stride_y);
143
 
            s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3],
144
 
                                             s->dest[0] - v_dist * s->linesize + 8,
145
 
                                             stride_y);
146
 
            s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4],
147
 
                                             s->dest[1] - 8 * s->uvlinesize,
148
 
                                             s->uvlinesize);
149
 
            s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5],
150
 
                                             s->dest[2] - 8 * s->uvlinesize,
151
 
                                             s->uvlinesize);
 
137
            s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0],
 
138
                                              s->dest[0] - 16 * s->linesize,
 
139
                                              stride_y);
 
140
            s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1],
 
141
                                              s->dest[0] - 16 * s->linesize + 8,
 
142
                                              stride_y);
 
143
            s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2],
 
144
                                              s->dest[0] - v_dist * s->linesize,
 
145
                                              stride_y);
 
146
            s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3],
 
147
                                              s->dest[0] - v_dist * s->linesize + 8,
 
148
                                              stride_y);
 
149
            s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4],
 
150
                                              s->dest[1] - 8 * s->uvlinesize,
 
151
                                              s->uvlinesize);
 
152
            s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5],
 
153
                                              s->dest[2] - 8 * s->uvlinesize,
 
154
                                              s->uvlinesize);
152
155
        }
153
156
    }
154
157
 
352
355
 
353
356
    if ((!v->field_mode ||
354
357
         (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
355
 
        !v->s.last_picture.f.data[0])
 
358
        !v->s.last_picture.f->data[0])
356
359
        return;
357
360
 
358
361
    mx = s->mv[dir][0][0];
384
387
    }
385
388
    if (!dir) {
386
389
        if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
387
 
            srcY = s->current_picture.f.data[0];
388
 
            srcU = s->current_picture.f.data[1];
389
 
            srcV = s->current_picture.f.data[2];
 
390
            srcY = s->current_picture.f->data[0];
 
391
            srcU = s->current_picture.f->data[1];
 
392
            srcV = s->current_picture.f->data[2];
390
393
            luty  = v->curr_luty;
391
394
            lutuv = v->curr_lutuv;
392
395
            use_ic = v->curr_use_ic;
393
396
        } else {
394
 
            srcY = s->last_picture.f.data[0];
395
 
            srcU = s->last_picture.f.data[1];
396
 
            srcV = s->last_picture.f.data[2];
 
397
            srcY = s->last_picture.f->data[0];
 
398
            srcU = s->last_picture.f->data[1];
 
399
            srcV = s->last_picture.f->data[2];
397
400
            luty  = v->last_luty;
398
401
            lutuv = v->last_lutuv;
399
402
            use_ic = v->last_use_ic;
400
403
        }
401
404
    } else {
402
 
        srcY = s->next_picture.f.data[0];
403
 
        srcU = s->next_picture.f.data[1];
404
 
        srcV = s->next_picture.f.data[2];
 
405
        srcY = s->next_picture.f->data[0];
 
406
        srcU = s->next_picture.f->data[1];
 
407
        srcV = s->next_picture.f->data[2];
405
408
        luty  = v->next_luty;
406
409
        lutuv = v->next_lutuv;
407
410
        use_ic = v->next_use_ic;
434
437
    srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
435
438
 
436
439
    if (v->field_mode && v->ref_field_type[dir]) {
437
 
        srcY += s->current_picture_ptr->f.linesize[0];
438
 
        srcU += s->current_picture_ptr->f.linesize[1];
439
 
        srcV += s->current_picture_ptr->f.linesize[2];
 
440
        srcY += s->current_picture_ptr->f->linesize[0];
 
441
        srcU += s->current_picture_ptr->f->linesize[1];
 
442
        srcV += s->current_picture_ptr->f->linesize[2];
440
443
    }
441
444
 
442
445
    /* for grayscale we should not try to read from unknown area */
571
574
 
572
575
    if ((!v->field_mode ||
573
576
         (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
574
 
        !v->s.last_picture.f.data[0])
 
577
        !v->s.last_picture.f->data[0])
575
578
        return;
576
579
 
577
580
    mx = s->mv[dir][n][0];
579
582
 
580
583
    if (!dir) {
581
584
        if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
582
 
            srcY = s->current_picture.f.data[0];
 
585
            srcY = s->current_picture.f->data[0];
583
586
            luty = v->curr_luty;
584
587
            use_ic = v->curr_use_ic;
585
588
        } else {
586
 
            srcY = s->last_picture.f.data[0];
 
589
            srcY = s->last_picture.f->data[0];
587
590
            luty = v->last_luty;
588
591
            use_ic = v->last_use_ic;
589
592
        }
590
593
    } else {
591
 
        srcY = s->next_picture.f.data[0];
 
594
        srcY = s->next_picture.f->data[0];
592
595
        luty = v->next_luty;
593
596
        use_ic = v->next_use_ic;
594
597
    }
686
689
 
687
690
    srcY += src_y * s->linesize + src_x;
688
691
    if (v->field_mode && v->ref_field_type[dir])
689
 
        srcY += s->current_picture_ptr->f.linesize[0];
 
692
        srcY += s->current_picture_ptr->f->linesize[0];
690
693
 
691
694
    if (fieldmv && !(src_y & 1))
692
695
        v_edge_pos--;
816
819
    uint8_t (*lutuv)[256];
817
820
    int use_ic;
818
821
 
819
 
    if (!v->field_mode && !v->s.last_picture.f.data[0])
 
822
    if (!v->field_mode && !v->s.last_picture.f->data[0])
820
823
        return;
821
824
    if (s->flags & CODEC_FLAG_GRAY)
822
825
        return;
847
850
        if (dominant)
848
851
            chroma_ref_type = !v->cur_field_type;
849
852
    }
850
 
    if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0])
 
853
    if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f->data[0])
851
854
        return;
852
855
    s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
853
856
    s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
878
881
 
879
882
    if (!dir) {
880
883
        if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) {
881
 
            srcU = s->current_picture.f.data[1];
882
 
            srcV = s->current_picture.f.data[2];
 
884
            srcU = s->current_picture.f->data[1];
 
885
            srcV = s->current_picture.f->data[2];
883
886
            lutuv = v->curr_lutuv;
884
887
            use_ic = v->curr_use_ic;
885
888
        } else {
886
 
            srcU = s->last_picture.f.data[1];
887
 
            srcV = s->last_picture.f.data[2];
 
889
            srcU = s->last_picture.f->data[1];
 
890
            srcV = s->last_picture.f->data[2];
888
891
            lutuv = v->last_lutuv;
889
892
            use_ic = v->last_use_ic;
890
893
        }
891
894
    } else {
892
 
        srcU = s->next_picture.f.data[1];
893
 
        srcV = s->next_picture.f.data[2];
 
895
        srcU = s->next_picture.f->data[1];
 
896
        srcV = s->next_picture.f->data[2];
894
897
        lutuv = v->next_lutuv;
895
898
        use_ic = v->next_use_ic;
896
899
    }
905
908
 
906
909
    if (v->field_mode) {
907
910
        if (chroma_ref_type) {
908
 
            srcU += s->current_picture_ptr->f.linesize[1];
909
 
            srcV += s->current_picture_ptr->f.linesize[2];
 
911
            srcU += s->current_picture_ptr->f->linesize[1];
 
912
            srcV += s->current_picture_ptr->f->linesize[2];
910
913
        }
911
914
    }
912
915
 
1011
1014
        uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width  >> 1);
1012
1015
        uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
1013
1016
        if (i < 2 ? dir : dir2) {
1014
 
            srcU = s->next_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
1015
 
            srcV = s->next_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
 
1017
            srcU = s->next_picture.f->data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
 
1018
            srcV = s->next_picture.f->data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
1016
1019
            lutuv  = v->next_lutuv;
1017
1020
            use_ic = v->next_use_ic;
1018
1021
        } else {
1019
 
            srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
1020
 
            srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
 
1022
            srcU = s->last_picture.f->data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
 
1023
            srcV = s->last_picture.f->data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
1021
1024
            lutuv  = v->last_lutuv;
1022
1025
            use_ic = v->last_use_ic;
1023
1026
        }
1867
1870
                } else if (c_valid) {
1868
1871
                    px = C[0];
1869
1872
                    py = C[1];
1870
 
                }
 
1873
                } else
 
1874
                    px = py = 0;
1871
1875
            }
1872
1876
        } else if (total_valid == 1) {
1873
1877
            px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
1906
1910
    int v_edge_pos = s->v_edge_pos >> v->field_mode;
1907
1911
    int use_ic = v->next_use_ic;
1908
1912
 
1909
 
    if (!v->field_mode && !v->s.next_picture.f.data[0])
 
1913
    if (!v->field_mode && !v->s.next_picture.f->data[0])
1910
1914
        return;
1911
1915
 
1912
1916
    mx   = s->mv[1][0][0];
1922
1926
        uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
1923
1927
        uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
1924
1928
    }
1925
 
    srcY = s->next_picture.f.data[0];
1926
 
    srcU = s->next_picture.f.data[1];
1927
 
    srcV = s->next_picture.f.data[2];
 
1929
    srcY = s->next_picture.f->data[0];
 
1930
    srcU = s->next_picture.f->data[1];
 
1931
    srcV = s->next_picture.f->data[2];
1928
1932
 
1929
1933
    src_x   = s->mb_x * 16 + (mx   >> 2);
1930
1934
    src_y   = s->mb_y * 16 + (my   >> 2);
1948
1952
    srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
1949
1953
 
1950
1954
    if (v->field_mode && v->ref_field_type[1]) {
1951
 
        srcY += s->current_picture_ptr->f.linesize[0];
1952
 
        srcU += s->current_picture_ptr->f.linesize[1];
1953
 
        srcV += s->current_picture_ptr->f.linesize[2];
 
1955
        srcY += s->current_picture_ptr->f->linesize[0];
 
1956
        srcU += s->current_picture_ptr->f->linesize[1];
 
1957
        srcV += s->current_picture_ptr->f->linesize[2];
1954
1958
    }
1955
1959
 
1956
1960
    /* for grayscale we should not try to read from unknown area */
3016
3020
    int scale;
3017
3021
    int q1, q2 = 0;
3018
3022
 
3019
 
    s->dsp.clear_block(block);
 
3023
    s->bdsp.clear_block(block);
3020
3024
 
3021
3025
    /* XXX: Guard against dumb values of mquant */
3022
3026
    mquant = (mquant < 1) ? 0 : ((mquant > 31) ? 31 : mquant);
3223
3227
    int ttblk = ttmb & 7;
3224
3228
    int pat = 0;
3225
3229
 
3226
 
    s->dsp.clear_block(block);
 
3230
    s->bdsp.clear_block(block);
3227
3231
 
3228
3232
    if (ttmb == -1) {
3229
3233
        ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index].table, VC1_TTBLK_VLC_BITS, 1)];
3276
3280
                v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);
3277
3281
            else {
3278
3282
                v->vc1dsp.vc1_inv_trans_8x8(block);
3279
 
                s->dsp.add_pixels_clamped(block, dst, linesize);
 
3283
                s->idsp.add_pixels_clamped(block, dst, linesize);
3280
3284
            }
3281
3285
        }
3282
3286
        break;
3607
3611
                    if (v->rangeredfrm)
3608
3612
                        for (j = 0; j < 64; j++)
3609
3613
                            s->block[i][j] <<= 1;
3610
 
                    s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
 
3614
                    s->idsp.put_signed_pixels_clamped(s->block[i],
 
3615
                                                      s->dest[dst_idx] + off,
 
3616
                                                      i & 4 ? s->uvlinesize
 
3617
                                                            : s->linesize);
3611
3618
                    if (v->pq >= 9 && v->overlap) {
3612
3619
                        if (v->c_avail)
3613
3620
                            v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
3715
3722
                    if (v->rangeredfrm)
3716
3723
                        for (j = 0; j < 64; j++)
3717
3724
                            s->block[i][j] <<= 1;
3718
 
                    s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off,
3719
 
                                                     (i & 4) ? s->uvlinesize : s->linesize);
 
3725
                    s->idsp.put_signed_pixels_clamped(s->block[i],
 
3726
                                                      s->dest[dst_idx] + off,
 
3727
                                                      (i & 4) ? s->uvlinesize
 
3728
                                                              : s->linesize);
3720
3729
                    if (v->pq >= 9 && v->overlap) {
3721
3730
                        if (v->c_avail)
3722
3731
                            v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
3865
3874
                    stride_y = s->uvlinesize;
3866
3875
                    off = 0;
3867
3876
                }
3868
 
                s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);
 
3877
                s->idsp.put_signed_pixels_clamped(s->block[i],
 
3878
                                                  s->dest[dst_idx] + off,
 
3879
                                                  stride_y);
3869
3880
                //TODO: loop filter
3870
3881
            }
3871
3882
 
4027
4038
                continue;
4028
4039
            v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
4029
4040
            off  = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
4030
 
            s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);
 
4041
            s->idsp.put_signed_pixels_clamped(s->block[i],
 
4042
                                              s->dest[dst_idx] + off,
 
4043
                                              (i & 4) ? s->uvlinesize
 
4044
                                                      : s->linesize);
4031
4045
            // TODO: loop filter
4032
4046
        }
4033
4047
    } else {
4229
4243
            if (v->rangeredfrm)
4230
4244
                for (j = 0; j < 64; j++)
4231
4245
                    s->block[i][j] <<= 1;
4232
 
            s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
 
4246
            s->idsp.put_signed_pixels_clamped(s->block[i],
 
4247
                                              s->dest[dst_idx] + off,
 
4248
                                              i & 4 ? s->uvlinesize
 
4249
                                                    : s->linesize);
4233
4250
        } else if (val) {
4234
4251
            vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
4235
4252
                               first_block, s->dest[dst_idx] + off,
4301
4318
                for (j = 0; j < 64; j++)
4302
4319
                    s->block[i][j] <<= 1;
4303
4320
            off  = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
4304
 
            s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);
 
4321
            s->idsp.put_signed_pixels_clamped(s->block[i],
 
4322
                                              s->dest[dst_idx] + off,
 
4323
                                              (i & 4) ? s->uvlinesize
 
4324
                                                      : s->linesize);
4305
4325
            // TODO: yet to perform loop filter
4306
4326
        }
4307
4327
    } else {
4520
4540
                stride_y = s->uvlinesize;
4521
4541
                off = 0;
4522
4542
            }
4523
 
            s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);
 
4543
            s->idsp.put_signed_pixels_clamped(s->block[i],
 
4544
                                              s->dest[dst_idx] + off,
 
4545
                                              stride_y);
4524
4546
        }
4525
4547
    } else {
4526
4548
        s->mb_intra = v->is_intra[s->mb_x] = 0;
4794
4816
            dst[3] = dst[2] + 8;
4795
4817
            dst[4] = s->dest[1];
4796
4818
            dst[5] = s->dest[2];
4797
 
            s->dsp.clear_blocks(s->block[0]);
 
4819
            s->bdsp.clear_blocks(s->block[0]);
4798
4820
            mb_pos = s->mb_x + s->mb_y * s->mb_width;
4799
4821
            s->current_picture.mb_type[mb_pos]                     = MB_TYPE_INTRA;
4800
4822
            s->current_picture.qscale_table[mb_pos]                = v->pq;
4824
4846
                    if (v->rangeredfrm)
4825
4847
                        for (j = 0; j < 64; j++)
4826
4848
                            s->block[k][j] <<= 1;
4827
 
                    s->dsp.put_signed_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize);
 
4849
                    s->idsp.put_signed_pixels_clamped(s->block[k], dst[k],
 
4850
                                                      k & 4 ? s->uvlinesize
 
4851
                                                            : s->linesize);
4828
4852
                } else {
4829
4853
                    if (v->rangeredfrm)
4830
4854
                        for (j = 0; j < 64; j++)
4831
4855
                            s->block[k][j] = (s->block[k][j] - 64) << 1;
4832
 
                    s->dsp.put_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize);
 
4856
                    s->idsp.put_pixels_clamped(s->block[k], dst[k],
 
4857
                                               k & 4 ? s->uvlinesize
 
4858
                                                     : s->linesize);
4833
4859
                }
4834
4860
            }
4835
4861
 
4934
4960
        for (;s->mb_x < s->mb_width; s->mb_x++) {
4935
4961
            int16_t (*block)[64] = v->block[v->cur_blk_idx];
4936
4962
            ff_update_block_index(s);
4937
 
            s->dsp.clear_blocks(block[0]);
 
4963
            s->bdsp.clear_blocks(block[0]);
4938
4964
            mb_pos = s->mb_x + s->mb_y * s->mb_stride;
4939
4965
            s->current_picture.mb_type[mb_pos + v->mb_off]                         = MB_TYPE_INTRA;
4940
4966
            s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
5158
5184
{
5159
5185
    MpegEncContext *s = &v->s;
5160
5186
 
5161
 
    if (!v->s.last_picture.f.data[0])
 
5187
    if (!v->s.last_picture.f->data[0])
5162
5188
        return;
5163
5189
 
5164
5190
    ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END);
5167
5193
        s->mb_x = 0;
5168
5194
        init_block_index(v);
5169
5195
        ff_update_block_index(s);
5170
 
        memcpy(s->dest[0], s->last_picture.f.data[0] + s->mb_y * 16 * s->linesize,   s->linesize   * 16);
5171
 
        memcpy(s->dest[1], s->last_picture.f.data[1] + s->mb_y *  8 * s->uvlinesize, s->uvlinesize *  8);
5172
 
        memcpy(s->dest[2], s->last_picture.f.data[2] + s->mb_y *  8 * s->uvlinesize, s->uvlinesize *  8);
 
5196
        memcpy(s->dest[0], s->last_picture.f->data[0] + s->mb_y * 16 * s->linesize,   s->linesize   * 16);
 
5197
        memcpy(s->dest[1], s->last_picture.f->data[1] + s->mb_y *  8 * s->uvlinesize, s->uvlinesize *  8);
 
5198
        memcpy(s->dest[2], s->last_picture.f->data[2] + s->mb_y *  8 * s->uvlinesize, s->uvlinesize *  8);
5173
5199
        ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
5174
5200
        s->first_slice_line = 0;
5175
5201
    }
5368
5394
                           v->sprite_output_frame->linesize[plane] * row;
5369
5395
 
5370
5396
            for (sprite = 0; sprite <= v->two_sprites; sprite++) {
5371
 
                uint8_t *iplane = s->current_picture.f.data[plane];
5372
 
                int      iline  = s->current_picture.f.linesize[plane];
 
5397
                uint8_t *iplane = s->current_picture.f->data[plane];
 
5398
                int      iline  = s->current_picture.f->linesize[plane];
5373
5399
                int      ycoord = yoff[sprite] + yadv[sprite] * row;
5374
5400
                int      yline  = ycoord >> 16;
5375
5401
                int      next_line;
5376
5402
                ysub[sprite] = ycoord & 0xFFFF;
5377
5403
                if (sprite) {
5378
 
                    iplane = s->last_picture.f.data[plane];
5379
 
                    iline  = s->last_picture.f.linesize[plane];
 
5404
                    iplane = s->last_picture.f->data[plane];
 
5405
                    iline  = s->last_picture.f->linesize[plane];
5380
5406
                }
5381
5407
                next_line = FFMIN(yline + 1, (v->sprite_height >> !!plane) - 1) * iline;
5382
5408
                if (!(xoff[sprite] & 0xFFFF) && xadv[sprite] == 1 << 16) {
5445
5471
 
5446
5472
    vc1_parse_sprites(v, gb, &sd);
5447
5473
 
5448
 
    if (!s->current_picture.f.data[0]) {
 
5474
    if (!s->current_picture.f->data[0]) {
5449
5475
        av_log(avctx, AV_LOG_ERROR, "Got no sprites\n");
5450
5476
        return -1;
5451
5477
    }
5452
5478
 
5453
 
    if (v->two_sprites && (!s->last_picture_ptr || !s->last_picture.f.data[0])) {
 
5479
    if (v->two_sprites && (!s->last_picture_ptr || !s->last_picture.f->data[0])) {
5454
5480
        av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n");
5455
5481
        v->two_sprites = 0;
5456
5482
    }
5470
5496
{
5471
5497
    VC1Context *v     = avctx->priv_data;
5472
5498
    MpegEncContext *s = &v->s;
5473
 
    AVFrame *f = &s->current_picture.f;
 
5499
    AVFrame *f = s->current_picture.f;
5474
5500
    int plane, i;
5475
5501
 
5476
5502
    /* Windows Media Image codecs have a convergence interval of two keyframes.
5593
5619
    if (!avctx->extradata_size || !avctx->extradata)
5594
5620
        return -1;
5595
5621
    if (!(avctx->flags & CODEC_FLAG_GRAY))
5596
 
        avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
 
5622
        avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
5597
5623
    else
5598
5624
        avctx->pix_fmt = AV_PIX_FMT_GRAY8;
5599
 
    avctx->hwaccel = ff_find_hwaccel(avctx);
5600
5625
    v->s.avctx = avctx;
5601
5626
 
5602
5627
    if (ff_vc1_init_common(v) < 0)
5603
5628
        return -1;
 
5629
    ff_blockdsp_init(&s->bdsp, avctx);
5604
5630
    ff_h264chroma_init(&v->h264chroma, 8);
5605
 
    ff_vc1dsp_init(&v->vc1dsp);
 
5631
    ff_qpeldsp_init(&s->qdsp);
5606
5632
 
5607
5633
    if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) {
5608
5634
        int count = 0;
5768
5794
    if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) {
5769
5795
        /* special case for last picture */
5770
5796
        if (s->low_delay == 0 && s->next_picture_ptr) {
5771
 
            if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
 
5797
            if ((ret = av_frame_ref(pict, s->next_picture_ptr->f)) < 0)
5772
5798
                return ret;
5773
5799
            s->next_picture_ptr = NULL;
5774
5800
 
5934
5960
    }
5935
5961
 
5936
5962
    // for skipping the frame
5937
 
    s->current_picture.f.pict_type = s->pict_type;
5938
 
    s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
 
5963
    s->current_picture.f->pict_type = s->pict_type;
 
5964
    s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
5939
5965
 
5940
5966
    /* skip B-frames if we don't have reference frames */
5941
5967
    if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) {
5942
 
        goto err;
 
5968
        goto end;
5943
5969
    }
5944
5970
    if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
5945
5971
        (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
5959
5985
    }
5960
5986
 
5961
5987
    // process pulldown flags
5962
 
    s->current_picture_ptr->f.repeat_pict = 0;
 
5988
    s->current_picture_ptr->f->repeat_pict = 0;
5963
5989
    // Pulldown flags are only valid when 'broadcast' has been set.
5964
5990
    // So ticks_per_frame will be 2
5965
5991
    if (v->rff) {
5966
5992
        // repeat field
5967
 
        s->current_picture_ptr->f.repeat_pict = 1;
 
5993
        s->current_picture_ptr->f->repeat_pict = 1;
5968
5994
    } else if (v->rptfrm) {
5969
5995
        // repeat frames
5970
 
        s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
 
5996
        s->current_picture_ptr->f->repeat_pict = v->rptfrm * 2;
5971
5997
    }
5972
5998
 
5973
 
    s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
5974
 
    s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
 
5999
    s->me.qpel_put = s->qdsp.put_qpel_pixels_tab;
 
6000
    s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
5975
6001
 
5976
6002
    if (avctx->hwaccel) {
5977
6003
        if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
5988
6014
        v->bits = buf_size * 8;
5989
6015
        v->end_mb_x = s->mb_width;
5990
6016
        if (v->field_mode) {
5991
 
            s->current_picture.f.linesize[0] <<= 1;
5992
 
            s->current_picture.f.linesize[1] <<= 1;
5993
 
            s->current_picture.f.linesize[2] <<= 1;
 
6017
            s->current_picture.f->linesize[0] <<= 1;
 
6018
            s->current_picture.f->linesize[1] <<= 1;
 
6019
            s->current_picture.f->linesize[2] <<= 1;
5994
6020
            s->linesize                      <<= 1;
5995
6021
            s->uvlinesize                    <<= 1;
5996
6022
        }
6049
6075
        }
6050
6076
        if (v->field_mode) {
6051
6077
            v->second_field = 0;
6052
 
            s->current_picture.f.linesize[0] >>= 1;
6053
 
            s->current_picture.f.linesize[1] >>= 1;
6054
 
            s->current_picture.f.linesize[2] >>= 1;
 
6078
            s->current_picture.f->linesize[0] >>= 1;
 
6079
            s->current_picture.f->linesize[1] >>= 1;
 
6080
            s->current_picture.f->linesize[2] >>= 1;
6055
6081
            s->linesize                      >>= 1;
6056
6082
            s->uvlinesize                    >>= 1;
6057
6083
            if (v->s.pict_type != AV_PICTURE_TYPE_BI && v->s.pict_type != AV_PICTURE_TYPE_B) {
6084
6110
        *got_frame = 1;
6085
6111
    } else {
6086
6112
        if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
6087
 
            if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
 
6113
            if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
6088
6114
                goto err;
6089
6115
            ff_print_debug_info(s, s->current_picture_ptr);
6090
6116
            *got_frame = 1;
6091
6117
        } else if (s->last_picture_ptr != NULL) {
6092
 
            if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
 
6118
            if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
6093
6119
                goto err;
6094
6120
            ff_print_debug_info(s, s->last_picture_ptr);
6095
6121
            *got_frame = 1;
6121
6147
};
6122
6148
 
6123
6149
static const enum AVPixelFormat vc1_hwaccel_pixfmt_list_420[] = {
6124
 
#if CONFIG_DXVA2
 
6150
#if CONFIG_VC1_DXVA2_HWACCEL
6125
6151
    AV_PIX_FMT_DXVA2_VLD,
6126
6152
#endif
6127
 
#if CONFIG_VAAPI
 
6153
#if CONFIG_VC1_VAAPI_HWACCEL
6128
6154
    AV_PIX_FMT_VAAPI_VLD,
6129
6155
#endif
6130
 
#if CONFIG_VDPAU
 
6156
#if CONFIG_VC1_VDPAU_HWACCEL
6131
6157
    AV_PIX_FMT_VDPAU,
6132
6158
#endif
6133
6159
    AV_PIX_FMT_YUV420P,
6178
6204
    .decode         = vc1_decode_frame,
6179
6205
    .capabilities   = CODEC_CAP_DR1,
6180
6206
    .flush          = vc1_sprite_flush,
6181
 
    .pix_fmts       = ff_pixfmt_list_420
 
6207
    .pix_fmts       = (const enum AVPixelFormat[]) {
 
6208
        AV_PIX_FMT_YUV420P,
 
6209
        AV_PIX_FMT_NONE
 
6210
    },
6182
6211
};
6183
6212
#endif
6184
6213
 
6194
6223
    .decode         = vc1_decode_frame,
6195
6224
    .capabilities   = CODEC_CAP_DR1,
6196
6225
    .flush          = vc1_sprite_flush,
6197
 
    .pix_fmts       = ff_pixfmt_list_420
 
6226
    .pix_fmts       = (const enum AVPixelFormat[]) {
 
6227
        AV_PIX_FMT_YUV420P,
 
6228
        AV_PIX_FMT_NONE
 
6229
    },
6198
6230
};
6199
6231
#endif