Mercurial > libavcodec.hg
changeset 5179:04bbac6e28df libavcodec
modify msmpeg4 functions to generate VC1 compatible block layer bitstream
patch by Fortin Denis: \fortin nerim net/
original thread: [FFmpeg-devel] [PATCH] wmv3 encoder : msmpeg4.c changes
date: 06/19/2007 09:54 PM
author | benoit |
---|---|
date | Fri, 22 Jun 2007 08:35:21 +0000 |
parents | b215d5a5fa9a |
children | 3d6f2ff62910 |
files | msmpeg4.c |
diffstat | 1 files changed, 21 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/msmpeg4.c Thu Jun 21 07:53:48 2007 +0000 +++ b/msmpeg4.c Fri Jun 22 08:35:21 2007 +0000 @@ -783,7 +783,8 @@ static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr) { int sign, code; - int pred; + int pred, extquant; + int extrabits = 0; if(s->msmpeg4_version==1){ int32_t *dc_val; @@ -825,6 +826,15 @@ code = level; if (code > DC_MAX) code = DC_MAX; + else if( s->msmpeg4_version>=6 ) { + if( s->qscale == 1 ) { + extquant = (level + 3) & 0x3; + code = ((level+3)>>2); + } else if( s->qscale == 2 ) { + extquant = (level + 1) & 0x1; + code = ((level+1)>>1); + } + } if (s->dc_table_index == 0) { if (n < 4) { @@ -840,8 +850,13 @@ } } + if(s->msmpeg4_version>=6 && s->qscale<=2) + extrabits = 3 - s->qscale; + if (code == DC_MAX) - put_bits(&s->pb, 8, level); + put_bits(&s->pb, 8 + extrabits, level); + else if(extrabits > 0)//== VC1 && s->qscale<=2 + put_bits(&s->pb, extrabits, extquant); if (level != 0) { put_bits(&s->pb, 1, sign); @@ -868,7 +883,7 @@ } else { rl = &rl_table[3 + s->rl_chroma_table_index]; } - run_diff = 0; + run_diff = s->msmpeg4_version>=6; scantable= s->intra_scantable.permutated; } else { i = 0; @@ -881,7 +896,7 @@ } /* recalculate block_last_index for M$ wmv1 */ - if(s->msmpeg4_version>=4 && s->block_last_index[n]>0){ + if(s->msmpeg4_version>=4 && s->msmpeg4_version<6 && s->block_last_index[n]>0){ for(last_index=63; last_index>=0; last_index--){ if(block[scantable[last_index]]) break; } @@ -937,8 +952,9 @@ if(s->esc3_level_length==0){ s->esc3_level_length=8; s->esc3_run_length= 6; + //ESCLVLSZ + ESCRUNSZ if(s->qscale<8) - put_bits(&s->pb, 6, 3); + put_bits(&s->pb, 6 + (s->msmpeg4_version>=6), 3); else put_bits(&s->pb, 8, 3); }