hrev52186 adds 1 changeset to branch 'master'
old head: 247f2fb6917ce95d6a0535a42c16d954be6ad165
new head: c85dd27c9e06bf4dff8d51ab79d9570003018471
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=c85dd27c9e06+%5E247f2fb6917c
----------------------------------------------------------------------------
c85dd27c9e06: AVCodecEncoder: Use new API
Change-Id: I5b985cebf241e67f901e93a5a4bb61a67a659cdf
[ JackBurton79 <stefano.ceccherini@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev52186
Commit: c85dd27c9e06bf4dff8d51ab79d9570003018471
URL: https://git.haiku-os.org/haiku/commit/?id=c85dd27c9e06
Author: JackBurton79 <stefano.ceccherini@xxxxxxxxx>
Date: Tue Aug 7 15:46:39 2018 UTC
Committer: Barrett17 <b.vitruvio@xxxxxxxxx>
Commit-Date: Tue Aug 7 16:40:15 2018 UTC
----------------------------------------------------------------------------
1 file changed, 19 insertions(+), 20 deletions(-)
.../media/plugins/ffmpeg/AVCodecEncoder.cpp | 39 ++++++++++----------
----------------------------------------------------------------------------
diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
index f7f7aa7de2..c6d64b8665 100644
--- a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
@@ -700,31 +700,30 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64
frameCount,
fDstFrame.linesize);
// Encode one video chunk/frame.
- int gotPacket;
+ int result = avcodec_send_frame(fCodecContext, fFrame);
+ if (result != 0) {
+ TRACE(" avcodec_send_frame() failed: %d\n", result);
+ return B_ERROR;
+ }
+
+ // avcodec.h says we need to set it.
+ fFrame->pts++;
+
AVPacket pkt;
pkt.data = NULL;
pkt.size = 0;
av_init_packet(&pkt);
- int usedBytes = avcodec_encode_video2(fCodecContext, &pkt,
fFrame, &gotPacket);
- // avcodec.h says we need to set it.
- fFrame->pts++;
-
- if (usedBytes < 0) {
- TRACE(" avcodec_encode_video() failed: %d\n",
usedBytes);
- return B_ERROR;
- }
-
- // Maybe we need to use this PTS to calculate start_time:
- if (pkt.pts != AV_NOPTS_VALUE) {
- TRACE(" codec frame PTS: %lld (codec time_base:
%d/%d)\n",
- pkt.pts, fCodecContext->time_base.num,
- fCodecContext->time_base.den);
- } else {
- TRACE(" codec frame PTS: N/A (codec time_base:
%d/%d)\n",
- fCodecContext->time_base.num,
fCodecContext->time_base.den);
- }
+ if (avcodec_receive_packet(fCodecContext, &pkt) == 0) {
+ // Maybe we need to use this PTS to calculate
start_time:
+ if (pkt.pts != AV_NOPTS_VALUE) {
+ TRACE(" codec frame PTS: %lld (codec
time_base: %d/%d)\n",
+ pkt.pts, fCodecContext->time_base.num,
+ fCodecContext->time_base.den);
+ } else {
+ TRACE(" codec frame PTS: N/A (codec time_base:
%d/%d)\n",
+ fCodecContext->time_base.num,
fCodecContext->time_base.den);
+ }
- if (gotPacket == 1) {
// Setup media_encode_info, most important is the time
stamp.
info->start_time = (bigtime_t)(fFramesWritten *
1000000LL
/ fInputFormat.u.raw_video.field_rate);