[FFmpeg-devel] [PATCH] correctly handle MSRLE uncompressed
Baptiste Coudurier
baptiste.coudurier
Wed May 27 23:46:20 CEST 2009
On 5/27/2009 1:50 AM, Kostya wrote:
> On Wed, May 27, 2009 at 12:50:47AM -0700, Baptiste Coudurier wrote:
>> Kostya wrote:
>>>> [...]
>>>>
>>>> - ff_msrle_decode(avctx, (AVPicture*)&s->frame, avctx->bits_per_coded_sample, buf, buf_size);
>>>> + /* FIXME how to correctly detected RLE ??? */
>>> s/detected/detect/
>> Changed.
>>
>>>> + if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
>>>> + 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;
>>> again, maybe
>>> for (j = 0; j < width; j += 2) {
>>> ptr[j+0] = buf[j>>1] >> 4;
>>> ptr[j+1] = buf[j>>1] & 0xF;
>>> }
>>> if (width & 1) ptr[width-1] = buf[j>>1] >> 4;
>>>
>>> thus you'll get rid of unneeded multiplication as well
>>> but if you think this is better, commit this
>> Good :)
>> Changed, I adapted a bit and kept indentation like previous lines,
>> if you don't mind, I can keep your way if you prefer of course.
>
> the excerpt above was written for purely demonstration purposes,
> so identation should be like in yours patch, of course
>
> Oh, and change loop condition to (j = 0; j < avctx->width - 1; j += 2)
> otherwise it will unpack one extraneous pixel in loop for odd widths.
> Besides that patch ok.
Right, changed and applied. Thanks for the review :)
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list