File indexing completed on 2025-01-19 03:57:06

0001 /*********************************************************
0002  * Copyright (C) 2020, Val Doroshchuk <valbok@gmail.com> *
0003  *                                                       *
0004  * This file is part of QtAVPlayer.                      *
0005  * Free Qt Media Player based on FFmpeg.                 *
0006  *********************************************************/
0007 
0008 #include "qavvideobuffer_gpu_p.h"
0009 #include <QDebug>
0010 
0011 extern "C" {
0012 #include <libavutil/hwcontext.h>
0013 #include <libavutil/pixdesc.h>
0014 }
0015 
0016 QT_BEGIN_NAMESPACE
0017 
0018 QAVVideoFrame::MapData QAVVideoBuffer_GPU::map()
0019 {
0020     auto mapData = m_cpu.map();
0021     if (mapData.format == AV_PIX_FMT_NONE) {
0022         int ret = av_hwframe_transfer_data(m_cpu.frame().frame(), m_frame.frame(), 0);
0023         if (ret < 0) {
0024             qWarning() << "Could not av_hwframe_transfer_data:" << ret;
0025             return {};
0026         }
0027         m_frame = QAVVideoFrame();
0028         mapData = m_cpu.map();
0029     }
0030 
0031     return mapData;
0032 }
0033 
0034 QT_END_NAMESPACE