[FFmpeg-devel] [PATCH]Fix mono pam encoding
Michael Niedermayer
michaelni at gmx.at
Sat Dec 31 16:13:25 CET 2011
On Sat, Dec 31, 2011 at 01:52:12PM +0100, Carl Eugen Hoyos wrote:
> Hi!
>
> Attached fixes encoding of mono* to pam.
> The decoder is less trivial, it currently works correctly for mono pnm, fails
> for monob pam.
>
> Please comment, Carl Eugen
> pamenc.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
> 8de7f69245abf477a8df236747f369c942f8290c patchpamblack.diff
> diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c
> index 28fe7e1..1cea9e6 100644
> --- a/libavcodec/pamenc.c
> +++ b/libavcodec/pamenc.c
> @@ -50,7 +50,7 @@ static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf,
> h = avctx->height;
> w = avctx->width;
> switch (avctx->pix_fmt) {
> - case PIX_FMT_MONOWHITE:
> + case PIX_FMT_MONOBLACK:
> n = (w + 7) >> 3;
> depth = 1;
> maxval = 1;
> @@ -97,6 +97,13 @@ static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf,
> }
> ptr += linesize;
> }
> + } else if (avctx->pix_fmt == PIX_FMT_MONOBLACK){
> + int j;
> + for (i = 0; i < h; i++) {
> + for (j = 0; j < w; j++)
> + *s->bytestream++ = ptr[j >> 3] >> (7 - j % 8) & 1;
(j&7) is faster with dumb compilers
otherwise LGTM
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111231/1d8000e8/attachment.asc>
More information about the ffmpeg-devel
mailing list