Revision 2a1f431d

View differences:

libavcodec/dsputil.h
66 66

  
67 67
void ff_h264_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul);
68 68
void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qp);
69
void ff_chroma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul);
69 70
void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
70 71

  
71 72
void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1,
libavcodec/h264.c
246 246
    return 0;
247 247
}
248 248

  
249
#if 0
250
/**
251
 * DCT transforms the 16 dc values.
252
 * @param qp quantization parameter ??? FIXME
253
 */
254
static void h264_luma_dc_dct_c(DCTELEM *block/*, int qp*/){
255
//    const int qmul= dequant_coeff[qp][0];
256
    int i;
257
    int temp[16]; //FIXME check if this is a good idea
258
    static const int x_offset[4]={0, 1*stride, 4* stride,  5*stride};
259
    static const int y_offset[4]={0, 2*stride, 8* stride, 10*stride};
260

  
261
    for(i=0; i<4; i++){
262
        const int offset= y_offset[i];
263
        const int z0= block[offset+stride*0] + block[offset+stride*4];
264
        const int z1= block[offset+stride*0] - block[offset+stride*4];
265
        const int z2= block[offset+stride*1] - block[offset+stride*5];
266
        const int z3= block[offset+stride*1] + block[offset+stride*5];
267

  
268
        temp[4*i+0]= z0+z3;
269
        temp[4*i+1]= z1+z2;
270
        temp[4*i+2]= z1-z2;
271
        temp[4*i+3]= z0-z3;
272
    }
273

  
274
    for(i=0; i<4; i++){
275
        const int offset= x_offset[i];
276
        const int z0= temp[4*0+i] + temp[4*2+i];
277
        const int z1= temp[4*0+i] - temp[4*2+i];
278
        const int z2= temp[4*1+i] - temp[4*3+i];
279
        const int z3= temp[4*1+i] + temp[4*3+i];
280

  
281
        block[stride*0 +offset]= (z0 + z3)>>1;
282
        block[stride*2 +offset]= (z1 + z2)>>1;
283
        block[stride*8 +offset]= (z1 - z2)>>1;
284
        block[stride*10+offset]= (z0 - z3)>>1;
285
    }
286
}
287
#endif
288

  
289
#undef xStride
290
#undef stride
291

  
292
static void chroma_dc_dequant_idct_c(DCTELEM *block, int qmul){
293
    const int stride= 16*2;
294
    const int xStride= 16;
295
    int a,b,c,d,e;
296

  
297
    a= block[stride*0 + xStride*0];
298
    b= block[stride*0 + xStride*1];
299
    c= block[stride*1 + xStride*0];
300
    d= block[stride*1 + xStride*1];
301

  
302
    e= a-b;
303
    a= a+b;
304
    b= c-d;
305
    c= c+d;
306

  
307
    block[stride*0 + xStride*0]= ((a+c)*qmul) >> 7;
308
    block[stride*0 + xStride*1]= ((e+b)*qmul) >> 7;
309
    block[stride*1 + xStride*0]= ((a-c)*qmul) >> 7;
310
    block[stride*1 + xStride*1]= ((e-b)*qmul) >> 7;
311
}
312

  
313
#if 0
314
static void chroma_dc_dct_c(DCTELEM *block){
315
    const int stride= 16*2;
316
    const int xStride= 16;
317
    int a,b,c,d,e;
318

  
319
    a= block[stride*0 + xStride*0];
320
    b= block[stride*0 + xStride*1];
321
    c= block[stride*1 + xStride*0];
322
    d= block[stride*1 + xStride*1];
323

  
324
    e= a-b;
325
    a= a+b;
326
    b= c-d;
327
    c= c+d;
328

  
329
    block[stride*0 + xStride*0]= (a+c);
330
    block[stride*0 + xStride*1]= (e+b);
331
    block[stride*1 + xStride*0]= (a-c);
332
    block[stride*1 + xStride*1]= (e-b);
333
}
334
#endif
335

  
336 249
static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list,
337 250
                           uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
338 251
                           int src_x_offset, int src_y_offset,
......
1283 1196
                    }
1284 1197
                }
1285 1198
            }else{
1199
                int chroma_qpu = h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0];
1200
                int chroma_qpv = h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0];
1286 1201
                if(is_h264){
1287 1202
                    if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+0] ])
1288
                        chroma_dc_dequant_idct_c(h->mb + 16*16     , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
1203
                        h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16+0*16, &h->mb_chroma_dc[0], chroma_qpu );
1289 1204
                    if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+1] ])
1290
                        chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
1205
                        h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16+4*16, &h->mb_chroma_dc[1], chroma_qpv );
1291 1206
                    h->h264dsp.h264_idct_add8(dest, block_offset,
1292 1207
                                              h->mb, uvlinesize,
1293 1208
                                              h->non_zero_count_cache);
