1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Fix bits_per_coded_sample when encoding png with frame-level multithreading.

Fixes ticket #2290.
This commit is contained in:
Carl Eugen Hoyos 2013-02-20 22:54:21 +01:00
parent 624fb5f965
commit c4dc6c4c86

View File

@ -244,12 +244,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
color_type = PNG_COLOR_TYPE_RGB; color_type = PNG_COLOR_TYPE_RGB;
break; break;
case AV_PIX_FMT_RGBA: case AV_PIX_FMT_RGBA:
avctx->bits_per_coded_sample = 32;
bit_depth = 8; bit_depth = 8;
color_type = PNG_COLOR_TYPE_RGB_ALPHA; color_type = PNG_COLOR_TYPE_RGB_ALPHA;
break; break;
case AV_PIX_FMT_RGB24: case AV_PIX_FMT_RGB24:
avctx->bits_per_coded_sample = 24;
bit_depth = 8; bit_depth = 8;
color_type = PNG_COLOR_TYPE_RGB; color_type = PNG_COLOR_TYPE_RGB;
break; break;
@ -258,7 +256,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
color_type = PNG_COLOR_TYPE_GRAY; color_type = PNG_COLOR_TYPE_GRAY;
break; break;
case AV_PIX_FMT_GRAY8: case AV_PIX_FMT_GRAY8:
avctx->bits_per_coded_sample = 0x28;
bit_depth = 8; bit_depth = 8;
color_type = PNG_COLOR_TYPE_GRAY; color_type = PNG_COLOR_TYPE_GRAY;
break; break;
@ -267,12 +264,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
color_type = PNG_COLOR_TYPE_GRAY_ALPHA; color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
break; break;
case AV_PIX_FMT_MONOBLACK: case AV_PIX_FMT_MONOBLACK:
avctx->bits_per_coded_sample =
bit_depth = 1; bit_depth = 1;
color_type = PNG_COLOR_TYPE_GRAY; color_type = PNG_COLOR_TYPE_GRAY;
break; break;
case AV_PIX_FMT_PAL8: case AV_PIX_FMT_PAL8:
avctx->bits_per_coded_sample =
bit_depth = 8; bit_depth = 8;
color_type = PNG_COLOR_TYPE_PALETTE; color_type = PNG_COLOR_TYPE_PALETTE;
break; break;
@ -437,6 +432,23 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int png_enc_init(AVCodecContext *avctx){ static av_cold int png_enc_init(AVCodecContext *avctx){
PNGEncContext *s = avctx->priv_data; PNGEncContext *s = avctx->priv_data;
switch(avctx->pix_fmt) {
case AV_PIX_FMT_RGBA:
avctx->bits_per_coded_sample = 32;
break;
case AV_PIX_FMT_RGB24:
avctx->bits_per_coded_sample = 24;
break;
case AV_PIX_FMT_GRAY8:
avctx->bits_per_coded_sample = 0x28;
break;
case AV_PIX_FMT_MONOBLACK:
avctx->bits_per_coded_sample = 1;
break;
case AV_PIX_FMT_PAL8:
avctx->bits_per_coded_sample = 8;
}
avcodec_get_frame_defaults(&s->picture); avcodec_get_frame_defaults(&s->picture);
avctx->coded_frame= &s->picture; avctx->coded_frame= &s->picture;
ff_dsputil_init(&s->dsp, avctx); ff_dsputil_init(&s->dsp, avctx);