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

Function get_packets

libhb/encavcodecaudio.c:426–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426static void get_packets( hb_work_object_t * w, hb_buffer_list_t * list )
427{
428 hb_work_private_t * pv = w->private_data;
429 hb_audio_t * audio = w->audio;
430
431 while (1)
432 {
433 // Prepare output packet
434 int ret;
435 hb_buffer_t * out;
436
437 ret = avcodec_receive_packet(pv->context, pv->pkt);
438 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
439 {
440 break;
441 }
442 if (ret < 0)
443 {
444 hb_log("encavcodecaudio: avcodec_receive_packet failed");
445 break;
446 }
447
448 out = hb_buffer_init(pv->pkt->size);
449 memcpy(out->data, pv->pkt->data, out->size);
450
451 // FIXME: On windows builds, there is an upstream bug in the lame
452 // encoder that causes an extra output packet that has the same
453 // timestamp as the second to last packet. This causes an error
454 // during muxing. Work around it by dropping such packets here.
455 // See: https://github.com/HandBrake/HandBrake/issues/726
456 if (pv->pkt->pts > pv->last_pts)
457 {
458 // The output pts from libav is in context->time_base. Convert it
459 // back to our timebase.
460 out->s.start = av_rescale_q(pv->pkt->pts, pv->context->time_base,
461 (AVRational){1, 90000});
462 out->s.duration = (double)90000 * pv->samples_per_frame /
463 audio->config.out.samplerate;
464 out->s.stop = out->s.start + out->s.duration;
465 out->s.type = AUDIO_BUF;
466 out->s.frametype = HB_FRAME_AUDIO;
467
468 hb_buffer_list_append(list, out);
469 pv->last_pts = pv->pkt->pts;
470 }
471 av_packet_unref(pv->pkt);
472 }
473}
474
475static void Encode(hb_work_object_t *w, hb_buffer_list_t *list)
476{

Callers 2

EncodeFunction · 0.70
FlushFunction · 0.70

Calls 3

hb_logFunction · 0.85
hb_buffer_initFunction · 0.85
hb_buffer_list_appendFunction · 0.85

Tested by

no test coverage detected