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

Function mpeg1_encode_picture_header

libavcodec/mpeg12enc.c:340–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338}
339
340static int mpeg1_encode_picture_header(MPVMainEncContext *const m)
341{
342 MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)m;
343 MPVEncContext *const s = &m->s;
344 const AVFrameSideData *side_data;
345
346 put_bits_assume_flushed(&s->pb);
347
348 mpeg1_encode_sequence_header(mpeg12);
349
350 /* MPEG-1 picture header */
351 put_header(s, PICTURE_START_CODE);
352 /* temporal reference */
353
354 put_bits(&s->pb, 10,
355 (s->picture_number - mpeg12->gop_picture_number) & 0x3ff);
356 put_bits(&s->pb, 3, s->c.pict_type);
357
358 m->vbv_delay_pos = put_bytes_count(&s->pb, 0);
359 put_bits(&s->pb, 16, 0xFFFF); /* vbv_delay */
360
361 // RAL: Forward f_code also needed for B-frames
362 if (s->c.pict_type == AV_PICTURE_TYPE_P ||
363 s->c.pict_type == AV_PICTURE_TYPE_B) {
364 put_bits(&s->pb, 1, 0); /* half pel coordinates */
365 if (s->c.codec_id == AV_CODEC_ID_MPEG1VIDEO)
366 put_bits(&s->pb, 3, s->f_code); /* forward_f_code */
367 else
368 put_bits(&s->pb, 3, 7); /* forward_f_code */
369 }
370
371 // RAL: Backward f_code necessary for B-frames
372 if (s->c.pict_type == AV_PICTURE_TYPE_B) {
373 put_bits(&s->pb, 1, 0); /* half pel coordinates */
374 if (s->c.codec_id == AV_CODEC_ID_MPEG1VIDEO)
375 put_bits(&s->pb, 3, s->b_code); /* backward_f_code */
376 else
377 put_bits(&s->pb, 3, 7); /* backward_f_code */
378 }
379
380 put_bits(&s->pb, 1, 0); /* extra bit picture */
381
382 s->c.frame_pred_frame_dct = 1;
383 if (s->c.codec_id == AV_CODEC_ID_MPEG2VIDEO) {
384 put_header(s, EXT_START_CODE);
385 put_bits(&s->pb, 4, 8); /* pic ext */
386 if (s->c.pict_type == AV_PICTURE_TYPE_P ||
387 s->c.pict_type == AV_PICTURE_TYPE_B) {
388 put_bits(&s->pb, 4, s->f_code);
389 put_bits(&s->pb, 4, s->f_code);
390 } else {
391 put_bits(&s->pb, 8, 255);
392 }
393 if (s->c.pict_type == AV_PICTURE_TYPE_B) {
394 put_bits(&s->pb, 4, s->b_code);
395 put_bits(&s->pb, 4, s->b_code);
396 } else {
397 put_bits(&s->pb, 8, 255);

Callers

nothing calls this directly

Calls 9

put_bits_assume_flushedFunction · 0.85
put_bytes_countFunction · 0.85
av_frame_get_side_dataFunction · 0.85
put_bits32Function · 0.85
av_logFunction · 0.85
put_headerFunction · 0.70
put_bitsFunction · 0.70

Tested by

no test coverage detected