MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / nal_encode

Function nal_encode

libhb/encx264.c:689–813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687}
688
689static hb_buffer_t *nal_encode( hb_work_object_t *w, x264_picture_t *pic_out,
690 int i_nal, x264_nal_t *nal )
691{
692 hb_buffer_t *buf = NULL;
693 hb_work_private_t *pv = w->private_data;
694 hb_job_t *job = pv->job;
695 int payload_size = 0;
696
697 for (int i = 0; i < i_nal; i++)
698 {
699 payload_size += nal[i].i_payload;
700 }
701
702 buf = hb_buffer_init(payload_size);
703 buf->size = 0;
704 buf->s.frametype = 0;
705
706 // use the pts to get the original frame's duration.
707 buf->s.duration = AV_NOPTS_VALUE;
708 buf->s.start = pic_out->i_pts;
709 buf->s.stop = AV_NOPTS_VALUE;
710 buf->s.renderOffset = pic_out->i_dts;
711 if (!*w->init_delay && pic_out->i_dts < 0)
712 {
713 *w->init_delay = -pic_out->i_dts;
714 }
715
716 /* Determine what type of frame we have. */
717 switch (pic_out->i_type)
718 {
719 case X264_TYPE_IDR:
720 buf->s.frametype = HB_FRAME_IDR;
721 break;
722
723 case X264_TYPE_P:
724 buf->s.frametype = HB_FRAME_P;
725 break;
726
727 case X264_TYPE_B:
728 buf->s.frametype = HB_FRAME_B;
729 break;
730
731 case X264_TYPE_BREF:
732 buf->s.frametype = HB_FRAME_BREF;
733 break;
734
735 case X264_TYPE_I:
736 default:
737 buf->s.frametype = HB_FRAME_I;
738 break;
739 }
740 buf->s.flags = 0;
741
742 if (pic_out->b_keyframe)
743 {
744 buf->s.flags |= HB_FLAG_FRAMETYPE_KEY;
745 /* if we have a chapter marker pending and this
746 frame's presentation time stamp is at or after

Callers 2

x264_encodeFunction · 0.70
encx264WorkFunction · 0.70

Calls 3

hb_buffer_initFunction · 0.85
hb_chapter_dequeueFunction · 0.85
hb_buffer_closeFunction · 0.85

Tested by

no test coverage detected