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

Function h261_encode_mb

libavcodec/h261enc.c:227–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64],
228 int motion_x, int motion_y)
229{
230 /* The following is only allowed because this encoder
231 * does not use slice threading. */
232 H261EncContext *const h = (H261EncContext *)s;
233 int mvd, mv_diff_x, mv_diff_y, i, cbp;
234 cbp = 63; // avoid warning
235 mvd = 0;
236
237 s->c.mtype = 0;
238
239 if (!s->c.mb_intra) {
240 /* compute cbp */
241 cbp = get_cbp(s->c.block_last_index);
242
243 /* mvd indicates if this block is motion compensated */
244 mvd = motion_x | motion_y;
245
246 if ((cbp | mvd) == 0) {
247 /* skip macroblock */
248 s->mb_skip_run++;
249 s->c.last_mv[0][0][0] = 0;
250 s->c.last_mv[0][0][1] = 0;
251 s->c.qscale -= s->dquant;
252 return;
253 }
254 }
255
256 /* MB is not skipped, encode MBA */
257 put_bits(&s->pb,
258 ff_h261_mba_bits[s->mb_skip_run],
259 ff_h261_mba_code[s->mb_skip_run]);
260 s->mb_skip_run = 0;
261
262 /* calculate MTYPE */
263 if (!s->c.mb_intra) {
264 s->c.mtype++;
265
266 if (mvd || s->loop_filter)
267 s->c.mtype += 3;
268 if (s->loop_filter)
269 s->c.mtype += 3;
270 if (cbp)
271 s->c.mtype++;
272 av_assert1(s->c.mtype > 1);
273 }
274
275 if (s->dquant && cbp) {
276 s->c.mtype++;
277 } else
278 s->c.qscale -= s->dquant;
279
280 put_bits(&s->pb,
281 ff_h261_mtype_bits[s->c.mtype],
282 ff_h261_mtype_code[s->c.mtype]);
283
284 s->c.mtype = ff_h261_mtype_map[s->c.mtype];

Callers

nothing calls this directly

Calls 5

get_cbpFunction · 0.85
ff_set_qscaleFunction · 0.85
h261_encode_motionFunction · 0.85
h261_encode_blockFunction · 0.85
put_bitsFunction · 0.70

Tested by

no test coverage detected