[FFmpeg-devel] [PATCH] swscale: factorize plane copying code out of 2 functions

Ramiro Polla ramiro.polla
Thu Sep 16 03:14:30 CEST 2010


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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: copyPlane_width_stride.diff
Type: text/x-patch
Size: 449 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100915/f3abd460/attachment.bin>



More information about the ffmpeg-devel mailing list