[FFmpeg-devel] [PATCH] libvpx: deadline & profile support

James Zern jzern
Mon Jun 14 22:20:20 CEST 2010


The attached makes a pass at mapping the libvpx deadline, cpuused,
error resilience and profile parameters.
The first three are combined into level with deadline in the hundred's
place and cpuused from 0-32, with a negative level setting error
resilience. This results in only mapping the pre-defined deadline
values (encode takes a microsecond value) and does combine slightly
unrelated parameters, so suggestions for a better setup are more than
welcome.

* Error resilient mode indicates to the encoder that it should take
* measures appropriate for streaming over lossy or noisy links, if
* possible. Set to 1 to enable this feature, 0 to disable it.
g_error_resilient;

Description of cpuused in relation to deadline [1].

[1]: http://www.webmproject.org/tools/encoder-parameters/#2_encode_quality_vs_speed
-------------- next part --------------
Index: libavcodec/libvpxenc.c
===================================================================
--- libavcodec/libvpxenc.c	(revision 23607)
+++ libavcodec/libvpxenc.c	(working copy)
@@ -276,7 +276,29 @@ static av_cold int vp8_init(AVCodecConte
         enccfg.rc_twopass_stats_in = ctx->twopass_stats;
     }
 
-    ctx->deadline = VPX_DL_GOOD_QUALITY;
+    /* 0-3: For non-zero values the encoder increasingly optimizes for reduced
+       complexity playback on low powered devices at the expense of encode
+       quality. */
+    if (avctx->profile != FF_PROFILE_UNKNOWN)
+        enccfg.g_profile = avctx->profile;
+    switch (FFABS(avctx->level) / 100) {
+    case 1:
+        ctx->deadline = VPX_DL_BEST_QUALITY;
+        break;
+    case 2:
+    default:
+        ctx->deadline = VPX_DL_GOOD_QUALITY;
+        break;
+    case 3:
+        ctx->deadline = VPX_DL_REALTIME;
+        break;
+    }
+    av_log(avctx, AV_LOG_DEBUG, "Using deadline: %lu\n", ctx->deadline);
+
+    if (avctx->level != FF_LEVEL_UNKNOWN) {
+        enccfg.g_error_resilient = avctx->level < 0;
+        cpuused                  = FFABS(avctx->level) % 100 - 16; //[-16,16]
+    }
 
     dump_enc_cfg(avctx, &enccfg);
     /* Construct Encoder Context */



More information about the ffmpeg-devel mailing list