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

James Zern jzern
Wed Oct 20 02:54:21 CEST 2010


On Sun, Oct 17, 2010 at 15:01, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Tue, Oct 12, 2010 at 02:28:22PM -0700, Jason Garrett-Glaser 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.
>
> that also could be usefull to ffv1
>
Attached is a pass at this. It's split between the option addition,
libvpxenc and libx264. I wasn't sure about ffv1 given the version and
[hv]_slices differences otherwise I would have attached one for that
as well.
For the new member I was thinking slice_count, but noticed that was
already taken. As far as I could tell only the real video codecs are
using that, but didn't think it should be reused if it serves a
different purpose. The default of 0 should avoid changing the default
behavior of libvpx and x264.
-------------- next part --------------
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4bddbaa..705259e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -31,7 +31,7 @@
 #include "libavutil/cpu.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 92
+#define LIBAVCODEC_VERSION_MINOR 93
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -2744,6 +2744,15 @@ typedef struct AVCodecContext {
      * - decoding: unused
      */
     int lpc_passes;
+
+    /**
+     * Number of slices.
+     * Indicates number of picture subdivisions. Used for parallelized
+     * decoding.
+     * - encoding: Set by user
+     * - decoding: unused
+     */
+    int slices;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 6969d42..ef7573c 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -425,6 +425,7 @@ static const AVOption options[]={
 {"levinson", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, A|E, "lpc_type"},
 {"cholesky", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, A|E, "lpc_type"},
 {"lpc_passes", "number of passes to use for Cholesky factorization during LPC analysis", OFFSET(lpc_passes), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
+{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
 {NULL},
 };
 
-------------- next part --------------
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 77a3bbf..4e16c72 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -310,6 +310,7 @@ static av_cold int vp8_init(AVCodecContext *avctx)
     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(avctx->slices));
 
     //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,
-------------- next part --------------
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 8387f41..7ce04a6 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -294,6 +294,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
 
     x4->params.b_interlaced   = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
 
+    x4->params.i_slice_count  = avctx->slices;
+
     if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
         x4->params.b_repeat_headers = 0;
 



More information about the ffmpeg-devel mailing list