[FFmpeg-devel] ivfenc: add AV1 support

Submitted by Tristan Matthews on Dec. 10, 2017, 11:28 p.m.

Details

Message ID 20171210232850.23139-1-tmatth@videolan.org
State New
Headers show

Commit Message

Tristan Matthews Dec. 10, 2017, 11:28 p.m.
libaom tools work with ivf files.
---
 libavformat/ivfenc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Rostislav Pehlivanov Dec. 13, 2017, 3:12 p.m.
On 10 December 2017 at 23:28, Tristan Matthews <tmatth@videolan.org> wrote:

> libaom tools work with ivf files.
> ---
>  libavformat/ivfenc.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
> index fdc0ee03e1..2d1f9aeef6 100644
> --- a/libavformat/ivfenc.c
> +++ b/libavformat/ivfenc.c
> @@ -37,14 +37,16 @@ static int ivf_write_header(AVFormatContext *s)
>      }
>      par = s->streams[0]->codecpar;
>      if (par->codec_type != AVMEDIA_TYPE_VIDEO ||
> -        !(par->codec_id == AV_CODEC_ID_VP8 || par->codec_id ==
> AV_CODEC_ID_VP9)) {
> -        av_log(s, AV_LOG_ERROR, "Currently only VP8 and VP9 are
> supported!\n");
> +        !(par->codec_id == AV_CODEC_ID_VP8 || par->codec_id ==
> AV_CODEC_ID_VP9 ||
> +          par->codec_id == AV_CODEC_ID_AV1)) {
> +        av_log(s, AV_LOG_ERROR, "Currently only VP8, VP9 and AV1 are
> supported!\n");
>          return AVERROR(EINVAL);
>      }
>      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, par->codec_tag ? par->codec_tag : par->codec_id ==
> AV_CODEC_ID_VP9 ? AV_RL32("VP90") :
> +            par->codec_id ==  AV_CODEC_ID_VP8 ? AV_RL32("VP80") :
> AV_RL32("AV01"));
>      avio_wl16(pb, par->width);
>      avio_wl16(pb, par->height);
>      avio_wl32(pb, s->streams[0]->time_base.den);
> @@ -100,6 +102,7 @@ static int ivf_check_bitstream(struct AVFormatContext
> *s, const AVPacket *pkt)
>  static const AVCodecTag codec_ivf_tags[] = {
>      { AV_CODEC_ID_VP8,  MKTAG('V', 'P', '8', '0') },
>      { AV_CODEC_ID_VP9,  MKTAG('V', 'P', '9', '0') },
> +    { AV_CODEC_ID_AV1,  MKTAG('A', 'V', '0', '1') },
>      { AV_CODEC_ID_NONE, 0 }
>  };
>
> --
> 2.15.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Thanks, pushed
Ronald S. Bultje Dec. 13, 2017, 4:08 p.m.
Hi,

On Sun, Dec 10, 2017 at 6:28 PM, Tristan Matthews <tmatth@videolan.org>
wrote:

> -    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, par->codec_tag ? par->codec_tag : par->codec_id ==
> AV_CODEC_ID_VP9 ? AV_RL32("VP90") :
> +            par->codec_id ==  AV_CODEC_ID_VP8 ? AV_RL32("VP80") :
> AV_RL32("AV01"));


I'm frowning at you.

Ronald

Patch hide | download patch | download mbox

diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index fdc0ee03e1..2d1f9aeef6 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -37,14 +37,16 @@  static int ivf_write_header(AVFormatContext *s)
     }
     par = s->streams[0]->codecpar;
     if (par->codec_type != AVMEDIA_TYPE_VIDEO ||
-        !(par->codec_id == AV_CODEC_ID_VP8 || par->codec_id == AV_CODEC_ID_VP9)) {
-        av_log(s, AV_LOG_ERROR, "Currently only VP8 and VP9 are supported!\n");
+        !(par->codec_id == AV_CODEC_ID_VP8 || par->codec_id == AV_CODEC_ID_VP9 ||
+          par->codec_id == AV_CODEC_ID_AV1)) {
+        av_log(s, AV_LOG_ERROR, "Currently only VP8, VP9 and AV1 are supported!\n");
         return AVERROR(EINVAL);
     }
     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, par->codec_tag ? par->codec_tag : par->codec_id ==  AV_CODEC_ID_VP9 ? AV_RL32("VP90") :
+            par->codec_id ==  AV_CODEC_ID_VP8 ? AV_RL32("VP80") : AV_RL32("AV01"));
     avio_wl16(pb, par->width);
     avio_wl16(pb, par->height);
     avio_wl32(pb, s->streams[0]->time_base.den);
@@ -100,6 +102,7 @@  static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
 static const AVCodecTag codec_ivf_tags[] = {
     { AV_CODEC_ID_VP8,  MKTAG('V', 'P', '8', '0') },
     { AV_CODEC_ID_VP9,  MKTAG('V', 'P', '9', '0') },
+    { AV_CODEC_ID_AV1,  MKTAG('A', 'V', '0', '1') },
     { AV_CODEC_ID_NONE, 0 }
 };