Originally committed as revision 3093 to svn://svn.ffmpeg.org/ffmpeg/trunk
Michael Niedermayer authored on 2004/04/30 22:44:29... | ... |
@@ -164,6 +164,7 @@ static int debug = 0; |
164 | 164 |
static int debug_mv = 0; |
165 | 165 |
static int me_threshold = 0; |
166 | 166 |
static int mb_threshold = 0; |
167 |
+static int intra_dc_precision = 0; |
|
167 | 168 |
extern int loop_input; /* currently a hack */ |
168 | 169 |
|
169 | 170 |
static int gop_size = 12; |
... | ... |
@@ -2893,6 +2894,7 @@ static void opt_output_file(const char *filename) |
2893 | 2893 |
video_enc->idct_algo = idct_algo; |
2894 | 2894 |
video_enc->me_threshold= me_threshold; |
2895 | 2895 |
video_enc->mb_threshold= mb_threshold; |
2896 |
+ video_enc->intra_dc_precision= intra_dc_precision; |
|
2896 | 2897 |
video_enc->strict_std_compliance = strict; |
2897 | 2898 |
video_enc->error_rate = error_rate; |
2898 | 2899 |
video_enc->noise_reduction= noise_reduction; |
... | ... |
@@ -3580,6 +3582,7 @@ const OptionDef options[] = { |
3580 | 3580 |
{ "qns", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qns}, "quantization noise shaping", "" }, |
3581 | 3581 |
{ "sc_threshold", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_sc_threshold}, "scene change threshold", "threshold" }, |
3582 | 3582 |
{ "me_range", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_range}, "limit motion vectors range (1023 for DivX player)", "range" }, |
3583 |
+ { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_dc_precision}, "intra_dc_precision", "precision" }, |
|
3583 | 3584 |
|
3584 | 3585 |
/* audio options */ |
3585 | 3586 |
{ "ab", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_bitrate}, "set audio bitrate (in kbit/s)", "bitrate", }, |
... | ... |
@@ -17,7 +17,7 @@ extern "C" { |
17 | 17 |
|
18 | 18 |
#define FFMPEG_VERSION_INT 0x000408 |
19 | 19 |
#define FFMPEG_VERSION "0.4.8" |
20 |
-#define LIBAVCODEC_BUILD 4710 |
|
20 |
+#define LIBAVCODEC_BUILD 4711 |
|
21 | 21 |
|
22 | 22 |
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT |
23 | 23 |
#define LIBAVCODEC_VERSION FFMPEG_VERSION |
... | ... |
@@ -1584,6 +1584,13 @@ typedef struct AVCodecContext { |
1584 | 1584 |
* - decoding: unused |
1585 | 1585 |
*/ |
1586 | 1586 |
int mb_threshold; |
1587 |
+ |
|
1588 |
+ /** |
|
1589 |
+ * |
|
1590 |
+ * - encoding: set by user |
|
1591 |
+ * - decoding: unused |
|
1592 |
+ */ |
|
1593 |
+ int intra_dc_precision; |
|
1587 | 1594 |
} AVCodecContext; |
1588 | 1595 |
|
1589 | 1596 |
|
... | ... |
@@ -360,7 +360,7 @@ static void common_init(MpegEncContext *s) |
360 | 360 |
{ |
361 | 361 |
|
362 | 362 |
s->y_dc_scale_table= |
363 |
- s->c_dc_scale_table= ff_mpeg1_dc_scale_table; |
|
363 |
+ s->c_dc_scale_table= mpeg2_dc_scale_table[s->intra_dc_precision]; |
|
364 | 364 |
|
365 | 365 |
} |
366 | 366 |
|
... | ... |
@@ -837,6 +837,27 @@ void ff_mpeg1_encode_init(MpegEncContext *s) |
837 | 837 |
|
838 | 838 |
static inline void encode_dc(MpegEncContext *s, int diff, int component) |
839 | 839 |
{ |
840 |
+ if(((unsigned) (diff+255)) >= 511){ |
|
841 |
+ int index; |
|
842 |
+ |
|
843 |
+ if(diff<0){ |
|
844 |
+ index= av_log2_16bit(-2*diff); |
|
845 |
+ diff--; |
|
846 |
+ }else{ |
|
847 |
+ index= av_log2_16bit(2*diff); |
|
848 |
+ } |
|
849 |
+ if (component == 0) { |
|
850 |
+ put_bits( |
|
851 |
+ &s->pb, |
|
852 |
+ vlc_dc_lum_bits[index] + index, |
|
853 |
+ (vlc_dc_lum_code[index]<<index) + (diff & ((1 << index) - 1))); |
|
854 |
+ }else{ |
|
855 |
+ put_bits( |
|
856 |
+ &s->pb, |
|
857 |
+ vlc_dc_chroma_bits[index] + index, |
|
858 |
+ (vlc_dc_chroma_code[index]<<index) + (diff & ((1 << index) - 1))); |
|
859 |
+ } |
|
860 |
+ }else{ |
|
840 | 861 |
if (component == 0) { |
841 | 862 |
put_bits( |
842 | 863 |
&s->pb, |
... | ... |
@@ -848,6 +869,7 @@ static inline void encode_dc(MpegEncContext *s, int diff, int component) |
848 | 848 |
mpeg1_chr_dc_uni[diff+255]&0xFF, |
849 | 849 |
mpeg1_chr_dc_uni[diff+255]>>8); |
850 | 850 |
} |
851 |
+ } |
|
851 | 852 |
} |
852 | 853 |
|
853 | 854 |
static void mpeg1_encode_block(MpegEncContext *s, |
... | ... |
@@ -890,6 +890,7 @@ int MPV_encode_init(AVCodecContext *avctx) |
890 | 890 |
s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0; |
891 | 891 |
s->mpeg_quant= avctx->mpeg_quant; |
892 | 892 |
s->rtp_mode= !!avctx->rtp_payload_size; |
893 |
+ s->intra_dc_precision= avctx->intra_dc_precision; |
|
893 | 894 |
|
894 | 895 |
if (s->gop_size <= 1) { |
895 | 896 |
s->intra_only = 1; |
... | ... |
@@ -4009,7 +4010,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ |
4009 | 4009 |
for(i=0; i<3; i++){ |
4010 | 4010 |
/* init last dc values */ |
4011 | 4011 |
/* note: quant matrix value (8) is implied here */ |
4012 |
- s->last_dc[i] = 128; |
|
4012 |
+ s->last_dc[i] = 128 << s->intra_dc_precision; |
|
4013 | 4013 |
|
4014 | 4014 |
s->current_picture_ptr->error[i] = 0; |
4015 | 4015 |
} |