[FFmpeg-devel] [PATCH] swscale-test: add md5 output
Stefano Sabatini
stefano.sabatini-lala
Thu Aug 19 23:39:24 CEST 2010
On date Thursday 2010-08-19 16:16:09 -0300, Ramiro Polla encoded:
> On Thu, Aug 19, 2010 at 11:52 AM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
> > On Thu, Aug 19, 2010 at 7:32 AM, Stefano Sabatini
> > <stefano.sabatini-lala at poste.it> wrote:
> >> On date Thursday 2010-08-19 00:44:17 -0300, Ramiro Polla encoded:
> >>> On Tue, Aug 17, 2010 at 9:14 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >>> > On Mon, Aug 16, 2010 at 05:09:35PM -0300, Ramiro Polla wrote:
> >>> BTW we're currently allocating stride*height for all planes, it'd be
> >>> nice if there was a function that could give back the result of the
> >>> size[] calculation from av_fill_image_pointers() (Stefano might want
> >>> to do this =).
> >>
> >> You can use av_fill_image_pointers() and pass NULL to ptr.
> >> Check how it's done in avfilter_default_get_video_buffer().
> >
> > That's not so straight-forward. From what I understood in the
> > function, to get the size of each plane I'd have to calculate some
> > more based on data pointers, total size, and number of planes. And the
> > size[] array in that function should already contain what I need.
>
> Something like attached (I know it's not ready yet, it duplicates code
> and lacks documentation, but just to have an idea)
> Index: libavcore/imgutils.h
> ===================================================================
> --- libavcore/imgutils.h (revision 24839)
> +++ libavcore/imgutils.h (working copy)
> @@ -78,6 +78,9 @@
> */
> int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width);
>
> +int av_fill_image_plane_sizes(int size[4], enum PixelFormat pix_fmt,
> + int width, int height);
> +
This name or av_{fill,get}_image_planesizes() should be fine.
> /**
> * Fill plane data pointers for an image with pixel format pix_fmt and
> * height height.
> Index: libavcore/imgutils.c
> ===================================================================
> --- libavcore/imgutils.c (revision 24839)
> +++ libavcore/imgutils.c (working copy)
> @@ -65,6 +65,42 @@
> return 0;
> }
>
> +int av_fill_image_plane_sizes(int size[4], enum PixelFormat pix_fmt,
> + int width, int height)
> +{
> + int i, total_size, has_plane[4], linesizes[4];
> +
> + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
> + memset(size , 0, sizeof(size));
> + memset(has_plane, 0, sizeof(has_plane));
> +
> + if (desc->flags & PIX_FMT_HWACCEL)
> + return AVERROR(EINVAL);
> +
> + av_fill_image_linesizes(linesizes, pix_fmt, width);
> +
> + size[0] = linesizes[0] * height;
> +
> + if (desc->flags & PIX_FMT_PAL) {
> + size[0] = (size[0] + 3) & ~3;
> + size[1] = 256 * 4;
> + return size[0] + size[1];
> + }
> +
> + for (i = 0; i < 4; i++)
> + has_plane[desc->comp[i].plane] = 1;
> +
> + total_size = size[0];
> + for (i = 1; has_plane[i] && i < 4; i++) {
> + int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
> + h = (height + (1 << s) - 1) >> s;
> + size[i] = h * linesizes[i];
> + total_size += size[i];
> + }
> +
> + return total_size;
If you think this would be useful, I'm not against that. You can avoid
duplication using the function inside av_fill_image_pointers().
Regards.
More information about the ffmpeg-devel
mailing list