Mercurial > mplayer.hg
changeset 34635:7e0f50b4921c
Fix vo_png after FFmpeg merge.
Now avcodec_open2() function wants a valid avctx->pix_fmt to be set,
but the current vo_png opens the encoder in preinit() function,
long before the exact pixel format is know.
The fix moves the avcodec_open2() function to vo_png::config() and
adds a check for changed pixel format in case there are more config() calls.
author | iive |
---|---|
date | Tue, 14 Feb 2012 17:06:09 +0000 |
parents | 0ef7177a063b |
children | fde1a35cf043 |
files | libvo/vo_png.c |
diffstat | 1 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/vo_png.c Tue Feb 14 16:50:42 2012 +0000 +++ b/libvo/vo_png.c Tue Feb 14 17:06:09 2012 +0000 @@ -55,6 +55,7 @@ static int z_compression; static char *png_outdir; static char *png_outfile_prefix; +static uint32_t png_format; static int framenum; static int use_alpha; static AVCodecContext *avctx; @@ -122,6 +123,22 @@ png_mkdir(buf, 1); mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression); + + if (avctx && png_format != format) { + avcodec_close(avctx); + av_freep(&avctx); + } + + if (!avctx) { + avctx = avcodec_alloc_context3(NULL); + avctx->compression_level = z_compression; + avctx->pix_fmt = imgfmt2pixfmt(format); + if (avcodec_open2(avctx, avcodec_find_encoder(CODEC_ID_PNG), NULL) < 0) { + uninit(); + return -1; + } + png_format = format; + } return 0; } @@ -145,7 +162,6 @@ avctx->width = mpi->w; avctx->height = mpi->h; - avctx->pix_fmt = imgfmt2pixfmt(mpi->imgfmt); pic.data[0] = mpi->planes[0]; pic.linesize[0] = mpi->stride[0]; buffersize = mpi->w * mpi->h * 8; @@ -232,12 +248,6 @@ return -1; } avcodec_register_all(); - avctx = avcodec_alloc_context3(NULL); - if (avcodec_open2(avctx, avcodec_find_encoder(CODEC_ID_PNG), NULL) < 0) { - uninit(); - return -1; - } - avctx->compression_level = z_compression; return 0; }