diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-04-30 13:44:29 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-04-30 13:44:29 +0000 |
commit | bf266e195aa8ce938caab674c2b75defbf8db661 (patch) | |
tree | f6a9999149b207f5094ede46b2cfa09fd3ee991c /libavcodec | |
parent | 26d4f26bb72622a5f8336f763bae75e97eb9217d (diff) | |
download | ffmpeg-bf266e195aa8ce938caab674c2b75defbf8db661.tar.gz |
intra_dc_precission>0 encoding support
Originally committed as revision 3093 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 9 | ||||
-rw-r--r-- | libavcodec/mpeg12.c | 24 | ||||
-rw-r--r-- | libavcodec/mpegvideo.c | 3 |
3 files changed, 33 insertions, 3 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a81c865b3f..6a4d223769 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -17,7 +17,7 @@ extern "C" { #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 @@ typedef struct AVCodecContext { * - decoding: unused */ int mb_threshold; + + /** + * + * - encoding: set by user + * - decoding: unused + */ + int intra_dc_precision; } AVCodecContext; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 0d6583c890..93e21af100 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -360,7 +360,7 @@ static void common_init(MpegEncContext *s) { 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 @@ void ff_mpeg1_encode_init(MpegEncContext *s) 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]<<index) + (diff & ((1 << index) - 1))); + }else{ + put_bits( + &s->pb, + vlc_dc_chroma_bits[index] + index, + (vlc_dc_chroma_code[index]<<index) + (diff & ((1 << index) - 1))); + } + }else{ if (component == 0) { put_bits( &s->pb, @@ -848,6 +869,7 @@ static inline void encode_dc(MpegEncContext *s, int diff, int component) mpeg1_chr_dc_uni[diff+255]&0xFF, mpeg1_chr_dc_uni[diff+255]>>8); } + } } static void mpeg1_encode_block(MpegEncContext *s, diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 772775cdad..1fa39e0f1f 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -890,6 +890,7 @@ int MPV_encode_init(AVCodecContext *avctx) 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 @@ static int encode_thread(AVCodecContext *c, void *arg){ 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; } |