History

avformat/mov.: Make the process of uuid-xmp atom faster.

Chen Meng committed 10 years ago

Commit 25e35b31 parent 4240e5b1 file · +18 −14Browse files

Unified · Split

libavformat/mov.c+18−14
@@ -4776,24 +4776,28 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 4775 unmodified lines
47764776 } else if (!memcmp(uuid, uuid_xmp, sizeof(uuid))) {
47774777 uint8_t *buffer;
47784778 size_t len = atom.size - sizeof(uuid);
4779−
4780− buffer = av_mallocz(len + 1);
4781− if (!buffer) {
4782− return AVERROR(ENOMEM);
4783− }
4784− ret = avio_read(pb, buffer, len);
4785− if (ret < 0) {
4786− av_free(buffer);
4787− return ret;
4788− } else if (ret != len) {
4789− av_free(buffer);
4790− return AVERROR_INVALIDDATA;
4791− }
47924779 if (c->export_xmp) {
4780+ buffer = av_mallocz(len + 1);
4781+ if (!buffer) {
4782+ return AVERROR(ENOMEM);
4783+ }
4784+ ret = avio_read(pb, buffer, len);
4785+ if (ret < 0) {
4786+ av_free(buffer);
4787+ return ret;
4788+ } else if (ret != len) {
4789+ av_free(buffer);
4790+ return AVERROR_INVALIDDATA;
4791+ }
47934792 buffer[len] = '\0';
47944793 av_dict_set(&c->fc->metadata, "xmp", buffer, 0);
4794+ av_free(buffer);
4795+ } else {
4796+ // skip all uuid atom, which makes it fast for long uuid-xmp file
4797+ ret = avio_skip(pb, len);
4798+ if (ret < 0)
4799+ return ret;
47954800 }
4796− av_free(buffer);
47974801 } else if (!memcmp(uuid, uuid_spherical, sizeof(uuid))) {
47984802 size_t len = atom.size - sizeof(uuid);
47994803 ret = mov_parse_uuid_spherical(sc, pb, len);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t