diff mbox

[FFmpeg-devel,libdav1d.c] : Add options for spatial layers.

Message ID 20191127172128.109224-1-tfoucu@gmail.com
State Superseded
Headers show

Commit Message

Thierry Foucu Nov. 27, 2019, 5:21 p.m. UTC
Disable by default to output all the layers, to match libaomdec wrapper.
Add option to select the operating point for the spatial layers.
Update the documentation with the new options.
---
 doc/decoders.texi     | 6 ++++++
 libavcodec/libdav1d.c | 8 ++++++++
 2 files changed, 14 insertions(+)

Comments

Moritz Barsnick Nov. 28, 2019, midnight UTC | #1
On Wed, Nov 27, 2019 at 09:21:28 -0800, Thierry Foucu wrote:
> +@item oppoint
> +Select an operating point of a scalable AV1 bitstream (0 - 32)
[...]
> +    { "oppoint",  "Select an operating point of the scalable bitstream", OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, 0, 31, VD },

0 to 31 or 0 to 32?

> +@item alllayer
> +Output all spatial layers of a scalable AV1 bitstream. The default value is false.
[...]
> +    { "alllayers", "Output all spatial layers", OFFSET(all_layers), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
"alllayers", not "alllayer"

Cheers,
Moritz
James Almer Nov. 28, 2019, 12:02 a.m. UTC | #2
On 11/27/2019 9:00 PM, Moritz Barsnick wrote:
> On Wed, Nov 27, 2019 at 09:21:28 -0800, Thierry Foucu wrote:
>> +@item oppoint
>> +Select an operating point of a scalable AV1 bitstream (0 - 32)
> [...]
>> +    { "oppoint",  "Select an operating point of the scalable bitstream", OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, 0, 31, VD },
> 
> 0 to 31 or 0 to 32?

0 to 31. It's 32 operating points in total.

> 
>> +@item alllayer
>> +Output all spatial layers of a scalable AV1 bitstream. The default value is false.
> [...]
>> +    { "alllayers", "Output all spatial layers", OFFSET(all_layers), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
> "alllayers", not "alllayer"
> 
> Cheers,
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Thierry Foucu Nov. 28, 2019, 12:24 a.m. UTC | #3
On Wed, Nov 27, 2019 at 4:02 PM James Almer <jamrial@gmail.com> wrote:

> On 11/27/2019 9:00 PM, Moritz Barsnick wrote:
> > On Wed, Nov 27, 2019 at 09:21:28 -0800, Thierry Foucu wrote:
> >> +@item oppoint
> >> +Select an operating point of a scalable AV1 bitstream (0 - 32)
> > [...]
> >> +    { "oppoint",  "Select an operating point of the scalable
> bitstream", OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, 0, 31,
> VD },
> >
> > 0 to 31 or 0 to 32?
>
> 0 to 31. It's 32 operating points in total.
>

thanks..
Will update the patch


>
> >
> >> +@item alllayer
> >> +Output all spatial layers of a scalable AV1 bitstream. The default
> value is false.
> > [...]
> >> +    { "alllayers", "Output all spatial layers", OFFSET(all_layers),
> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
> > "alllayers", not "alllayer"
> >
>

Sorry, will update the patch.


> > Cheers,
> > Moritz
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Andreas Rheinhardt Nov. 28, 2019, 5:08 a.m. UTC | #4
Thierry Foucu:
> Disable by default to output all the layers, to match libaomdec wrapper.
> Add option to select the operating point for the spatial layers.
> Update the documentation with the new options.
> ---
>  doc/decoders.texi     | 6 ++++++
>  libavcodec/libdav1d.c | 8 ++++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/doc/decoders.texi b/doc/decoders.texi
> index 676e062e72..86c899b5be 100644
> --- a/doc/decoders.texi
> +++ b/doc/decoders.texi
> @@ -71,6 +71,12 @@ Set amount of tile threads to use during decoding. The default value is 0 (autod
>  Apply film grain to the decoded video if present in the bitstream. Defaults to the
>  internal default of the library.
>  
> +@item oppoint
> +Select an operating point of a scalable AV1 bitstream (0 - 32)

Should be 0 - 31.
> +
> +@item alllayer
> +Output all spatial layers of a scalable AV1 bitstream. The default value is false.
> +
>  @end table
>  
>  @section libdavs2
> diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
> index cf4b178f1d..ea4ef641bf 100644
> --- a/libavcodec/libdav1d.c
> +++ b/libavcodec/libdav1d.c
> @@ -40,6 +40,8 @@ typedef struct Libdav1dContext {
>      int tile_threads;
>      int frame_threads;
>      int apply_grain;
> +    int operating_point;
> +    int all_layers;
>  } Libdav1dContext;
>  
>  static const enum AVPixelFormat pix_fmt[][3] = {
> @@ -134,6 +136,10 @@ static av_cold int libdav1d_init(AVCodecContext *c)
>      if (dav1d->apply_grain >= 0)
>          s.apply_grain = dav1d->apply_grain;
>  
> +    s.all_layers = dav1d->all_layers;
> +    if (dav1d->operating_point >= 0)
> +        s.operating_point = dav1d->operating_point;
> +
>      s.n_tile_threads = dav1d->tile_threads
>                       ? dav1d->tile_threads
>                       : FFMIN(floor(sqrt(threads)), DAV1D_MAX_TILE_THREADS);
> @@ -378,6 +384,8 @@ static const AVOption libdav1d_options[] = {
>      { "tilethreads", "Tile threads", OFFSET(tile_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_TILE_THREADS, VD },
>      { "framethreads", "Frame threads", OFFSET(frame_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_THREADS, VD },
>      { "filmgrain", "Apply Film Grain", OFFSET(apply_grain), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VD },
> +    { "oppoint",  "Select an operating point of the scalable bitstream", OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, 0, 31, VD },

If I am not mistaken, it is not possible (you get an error message and
the default value is not set) to have a default value outside of the
range of allowed values. That is because write_number() which performs
the range checks in libavutil/opt.c is also called to write the
default values. Would be nice if you could make having a default value
outside of the range of allowed values work.

I can't comment on the rest of the patch, being entirely unfamiliar
with dav1d.

- Andreas
diff mbox

Patch

diff --git a/doc/decoders.texi b/doc/decoders.texi
index 676e062e72..86c899b5be 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -71,6 +71,12 @@  Set amount of tile threads to use during decoding. The default value is 0 (autod
 Apply film grain to the decoded video if present in the bitstream. Defaults to the
 internal default of the library.
 
+@item oppoint
+Select an operating point of a scalable AV1 bitstream (0 - 32)
+
+@item alllayer
+Output all spatial layers of a scalable AV1 bitstream. The default value is false.
+
 @end table
 
 @section libdavs2
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index cf4b178f1d..ea4ef641bf 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -40,6 +40,8 @@  typedef struct Libdav1dContext {
     int tile_threads;
     int frame_threads;
     int apply_grain;
+    int operating_point;
+    int all_layers;
 } Libdav1dContext;
 
 static const enum AVPixelFormat pix_fmt[][3] = {
@@ -134,6 +136,10 @@  static av_cold int libdav1d_init(AVCodecContext *c)
     if (dav1d->apply_grain >= 0)
         s.apply_grain = dav1d->apply_grain;
 
+    s.all_layers = dav1d->all_layers;
+    if (dav1d->operating_point >= 0)
+        s.operating_point = dav1d->operating_point;
+
     s.n_tile_threads = dav1d->tile_threads
                      ? dav1d->tile_threads
                      : FFMIN(floor(sqrt(threads)), DAV1D_MAX_TILE_THREADS);
@@ -378,6 +384,8 @@  static const AVOption libdav1d_options[] = {
     { "tilethreads", "Tile threads", OFFSET(tile_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_TILE_THREADS, VD },
     { "framethreads", "Frame threads", OFFSET(frame_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_THREADS, VD },
     { "filmgrain", "Apply Film Grain", OFFSET(apply_grain), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VD },
+    { "oppoint",  "Select an operating point of the scalable bitstream", OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, 0, 31, VD },
+    { "alllayers", "Output all spatial layers", OFFSET(all_layers), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
     { NULL }
 };