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

2016-09-08 Thread Michael Niedermayer
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


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-09-08 Thread Alex Converse
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

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel