Message ID | 1473378063-964-2-git-send-email-alex.converse@gmail.com |
---|---|
State | Superseded |
Headers | show |
On Thu, Sep 08, 2016 at 04:41:03PM -0700, Alex Converse wrote: > 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'); unused > + > +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)); a better solution is to set AVOutputFormat.codec_tag correctly that way the tag is also shown correctly durng muxing [...]
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);