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

Function ff_h2645_packet_split

libavcodec/h2645_parse.c:527–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
528 void *logctx, int nal_length_size,
529 enum AVCodecID codec_id, int flags)
530{
531 GetByteContext bc;
532 int consumed, ret = 0;
533 int next_avc = (flags & H2645_FLAG_IS_NALFF) ? 0 : length;
534 int64_t padding = (flags & H2645_FLAG_SMALL_PADDING) ? 0 : MAX_MBPAIR_SIZE;
535
536 bytestream2_init(&bc, buf, length);
537 alloc_rbsp_buffer(&pkt->rbsp, length + padding, !!(flags & H2645_FLAG_USE_REF));
538
539 if (!pkt->rbsp.rbsp_buffer)
540 return AVERROR(ENOMEM);
541
542 pkt->rbsp.rbsp_buffer_size = 0;
543 pkt->nb_nals = 0;
544 while (bytestream2_get_bytes_left(&bc) >= 4) {
545 H2645NAL *nal;
546 int extract_length = 0;
547 int skip_trailing_zeros = 1;
548
549 if (bytestream2_tell(&bc) == next_avc) {
550 int i = 0;
551 extract_length = get_nalsize(nal_length_size,
552 bc.buffer, bytestream2_get_bytes_left(&bc), &i, logctx);
553 if (extract_length < 0)
554 return extract_length;
555
556 bytestream2_skip(&bc, nal_length_size);
557
558 next_avc = bytestream2_tell(&bc) + extract_length;
559 } else {
560 int buf_index;
561
562 if (bytestream2_tell(&bc) > next_avc)
563 av_log(logctx, AV_LOG_WARNING, "Exceeded next NALFF position, re-syncing.\n");
564
565 /* search start code */
566 buf_index = find_next_start_code(bc.buffer, buf + next_avc);
567
568 bytestream2_skip(&bc, buf_index);
569
570 if (!bytestream2_get_bytes_left(&bc)) {
571 if (pkt->nb_nals > 0) {
572 // No more start codes: we discarded some irrelevant
573 // bytes at the end of the packet.
574 return 0;
575 } else {
576 av_log(logctx, AV_LOG_ERROR, "No start code is found.\n");
577 return AVERROR_INVALIDDATA;
578 }
579 }
580
581 extract_length = FFMIN(bytestream2_get_bytes_left(&bc), next_avc - bytestream2_tell(&bc));
582
583 if (bytestream2_tell(&bc) >= next_avc) {
584 /* skip to the start of the next NAL */

Callers 12

cbs_h265_split_fragmentFunction · 0.85
cbs_h266_split_fragmentFunction · 0.85
cbs_lcevc_split_fragmentFunction · 0.85
decode_extradata_psFunction · 0.85
parse_nal_unitsFunction · 0.85
cbs_h264_split_fragmentFunction · 0.85
decode_nal_unitsFunction · 0.85
decode_nal_unitsFunction · 0.85
parse_nal_unitsFunction · 0.85
hevc_decode_nal_unitsFunction · 0.85
extract_extradata_h2645Function · 0.85
extract_extradata_lcevcFunction · 0.85

Calls 15

bytestream2_initFunction · 0.85
alloc_rbsp_bufferFunction · 0.85
bytestream2_tellFunction · 0.85
get_nalsizeFunction · 0.85
bytestream2_skipFunction · 0.85
av_logFunction · 0.85
av_fast_reallocFunction · 0.85
av_malloc_arrayFunction · 0.85
ff_h2645_extract_rbspFunction · 0.85
get_bit_lengthFunction · 0.85
init_get_bitsFunction · 0.85

Tested by

no test coverage detected