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

Function alloc_rbsp_buffer

libavcodec/h2645_parse.c:480–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478}
479
480static void alloc_rbsp_buffer(H2645RBSP *rbsp, unsigned int size, int use_ref)
481{
482 int min_size = size;
483
484 if (size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
485 goto fail;
486 size += AV_INPUT_BUFFER_PADDING_SIZE;
487
488 if (rbsp->rbsp_buffer_alloc_size >= size &&
489 (!rbsp->rbsp_buffer_ref || av_buffer_is_writable(rbsp->rbsp_buffer_ref))) {
490 av_assert0(rbsp->rbsp_buffer);
491 memset(rbsp->rbsp_buffer + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
492 return;
493 }
494
495 size = FFMIN(size + size / 16 + 32, INT_MAX);
496
497 if (rbsp->rbsp_buffer_ref)
498 av_buffer_unref(&rbsp->rbsp_buffer_ref);
499 else
500 av_free(rbsp->rbsp_buffer);
501
502 rbsp->rbsp_buffer = av_mallocz(size);
503 if (!rbsp->rbsp_buffer)
504 goto fail;
505 rbsp->rbsp_buffer_alloc_size = size;
506
507 if (use_ref) {
508 rbsp->rbsp_buffer_ref = av_buffer_create(rbsp->rbsp_buffer, size,
509 NULL, NULL, 0);
510 if (!rbsp->rbsp_buffer_ref)
511 goto fail;
512 }
513
514 return;
515
516fail:
517 rbsp->rbsp_buffer_alloc_size = 0;
518 if (rbsp->rbsp_buffer_ref) {
519 av_buffer_unref(&rbsp->rbsp_buffer_ref);
520 rbsp->rbsp_buffer = NULL;
521 } else
522 av_freep(&rbsp->rbsp_buffer);
523
524 return;
525}
526
527int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
528 void *logctx, int nal_length_size,

Callers 1

ff_h2645_packet_splitFunction · 0.85

Calls 6

av_buffer_is_writableFunction · 0.85
av_buffer_unrefFunction · 0.85
av_buffer_createFunction · 0.85
av_freepFunction · 0.85
av_freeFunction · 0.50
av_malloczFunction · 0.50

Tested by

no test coverage detected