diff options
author | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2013-02-21 01:54:21 +0400 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2013-02-21 11:59:38 +0400 |
commit | 4c2b6ce26cf92f66d50dcd8335ebb78a54169015 (patch) | |
tree | 3d5e592934ecbb59c9af26c9d833de2abdc9e59b | |
parent | 98d06b046dfec1a61cfd04906aff213b6fcce7e4 (diff) |
Fix bits_per_coded_sample when encoding png with frame-level multithreading.
Fixes ticket #2290.
(cherry picked from commit c4dc6c4c86a052b7ba53fa7ae0c1b0643ad70d0b)
Conflicts:
libavcodec/pngenc.c
-rw-r--r-- | libavcodec/pngenc.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 0d00a0866c..96511b3df3 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -244,12 +244,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, color_type = PNG_COLOR_TYPE_RGB; break; case PIX_FMT_RGBA: - avctx->bits_per_coded_sample = 32; bit_depth = 8; color_type = PNG_COLOR_TYPE_RGB_ALPHA; break; case PIX_FMT_RGB24: - avctx->bits_per_coded_sample = 24; bit_depth = 8; color_type = PNG_COLOR_TYPE_RGB; break; @@ -258,7 +256,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, color_type = PNG_COLOR_TYPE_GRAY; break; case PIX_FMT_GRAY8: - avctx->bits_per_coded_sample = 0x28; bit_depth = 8; color_type = PNG_COLOR_TYPE_GRAY; break; @@ -267,12 +264,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, color_type = PNG_COLOR_TYPE_GRAY_ALPHA; break; case PIX_FMT_MONOBLACK: - avctx->bits_per_coded_sample = bit_depth = 1; color_type = PNG_COLOR_TYPE_GRAY; break; case PIX_FMT_PAL8: - avctx->bits_per_coded_sample = bit_depth = 8; color_type = PNG_COLOR_TYPE_PALETTE; break; @@ -432,6 +427,23 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, static av_cold int png_enc_init(AVCodecContext *avctx){ PNGEncContext *s = avctx->priv_data; + switch(avctx->pix_fmt) { + case PIX_FMT_RGBA: + avctx->bits_per_coded_sample = 32; + break; + case PIX_FMT_RGB24: + avctx->bits_per_coded_sample = 24; + break; + case PIX_FMT_GRAY8: + avctx->bits_per_coded_sample = 0x28; + break; + case PIX_FMT_MONOBLACK: + avctx->bits_per_coded_sample = 1; + break; + case PIX_FMT_PAL8: + avctx->bits_per_coded_sample = 8; + } + avcodec_get_frame_defaults(&s->picture); avctx->coded_frame= &s->picture; ff_dsputil_init(&s->dsp, avctx); |