[artwork] Fix for issue #345 and #367: Broken PNG rescaling

This commit is contained in:
ejurgensen 2017-03-15 22:12:37 +01:00
parent efd6805f9e
commit ef13abe2cf
1 changed files with 4 additions and 5 deletions

View File

@ -456,11 +456,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
dst->codec_id = dst_fmt->video_codec; dst->codec_id = dst_fmt->video_codec;
dst->codec_type = AVMEDIA_TYPE_VIDEO; dst->codec_type = AVMEDIA_TYPE_VIDEO;
if (dst_fmt->video_codec == AV_CODEC_ID_PNG) dst->pix_fmt = avcodec_default_get_format(dst, img_encoder->pix_fmts);
dst->pix_fmt = AV_PIX_FMT_RGB24;
else
dst->pix_fmt = avcodec_find_best_pix_fmt_of_list((enum AVPixelFormat *)img_encoder->pix_fmts, src->pix_fmt, 1, NULL);
if (dst->pix_fmt < 0) if (dst->pix_fmt < 0)
{ {
DPRINTF(E_LOG, L_ART, "Could not determine best pixel format\n"); DPRINTF(E_LOG, L_ART, "Could not determine best pixel format\n");
@ -513,6 +509,9 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
#else #else
avpicture_fill((AVPicture *)o_frame, buf, dst->pix_fmt, src->width, src->height); avpicture_fill((AVPicture *)o_frame, buf, dst->pix_fmt, src->width, src->height);
#endif #endif
o_frame->height = dst->height;
o_frame->width = dst->width;
o_frame->format = dst->pix_fmt;
swsctx = sws_getContext(src->width, src->height, src->pix_fmt, swsctx = sws_getContext(src->width, src->height, src->pix_fmt,
dst->width, dst->height, dst->pix_fmt, dst->width, dst->height, dst->pix_fmt,