diff mbox

[FFmpeg-devel,v2,2/2] avcodec/libvpxenc: add a way to explicitly set temporal layer id

Message ID 20191217224221.47324-2-wonkap@google.com
State Superseded
Headers show

Commit Message

Wonkap Jang Dec. 17, 2019, 10:42 p.m. UTC
In order for rate control to correctly allocate bitrate to each temporal
layer, correct temporal layer id has to be set to each frame. This
commit provides the ability to set correct temporal layer id for each
frame.
---
 libavcodec/libvpxenc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Dec. 18, 2019, 10:58 p.m. UTC | #1
On Tue, Dec 17, 2019 at 02:42:21PM -0800, Wonkap Jang wrote:
> In order for rate control to correctly allocate bitrate to each temporal
> layer, correct temporal layer id has to be set to each frame. This
> commit provides the ability to set correct temporal layer id for each
> frame.
> ---
>  libavcodec/libvpxenc.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

these 2 patches together fail to build

CC	libavcodec/libvpxenc.o
libavcodec/libvpxenc.c: In function ‘vpx_encode’:
libavcodec/libvpxenc.c:1541:25: error: ‘vpx_svc_layer_id_t’ has no member named ‘temporal_layer_id_per_spatial’
                 layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
                         ^
libavcodec/libvpxenc.c:1572:17: error: ‘vpx_svc_layer_id_t’ has no member named ‘temporal_layer_id_per_spatial’
         layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
                 ^
make: *** [libavcodec/libvpxenc.o] Error 1

[...]
Wonkap Jang Dec. 19, 2019, 12:59 a.m. UTC | #2
Hi Michael,

On Wed, Dec 18, 2019 at 2:59 PM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Tue, Dec 17, 2019 at 02:42:21PM -0800, Wonkap Jang wrote:
> > In order for rate control to correctly allocate bitrate to each temporal
> > layer, correct temporal layer id has to be set to each frame. This
> > commit provides the ability to set correct temporal layer id for each
> > frame.
> > ---
> >  libavcodec/libvpxenc.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
>
> these 2 patches together fail to build
>
> CC      libavcodec/libvpxenc.o
> libavcodec/libvpxenc.c: In function ‘vpx_encode’:
> libavcodec/libvpxenc.c:1541:25: error: ‘vpx_svc_layer_id_t’ has no member
> named ‘temporal_layer_id_per_spatial’
>                  layer_id.temporal_layer_id_per_spatial[0] =
> layer_id.temporal_layer_id;
>                          ^
> libavcodec/libvpxenc.c:1572:17: error: ‘vpx_svc_layer_id_t’ has no member
> named ‘temporal_layer_id_per_spatial’
>          layer_id.temporal_layer_id_per_spatial[0] =
> layer_id.temporal_layer_id;
>                  ^
> make: *** [libavcodec/libvpxenc.o] Error 1
>
> Looks like I missed guarding it with version number. I'll make the change.

Thanks,

Wonkap


> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Freedom in capitalist society always remains about the same as it was in
> ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
> _______________________________________________
> 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".
diff mbox

Patch

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 7612551a56..c225447515 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1527,11 +1527,20 @@  static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt,
 #endif
         if (frame->pict_type == AV_PICTURE_TYPE_I)
             flags |= VPX_EFLAG_FORCE_KF;
-        if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8 && frame->metadata) {
+        if (frame->metadata) {
             AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", NULL, 0);
             if (en) {
                 flags |= strtoul(en->value, NULL, 10);
             }
+
+            memset(&layer_id, 0, sizeof(vpx_svc_layer_id_t));
+
+            en = av_dict_get(frame->metadata, "temporal_id", NULL, 0);
+            if (en) {
+                layer_id.temporal_layer_id = strtoul(en->value, NULL, 10);
+                layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
+                layer_id_valid = 1;
+            }
         }
 
         if (sd) {