r38306 - trunk/libvo/vo_png.c
Author: reimar Date: Sat May 1 20:45:29 2021 New Revision: 38306 Log: vo_png: switch to new FFmpeg API. Modified: trunk/libvo/vo_png.c Modified: trunk/libvo/vo_png.c ============================================================================== --- trunk/libvo/vo_png.c Thu Apr 15 22:26:53 2021 (r38305) +++ trunk/libvo/vo_png.c Sat May 1 20:45:29 2021 (r38306) @@ -150,8 +150,7 @@ config(uint32_t width, uint32_t height, static uint32_t draw_image(mp_image_t* mpi){ AVFrame *pic; - int buffersize; - int res, got_pkt; + int res; char buf[100]; FILE *outfile; AVPacket pkt; @@ -174,26 +173,25 @@ static uint32_t draw_image(mp_image_t* m pic->format = imgfmt2pixfmt(png_format); pic->data[0] = mpi->planes[0]; pic->linesize[0] = mpi->stride[0]; - buffersize = mpi->w * mpi->h * 8; - if (outbuffer_size < buffersize) { - av_freep(&outbuffer); - outbuffer = av_malloc(buffersize); - outbuffer_size = buffersize; - } av_init_packet(&pkt); - pkt.data = outbuffer; - pkt.size = outbuffer_size; - res = avcodec_encode_video2(avctx, &pkt, pic, &got_pkt); + res = avcodec_send_frame(avctx, pic); + if (res >= 0) { + res = avcodec_receive_packet(avctx, &pkt); + if (res == AVERROR(EAGAIN)) { + avcodec_send_frame(avctx, NULL); + res = avcodec_receive_packet(avctx, &pkt); + } + } av_frame_free(&pic); - if (res < 0 || !got_pkt) { + if (res < 0) { mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng); } else { - fwrite(outbuffer, pkt.size, 1, outfile); + fwrite(pkt.data, pkt.size, 1, outfile); } fclose(outfile); - av_free_packet(&pkt); + av_packet_unref(&pkt); return VO_TRUE; } @@ -251,7 +249,6 @@ static int preinit(const char *arg) if (subopt_parse(arg, subopts) != 0) { return -1; } - avcodec_register_all(); return 0; }
participants (1)
-
reimar