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

Function check_sync_pes

libavformat/ty.c:479–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477}
478
479static int check_sync_pes(AVFormatContext *s, AVPacket *pkt,
480 int32_t offset, int32_t rec_len)
481{
482 TYDemuxContext *ty = s->priv_data;
483
484 if (offset < 0 || offset + ty->pes_length > rec_len) {
485 /* entire PES header not present */
486 ff_dlog(s, "PES header at %"PRId32" not complete in record. storing.\n", offset);
487 /* save the partial pes header */
488 if (offset < 0) {
489 /* no header found, fake some 00's (this works, believe me) */
490 memset(ty->pes_buffer, 0, 4);
491 ty->pes_buf_cnt = 4;
492 if (rec_len > 4)
493 ff_dlog(s, "PES header not found in record of %"PRId32" bytes!\n", rec_len);
494 return -1;
495 }
496 /* copy the partial pes header we found */
497 memcpy(ty->pes_buffer, pkt->data + offset, rec_len - offset);
498 ty->pes_buf_cnt = rec_len - offset;
499
500 if (offset > 0) {
501 /* PES Header was found, but not complete, so trim the end of this record */
502 pkt->size -= rec_len - offset;
503 return 1;
504 }
505 return -1; /* partial PES, no audio data */
506 }
507 /* full PES header present, extract PTS */
508 ty->last_audio_pts = ff_parse_pes_pts(&pkt->data[ offset + ty->pts_offset]);
509 if (ty->first_audio_pts == AV_NOPTS_VALUE)
510 ty->first_audio_pts = ty->last_audio_pts;
511 pkt->pts = ty->last_audio_pts;
512 memmove(pkt->data + offset, pkt->data + offset + ty->pes_length, rec_len - ty->pes_length);
513 pkt->size -= ty->pes_length;
514 return 0;
515}
516
517static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
518{

Callers 1

demux_audioFunction · 0.85

Calls 1

ff_parse_pes_ptsFunction · 0.85

Tested by

no test coverage detected