MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / wmv2_encode_mb

Function wmv2_encode_mb

libavcodec/wmv2enc.c:152–220  ·  view source on GitHub ↗

Nearly identical to wmv1 but that is just because we do not use the * useless M$ crap features. It is duplicated here in case someone wants * to add support for these crap features. */

Source from the content-addressed store, hash-verified

150 * useless M$ crap features. It is duplicated here in case someone wants
151 * to add support for these crap features. */
152static void wmv2_encode_mb(MPVEncContext *const s, int16_t block[][64],
153 int motion_x, int motion_y)
154{
155 WMV2EncContext *const w = (WMV2EncContext *) s;
156 int cbp, coded_cbp, i;
157 int pred_x, pred_y;
158 uint8_t *coded_block;
159
160 ff_msmpeg4_handle_slices(s);
161
162 if (!s->c.mb_intra) {
163 /* compute cbp */
164 cbp = 0;
165 for (i = 0; i < 6; i++)
166 if (s->c.block_last_index[i] >= 0)
167 cbp |= 1 << (5 - i);
168
169 put_bits(&s->pb,
170 ff_wmv2_inter_table[w->cbp_table_index][cbp + 64][1],
171 ff_wmv2_inter_table[w->cbp_table_index][cbp + 64][0]);
172
173 s->misc_bits += get_bits_diff(s);
174 /* motion vector */
175 ff_h263_pred_motion(&s->c, 0, 0, &pred_x, &pred_y);
176 ff_msmpeg4_encode_motion(&w->msmpeg4, motion_x - pred_x,
177 motion_y - pred_y);
178 s->mv_bits += get_bits_diff(s);
179 } else {
180 /* compute cbp */
181 cbp = 0;
182 coded_cbp = 0;
183 for (i = 0; i < 6; i++) {
184 int val = (s->c.block_last_index[i] >= 1);
185
186 cbp |= val << (5 - i);
187 if (i < 4) {
188 /* predict value for close blocks only for luma */
189 int pred = ff_msmpeg4_coded_block_pred(&s->c, i, &coded_block);
190 *coded_block = val;
191 val = val ^ pred;
192 }
193 coded_cbp |= val << (5 - i);
194 }
195
196 if (s->c.pict_type == AV_PICTURE_TYPE_I)
197 put_bits(&s->pb,
198 ff_msmp4_mb_i_table[coded_cbp][1],
199 ff_msmp4_mb_i_table[coded_cbp][0]);
200 else
201 put_bits(&s->pb,
202 ff_wmv2_inter_table[w->cbp_table_index][cbp][1],
203 ff_wmv2_inter_table[w->cbp_table_index][cbp][0]);
204 put_bits(&s->pb, 1, 0); /* no AC prediction yet */
205 if (s->c.inter_intra_pred) {
206 s->c.h263_aic_dir = 0;
207 put_bits(&s->pb,
208 ff_table_inter_intra[s->c.h263_aic_dir][1],
209 ff_table_inter_intra[s->c.h263_aic_dir][0]);

Callers

nothing calls this directly

Calls 7

ff_msmpeg4_handle_slicesFunction · 0.85
get_bits_diffFunction · 0.85
ff_h263_pred_motionFunction · 0.85
ff_msmpeg4_encode_motionFunction · 0.85
ff_msmpeg4_encode_blockFunction · 0.85
put_bitsFunction · 0.70

Tested by

no test coverage detected