1294 1209
                }else{
1295
                    chroma_dc_dequant_idct_c(h->mb + 16*16     , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
1296
                    chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
1210
                    h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16+0*16, &h->mb_chroma_dc[0], chroma_qpu );
1211
                    h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16+4*16, &h->mb_chroma_dc[1], chroma_qpv );
1297 1212
                    for(i=16; i<16+8; i++){
1298 1213
                        if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
1299 1214
                            uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i];
libavcodec/h264.h
407 407

  
408 408
    DECLARE_ALIGNED(16, DCTELEM, mb)[16*24];
409 409
    DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[16];
410
    DECLARE_ALIGNED(16, DCTELEM, mb_chroma_dc)[2][4];
410 411
    DCTELEM mb_padding[256];        ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb
411 412

  
412 413
    /**
libavcodec/h264_cabac.c
1680 1680

  
1681 1681
        if( cbp&0x30 ){
1682 1682
            int c;
1683
            AV_ZERO128(h->mb_chroma_dc);
1683 1684
            for( c = 0; c < 2; c++ ) {
1684 1685
                //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
1685
                decode_cabac_residual_dc(h, h->mb + 256 + 16*4*c, 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
1686
                decode_cabac_residual_dc(h, h->mb_chroma_dc[c], 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
1686 1687
            }
1687 1688
        }
1688 1689

  
libavcodec/h264_cavlc.c
987 987
        }
988 988

  
989 989
        if(cbp&0x30){
990
            AV_ZERO128(h->mb_chroma_dc);
990 991
            for(chroma_idx=0; chroma_idx<2; chroma_idx++)
991
                if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma_dc_scan, NULL, 4) < 0){
992
                if( decode_residual(h, gb, h->mb_chroma_dc[chroma_idx], CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma_dc_scan, NULL, 4) < 0){
992 993
                    return -1;
993 994
                }
994 995
        }
libavcodec/h264data.h
79 79
};
80 80

  
81 81
static const uint8_t chroma_dc_scan[4]={
82
 (0+0*2)*16, (1+0*2)*16,
83
 (0+1*2)*16, (1+1*2)*16,  //FIXME
82
 0,1,2,3
84 83
};
85 84

  
86 85
// zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)]
libavcodec/h264dsp.c
283 283
    c->h264_idct_add8      = ff_h264_idct_add8_c;
284 284
    c->h264_idct_add16intra= ff_h264_idct_add16intra_c;
285 285
    c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_c;
286
    c->h264_chroma_dc_dequant_idct= ff_chroma_dc_dequant_idct_c;
286 287

  
287 288
    c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c;
288 289
    c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c;
libavcodec/h264dsp.h
68 68
    void (*h264_idct_add8)(uint8_t **dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
69 69
    void (*h264_idct_add16intra)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
70 70
    void (*h264_luma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul);
71
    void (*h264_chroma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul);
71 72
}H264DSPContext;
72 73

  
73 74
void ff_h264dsp_init(H264DSPContext *c);
libavcodec/h264idct.c
250 250
        output[stride* 4+offset]= ((((z1 - z2)*qmul + 128 ) >> 8));
251 251
        output[stride* 5+offset]= ((((z0 - z3)*qmul + 128 ) >> 8));
252 252
    }
253
#undef stride
254
}
255

  
256
void ff_chroma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul){
257
    const int stride= 16*2;
258
    const int xStride= 16;
259
    int a,b,c,d,e;
260

  
261
    a= input[0];
262
    b= input[1];
263
    c= input[2];
264
    d= input[3];
265

  
266
    e= a-b;
267
    a= a+b;
268
    b= c-d;
269
    c= c+d;
270

  
271
    output[stride*0 + xStride*0]= ((a+c)*qmul) >> 7;
272
    output[stride*0 + xStride*1]= ((e+b)*qmul) >> 7;
273
    output[stride*1 + xStride*0]= ((a-c)*qmul) >> 7;
274
    output[stride*1 + xStride*1]= ((e-b)*qmul) >> 7;
253 275
}
libavcodec/svq3.c
671 671
        }
672 672

  
673 673
        if ((cbp & 0x30)) {
674
            AV_ZERO128(h->mb_chroma_dc);
674 675
            for (i = 0; i < 2; ++i) {
675
              if (svq3_decode_block(&s->gb, &h->mb[16*(16 + 4*i)], 0, 3)){
676
                av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma dc block\n");
677
                return -1;
678
              }
676
                if (svq3_decode_block(&s->gb, h->mb_chroma_dc[i], 0, 3)){
677
                    av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma dc block\n");
678
                    return -1;
679
                }
679 680
            }
680 681

  
681 682
            if ((cbp & 0x20)) {

Also available in: Unified diff