[vlc-devel] [PATCH v2 01/14] chroma: copy: set the picture test buffers after picture_NewFromResource()
Steve Lhomme
robux4 at ycbcr.xyz
Fri Aug 14 14:07:54 CEST 2020
Changes in v2:
- without many patches already merged
- rename picture_NewFromResource to picture_NewWithGC
- fix intermediate patches for the unaligned copy testing
- with Alexandre's patch to copy the picture_context in the pool
(although not totally related, but at some point gc+p_sys and
picture_context_t should be one)
On 2020-08-14 14:01, Steve Lhomme wrote:
> ---
> modules/video_chroma/copy.c | 47 ++++++++++++++++++++++++++++++-------
> 1 file changed, 38 insertions(+), 9 deletions(-)
>
> diff --git a/modules/video_chroma/copy.c b/modules/video_chroma/copy.c
> index 2ad9d2b7a71..875f5071af4 100644
> --- a/modules/video_chroma/copy.c
> +++ b/modules/video_chroma/copy.c
> @@ -1015,6 +1015,18 @@ static const struct test_size sizes[] = {
> };
> #define NB_SIZES ARRAY_SIZE(sizes)
>
> +typedef struct
> +{
> + int i_planes;
> + struct
> + {
> + uint8_t *p_pixels; /**< Start of the plane's data */
> + int i_lines; /**< Number of lines, including margins */
> + int i_pitch; /**< Number of bytes in a line, including margins */
> + } p[PICTURE_PLANE_MAX];
> +
> +} pic_test_resource;
> +
> static void piccheck(picture_t *pic, const vlc_chroma_description_t *dsc,
> bool init)
> {
> @@ -1085,8 +1097,10 @@ static void piccheck(picture_t *pic, const vlc_chroma_description_t *dsc,
>
> static void pic_rsc_destroy(picture_t *pic)
> {
> - for (unsigned i = 0; i < 3; i++)
> - free(pic->p[i].p_pixels);
> + pic_test_resource *rsc = pic->p_sys;
> + for (int i = 0; i < rsc->i_planes; i++)
> + free(rsc->p[i].p_pixels);
> + free(rsc);
> }
>
> static picture_t *pic_new_unaligned(const video_format_t *fmt)
> @@ -1095,15 +1109,30 @@ static picture_t *pic_new_unaligned(const video_format_t *fmt)
> * from the source picture */
> const vlc_chroma_description_t *dsc = vlc_fourcc_GetChromaDescription(fmt->i_chroma);
> assert(dsc);
> - picture_resource_t rsc = { .pf_destroy = pic_rsc_destroy };
> - for (unsigned i = 0; i < dsc->plane_count; i++)
> + pic_test_resource *rsc = malloc(sizeof(*rsc));
> + if (unlikely(rsc == NULL))
> + return NULL;
> + picture_resource_t gc = { .pf_destroy = pic_rsc_destroy };
> + picture_t *pic = picture_NewFromResource(fmt, &gc);
> + if (unlikely(pic == NULL))
> + {
> + free(rsc);
> + return NULL;
> + }
> + pic->p_sys = rsc;
> + rsc->i_planes = dsc->plane_count;
> + for (int i = 0; i < rsc->i_planes; i++)
> {
> - rsc.p[i].i_lines = ((fmt->i_visible_height + (dsc->p[i].h.den - 1)) / dsc->p[i].h.den) * dsc->p[i].h.num;
> - rsc.p[i].i_pitch = ((fmt->i_visible_width + (dsc->p[i].w.den - 1)) / dsc->p[i].w.den) * dsc->p[i].w.num * dsc->pixel_size;
> - rsc.p[i].p_pixels = malloc(rsc.p[i].i_lines * rsc.p[i].i_pitch);
> - assert(rsc.p[i].p_pixels);
> + rsc->p[i].i_lines = ((fmt->i_visible_height + (dsc->p[i].h.den - 1)) / dsc->p[i].h.den) * dsc->p[i].h.num;
> + rsc->p[i].i_pitch = ((fmt->i_visible_width + (dsc->p[i].w.den - 1)) / dsc->p[i].w.den) * dsc->p[i].w.num * dsc->pixel_size;
> + rsc->p[i].p_pixels = malloc(rsc->p[i].i_lines * rsc->p[i].i_pitch);
> + assert(rsc->p[i].p_pixels);
> +
> + pic->p[i].i_lines = rsc->p[i].i_lines;
> + pic->p[i].i_pitch = rsc->p[i].i_pitch;
> + pic->p[i].p_pixels = rsc->p[i].p_pixels;
> }
> - return picture_NewFromResource(fmt, &rsc);
> + return pic;
> }
>
> int main(void)
> --
> 2.26.2
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list