diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-01-16 18:40:37 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-28 12:17:50 +0400 |
commit | b7f8bfef2506dfd44d638e2280f00e301823fb2c (patch) | |
tree | 9b4e96fe8399516932fc611d80447911afa4ebdd /intern | |
parent | 8c3b27ce279f1f0904af3c220d92acfa1f20a70e (diff) |
libavcodec API usage: use new video encoding API
avcodec_encode_video() has been replaced with avcodec_encode_video2()
in new libavcodec versions.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ffmpeg/ffmpeg_compat.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index 3243781940e..3a130d6d3d6 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -357,4 +357,35 @@ int64_t av_get_pts_from_frame(AVFormatContext *avctx, AVFrame * picture) # define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio #endif +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 1, 0) +FFMPEG_INLINE +int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_output) +{ + int outsize, ret; + + ret = av_new_packet(pkt, avctx->width * avctx->height * 7 + 10000); + if (ret < 0) + return ret; + + outsize = avcodec_encode_video(avctx, pkt->data, pkt->size, frame); + if (outsize <= 0) { + *got_output = 0; + av_free_packet(pkt); + } + else { + *got_output = 1; + av_shrink_packet(pkt, outsize); + if (avctx->coded_frame) { + pkt->pts = avctx->coded_frame->pts; + if (avctx->coded_frame->key_frame) + pkt->flags |= AV_PKT_FLAG_KEY; + } + } + + return outsize >= 0 ? 0 : outsize; +} + +#endif + #endif |