[FFmpeg-devel] [PATCH] correctly handle MSRLE uncompressed

Baptiste Coudurier baptiste.coudurier
Wed May 27 08:51:08 CEST 2009


On 5/26/2009 10:01 PM, Kostya wrote:
> On Tue, May 26, 2009 at 09:00:41PM -0700, Baptiste Coudurier wrote:
>> Hi Kostya,
>>
>> On 5/24/2009 3:17 AM, Kostya wrote:
>>>> [...]
>>>>
>>>> @@ -88,8 +101,31 @@
>>>>          }
>>>>      }
>>>>  
>>>> -    ff_msrle_decode(avctx, (AVPicture*)&s->frame, avctx->bits_per_coded_sample, buf, buf_size);
>>>> +    /* FIXME how to correctly detected RLE ??? */
>>> how to correctly detect RLE
>>> Hint: escape codes at the end
>> Humm, like 0 1 ?
>>
>>>> +    if (avctx->height * istride == avpkt->size) {
>>>> +        int linesize = avctx->width * avctx->bits_per_coded_sample / 8;
>>>> +        uint8_t *ptr = s->frame.data[0];
>>>> +        uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
>>>> +        int i, j;
>>>>  
>>>> +        for (i = 0; i < avctx->height; i++) {
>>>> +            if (avctx->bits_per_coded_sample == 4) {
>>>> +                for (j = 0; j < linesize; j++) {
>>>> +                    ptr[j*2+0] = buf[j] >> 4;
>>>> +                    ptr[j*2+1] = buf[j] & 0xf;
>>>> +                }
>>>> +                if (j*2 < avctx->width)
>>>> +                    ptr[j*2+0] = buf[j] >> 4;
>>> I'd rather write for(j = 0; j < avctx->width; j += 2){unpack byte}
>>> without an additional condition
>> Wouldn't this write one sample too much ?
> 
> It will, but since stride >= width and stride is even, this is not an
> out of bounds write.

Humm, isn't align 1 for PAL8 according to avcodec_align_dimensions ?

> Alternatively you can introduce PIX_FMT_PAL4 and do not unpack source at
> all ;).

Well, maybe it is not worth, since this would require conversions from
and to it.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: msrle_uncompressed2.patch
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090526/c0257f75/attachment.txt>



More information about the ffmpeg-devel mailing list