# HG changeset patch # User michael # Date 1083332669 0 # Node ID 938e47c809b0daccbf8fb8660f9c5813f4f63fde # Parent fa09319b80afb62aa48070984bd2c0f1bef74a07 intra_dc_precission>0 encoding support diff -r fa09319b80af -r 938e47c809b0 avcodec.h --- a/avcodec.h Fri Apr 30 01:35:45 2004 +0000 +++ b/avcodec.h Fri Apr 30 13:44:29 2004 +0000 @@ -17,7 +17,7 @@ #define FFMPEG_VERSION_INT 0x000408 #define FFMPEG_VERSION "0.4.8" -#define LIBAVCODEC_BUILD 4710 +#define LIBAVCODEC_BUILD 4711 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION @@ -1584,6 +1584,13 @@ * - decoding: unused */ int mb_threshold; + + /** + * + * - encoding: set by user + * - decoding: unused + */ + int intra_dc_precision; } AVCodecContext; diff -r fa09319b80af -r 938e47c809b0 mpeg12.c --- a/mpeg12.c Fri Apr 30 01:35:45 2004 +0000 +++ b/mpeg12.c Fri Apr 30 13:44:29 2004 +0000 @@ -360,7 +360,7 @@ { s->y_dc_scale_table= - s->c_dc_scale_table= ff_mpeg1_dc_scale_table; + s->c_dc_scale_table= mpeg2_dc_scale_table[s->intra_dc_precision]; } @@ -837,6 +837,27 @@ static inline void encode_dc(MpegEncContext *s, int diff, int component) { + if(((unsigned) (diff+255)) >= 511){ + int index; + + if(diff<0){ + index= av_log2_16bit(-2*diff); + diff--; + }else{ + index= av_log2_16bit(2*diff); + } + if (component == 0) { + put_bits( + &s->pb, + vlc_dc_lum_bits[index] + index, + (vlc_dc_lum_code[index]<pb, + vlc_dc_chroma_bits[index] + index, + (vlc_dc_chroma_code[index]<pb, @@ -848,6 +869,7 @@ mpeg1_chr_dc_uni[diff+255]&0xFF, mpeg1_chr_dc_uni[diff+255]>>8); } + } } static void mpeg1_encode_block(MpegEncContext *s, diff -r fa09319b80af -r 938e47c809b0 mpegvideo.c --- a/mpegvideo.c Fri Apr 30 01:35:45 2004 +0000 +++ b/mpegvideo.c Fri Apr 30 13:44:29 2004 +0000 @@ -890,6 +890,7 @@ s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0; s->mpeg_quant= avctx->mpeg_quant; s->rtp_mode= !!avctx->rtp_payload_size; + s->intra_dc_precision= avctx->intra_dc_precision; if (s->gop_size <= 1) { s->intra_only = 1; @@ -4009,7 +4010,7 @@ for(i=0; i<3; i++){ /* init last dc values */ /* note: quant matrix value (8) is implied here */ - s->last_dc[i] = 128; + s->last_dc[i] = 128 << s->intra_dc_precision; s->current_picture_ptr->error[i] = 0; }