Skip to content

Commit

Permalink
fix nv21;
Browse files Browse the repository at this point in the history
修改文件信息打印输出;
  • Loading branch information
RealChuan committed Aug 24, 2023
1 parent bbab7f1 commit e77d52e
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 33 deletions.
43 changes: 19 additions & 24 deletions ffmpeg/formatcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,6 @@ class FormatContext::FormatContextPrivate
}
}

void printMetaData()
{
AVDictionaryEntry *tag = nullptr;
while (nullptr != (tag = av_dict_get(formatCtx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
qDebug() << tag->key << QString::fromUtf8(tag->value);
}
}

void printInformation()
{
qInfo() << tr("AV Format Name: ") << formatCtx->iformat->name;
QTime time(QTime::fromMSecsSinceStartOfDay(formatCtx->duration / 1000));
qInfo() << QObject::tr("Duration:") << time.toString("hh:mm:ss.zzz");

if (formatCtx->pb) {
// FIXME hack, ffplay maybe should not use avio_feof() to test for the end
formatCtx->pb->eof_reached = 0;
}
}

FormatContext *q_ptr;

AVFormatContext *formatCtx = nullptr;
Expand Down Expand Up @@ -276,10 +256,10 @@ bool FormatContext::findStream()
SET_ERROR_CODE(ret);
return false;
}
qDebug() << "The video file contains the number of stream information:"
<< d_ptr->formatCtx->nb_streams;
d_ptr->printInformation();
d_ptr->printMetaData();
if (d_ptr->formatCtx->pb) {
// FIXME hack, ffplay maybe should not use avio_feof() to test for the end
d_ptr->formatCtx->pb->eof_reached = 0;
}
d_ptr->findStreamIndex();
return true;
}
Expand Down Expand Up @@ -409,6 +389,21 @@ bool FormatContext::seek(int index, qint64 timestamp)
ERROR_RETURN(ret)
}

void FormatContext::printFileInfo()
{
Q_ASSERT(d_ptr->formatCtx != nullptr);
qInfo() << "AV Format Name:" << d_ptr->formatCtx->iformat->name;
QTime time(QTime::fromMSecsSinceStartOfDay(d_ptr->formatCtx->duration / 1000));
qInfo() << "Duration:" << time.toString("hh:mm:ss.zzz");

// Metadata
AVDictionaryEntry *tag = nullptr;
while (nullptr
!= (tag = av_dict_get(d_ptr->formatCtx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
qInfo() << tag->key << QString::fromUtf8(tag->value);
}
}

void FormatContext::dumpFormat()
{
Q_ASSERT(d_ptr->formatCtx != nullptr);
Expand Down
2 changes: 2 additions & 0 deletions ffmpeg/formatcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class FFMPEG_EXPORT FormatContext : public QObject

[[nodiscard]] auto coverImage() const -> QImage &;

void printFileInfo();

void dumpFormat();

auto avFormatContext() -> AVFormatContext *;
Expand Down
1 change: 0 additions & 1 deletion ffmpeg/frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ void Frame::copyPropsFrom(Frame *src)
d_ptr->frame->key_frame = srcFrame->key_frame;
d_ptr->frame->width = srcFrame->width;
d_ptr->frame->height = srcFrame->height;
d_ptr->frame->format = srcFrame->format;
}

auto Frame::imageAlloc(const QSize &size, AVPixelFormat pix_fmt, int align) -> bool
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/gpu/bufferref.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool BufferRef::hwdeviceCtxCreate(AVHWDeviceType hwDeviceType)
{
auto ret = av_hwdevice_ctx_create(&d_ptr->bufferRef, hwDeviceType, nullptr, nullptr, 0);
if (ret < 0) {
qWarning() << "Failed to create specified HW device.";
qWarning() << "Failed to create Gpu device context: " << hwDeviceType;
SET_ERROR_CODE(ret);
return false;
}
Expand Down
4 changes: 1 addition & 3 deletions ffmpeg/gpu/hardwaredecode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <ffmpeg/codeccontext.h>
#include <ffmpeg/ffmpegutils.hpp>
#include <ffmpeg/frame.hpp>
#include <ffmpeg/videoframeconverter.hpp>

#include <QDebug>

Expand Down Expand Up @@ -66,8 +65,7 @@ bool HardWareDecode::initPixelFormat(const AVCodec *decoder)
}
for (AVHWDeviceType type : qAsConst(d_ptr->hwDeviceTypes)) {
hw_pix_fmt = Utils::getPixelFormat(decoder, type);
if (hw_pix_fmt != AV_PIX_FMT_NONE
&& VideoFrameConverter::isSupportedInput_pix_fmt(hw_pix_fmt)) {
if (hw_pix_fmt != AV_PIX_FMT_NONE) {
d_ptr->hwDeviceType = type;
break;
}
Expand Down
1 change: 1 addition & 0 deletions ffmpeg/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ bool Player::initAvCodec()
}

d_ptr->isopen = true;
d_ptr->formatCtx->printFileInfo();
d_ptr->formatCtx->dumpFormat();
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions ffmpeg/videorender/openglrender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,11 @@ void OpenglRender::updateNV12()
glBindTexture(GL_TEXTURE_2D, d_ptr->textureUV);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_LUMINANCE_ALPHA, //GL_RG, GL_LUMINANCE_ALPHA
GL_RG, // GL_RG GL_LUMINANCE_ALPHA
frame->width / 2,
frame->height / 2,
0,
GL_LUMINANCE_ALPHA, //GL_RG, GL_LUMINANCE_ALPHA
GL_RG, // GL_RG GL_LUMINANCE_ALPHA
GL_UNSIGNED_BYTE,
frame->data[1]);
}
Expand Down
4 changes: 2 additions & 2 deletions ffmpeg/videorender/shader/video.frag
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ void main()
} else if (format == 23 || format == 159) { // NV12 P010LE
yuv.x = texture(tex_y, TexCord).r;
yuv.y = texture(tex_uv, TexCord).r;
yuv.z = texture(tex_uv, TexCord).a;
yuv.z = texture(tex_uv, TexCord).g;
} else if (format == 24) { // NV21
yuv.x = texture(tex_y, TexCord).r;
yuv.y = texture(tex_uv, TexCord).a;
yuv.y = texture(tex_uv, TexCord).g;
yuv.z = texture(tex_uv, TexCord).r;
} else if (format == 25) { // ARGB
FragColor = texture(tex_rgba, TexCord).gbar;
Expand Down

0 comments on commit e77d52e

Please sign in to comment.