hrev52189 adds 1 changeset to branch 'master'
old head: 57893202f1849d6e49e3ae88ca6202c18713b775
new head: 740114b89c10fadc92d68890574c6f286053f180
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=740114b89c10+%5E57893202f184
----------------------------------------------------------------------------
740114b89c10: Allocate the packet via ffmpeg.
Seems we aren't allowed anymore to handle it ourselves.
[ stefano <stefano@nb0001.iacpud.local> ]
----------------------------------------------------------------------------
Revision: hrev52189
Commit: 740114b89c10fadc92d68890574c6f286053f180
URL: https://git.haiku-os.org/haiku/commit/?id=740114b89c10
Author: stefano <stefano@nb0001.iacpud.local>
Date: Wed Aug 8 10:03:21 2018 UTC
Committer: JackBurton79 <stefano.ceccherini@xxxxxxxxx>
Commit-Date: Wed Aug 8 10:11:53 2018 UTC
----------------------------------------------------------------------------
1 file changed, 10 insertions(+), 8 deletions(-)
.../media/plugins/ffmpeg/AVCodecEncoder.cpp | 18 ++++++++++--------
----------------------------------------------------------------------------
diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
index c6d64b8665..ec62d04afb 100644
--- a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
@@ -709,15 +709,14 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64
frameCount,
// avcodec.h says we need to set it.
fFrame->pts++;
- AVPacket pkt;
- pkt.data = NULL;
- pkt.size = 0;
- av_init_packet(&pkt);
- if (avcodec_receive_packet(fCodecContext, &pkt) == 0) {
+ AVPacket* pkt = av_packet_alloc();
+ // TODO: Since av_codec_receive_packet() could return more than
one packet for one frame,
+ // we should run this in a loop, like the ffmpeg example do.
+ if (avcodec_receive_packet(fCodecContext, pkt) == 0) {
// Maybe we need to use this PTS to calculate
start_time:
- if (pkt.pts != AV_NOPTS_VALUE) {
+ if (pkt->pts != AV_NOPTS_VALUE) {
TRACE(" codec frame PTS: %lld (codec
time_base: %d/%d)\n",
- pkt.pts, fCodecContext->time_base.num,
+ pkt->pts, fCodecContext->time_base.num,
fCodecContext->time_base.den);
} else {
TRACE(" codec frame PTS: N/A (codec time_base:
%d/%d)\n",
@@ -733,17 +732,20 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64
frameCount,
info->flags |= B_MEDIA_KEY_FRAME;
// Write the chunk
- ret = WriteChunk(pkt.data, pkt.size, info);
+ ret = WriteChunk(pkt->data, pkt->size, info);
if (ret != B_OK) {
TRACE(" error writing chunk: %s\n",
strerror(ret));
break;
}
+ av_packet_unref(pkt);
}
+
// Skip to the next frame (but usually, there is only one to
encode
// for video).
frameCount--;
fFramesWritten++;
buffer = (const void*)((const uint8*)buffer + bufferSize);
+ av_packet_free(&pkt);
}
return ret;
}