Revision 2ae7e124 libavcodec/dv.c

View differences:

libavcodec/dv.c
92 92

  
93 93
static int dv_init_dynamic_tables(const DVprofile *d)
94 94
{
95
    int j,i,c,s,p;
95
    int j,i,c,s,p,k;
96 96

  
97
    if (d->work_chunks[dv_work_pool_size(d)-1])
97
    if (d->work_chunks[dv_work_pool_size(d)-1].buf_offset)
98 98
        return 0;
99 99

  
100 100
    p = i = 0;
......
105 105
                 p += !(j%3);
106 106
                 if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) &&
107 107
                     !(DV_PROFILE_IS_720p50(d) && s > 9)) {
108
                     d->work_chunks[i++] = (void*)(size_t)((p<<18)|(c << 16)|(s << 8)|j);
108
                     for (k=0; k<5; k++)
109
                         d->work_chunks[i].mb_coordinates[k] = d->video_place[(c*d->difseg_size+s)*27*5 + j*5 + k];
110
                     d->work_chunks[i++].buf_offset = p;
109 111
                 }
110 112
                 p += 5;
111 113
            }
......
381 383
    }
382 384
}
383 385

  
384
static inline void dv_calculate_mb_xy(DVVideoContext *s, int work_chunk, int m, int *mb_x, int *mb_y)
386
static inline void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chunk, int m, int *mb_x, int *mb_y)
385 387
{
386
     int i, chan, seg, slot;
387

  
388
     chan = (work_chunk>>16)&0x03;
389
     seg  = (work_chunk>>8)&0xff;
390
     slot = (work_chunk)&0xff;
391

  
392
     i = (chan*s->sys->difseg_size+seg)*27*5 + slot*5 + m;
393
     *mb_x = s->sys->video_place[i] & 0xff;
394
     *mb_y = s->sys->video_place[i] >> 8;
388
     *mb_x = work_chunk->mb_coordinates[m] & 0xff;
389
     *mb_y = work_chunk->mb_coordinates[m] >> 8;
395 390

  
396 391
     /* We work with 720p frames split in half. The odd half-frame (chan==2,3) is displaced :-( */
397 392
     if (s->sys->height == 720 && !(s->buf[1]&0x0C)) {
......
400 395
}
401 396

  
402 397
/* mb_x and mb_y are in units of 8 pixels */
403
static inline void dv_decode_video_segment(DVVideoContext *s, int work_chunk)
398
static inline void dv_decode_video_segment(DVVideoContext *s, DVwork_chunk *work_chunk)
404 399
{
405 400
    int quant, dc, dct_mode, class1, j;
406 401
    int mb_index, mb_x, mb_y, last_index;
......
424 419
    memset(sblock, 0, sizeof(sblock));
425 420

  
426 421
    /* pass 1 : read DC and AC coefficients in blocks */
427
    buf_ptr = &s->buf[(work_chunk>>18)*80];
422
    buf_ptr = &s->buf[work_chunk->buf_offset*80];
428 423
    block1  = &sblock[0][0];
429 424
    mb1     = mb_data;
430 425
    init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
......
862 857
    }
863 858
}
864 859

  
865
static inline void dv_encode_video_segment(DVVideoContext *s, int work_chunk)
860
static inline void dv_encode_video_segment(DVVideoContext *s, DVwork_chunk *work_chunk)
866 861
{
867 862
    int mb_index, i, j;
868 863
    int mb_x, mb_y, c_offset, linesize;
......
881 876

  
882 877
    assert((((int)block) & 15) == 0);
883 878

  
884
    dif = &s->buf[(work_chunk>>18)*80];
879
    dif = &s->buf[work_chunk->buf_offset*80];
885 880
    enc_blk = &enc_blks[0];
886 881
    pb = &pbs[0];
887 882
    for (mb_index = 0; mb_index < 5; mb_index++) {
......
1013 1008

  
1014 1009
static int dv_decode_mt(AVCodecContext *avctx, void* sl)
1015 1010
{
1016
    dv_decode_video_segment((DVVideoContext *)avctx->priv_data, *(size_t*)sl);
1011
    dv_decode_video_segment((DVVideoContext *)avctx->priv_data, (DVwork_chunk*)sl);
1017 1012
    return 0;
1018 1013
}
1019 1014

  
1020 1015
#ifdef CONFIG_DVVIDEO_ENCODER
1021 1016
static int dv_encode_mt(AVCodecContext *avctx, void* sl)
1022 1017
{
1023
    dv_encode_video_segment((DVVideoContext *)avctx->priv_data, *(size_t*)sl);
1018
    dv_encode_video_segment((DVVideoContext *)avctx->priv_data, (DVwork_chunk*)sl);
1024 1019
    return 0;
1025 1020
}
1026 1021
#endif
......
1056 1051

  
1057 1052
    s->buf = buf;
1058 1053
    avctx->execute(avctx, dv_decode_mt, s->sys->work_chunks, NULL,
1059
                   dv_work_pool_size(s->sys), sizeof(void*));
1054
                   dv_work_pool_size(s->sys), sizeof(DVwork_chunk));
1060 1055

  
1061 1056
    emms_c();
1062 1057

  
......
1209 1204

  
1210 1205
    s->buf = buf;
1211 1206
    c->execute(c, dv_encode_mt, s->sys->work_chunks, NULL,
1212
               dv_work_pool_size(s->sys), sizeof(void*));
1207
               dv_work_pool_size(s->sys), sizeof(DVwork_chunk));
1213 1208

  
1214 1209
    emms_c();
1215 1210

  

Also available in: Unified diff