[FFmpeg-devel] [PATCH] swscale: factorize plane copying code out of 2 functions
Michael Niedermayer
michaelni
Thu Sep 16 16:08:04 CEST 2010
On Wed, Sep 15, 2010 at 10:14:30PM -0300, Ramiro Polla wrote:
> On Sat, Sep 11, 2010 at 3:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Sat, Sep 11, 2010 at 11:35:41AM -0300, Ramiro Polla wrote:
> [...]
> >> ?swscale.c | ? 49 ++++++++++++++++++++++---------------------------
> >> ?1 file changed, 22 insertions(+), 27 deletions(-)
> >> 92af1cd640f3b04ccb3073506a34b51a7ee2aa07 ?copyPlane.diff
> >> Index: swscale.c
> >> ===================================================================
> >> --- swscale.c (revision 32157)
> >> +++ swscale.c (working copy)
> >> @@ -1308,24 +1308,32 @@
> >> ?#endif //!CONFIG_RUNTIME_CPUDETECT
> >> ?}
> >>
> >> -static int planarToNv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int srcSliceH, uint8_t* dstParam[], int dstStride[])
> >> +static void copyPlane(const uint8_t *src, int srcStride,
> >> + ? ? ? ? ? ? ? ? ? ? ?int srcSliceY, int srcSliceH, int width,
> >> + ? ? ? ? ? ? ? ? ? ? ?uint8_t *dst, int dstStride)
> >> ?{
> >> - ? ?uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
> >> - ? ?/* Copy Y plane */
> >> - ? ?if (dstStride[0]==srcStride[0] && srcStride[0] > 0)
> >> - ? ? ? ?memcpy(dst, src[0], srcSliceH*dstStride[0]);
> >> - ? ?else {
> >> + ? ?if (dstStride == srcStride && srcStride > 0) {
> >> + ? ? ? ?memcpy(dst, src, srcSliceH * dstStride);
> >
> > iam not sure this is safe if stride > width*bytes_per_sample
>
> So should it be only if (width == dstStride == srcStride && srcStride
> > 0)? (as in attached patch)
>
> > except that the patch should be ok
>
> Actually the patch would ignore strides. Fixed and applied. (btw this
> wasn't caught by swscale-test because it doesn't do strides)
> swscale.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 711561766d150bb05875d28bc61a1f3419d18cd3 copyPlane_width_stride.diff
> Index: swscale.c
> ===================================================================
> --- swscale.c (revision 32258)
> +++ swscale.c (working copy)
> @@ -1313,7 +1313,7 @@
> uint8_t *dst, int dstStride)
> {
> dst += dstStride * srcSliceY;
> - if (dstStride == srcStride && srcStride > 0) {
> + if (width == dstStride == srcStride && srcStride > 0) {
that does not work
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100916/02f73008/attachment.pgp>
More information about the ffmpeg-devel
mailing list