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

Function copy_frame

libhb/decavcodec.c:1151–1348  ·  view source on GitHub ↗

copy one video frame into an HB buf. If the frame isn't in our color space or at least one of its dimensions is odd, use sws_scale to convert/rescale it. Otherwise just copy the bits.

Source from the content-addressed store, hash-verified

1149// or at least one of its dimensions is odd, use sws_scale to convert/rescale it.
1150// Otherwise just copy the bits.
1151static hb_buffer_t *copy_frame( hb_work_private_t *pv )
1152{
1153 reordered_data_t * reordered = NULL;
1154 hb_buffer_t * out;
1155
1156 out = hb_avframe_to_video_buffer(pv->frame, (AVRational){1,1});
1157
1158 if (pv->frame->pts != AV_NOPTS_VALUE)
1159 {
1160 reordered = reordered_hash_rem(pv, pv->frame->pts);
1161 }
1162 if (reordered != NULL)
1163 {
1164 out->s.scr_sequence = reordered->scr_sequence;
1165 out->s.start = reordered->pts;
1166 out->s.new_chap = reordered->new_chap;
1167 pv->last_scr_sequence = reordered->scr_sequence;
1168 pv->last_chapter = reordered->new_chap;
1169 free(reordered);
1170 }
1171 else
1172 {
1173 out->s.scr_sequence = pv->last_scr_sequence;
1174 out->s.start = AV_NOPTS_VALUE;
1175 }
1176
1177 double frame_dur = pv->duration;
1178 if (pv->frame->repeat_pict)
1179 {
1180 frame_dur += pv->frame->repeat_pict * pv->field_duration;
1181 }
1182 if (out->s.start == AV_NOPTS_VALUE)
1183 {
1184 out->s.start = pv->next_pts;
1185 }
1186 else
1187 {
1188 pv->next_pts = out->s.start;
1189 }
1190 if (pv->next_pts != (int64_t)AV_NOPTS_VALUE)
1191 {
1192 pv->next_pts += frame_dur;
1193 out->s.stop = pv->next_pts;
1194 }
1195 out->s.duration = frame_dur;
1196
1197 if (out->s.new_chap > 0 && out->s.new_chap == pv->new_chap)
1198 {
1199 pv->new_chap = 0;
1200 }
1201 // It is possible that the buffer with new_chap gets dropped
1202 // by the decoder. So also check if the output buffer is after
1203 // the new_chap in the timeline.
1204 if (pv->new_chap > 0 &&
1205 (out->s.scr_sequence > pv->chap_scr ||
1206 (out->s.scr_sequence == pv->chap_scr && out->s.start > pv->chap_time)))
1207 {
1208 out->s.new_chap = pv->new_chap;

Callers 1

filter_videoFunction · 0.85

Calls 12

reordered_hash_remFunction · 0.85
hb_list_itemFunction · 0.85
hb_list_countFunction · 0.85
lang_for_code2Function · 0.85
hb_subsource_nameFunction · 0.85
hb_list_addFunction · 0.85
cc_fill_bufferFunction · 0.85
cc_send_to_decoderFunction · 0.85
hb_mastering_ff_to_hbFunction · 0.85
hb_data_initFunction · 0.85
hb_ambient_ff_to_hbFunction · 0.85

Tested by

no test coverage detected