[FFmpeg-devel] [PATCH 5/7] vp9: allocate 'b', 'block/uvblock' and 'eob/uveob' dynamically.

Clément Bœsch u at pkh.me
Tue Nov 26 10:41:30 CET 2013


On Mon, Nov 25, 2013 at 09:44:48PM -0500, Ronald S. Bultje wrote:
> ---
>  libavcodec/vp9.c | 40 ++++++++++++++++++++++++++++------------
>  1 file changed, 28 insertions(+), 12 deletions(-)
> 
> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
> index df9b197..6a99aeb 100644
> --- a/libavcodec/vp9.c
> +++ b/libavcodec/vp9.c
> @@ -98,7 +98,7 @@ typedef struct VP9Context {
>      VP56RangeCoder c;
>      VP56RangeCoder *c_b;
>      unsigned c_b_size;
> -    VP9Block b;
> +    VP9Block *b_base, *b;
>      int row, row7, col, col7;
>      uint8_t *dst[3];
>      ptrdiff_t y_stride, uv_stride;
> @@ -228,10 +228,8 @@ typedef struct VP9Context {
>      DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[71*80];
>  
>      // block reconstruction intermediates
> -    DECLARE_ALIGNED(32, int16_t, block)[4096];
> -    DECLARE_ALIGNED(32, int16_t, uvblock)[2][1024];
> -    uint8_t eob[256];
> -    uint8_t uveob[2][64];
> +    int16_t *block_base, *block, *uvblock_base[2], *uvblock[2];
> +    uint8_t *eob_base, *uveob_base[2], *eob, *uveob[2];
>      VP56mv min_mv, max_mv;
>      DECLARE_ALIGNED(32, uint8_t, tmp_y)[64*64];
>      DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][32*32];
> @@ -330,6 +328,15 @@ static int update_size(AVCodecContext *ctx, int w, int h)
>      assign(s->above_mv_ctx,        VP56mv(*)[2],          16);
>  #undef assign
>  
> +    av_free(s->b_base);
> +    av_free(s->block_base);
> +        s->b_base = av_malloc(sizeof(VP9Block));
> +        s->block_base = av_mallocz((64 * 64 + 128) * 3);

indent, unchecked alloc

> +        s->uvblock_base[0] = s->block_base + 64 * 64;
> +        s->uvblock_base[1] = s->uvblock_base[0] + 32 * 32;
> +        s->eob_base = (uint8_t *) (s->uvblock_base[1] + 32 * 32);
> +        s->uveob_base[0] = s->eob_base + 256;
> +        s->uveob_base[1] = s->uveob_base[0] + 64;
>      return 0;
>  }
>  
> @@ -908,7 +915,7 @@ static void find_ref_mvs(VP9Context *s,
>          [BS_4x4]   = {{  0, -1 }, { -1,  0 }, { -1, -1 }, {  0, -2 },
>                        { -2,  0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
>      };
> -    VP9Block *const b = &s->b;
> +    VP9Block *b = s->b;
>      int row = s->row, col = s->col, row7 = s->row7;
>      const int8_t (*p)[2] = mv_ref_blk_off[b->bs];
>  #define INVALID_MV 0x80008000U
> @@ -1121,7 +1128,7 @@ static av_always_inline int read_mv_component(VP9Context *s, int idx, int hp)
>  static void fill_mv(VP9Context *s,
>                      VP56mv *mv, int mode, int sb)
>  {
> -    VP9Block *const b = &s->b;
> +    VP9Block *b = s->b;
>  

I'm not sure why you need to remove the constness of the block here, I
don't see any access change to it in the diff. Can you elaborate?

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131126/4878c596/attachment.asc>


More information about the ffmpeg-devel mailing list