Lines Matching refs:frag
156 void ff_cbs_fragment_reset(CodedBitstreamFragment *frag) in ff_cbs_fragment_reset() argument
160 for (i = 0; i < frag->nb_units; i++) in ff_cbs_fragment_reset()
161 cbs_unit_uninit(&frag->units[i]); in ff_cbs_fragment_reset()
162 frag->nb_units = 0; in ff_cbs_fragment_reset()
164 av_buffer_unref(&frag->data_ref); in ff_cbs_fragment_reset()
165 frag->data = NULL; in ff_cbs_fragment_reset()
166 frag->data_size = 0; in ff_cbs_fragment_reset()
167 frag->data_bit_padding = 0; in ff_cbs_fragment_reset()
170 void ff_cbs_fragment_free(CodedBitstreamFragment *frag) in ff_cbs_fragment_free() argument
172 ff_cbs_fragment_reset(frag); in ff_cbs_fragment_free()
174 av_freep(&frag->units); in ff_cbs_fragment_free()
175 frag->nb_units_allocated = 0; in ff_cbs_fragment_free()
179 CodedBitstreamFragment *frag) in cbs_read_fragment_content() argument
183 for (i = 0; i < frag->nb_units; i++) { in cbs_read_fragment_content()
184 CodedBitstreamUnit *unit = &frag->units[i]; in cbs_read_fragment_content()
221 static int cbs_fill_fragment_data(CodedBitstreamFragment *frag, in cbs_fill_fragment_data() argument
224 av_assert0(!frag->data && !frag->data_ref); in cbs_fill_fragment_data()
226 frag->data_ref = in cbs_fill_fragment_data()
228 if (!frag->data_ref) in cbs_fill_fragment_data()
231 frag->data = frag->data_ref->data; in cbs_fill_fragment_data()
232 frag->data_size = size; in cbs_fill_fragment_data()
234 memcpy(frag->data, data, size); in cbs_fill_fragment_data()
235 memset(frag->data + size, 0, in cbs_fill_fragment_data()
242 CodedBitstreamFragment *frag, in cbs_read_data() argument
250 frag->data_ref = av_buffer_ref(buf); in cbs_read_data()
251 if (!frag->data_ref) in cbs_read_data()
254 frag->data = (uint8_t *)data; in cbs_read_data()
255 frag->data_size = size; in cbs_read_data()
258 err = cbs_fill_fragment_data(frag, data, size); in cbs_read_data()
263 err = ctx->codec->split_fragment(ctx, frag, header); in cbs_read_data()
267 return cbs_read_fragment_content(ctx, frag); in cbs_read_data()
271 CodedBitstreamFragment *frag, in ff_cbs_read_extradata() argument
274 return cbs_read_data(ctx, frag, NULL, in ff_cbs_read_extradata()
280 CodedBitstreamFragment *frag, in ff_cbs_read_extradata_from_codec() argument
283 return cbs_read_data(ctx, frag, NULL, in ff_cbs_read_extradata_from_codec()
289 CodedBitstreamFragment *frag, in ff_cbs_read_packet() argument
292 return cbs_read_data(ctx, frag, pkt->buf, in ff_cbs_read_packet()
297 CodedBitstreamFragment *frag, in ff_cbs_read() argument
300 return cbs_read_data(ctx, frag, NULL, in ff_cbs_read()
359 CodedBitstreamFragment *frag) in ff_cbs_write_fragment_data() argument
363 for (i = 0; i < frag->nb_units; i++) { in ff_cbs_write_fragment_data()
364 CodedBitstreamUnit *unit = &frag->units[i]; in ff_cbs_write_fragment_data()
381 av_buffer_unref(&frag->data_ref); in ff_cbs_write_fragment_data()
382 frag->data = NULL; in ff_cbs_write_fragment_data()
384 err = ctx->codec->assemble_fragment(ctx, frag); in ff_cbs_write_fragment_data()
389 av_assert0(frag->data && frag->data_ref); in ff_cbs_write_fragment_data()
396 CodedBitstreamFragment *frag) in ff_cbs_write_extradata() argument
400 err = ff_cbs_write_fragment_data(ctx, frag); in ff_cbs_write_extradata()
406 par->extradata = av_malloc(frag->data_size + in ff_cbs_write_extradata()
411 memcpy(par->extradata, frag->data, frag->data_size); in ff_cbs_write_extradata()
412 memset(par->extradata + frag->data_size, 0, in ff_cbs_write_extradata()
414 par->extradata_size = frag->data_size; in ff_cbs_write_extradata()
421 CodedBitstreamFragment *frag) in ff_cbs_write_packet() argument
426 err = ff_cbs_write_fragment_data(ctx, frag); in ff_cbs_write_packet()
430 buf = av_buffer_ref(frag->data_ref); in ff_cbs_write_packet()
437 pkt->data = frag->data; in ff_cbs_write_packet()
438 pkt->size = frag->data_size; in ff_cbs_write_packet()
699 static int cbs_insert_unit(CodedBitstreamFragment *frag, in cbs_insert_unit() argument
704 if (frag->nb_units < frag->nb_units_allocated) { in cbs_insert_unit()
705 units = frag->units; in cbs_insert_unit()
707 if (position < frag->nb_units) in cbs_insert_unit()
709 (frag->nb_units - position) * sizeof(*units)); in cbs_insert_unit()
711 units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units)); in cbs_insert_unit()
715 frag->nb_units_allocated = 2*frag->nb_units_allocated + 1; in cbs_insert_unit()
718 memcpy(units, frag->units, position * sizeof(*units)); in cbs_insert_unit()
720 if (position < frag->nb_units) in cbs_insert_unit()
721 memcpy(units + position + 1, frag->units + position, in cbs_insert_unit()
722 (frag->nb_units - position) * sizeof(*units)); in cbs_insert_unit()
727 if (units != frag->units) { in cbs_insert_unit()
728 av_free(frag->units); in cbs_insert_unit()
729 frag->units = units; in cbs_insert_unit()
732 ++frag->nb_units; in cbs_insert_unit()
737 int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, in ff_cbs_insert_unit_content() argument
748 position = frag->nb_units; in ff_cbs_insert_unit_content()
749 av_assert0(position >= 0 && position <= frag->nb_units); in ff_cbs_insert_unit_content()
759 err = cbs_insert_unit(frag, position); in ff_cbs_insert_unit_content()
765 unit = &frag->units[position]; in ff_cbs_insert_unit_content()
773 int ff_cbs_insert_unit_data(CodedBitstreamFragment *frag, in ff_cbs_insert_unit_data() argument
784 position = frag->nb_units; in ff_cbs_insert_unit_data()
785 av_assert0(position >= 0 && position <= frag->nb_units); in ff_cbs_insert_unit_data()
797 err = cbs_insert_unit(frag, position); in ff_cbs_insert_unit_data()
803 unit = &frag->units[position]; in ff_cbs_insert_unit_data()
812 void ff_cbs_delete_unit(CodedBitstreamFragment *frag, in ff_cbs_delete_unit() argument
815 av_assert0(0 <= position && position < frag->nb_units in ff_cbs_delete_unit()
818 cbs_unit_uninit(&frag->units[position]); in ff_cbs_delete_unit()
820 --frag->nb_units; in ff_cbs_delete_unit()
822 if (frag->nb_units > 0) in ff_cbs_delete_unit()
823 memmove(frag->units + position, in ff_cbs_delete_unit()
824 frag->units + position + 1, in ff_cbs_delete_unit()
825 (frag->nb_units - position) * sizeof(*frag->units)); in ff_cbs_delete_unit()