History

avcodec/libvpxenc: add a way to explicitly set temporal layer id

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.

Wonkap Jang committed 6 years ago

Commit f3bb5921 parent cf92f423 files · +24 −3Browse files

Unified · Split

3 files
  1. doc/encoders.texi +11 −1
  2. libavcodec/libvpxenc.c +12 −1
  3. libavcodec/version.h +1 −1
doc/encoders.texi+11−1
@@ -1918,7 +1918,17 @@ Currently supports the following options. · 1917 unmodified lines
1918@table @option1918@table @option
1919@item 01919@item 0
1920No temporal layering flags are provided internally,1920No temporal layering flags are provided internally,
1921relies on flags being passed in using metadata in AVFrame.1921relies on flags being passed in using @code{metadata} field in @code{AVFrame}
1922with following keys.
1923@table @option
1924@item vp8-flags
1925Sets the flags passed into the encoder to indicate the referencing scheme for
1926the current frame.
1927Refer to function @code{vpx_codec_encode} in @code{vpx/vpx_encoder.h} for more
1928details.
1929@item temporal_id
1930Explicitly sets the temporal id of the current frame to encode.
1931@end table
1922@item 21932@item 2
1923Two temporal layers. 0-1...1933Two temporal layers. 0-1...
1924@item 31934@item 3
libavcodec/libvpxenc.c+12−1
@@ -1519,11 +1519,22 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, · 1518 unmodified lines
1519#endif1519#endif
1520 if (frame->pict_type == AV_PICTURE_TYPE_I)1520 if (frame->pict_type == AV_PICTURE_TYPE_I)
1521 flags |= VPX_EFLAG_FORCE_KF;1521 flags |= VPX_EFLAG_FORCE_KF;
1522 if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8 && frame->metadata) {1522 if (frame->metadata) {
1523 AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", NULL, 0);1523 AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", NULL, 0);
1524 if (en) {1524 if (en) {
1525 flags |= strtoul(en->value, NULL, 10);1525 flags |= strtoul(en->value, NULL, 10);
1526 }1526 }
1527
1528 memset(&layer_id, 0, sizeof(layer_id));
1529
1530 en = av_dict_get(frame->metadata, "temporal_id", NULL, 0);
1531 if (en) {
1532 layer_id.temporal_layer_id = strtoul(en->value, NULL, 10);
1533#ifdef VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT
1534 layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id;
1535#endif
1536 layer_id_valid = 1;
1537 }
1527 }1538 }
1528 1539
1529 if (sd) {1540 if (sd) {
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29 29
30#define LIBAVCODEC_VERSION_MAJOR 5830#define LIBAVCODEC_VERSION_MAJOR 58
31#define LIBAVCODEC_VERSION_MINOR 6831#define LIBAVCODEC_VERSION_MINOR 68
32#define LIBAVCODEC_VERSION_MICRO 10132#define LIBAVCODEC_VERSION_MICRO 102
33 33
34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
35 LIBAVCODEC_VERSION_MINOR, \35 LIBAVCODEC_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t