On 11/08/13 15:33, Anton Khirnov wrote:
> From: Guillaume Martres <[email protected]>
> 

> diff --git a/configure b/configure
> index 2af4d2a..6be84a8 100755
> --- a/configure
> +++ b/configure
> @@ -1592,6 +1592,7 @@ h263i_decoder_select="h263_decoder"
>  h263p_encoder_select="h263_encoder"
>  h264_decoder_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
>  h264_decoder_suggest="error_resilience"
> +hevc_decoder_select="golomb videodsp"

The decoder can do w/out the parser?

> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h

Looks ok.

> diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h
> index afc7c98..d392ba96e 100644
> --- a/libavcodec/cabac_functions.h
> +++ b/libavcodec/cabac_functions.h
> @@ -162,4 +162,24 @@ static int av_unused get_cabac_terminate(CABACContext 
> *c){
>      }
>  }
>  
> +/**
> + * Skip @p n bytes and reset the decoder.
> + * @return the address of the first skipped byte or NULL if there's less 
> than @p n bytes left
> + */
> +static av_unused const uint8_t* skip_bytes(CABACContext *c, int n) {
> +    const uint8_t *ptr = c->bytestream;
> +
> +    if (c->low & 0x1)
> +        ptr--;
> +#if CABAC_BITS == 16
> +    if (c->low & 0x1FF)
> +        ptr--;
> +#endif
> +    if ((int) (c->bytestream_end - ptr) < n)
> +        return NULL;
> +    ff_init_cabac_decoder(c, ptr + n, c->bytestream_end - ptr);
> +
> +    return ptr;
> +}

skip_bytes is a bad name.

> diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c

> +const uint8_t ff_hevc_qpel_extra_before[4] = { 0, 3, 3, 2 };
> +const uint8_t ff_hevc_qpel_extra_after[4] = { 0, 3, 4, 4 };
> +const uint8_t ff_hevc_qpel_extra[4] = { 0, 6, 7, 6 };


align while at it

> +/**
> + * NOTE: Each function hls_foo correspond to the function foo in the
> + * specification (HLS stands for High Level Syntax).
> + */

Wonderful namespace clash... (nothing to be done about it)

> +#define WPP1

????

> +static void pic_arrays_free(HEVCContext *s)
> +{
> +    int i;
> +    HEVCSharedContext *sc = s->HEVCsc;
> +    av_freep(&sc->sao);
> +    av_freep(&sc->deblock);
> +
> +    av_freep(&sc->split_cu_flag);
> +    av_freep(&sc->skip_flag);
> +
> +    av_freep(&sc->tab_ct_depth);
> +
> +    av_freep(&sc->tab_ipm);
> +    av_freep(&sc->horizontal_bs);
> +    av_freep(&sc->vertical_bs);
> +
> +    av_freep(&sc->cbf_luma);
> +    av_freep(&sc->is_pcm);
> +
> +    av_freep(&sc->qp_y_tab);
> +
> +    av_freep(&sc->sh.entry_point_offset);
> +    av_freep(&sc->sh.size);
> +    av_freep(&sc->sh.offset);
> +
> +    for (i = 0; i < FF_ARRAY_ELEMS(sc->DPB); i++) {
> +        av_freep(&sc->DPB[i].tab_mvf);
> +        if (sc->DPB[i].refPicListTab != NULL) {
> +            ff_hevc_free_refPicListTab(s, &sc->DPB[i]);
> +            av_freep(&sc->DPB[i].refPicListTab);
> +        }
> +    }
> +}
> +
> +static int pic_arrays_init(HEVCContext *s)
> +{
> +    int i;
> +    HEVCSharedContext *sc = s->HEVCsc;
> +    int pic_size = sc->sps->pic_width_in_luma_samples * 
> sc->sps->pic_height_in_luma_samples;
> +    int pic_size_in_ctb = pic_size >> (sc->sps->log2_min_coding_block_size 
> << 1);
> +    int ctb_count = sc->sps->pic_width_in_ctbs * sc->sps->pic_height_in_ctbs;
> +    int pic_width_in_min_pu = s->HEVCsc->sps->pic_width_in_luma_samples >> 
> s->HEVCsc->sps->log2_min_pu_size;
> +    int pic_height_in_min_pu = s->HEVCsc->sps->pic_height_in_luma_samples >> 
> s->HEVCsc->sps->log2_min_pu_size;
> +    sc->bs_width = sc->sps->pic_width_in_luma_samples >> 3;
> +    sc->bs_height = sc->sps->pic_height_in_luma_samples >> 3;
> +    sc->sao = av_mallocz(ctb_count * sizeof(*sc->sao));
> +    sc->deblock = av_mallocz(ctb_count * sizeof(DBParams));
> +    sc->split_cu_flag = av_malloc(pic_size);
> +    if (!sc->sao || !sc->deblock || !sc->split_cu_flag)
> +        goto fail;
> +
> +    sc->skip_flag = av_malloc(pic_size_in_ctb);
> +    sc->tab_ct_depth = av_malloc(sc->sps->pic_height_in_min_cbs * 
> sc->sps->pic_width_in_min_cbs);
> +    if (!sc->skip_flag || !sc->tab_ct_depth)
> +        goto fail;
> +
> +    sc->tab_ipm = av_malloc(pic_height_in_min_pu * pic_width_in_min_pu);
> +    if (!sc->tab_ipm)
> +        goto fail;
> +
> +    sc->cbf_luma = av_malloc(pic_width_in_min_pu * pic_height_in_min_pu);
> +    sc->is_pcm = av_malloc(pic_width_in_min_pu * pic_height_in_min_pu);
> +    if (!sc->cbf_luma || !sc->is_pcm)
> +        goto fail;

What about checking only once?

> +
> +    sc->qp_y_tab = av_malloc(pic_size_in_ctb * sizeof(int8_t));
> +    if (!sc->qp_y_tab)
> +        goto fail;
> +
> +    for (i = 0; i < FF_ARRAY_ELEMS(sc->DPB); i++) {
> +        sc->DPB[i].tab_mvf = av_malloc(pic_width_in_min_pu  *
> +                                       pic_height_in_min_pu *
> +                                       sizeof(*sc->DPB[i].tab_mvf));

we do have the array variant for such situations.

> +        if (!sc->DPB[i].tab_mvf)
> +            goto fail;
> +        sc->DPB[i].refPicListTab = av_mallocz(ctb_count * 
> sizeof(RefPicListTab**));
> +        if (!sc->DPB[i].refPicListTab)
> +            goto fail;
> +    }
> +
> +    sc->horizontal_bs = av_mallocz(2 * sc->bs_width * sc->bs_height);
> +    sc->vertical_bs   = av_mallocz(2 * sc->bs_width * sc->bs_height);
> +    if (!sc->horizontal_bs || !sc->vertical_bs)
> +        goto fail;
> +    return 0;
> +fail:
> +    pic_arrays_free(s);
> +    return AVERROR(ENOMEM);
> +}

Next parts reviewed later.

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to