[FFmpeg-devel] [PATCH 2/2] Normalize VP8 and VP9 tags when writing IVF.

Michael Niedermayer michael at niedermayer.cc
Fri Sep 9 04:38:20 EEST 2016


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

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160909/ff0eed8f/attachment.sig>


More information about the ffmpeg-devel mailing list