File indexing completed on 2025-01-19 03:57:04
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 "qavframecodec_p.h" 0009 #include "qavcodec_p_p.h" 0010 0011 #include <QDebug> 0012 0013 extern "C" { 0014 #include <libavformat/avformat.h> 0015 #include <libavcodec/avcodec.h> 0016 } 0017 0018 QT_BEGIN_NAMESPACE 0019 0020 QAVFrameCodec::QAVFrameCodec() 0021 { 0022 } 0023 0024 QAVFrameCodec::QAVFrameCodec(QAVCodecPrivate &d) 0025 : QAVCodec(d) 0026 { 0027 } 0028 0029 int QAVFrameCodec::write(const QAVPacket &pkt) 0030 { 0031 Q_D(QAVCodec); 0032 if (!d->avctx) 0033 return AVERROR(EINVAL); 0034 return avcodec_send_packet(d->avctx, pkt ? pkt.packet() : nullptr); 0035 } 0036 0037 int QAVFrameCodec::read(QAVStreamFrame &frame) 0038 { 0039 Q_D(QAVCodec); 0040 if (!d->avctx) 0041 return AVERROR(EINVAL); 0042 auto f = static_cast<QAVFrame *>(&frame); 0043 return avcodec_receive_frame(d->avctx, f->frame()); 0044 } 0045 0046 QT_END_NAMESPACE