diff --git a/doc/Makefile b/doc/Makefile
index 41b0173e076a14ea93e6ffbf27b136e8dc807fd9..e46c658a33f69182806ea85fcef3cc70fbae7010 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -23,6 +23,7 @@ all-$(CONFIG_DOC): doc
 
 doc: documentation
 
+apidoc: doc/doxy/html
 documentation: $(DOCS)
 
 TEXIDEP = awk '/^@(verbatim)?include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
@@ -53,7 +54,10 @@ doc/%.1: TAG = MAN
 doc/%.1: doc/%.pod $(GENTEXI)
 	$(M)pod2man --section=1 --center=" " --release=" " $< > $@
 
-$(DOCS): | doc/
+$(DOCS) doc/doxy/html: | doc/
+
+doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(INSTHEADERS)
+	$(M)$(SRC_PATH)/doc/doxy-wrapper.sh $(SRC_PATH) $^
 
 install-man:
 
@@ -72,7 +76,8 @@ uninstall-man:
 
 clean::
 	$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 $(CLEANSUFFIXES:%=doc/%) doc/avoptions_*.texi
+	$(RM) -r doc/doxy/html
 
 -include $(wildcard $(DOCS:%=%.d))
 
-.PHONY: doc documentation
+.PHONY: apidoc doc documentation
diff --git a/doc/doxy-wrapper.sh b/doc/doxy-wrapper.sh
new file mode 100755
index 0000000000000000000000000000000000000000..6650e388504e415e74e6f6978618d92d371a5b96
--- /dev/null
+++ b/doc/doxy-wrapper.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+SRC_PATH="${1}"
+DOXYFILE="${2}"
+
+shift 2
+
+doxygen - <<EOF
+@INCLUDE        = ${DOXYFILE}
+INPUT           = $@
+HTML_HEADER     = ${SRC_PATH}/doc/doxy/header.html
+HTML_FOOTER     = ${SRC_PATH}/doc/doxy/footer.html
+HTML_STYLESHEET = ${SRC_PATH}/doc/doxy/doxy_stylesheet.css
+EOF
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index c4a590b27ffff762b7407adcec01ea86e9e8cb70..ba53e342da98e57d0e4c54fa891eee89d2d6d042 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1214,8 +1214,10 @@ static int matroska_merge_packets(AVPacket *out, AVPacket *in)
     int ret = av_grow_packet(out, in->size);
     if (ret < 0)
         return ret;
+
     memcpy(out->data + out->size - in->size, in->data, in->size);
-    av_destruct_packet(in);
+
+    av_free_packet(in);
     av_free(in);
     return 0;
 }
diff --git a/library.mak b/library.mak
index c472404da5b3faec52c43b874242e3808c9117a4..809d629d10bd2be0dbdcf7933c9acf6a46037917 100644
--- a/library.mak
+++ b/library.mak
@@ -6,6 +6,8 @@ LIBVERSION := $(lib$(NAME)_VERSION)
 LIBMAJOR   := $(lib$(NAME)_VERSION_MAJOR)
 INCINSTDIR := $(INCDIR)/lib$(NAME)
 
+INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
+
 all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME)
 all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME)