size -= 2;
if (cc_count && size >= cc_count * 3) {
- const uint64_t new_size = (s->a53_caption_size + cc_count
+ int old_size = s->buf_ref ? s->buf_ref->size : 0;
+ const uint64_t new_size = (old_size + cc_count
* UINT64_C(3));
int i, ret;
return AVERROR(EINVAL);
/* Allow merging of the cc data from two fields. */
- ret = av_reallocp(&s->a53_caption, new_size);
+ ret = av_buffer_realloc(&s->buf_ref, new_size);
if (ret < 0)
return ret;
for (i = 0; i < cc_count; i++) {
- s->a53_caption[s->a53_caption_size++] = get_bits(gb, 8);
- s->a53_caption[s->a53_caption_size++] = get_bits(gb, 8);
- s->a53_caption[s->a53_caption_size++] = get_bits(gb, 8);
+ s->buf_ref->data[old_size++] = get_bits(gb, 8);
+ s->buf_ref->data[old_size++] = get_bits(gb, 8);
+ s->buf_ref->data[old_size++] = get_bits(gb, 8);
}
skip_bits(gb, 8); // marker_bits
}
void ff_hevc_reset_sei(HEVCSEI *s)
{
- s->a53_caption.a53_caption_size = 0;
- av_freep(&s->a53_caption.a53_caption);
+ av_buffer_unref(&s->a53_caption.buf_ref);
}
metadata->MaxCLL, metadata->MaxFALL);
}
- if (s->sei.a53_caption.a53_caption) {
- AVFrameSideData* sd = av_frame_new_side_data(out,
- AV_FRAME_DATA_A53_CC,
- s->sei.a53_caption.a53_caption_size);
- if (sd)
- memcpy(sd->data, s->sei.a53_caption.a53_caption, s->sei.a53_caption.a53_caption_size);
- av_freep(&s->sei.a53_caption.a53_caption);
- s->sei.a53_caption.a53_caption_size = 0;
+ if (s->sei.a53_caption.buf_ref) {
+ HEVCSEIA53Caption *a53 = &s->sei.a53_caption;
+
+ AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref);
+ if (!sd)
+ av_buffer_unref(&a53->buf_ref);
+ a53->buf_ref = NULL;
+
s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
}