[FFmpeg-devel] [PATCH] libvpx: add token_partitions option

James Zern jzern
Wed Oct 13 20:49:50 CEST 2010


On Tue, Oct 12, 2010 at 14:28, Jason Garrett-Glaser
<darkshikari at gmail.com> wrote:
> On Tue, Oct 12, 2010 at 2:21 PM, James Zern <jzern at google.com> wrote:
>> Sorry for the delay in response to the ping on '[PATCH] libvpx:
>> deadline & profile support', I've been offline a bit and am just
>> coming back up to speed.
>> The attached adds a codec-specific option for libvpxenc to enable
>> setting the number of token partitions.
>> This does inherit a warning in the copy over from libvorbis for the
>> priv_class initialization. Should the AVCodec definition change or is
>> this acceptable?
>
> This seems like it should be a more generic option called --slices,
> which should be mapped to x264's slices option as well.
>
Do you think they're closely enough related to have libvpx reuse this
new option? I think the behavior is slightly different and token
partitions are limited to 1, 2, 4 & 8 in VP8, so this might cause a
bit of confusion.
Updated the original with the av_default_item_name addition as with libvorbis.
-------------- next part --------------
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h	(revision 25471)
+++ libavcodec/avcodec.h	(working copy)
@@ -32,7 +32,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 52
 #define LIBAVCODEC_VERSION_MINOR 92
-#define LIBAVCODEC_VERSION_MICRO  0
+#define LIBAVCODEC_VERSION_MICRO  1
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
Index: libavcodec/libvpxenc.c
===================================================================
--- libavcodec/libvpxenc.c	(revision 25471)
+++ libavcodec/libvpxenc.c	(working copy)
@@ -28,6 +28,7 @@
 #include <vpx/vpx_encoder.h>
 #include <vpx/vp8cx.h>
 
+#include "libavutil/opt.h"
 #include "avcodec.h"
 #include "libavutil/base64.h"
 
@@ -52,8 +53,22 @@
     struct vpx_fixed_buf twopass_stats;
     unsigned long deadline; //i.e., RT/GOOD/BEST
     struct FrameListData *coded_frame_list;
+
+    /**
+     * Number of token partitions.
+     * Indicates number of sub-streams in the bitstream. Used for parallelized
+     * decoding.
+     * Valid values are 1, 2, 4 & 8
+     */
+    int token_partitions;
 } VP8Context;
 
+static const AVOption options[]={
+{"token_partitions", "Number of sub-streams in bitstream (1,2,4,8). Used for parallelized decoding.", offsetof(VP8Context, token_partitions), FF_OPT_TYPE_INT, 1, 1, 8, AV_OPT_FLAG_ENCODING_PARAM},
+{NULL}
+};
+static const AVClass class = { "libvpx", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
+
 /** String mappings for enum vp8e_enc_control_id */
 static const char *ctlidstr[] = {
     [VP8E_UPD_ENTROPY]           = "VP8E_UPD_ENTROPY",
@@ -310,6 +325,7 @@
     av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
     codecctl_int(avctx, VP8E_SET_CPUUSED,           cpuused);
     codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
+    codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS,  av_log2(ctx->token_partitions));
 
     //provide dummy value to initialize wrapper, values will be updated each _encode()
     vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
@@ -505,4 +521,5 @@
     CODEC_CAP_DELAY,
     .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"),
+    .priv_class= &class,
 };



More information about the ffmpeg-devel mailing list