Mercurial > libavcodec.hg
comparison h264.c @ 8352:82790b28b6e0 libavcodec
Support the new lossless mode.
author | michael |
---|---|
date | Tue, 16 Dec 2008 20:09:09 +0000 |
parents | 7c00e980c153 |
children | add1a0d65370 |
comparison
equal
deleted
inserted
replaced
8351:91b681b7b6be | 8352:82790b28b6e0 |
---|---|
2364 const int mb_type= s->current_picture.mb_type[mb_xy]; | 2364 const int mb_type= s->current_picture.mb_type[mb_xy]; |
2365 uint8_t *dest_y, *dest_cb, *dest_cr; | 2365 uint8_t *dest_y, *dest_cb, *dest_cr; |
2366 int linesize, uvlinesize /*dct_offset*/; | 2366 int linesize, uvlinesize /*dct_offset*/; |
2367 int i; | 2367 int i; |
2368 int *block_offset = &h->block_offset[0]; | 2368 int *block_offset = &h->block_offset[0]; |
2369 const int transform_bypass = (s->qscale == 0 && h->sps.transform_bypass), is_h264 = (simple || s->codec_id == CODEC_ID_H264); | 2369 const int transform_bypass = !simple && (s->qscale == 0 && h->sps.transform_bypass); |
2370 const int is_h264 = simple || s->codec_id == CODEC_ID_H264; | |
2370 void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride); | 2371 void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride); |
2371 void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride); | 2372 void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride); |
2372 | 2373 |
2373 dest_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16; | 2374 dest_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16; |
2374 dest_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; | 2375 dest_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; |
2442 if(simple || !s->encoding){ | 2443 if(simple || !s->encoding){ |
2443 if(IS_8x8DCT(mb_type)){ | 2444 if(IS_8x8DCT(mb_type)){ |
2444 for(i=0; i<16; i+=4){ | 2445 for(i=0; i<16; i+=4){ |
2445 uint8_t * const ptr= dest_y + block_offset[i]; | 2446 uint8_t * const ptr= dest_y + block_offset[i]; |
2446 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ]; | 2447 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ]; |
2448 if(transform_bypass && h->sps.profile_idc==244 && dir<=1){ | |
2449 h->hpc.pred8x8l_add[dir](ptr, h->mb + i*16, linesize); | |
2450 }else{ | |
2447 const int nnz = h->non_zero_count_cache[ scan8[i] ]; | 2451 const int nnz = h->non_zero_count_cache[ scan8[i] ]; |
2448 h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000, | 2452 h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000, |
2449 (h->topright_samples_available<<i)&0x4000, linesize); | 2453 (h->topright_samples_available<<i)&0x4000, linesize); |
2450 if(nnz){ | 2454 if(nnz){ |
2451 if(nnz == 1 && h->mb[i*16]) | 2455 if(nnz == 1 && h->mb[i*16]) |
2452 idct_dc_add(ptr, h->mb + i*16, linesize); | 2456 idct_dc_add(ptr, h->mb + i*16, linesize); |
2453 else | 2457 else |
2454 idct_add(ptr, h->mb + i*16, linesize); | 2458 idct_add(ptr, h->mb + i*16, linesize); |
2455 } | 2459 } |
2460 } | |
2456 } | 2461 } |
2457 }else | 2462 }else |
2458 for(i=0; i<16; i++){ | 2463 for(i=0; i<16; i++){ |
2459 uint8_t * const ptr= dest_y + block_offset[i]; | 2464 uint8_t * const ptr= dest_y + block_offset[i]; |
2465 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ]; | |
2466 | |
2467 if(transform_bypass && h->sps.profile_idc==244 && dir<=1){ | |
2468 h->hpc.pred4x4_add[dir](ptr, h->mb + i*16, linesize); | |
2469 }else{ | |
2460 uint8_t *topright; | 2470 uint8_t *topright; |
2461 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ]; | |
2462 int nnz, tr; | 2471 int nnz, tr; |
2463 | |
2464 if(dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED){ | 2472 if(dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED){ |
2465 const int topright_avail= (h->topright_samples_available<<i)&0x8000; | 2473 const int topright_avail= (h->topright_samples_available<<i)&0x8000; |
2466 assert(mb_y || linesize <= block_offset[i]); | 2474 assert(mb_y || linesize <= block_offset[i]); |
2467 if(!topright_avail){ | 2475 if(!topright_avail){ |
2468 tr= ptr[3 - linesize]*0x01010101; | 2476 tr= ptr[3 - linesize]*0x01010101; |
2481 else | 2489 else |
2482 idct_add(ptr, h->mb + i*16, linesize); | 2490 idct_add(ptr, h->mb + i*16, linesize); |
2483 }else | 2491 }else |
2484 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); | 2492 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); |
2485 } | 2493 } |
2494 } | |
2486 } | 2495 } |
2487 } | 2496 } |
2488 }else{ | 2497 }else{ |
2489 h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize); | 2498 h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize); |
2490 if(is_h264){ | 2499 if(is_h264){ |
2504 | 2513 |
2505 | 2514 |
2506 if(!IS_INTRA4x4(mb_type)){ | 2515 if(!IS_INTRA4x4(mb_type)){ |
2507 if(is_h264){ | 2516 if(is_h264){ |
2508 if(IS_INTRA16x16(mb_type)){ | 2517 if(IS_INTRA16x16(mb_type)){ |
2518 if(transform_bypass && h->sps.profile_idc==244 && (h->intra16x16_pred_mode==VERT_PRED8x8 || h->intra16x16_pred_mode==HOR_PRED8x8)){ | |
2519 h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb, linesize); | |
2520 }else{ | |
2509 for(i=0; i<16; i++){ | 2521 for(i=0; i<16; i++){ |
2510 if(h->non_zero_count_cache[ scan8[i] ]) | 2522 if(h->non_zero_count_cache[ scan8[i] ]) |
2511 idct_add(dest_y + block_offset[i], h->mb + i*16, linesize); | 2523 idct_add(dest_y + block_offset[i], h->mb + i*16, linesize); |
2512 else if(h->mb[i*16]) | 2524 else if(h->mb[i*16]) |
2513 idct_dc_add(dest_y + block_offset[i], h->mb + i*16, linesize); | 2525 idct_dc_add(dest_y + block_offset[i], h->mb + i*16, linesize); |
2526 } | |
2514 } | 2527 } |
2515 }else{ | 2528 }else{ |
2516 const int di = IS_8x8DCT(mb_type) ? 4 : 1; | 2529 const int di = IS_8x8DCT(mb_type) ? 4 : 1; |
2517 for(i=0; i<16; i+=di){ | 2530 for(i=0; i<16; i+=di){ |
2518 int nnz = h->non_zero_count_cache[ scan8[i] ]; | 2531 int nnz = h->non_zero_count_cache[ scan8[i] ]; |
2543 idct_dc_add = s->dsp.h264_idct_dc_add; | 2556 idct_dc_add = s->dsp.h264_idct_dc_add; |
2544 chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp[0], h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]); | 2557 chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp[0], h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]); |
2545 chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp[1], h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]); | 2558 chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp[1], h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]); |
2546 } | 2559 } |
2547 if(is_h264){ | 2560 if(is_h264){ |
2561 if(transform_bypass && IS_INTRA(mb_type) && h->sps.profile_idc==244 && (h->chroma_pred_mode==VERT_PRED8x8 || h->chroma_pred_mode==HOR_PRED8x8)){ | |
2562 h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0], block_offset + 16, h->mb + 16*16, uvlinesize); | |
2563 h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1], block_offset + 20, h->mb + 20*16, uvlinesize); | |
2564 }else{ | |
2548 for(i=16; i<16+8; i++){ | 2565 for(i=16; i<16+8; i++){ |
2549 if(h->non_zero_count_cache[ scan8[i] ]) | 2566 if(h->non_zero_count_cache[ scan8[i] ]) |
2550 idct_add(dest[(i&4)>>2] + block_offset[i], h->mb + i*16, uvlinesize); | 2567 idct_add(dest[(i&4)>>2] + block_offset[i], h->mb + i*16, uvlinesize); |
2551 else if(h->mb[i*16]) | 2568 else if(h->mb[i*16]) |
2552 idct_dc_add(dest[(i&4)>>2] + block_offset[i], h->mb + i*16, uvlinesize); | 2569 idct_dc_add(dest[(i&4)>>2] + block_offset[i], h->mb + i*16, uvlinesize); |
2570 } | |
2553 } | 2571 } |
2554 }else{ | 2572 }else{ |
2555 for(i=16; i<16+8; i++){ | 2573 for(i=16; i<16+8; i++){ |
2556 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 2574 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
2557 uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i]; | 2575 uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i]; |
2591 static void hl_decode_mb(H264Context *h){ | 2609 static void hl_decode_mb(H264Context *h){ |
2592 MpegEncContext * const s = &h->s; | 2610 MpegEncContext * const s = &h->s; |
2593 const int mb_xy= h->mb_xy; | 2611 const int mb_xy= h->mb_xy; |
2594 const int mb_type= s->current_picture.mb_type[mb_xy]; | 2612 const int mb_type= s->current_picture.mb_type[mb_xy]; |
2595 int is_complex = FRAME_MBAFF || MB_FIELD || IS_INTRA_PCM(mb_type) || s->codec_id != CODEC_ID_H264 || | 2613 int is_complex = FRAME_MBAFF || MB_FIELD || IS_INTRA_PCM(mb_type) || s->codec_id != CODEC_ID_H264 || |
2596 (ENABLE_GRAY && (s->flags&CODEC_FLAG_GRAY)) || (ENABLE_H264_ENCODER && s->encoding) || ENABLE_SMALL; | 2614 (ENABLE_GRAY && (s->flags&CODEC_FLAG_GRAY)) || (ENABLE_H264_ENCODER && s->encoding) || ENABLE_SMALL || |
2615 s->qscale == 0; | |
2597 | 2616 |
2598 if(ENABLE_H264_ENCODER && !s->decode) | 2617 if(ENABLE_H264_ENCODER && !s->decode) |
2599 return; | 2618 return; |
2600 | 2619 |
2601 if (is_complex) | 2620 if (is_complex) |