[FFmpeg-devel] [PATCH 2/2] Normalize VP8 and VP9 tags when writing IVF.
Alex Converse
alex.converse at gmail.com
Fri Sep 9 02:41:03 EEST 2016
VP9-in-ISOM uses vp08 and vp09 tags, while ivf uses VP80 and VP90.
---
libavformat/ivfenc.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index 5dbcd97..1735606 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -26,6 +26,17 @@ typedef struct IVFEncContext {
uint64_t last_pts, sum_delta_pts;
} IVFEncContext;
+static const int canonical_tag_vp8 = MKTAG('V', 'P', '8', '0');
+static const int canonical_tag_vp9 = MKTAG('V', 'P', '9', '0');
+
+static uint32_t canonicalize_tag(AVCodecParameters *par) {
+ switch (par->codec_id) {
+ case AV_CODEC_ID_VP8: return MKTAG('V', 'P', '8', '0');
+ case AV_CODEC_ID_VP9: return MKTAG('V', 'P', '9', '0');
+ default: return par->codec_tag;
+ }
+}
+
static int ivf_write_header(AVFormatContext *s)
{
AVCodecParameters *par;
@@ -44,7 +55,7 @@ static int ivf_write_header(AVFormatContext *s)
avio_write(pb, "DKIF", 4);
avio_wl16(pb, 0); // version
avio_wl16(pb, 32); // header length
- avio_wl32(pb, par->codec_tag ? par->codec_tag : par->codec_id == AV_CODEC_ID_VP9 ? AV_RL32("VP90") : AV_RL32("VP80"));
+ avio_wl32(pb, canonicalize_tag(par));
avio_wl16(pb, par->width);
avio_wl16(pb, par->height);
avio_wl32(pb, s->streams[0]->time_base.den);
--
2.8.0.rc3.226.g39d4020
More information about the ffmpeg-devel
mailing list