[vlc-commits] qsv: allocate the mfxSyncPoint dynamically
Steve Lhomme
git at videolan.org
Wed Apr 4 18:28:10 CEST 2018
vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Tue Nov 7 13:26:05 2017 +0100| [b2fdb0eee9aa7aa7fe7651c180188e0c644f5214] | committer: Steve Lhomme
qsv: allocate the mfxSyncPoint dynamically
no real benefit except that's how ffmpeg does it
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b2fdb0eee9aa7aa7fe7651c180188e0c644f5214
---
modules/codec/qsv.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/modules/codec/qsv.c b/modules/codec/qsv.c
index 16a95e2221..c7e789a24b 100644
--- a/modules/codec/qsv.c
+++ b/modules/codec/qsv.c
@@ -270,7 +270,7 @@ typedef struct qsv_frame_pool_t
typedef struct async_task_t
{
mfxBitstream bs; // Intel's bitstream structure.
- mfxSyncPoint syncp; // Async Task Sync Point.
+ mfxSyncPoint *syncp; // Async Task Sync Point.
block_t *block; // VLC's block structure to be returned by Encode.
} async_task_t;
@@ -698,7 +698,7 @@ static block_t *qsv_synchronize_block(encoder_t *enc, async_task_t *task)
/* Synchronize and fill block_t. If the SyncOperation fails we leak :-/ (or we can segfault, ur choice) */
do {
- sts = MFXVideoCORE_SyncOperation(sys->session, task->syncp, QSV_SYNCPOINT_WAIT);
+ sts = MFXVideoCORE_SyncOperation(sys->session, *task->syncp, QSV_SYNCPOINT_WAIT);
} while (sts == MFX_WRN_IN_EXECUTION);
if (sts != MFX_ERR_NONE) {
msg_Err(enc, "SyncOperation failed, outputting garbage data. "
@@ -735,6 +735,11 @@ static void qsv_queue_encode_picture(encoder_t *enc, async_task_t *task,
mfxStatus sts;
mfxFrameSurface1 *frame = NULL;
+ if (!(task->syncp = calloc(1, sizeof(*task->syncp)))) {
+ msg_Err(enc, "Unable to allocate syncpoint for encoder output");
+ return;
+ }
+
if (pic) {
/* To avoid qsv -> vlc timestamp conversion overflow, we use timestamp relative
to the first picture received. That way, vlc will overflow before us.
@@ -745,6 +750,8 @@ static void qsv_queue_encode_picture(encoder_t *enc, async_task_t *task,
frame = qsv_frame_pool_Get(sys, pic);
if (!frame) {
msg_Warn(enc, "Unable to find an unlocked surface in the pool");
+ free(task->syncp);
+ task->syncp = NULL;
return;
}
}
@@ -752,6 +759,8 @@ static void qsv_queue_encode_picture(encoder_t *enc, async_task_t *task,
/* Allocate block_t and prepare mfxBitstream for encoder */
if (!(task->block = block_Alloc(sys->params.mfx.BufferSizeInKB * 1000))) {
msg_Err(enc, "Unable to allocate block for encoder output");
+ free(task->syncp);
+ task->syncp = NULL;
return;
}
memset(&task->bs, 0, sizeof(task->bs));
@@ -759,7 +768,7 @@ static void qsv_queue_encode_picture(encoder_t *enc, async_task_t *task,
task->bs.Data = task->block->p_buffer;
for (;;) {
- sts = MFXVideoENCODE_EncodeFrameAsync(sys->session, 0, frame, &task->bs, &task->syncp);
+ sts = MFXVideoENCODE_EncodeFrameAsync(sys->session, 0, frame, &task->bs, task->syncp);
if (sts != MFX_WRN_DEVICE_BUSY && sts != MFX_WRN_IN_EXECUTION)
break;
if (sys->busy_warn_counter++ % 16 == 0)
More information about the vlc-commits
mailing list