Mercurial > libavcodec.hg
changeset 3522:5de1edac254e libavcodec
Support range reduced frames
author | kostya |
---|---|
date | Sat, 29 Jul 2006 03:07:30 +0000 |
parents | ae749c2da968 |
children | 7407a264d243 |
files | vc1.c |
diffstat | 1 files changed, 61 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/vc1.c Sat Jul 29 03:05:29 2006 +0000 +++ b/vc1.c Sat Jul 29 03:07:30 2006 +0000 @@ -880,6 +880,14 @@ int ys, us, vs; DSPContext *dsp = &v->s.dsp; + if(v->rangeredfrm) { + int i, j, k; + for(k = 0; k < 6; k++) + for(j = 0; j < 8; j++) + for(i = 0; i < 8; i++) + block[k][i + j*8] = ((block[k][i + j*8] - 128) << 1) + 128; + + } ys = v->s.current_picture.linesize[0]; us = v->s.current_picture.linesize[1]; vs = v->s.current_picture.linesize[2]; @@ -943,7 +951,7 @@ srcV = s->edge_emu_buffer + 18 * s->linesize; } - if((v->mv_mode == MV_PMODE_INTENSITY_COMP) + if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) || (unsigned)src_x > s->h_edge_pos - (mx&3) - 16 || (unsigned)src_y > s->v_edge_pos - (my&3) - 16){ uint8_t *uvbuf= s->edge_emu_buffer + 18 * s->linesize; @@ -957,6 +965,26 @@ uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); srcU = uvbuf; srcV = uvbuf + 16; + /* if we deal with range reduction we need to scale source blocks */ + if(v->rangeredfrm) { + int i, j; + uint8_t *src, *src2; + + src = srcY; + for(j = 0; j < 17; j++) { + for(i = 0; i < 17; i++) src[i] = ((src[i] - 128) >> 1) + 128; + src += s->linesize; + } + src = srcU; src2 = srcV; + for(j = 0; j < 9; j++) { + for(i = 0; i < 9; i++) { + src[i] = ((src[i] - 128) >> 1) + 128; + src2[i] = ((src2[i] - 128) >> 1) + 128; + } + src += s->uvlinesize; + src2 += s->uvlinesize; + } + } /* if we deal with intensity compensation we need to scale source blocks */ if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { int i, j; @@ -1039,11 +1067,22 @@ srcY += src_y * s->linesize + src_x; - if((unsigned)src_x > s->h_edge_pos - (mx&3) - 16 + if(v->rangeredfrm || (unsigned)src_x > s->h_edge_pos - (mx&3) - 16 || (unsigned)src_y > s->v_edge_pos - (my&3) - 16){ ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 16+1, 16+1, src_x, src_y, s->h_edge_pos, s->v_edge_pos); srcY = s->edge_emu_buffer; + /* if we deal with range reduction we need to scale source blocks */ + if(v->rangeredfrm) { + int i, j; + uint8_t *src; + + src = srcY; + for(j = 0; j < 17; j++) { + for(i = 0; i < 17; i++) src[i] = ((src[i] - 128) >> 1) + 128; + src += s->linesize; + } + } } if(!s->quarter_sample) { // hpel mc @@ -1141,7 +1180,7 @@ uvsrc_y = clip(uvsrc_y, -8, s->mb_height * 8); srcU = s->last_picture.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; srcV = s->last_picture.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; - if((unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9 + if(v->rangeredfrm || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9 || (unsigned)uvsrc_y > (s->v_edge_pos >> 1) - 9){ ff_emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, 8+1, 8+1, uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); @@ -1149,6 +1188,22 @@ uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); srcU = s->edge_emu_buffer; srcV = s->edge_emu_buffer + 16; + + /* if we deal with range reduction we need to scale source blocks */ + if(v->rangeredfrm) { + int i, j; + uint8_t *src, *src2; + + src = srcU; src2 = srcV; + for(j = 0; j < 9; j++) { + for(i = 0; i < 9; i++) { + src[i] = ((src[i] - 128) >> 1) + 128; + src2[i] = ((src2[i] - 128) >> 1) + 128; + } + src += s->uvlinesize; + src2 += s->uvlinesize; + } + } } if(v->fastuvmc) { @@ -2578,6 +2633,7 @@ vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset); if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; vc1_inv_trans(s->block[i], 8, 8); + if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; for(j = 0; j < 64; j++) s->block[i][j] += 128; s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); /* TODO: proper loop filtering */ @@ -2681,6 +2737,7 @@ vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i&4)?v->codingset2:v->codingset); if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; vc1_inv_trans(s->block[i], 8, 8); + if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; for(j = 0; j < 64; j++) s->block[i][j] += 128; s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); /* TODO: proper loop filtering */ @@ -2846,6 +2903,7 @@ vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset); if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; vc1_inv_trans(s->block[i], 8, 8); + if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; for(j = 0; j < 64; j++) s->block[i][j] += 128; s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); /* TODO: proper loop filtering */