[FFmpeg-devel] [PATCH]Support encoding gray8a png

Michael Niedermayer michaelni at gmx.at
Sun Jan 15 21:14:40 CET 2012


On Sun, Jan 15, 2012 at 01:58:51AM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Successfully tested with reencoding gray8a png samples, I will not apply as 
> long as avcodec_find_best_pix_fmt2() thinks that gray8a is particularly 
> useful.
> 
> Carl Eugen

>  pngenc.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> f062e64c033d6955ee50b1b784ad693dfbbe6978  patchpngencg8a.diff
> diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
> index b35402e..27f1a58 100644
> --- a/libavcodec/pngenc.c
> +++ b/libavcodec/pngenc.c
> @@ -264,6 +264,10 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
>          bit_depth = 8;
>          color_type = PNG_COLOR_TYPE_GRAY;
>          break;
> +    case PIX_FMT_GRAY8A:
> +        bit_depth = 8;
> +        color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
> +        break;
>      case PIX_FMT_MONOBLACK:
>          bit_depth = 1;
>          color_type = PNG_COLOR_TYPE_GRAY;
> @@ -443,6 +447,6 @@ AVCodec ff_png_encoder = {
>      .priv_data_size = sizeof(PNGEncContext),
>      .init           = png_enc_init,
>      .encode         = encode_frame,
> -    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_PAL8, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, PIX_FMT_NONE},
> +    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_GRAY8A, PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_PAL8, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, PIX_FMT_NONE},

i think its better not to put gray as the first in case some
application picks the first supported.

otherwise LGTM

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- 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/20120115/4d3753bf/attachment.asc>


More information about the ffmpeg-devel mailing list