[FFmpeg-devel] [PATCH] VP8: simplify splitmv parsing

Ronald S. Bultje rsbultje
Mon Jun 28 18:08:29 CEST 2010


Hi,

On Mon, Jun 28, 2010 at 3:19 AM, David Conrad <lessen42 at gmail.com> wrote:
> On Jun 26, 2010, at 8:22 PM, Ronald S. Bultje wrote:
>> related to the previous patch, this patch simplifies the splitMV
>> reading since we don't need to spread out all MVs across 4x4 subblocks
>> (except if they are actually coded that way). This probably leads to a
>> modest speedup but I didn't test that.
>>
>> Ronald
>
>> Index: ffmpeg-svn/libavcodec/vp8.c
>> ===================================================================
>> --- ffmpeg-svn.orig/libavcodec/vp8.c ?2010-06-26 14:22:50.000000000 -0400
>> +++ ffmpeg-svn/libavcodec/vp8.c ? ? ? 2010-06-26 16:28:45.000000000 -0400
>> @@ -590,44 +590,54 @@
>>
>> ?/**
>> ? * Split motion vector prediction, 16.4.
>> + * @returns the number of motion vectors parsed (2, 4 or 16)
>> ? */
>> -static void decode_splitmvs(VP8Context ? ?*s, ?VP56RangeCoder *c,
>> +static int decode_splitmvs(VP8Context ? ?*s, ?VP56RangeCoder *c,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?VP8Macroblock *mb, VP56mv ? ? ? ? *base_mv)
>> ?{
>> ? ? ?int part_idx = mb->partitioning =
>> ? ? ? ? ?vp8_rac_get_tree(c, vp8_mbsplit_tree, vp8_mbsplit_prob);
>> ? ? ?int n, num = vp8_mbsplit_count[part_idx];
>> - ? ?VP56mv part_mv[16];
>> + ? ?const uint8_t *mbsplits = vp8_mbsplits[part_idx],
>> + ? ? ? ? ? ? ? ? ?*firstidx = vp8_mbfirstidx[part_idx];
>>
>> ? ? ?for (n = 0; n < num; n++) {
>> - ? ? ? ?int k = vp8_mbfirstidx[part_idx][n];
>> - ? ? ? ?const VP56mv *left ?= (k & 3) ? &mb->bmv[k - 1] : &mb[-1].bmv[k + 3],
>> - ? ? ? ? ? ? ? ? ? ? *above = (k > 3) ? &mb->bmv[k - 4] : &mb[-s->mb_stride].bmv[k + 12];
>> - ? ? ? ?const uint8_t *submv_prob = get_submv_prob(left, above);
>> + ? ? ? ?int k = firstidx[n];
>> + ? ? ? ?const VP56mv *left, *above;
>> + ? ? ? ?const uint8_t *submv_prob;
>> +
>> + ? ? ? ?if (!(k & 3)) {
>> + ? ? ? ? ? ?VP8Macroblock *left_mb = &mb[-1];
>> + ? ? ? ? ? ?left = &left_mb->bmv[vp8_mbsplits[left_mb->partitioning][k + 3]];
>> + ? ? ? ?} else
>> + ? ? ? ? ? ?left ?= &mb->bmv[mbsplits[k - 1]];
>> + ? ? ? ?if (k <= 3) {
>> + ? ? ? ? ? ?VP8Macroblock *above_mb = &mb[-s->mb_stride];
>> + ? ? ? ? ? ?above = &above_mb->bmv[vp8_mbsplits[above_mb->partitioning][k + 12]];
>> + ? ? ? ?} else
>> + ? ? ? ? ? ?above = &mb->bmv[mbsplits[k - 4]];
>> +
>> + ? ? ? ?submv_prob = get_submv_prob(left, above);
>
> I was thinking about splitting out bmv to its own array like in the mpeg decoders partly to make this cleaner (maybe). The idea being to switch(partitioning) here and fill_rect, though I'm not sure which would be faster or if that method would even be less LoC.
>
> So this is ok for now.

Thanks, applied.

Ronald



More information about the ffmpeg-devel mailing list