我应该为 *.png(PNG-24 和 PNG-8)图像使用什么AvPixelFormat ?我正在尝试使用 sws_scale 从 png 转换为 PIX_FMT_YUV420P
编辑,代码:
avpicture_fill((AVPicture*)m_encode_inpic, (uint8_t*)imagePixels, <WHAT PNG PIXELS FORMAT?>, m_imgInputWidth, m_imgInputHeight); //imagePixels is png bytes
avpicture_fill((AVPicture*)m_encode_outpic, m_encode_outbuffer, PIX_FMT_YUV420P, m_encode_codec_context->width, m_encode_codec_context->height);
av_image_alloc(m_encode_outpic->data, m_encode_outpic->linesize, m_encode_codec_context->width, m_encode_codec_context->height, m_encode_codec_context->pix_fmt, 1);
struct SwsContext* fooContext = sws_getContext(m_videoOutputWidth, m_videoOutputHeight, PIX_FMT_RGB32, m_encode_codec_context->width, m_encode_codec_context->height, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
sws_scale(fooContext, m_encode_inpic->data, m_encode_inpic->linesize, 0, m_encode_codec_context->height, m_encode_outpic->data, m_encode_outpic->linesize);
Jpeg 像素格式是 AV_PIX_FMT_YUVJ420P,但是 PNG 是什么格式呢?