summaryrefslogtreecommitdiff
path: root/libavcodec/mpeg4videoenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-24 01:01:21 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-24 01:01:21 +0200
commit2b0cdb7364fbe1e8a7e97d36ba36dc67fb24095e (patch)
tree696306b4a66d7598f2795f9fbae4557135ff9104 /libavcodec/mpeg4videoenc.c
parent42d44ec306d0656ace5cea63867f70fa686141cb (diff)
parent16ad77b357ebbe74a7bc9568904c328a2722651e (diff)
downloadffmpeg-2b0cdb7364fbe1e8a7e97d36ba36dc67fb24095e.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: Move id3v2 tag writing to a separate file. swscale: add missing colons to x86 assembly yuv2planeX. g722: split decoder and encoder into separate files cosmetics: remove extra spaces before end-of-statement semi-colons vorbisdec: check output buffer size before writing output wavpack: calculate bpp using av_get_bytes_per_sample() ac3enc: Set max value for mode options correctly lavc: move get_b_cbp() from h263.h to mpeg4videoenc.c mpeg12: move closed_gop from MpegEncContext to Mpeg1Context mpeg12: move full_pel from MpegEncContext to Mpeg1Context mpeg12: move Mpeg1Context from mpeg12.c to mpeg12.h mpegvideo: remove some unused variables from MpegEncContext. Conflicts: libavcodec/mpeg12.c libavformat/mp3enc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpeg4videoenc.c')
-rw-r--r--libavcodec/mpeg4videoenc.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index dac9a9c885..0c5c5f2280 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -425,6 +425,46 @@ static inline void mpeg4_encode_blocks(MpegEncContext * s, DCTELEM block[6][64],
}
}
+static inline int get_b_cbp(MpegEncContext * s, DCTELEM block[6][64],
+ int motion_x, int motion_y, int mb_type)
+{
+ int cbp = 0, i;
+
+ if (s->flags & CODEC_FLAG_CBP_RD) {
+ int score = 0;
+ const int lambda = s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
+
+ for (i = 0; i < 6; i++)
+ if (s->coded_score[i] < 0) {
+ score += s->coded_score[i];
+ cbp |= 1 << (5 - i);
+ }
+
+ if (cbp) {
+ int zero_score = -6;
+ if ((motion_x | motion_y | s->dquant | mb_type) == 0)
+ zero_score -= 4; //2*MV + mb_type + cbp bit
+
+ zero_score *= lambda;
+ if (zero_score <= score)
+ cbp = 0;
+ }
+
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i)) & 1) == 0) {
+ s->block_last_index[i] = -1;
+ s->dsp.clear_block(s->block[i]);
+ }
+ }
+ } else {
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0)
+ cbp |= 1 << (5 - i);
+ }
+ }
+ return cbp;
+}
+
//FIXME this is duplicated to h263.c
static const int dquant_code[5]= {1,0,9,2,3};
@@ -1213,7 +1253,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->inter_ac_vlc_length = uni_mpeg4_inter_rl_len;
s->inter_ac_vlc_last_length= uni_mpeg4_inter_rl_len + 128*64;
s->luma_dc_vlc_length= uni_DCtab_lum_len;
- s->chroma_dc_vlc_length= uni_DCtab_chrom_len;
s->ac_esc_length= 7+2+1+6+1+12+1;
s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table;
s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;