count++;
}
- if (!(fmts = av_malloc((count+1) * sizeof(int))))
+ if (!(fmts = av_malloc_array(count + 1, sizeof(*fmts))))
return NULL;
for (j = 0, i = 0; i < n; i++) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
size = av_image_get_buffer_size(frame->format, frame->width, frame->height, 1);
if ((ret = av_new_packet(pkt, size)) < 0)
- return ret;
+ goto fail;
av_image_copy_to_buffer(pkt->data, size, (const uint8_t **)frame->data, frame->linesize,
frame->format, frame->width, frame->height, 1);
size = frame->nb_samples * av_get_bytes_per_sample(frame->format) *
frame->channels;
if ((ret = av_new_packet(pkt, size)) < 0)
- return ret;
+ goto fail;
memcpy(pkt->data, frame->data[0], size);
}
frame_metadata = frame->metadata;
if (frame_metadata) {
- int size;
+ size_t size;
uint8_t *metadata = av_packet_pack_dictionary(frame_metadata, &size);
- if (!metadata)
- return AVERROR(ENOMEM);
+ if (!metadata) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
if ((ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
metadata, size)) < 0) {
av_freep(&metadata);
- return ret;
+ goto fail;
}
}
if ((ret = create_subcc_packet(avctx, frame, min_pts_sink_idx)) < 0) {
- av_frame_unref(frame);
- return ret;
+ goto fail;
}
pkt->stream_index = stream_idx;
pkt->pos = frame->pkt_pos;
av_frame_unref(frame);
return size;
+fail:
+ av_frame_unref(frame);
+ return ret;
+
}
#define OFFSET(x) offsetof(LavfiContext, x)
.category = AV_CLASS_CATEGORY_DEVICE_INPUT,
};
-AVInputFormat ff_lavfi_demuxer = {
+const AVInputFormat ff_lavfi_demuxer = {
.name = "lavfi",
.long_name = NULL_IF_CONFIG_SMALL("Libavfilter virtual input device"),
.priv_data_size = sizeof(LavfiContext),