[FFmpeg-devel] [PATCH] avcodec: add msrle encoder

Lynne dev at lynne.ee
Mon Aug 5 15:04:48 EEST 2019


Aug 5, 2019, 9:39 AM by onemda at gmail.com:

> Hi,
>
> Patch attached.
>

> int run = FFMIN(255, copy);

Just replace all FFMIN(255 with av_clip_uint8, should be faster, in theory, on some platforms.


> +        switch (s->pixel_size) {> +        case 3:> +            bytestream2_put_le24(&s->pb, AV_RL24(src));> +            break;> +        case 1:> +            bytestream2_put_byte(&s->pb, src[0]);> +            break;> +        }

Just replace all those switches with something line:
if (s->pixel_size == 3)
    bytestream2_put_le24(&s->pb, AV_RL24(src));
else
    bytestream2_put_byte(&s->pb, src[0]);

4 vs 8 lines.


Also, how do you signal that compression was worse than encoding the frame directly? In the code you just jump to memcpying the frame to the packet. Does the decoder just assume if the packet size is the max packet size its uncompressed?
If so you should check that the compressed stream isn't that same size by some chance, unless its impossible (e.g. compressed stream is always an odd amount of bytes or something).

Rest looks fine.


More information about the ffmpeg-devel mailing list