comparison dv.c @ 2849:c4311f623fd5 libavcodec

lowres support
author michael
date Fri, 02 Sep 2005 08:30:26 +0000
parents 712c84b9d8ce
children ef2149182f1c
comparison
equal deleted inserted replaced
2848:78ad77267785 2849:c4311f623fd5
226 s->dv_zigzag[0][i] = dsp.idct_permutation[ff_zigzag_direct[i]]; 226 s->dv_zigzag[0][i] = dsp.idct_permutation[ff_zigzag_direct[i]];
227 227
228 /* 248DCT setup */ 228 /* 248DCT setup */
229 s->fdct[1] = dsp.fdct248; 229 s->fdct[1] = dsp.fdct248;
230 s->idct_put[1] = simple_idct248_put; // FIXME: need to add it to DSP 230 s->idct_put[1] = simple_idct248_put; // FIXME: need to add it to DSP
231 memcpy(s->dv_zigzag[1], ff_zigzag248_direct, 64); 231 if(avctx->lowres){
232 for (i=0; i<64; i++){
233 int j= ff_zigzag248_direct[i];
234 s->dv_zigzag[1][i] = dsp.idct_permutation[(j&7) + (j&8)*4 + (j&48)/2];
235 }
236 }else
237 memcpy(s->dv_zigzag[1], ff_zigzag248_direct, 64);
232 238
233 /* XXX: do it only for constant case */ 239 /* XXX: do it only for constant case */
234 dv_build_unquantize_tables(s, dsp.idct_permutation); 240 dv_build_unquantize_tables(s, dsp.idct_permutation);
235 241
236 /* FIXME: I really don't think this should be here */ 242 /* FIXME: I really don't think this should be here */
375 GetBitContext gb; 381 GetBitContext gb;
376 BlockInfo mb_data[5 * 6], *mb, *mb1; 382 BlockInfo mb_data[5 * 6], *mb, *mb1;
377 DCTELEM sblock[5*6][64] __align8; 383 DCTELEM sblock[5*6][64] __align8;
378 uint8_t mb_bit_buffer[80 + 4] __align8; /* allow some slack */ 384 uint8_t mb_bit_buffer[80 + 4] __align8; /* allow some slack */
379 uint8_t vs_bit_buffer[5 * 80 + 4] __align8; /* allow some slack */ 385 uint8_t vs_bit_buffer[5 * 80 + 4] __align8; /* allow some slack */
386 const int log2_blocksize= 3-s->avctx->lowres;
380 387
381 assert((((int)mb_bit_buffer)&7)==0); 388 assert((((int)mb_bit_buffer)&7)==0);
382 assert((((int)vs_bit_buffer)&7)==0); 389 assert((((int)vs_bit_buffer)&7)==0);
383 390
384 memset(sblock, 0, sizeof(sblock)); 391 memset(sblock, 0, sizeof(sblock));
480 mb = mb_data; 487 mb = mb_data;
481 for(mb_index = 0; mb_index < 5; mb_index++) { 488 for(mb_index = 0; mb_index < 5; mb_index++) {
482 v = *mb_pos_ptr++; 489 v = *mb_pos_ptr++;
483 mb_x = v & 0xff; 490 mb_x = v & 0xff;
484 mb_y = v >> 8; 491 mb_y = v >> 8;
485 y_ptr = s->picture.data[0] + (mb_y * s->picture.linesize[0] * 8) + (mb_x * 8); 492 y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x)<<log2_blocksize);
486 if (s->sys->pix_fmt == PIX_FMT_YUV411P) 493 if (s->sys->pix_fmt == PIX_FMT_YUV411P)
487 c_offset = (mb_y * s->picture.linesize[1] * 8) + ((mb_x >> 2) * 8); 494 c_offset = ((mb_y * s->picture.linesize[1] + (mb_x >> 2))<<log2_blocksize);
488 else 495 else
489 c_offset = ((mb_y >> 1) * s->picture.linesize[1] * 8) + ((mb_x >> 1) * 8); 496 c_offset = (((mb_y >> 1) * s->picture.linesize[1] + (mb_x >> 1))<<log2_blocksize);
490 for(j = 0;j < 6; j++) { 497 for(j = 0;j < 6; j++) {
491 idct_put = s->idct_put[mb->dct_mode]; 498 idct_put = s->idct_put[mb->dct_mode && log2_blocksize==3];
492 if (j < 4) { 499 if (j < 4) {
493 if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x < (704 / 8)) { 500 if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x < (704 / 8)) {
494 /* NOTE: at end of line, the macroblock is handled as 420 */ 501 /* NOTE: at end of line, the macroblock is handled as 420 */
495 idct_put(y_ptr + (j * 8), s->picture.linesize[0], block); 502 idct_put(y_ptr + (j<<log2_blocksize), s->picture.linesize[0], block);
496 } else { 503 } else {
497 idct_put(y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->picture.linesize[0]), 504 idct_put(y_ptr + (((j & 1) + (j >> 1) * s->picture.linesize[0])<<log2_blocksize),
498 s->picture.linesize[0], block); 505 s->picture.linesize[0], block);
499 } 506 }
500 } else { 507 } else {
501 if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) { 508 if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
502 uint64_t aligned_pixels[64/8]; 509 uint64_t aligned_pixels[64/8];
503 uint8_t *pixels= (uint8_t*)aligned_pixels; 510 uint8_t *pixels= (uint8_t*)aligned_pixels;
504 uint8_t *c_ptr, *c_ptr1, *ptr; 511 uint8_t *c_ptr, *c_ptr1, *ptr, *ptr1;
505 int y, linesize; 512 int x, y, linesize;
506 /* NOTE: at end of line, the macroblock is handled as 420 */ 513 /* NOTE: at end of line, the macroblock is handled as 420 */
507 idct_put(pixels, 8, block); 514 idct_put(pixels, 8, block);
508 linesize = s->picture.linesize[6 - j]; 515 linesize = s->picture.linesize[6 - j];
509 c_ptr = s->picture.data[6 - j] + c_offset; 516 c_ptr = s->picture.data[6 - j] + c_offset;
510 ptr = pixels; 517 ptr = pixels;
511 for(y = 0;y < 8; y++) { 518 for(y = 0;y < (1<<log2_blocksize); y++) {
512 /* convert to 411P */ 519 ptr1= ptr + (1<<(log2_blocksize-1));
513 c_ptr1 = c_ptr + 8*linesize; 520 c_ptr1 = c_ptr + (linesize<<log2_blocksize);
514 c_ptr[0]= ptr[0]; c_ptr1[0]= ptr[4]; 521 for(x=0; x < (1<<(log2_blocksize-1)); x++){
515 c_ptr[1]= ptr[1]; c_ptr1[1]= ptr[5]; 522 c_ptr[x]= ptr[x]; c_ptr1[x]= ptr1[x];
516 c_ptr[2]= ptr[2]; c_ptr1[2]= ptr[6]; 523 }
517 c_ptr[3]= ptr[3]; c_ptr1[3]= ptr[7];
518 c_ptr += linesize; 524 c_ptr += linesize;
519 ptr += 8; 525 ptr += 8;
520 } 526 }
521 } else { 527 } else {
522 /* don't ask me why they inverted Cb and Cr ! */ 528 /* don't ask me why they inverted Cb and Cr ! */
922 928
923 s->picture.reference = 0; 929 s->picture.reference = 0;
924 s->picture.key_frame = 1; 930 s->picture.key_frame = 1;
925 s->picture.pict_type = FF_I_TYPE; 931 s->picture.pict_type = FF_I_TYPE;
926 avctx->pix_fmt = s->sys->pix_fmt; 932 avctx->pix_fmt = s->sys->pix_fmt;
927 avctx->width = s->sys->width; 933 avcodec_set_dimensions(avctx, s->sys->width, s->sys->height);
928 avctx->height = s->sys->height;
929 if(avctx->get_buffer(avctx, &s->picture) < 0) { 934 if(avctx->get_buffer(avctx, &s->picture) < 0) {
930 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); 935 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
931 return -1; 936 return -1;
932 } 937 }
933 s->picture.interlaced_frame = 1; 938 s->picture.interlaced_frame = 1;