#include "apetag.h"
#include "internal.h"
-#define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31)
+#define APE_TAG_FLAG_CONTAINS_HEADER (1U << 31)
#define APE_TAG_FLAG_LACKS_FOOTER (1 << 30)
#define APE_TAG_FLAG_IS_HEADER (1 << 29)
#define APE_TAG_FLAG_IS_BINARY (1 << 1)
av_dict_set(&st->metadata, key, filename, 0);
if ((id = ff_guess_image2_codec(filename)) != AV_CODEC_ID_NONE) {
- AVPacket pkt;
- int ret;
-
- ret = av_get_packet(s->pb, &pkt, size);
+ int ret = ff_add_attached_pic(s, st, s->pb, NULL, size);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Error reading cover art.\n");
return ret;
}
-
- st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
- st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = id;
-
- st->attached_pic = pkt;
- st->attached_pic.stream_index = st->index;
- st->attached_pic.flags |= AV_PKT_FLAG_KEY;
} else {
- if (ff_get_extradata(s, st->codecpar, s->pb, size) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
+ return ret;
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
}
} else {
{
AVDictionaryEntry *e = NULL;
int size, ret, count = 0;
- AVIOContext *dyn_bc = NULL;
- uint8_t *dyn_buf = NULL;
+ AVIOContext *dyn_bc;
+ uint8_t *dyn_buf;
if ((ret = avio_open_dyn_buf(&dyn_bc)) < 0)
- goto end;
+ return ret;
ff_standardize_creation_time(s);
while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
if (!count)
goto end;
- size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
+ size = avio_get_dyn_buf(dyn_bc, &dyn_buf);
if (size <= 0)
goto end;
size += APE_TAG_FOOTER_BYTES;
ffio_fill(s->pb, 0, 8); // reserved
end:
- if (dyn_bc && !dyn_buf)
- avio_close_dyn_buf(dyn_bc, &dyn_buf);
- av_freep(&dyn_buf);
+ ffio_free_dyn_buf(&dyn_bc);
return ret;
}