diff --git a/src/QtAV/VideoFrame.h b/src/QtAV/VideoFrame.h index 0f19f704..686c8a72 100644 --- a/src/QtAV/VideoFrame.h +++ b/src/QtAV/VideoFrame.h @@ -73,8 +73,8 @@ public: int planeWidth(int plane) const; int planeHeight(int plane) const; - float aspectRatio() const; - void setAspectRatio(float aspectRatio); + float displayAspectRatio() const; + void setDisplayAspectRatio(float displayAspectRatio); // no padded bytes int effectiveBytesPerLine(int plane) const; diff --git a/src/VideoDecoder.cpp b/src/VideoDecoder.cpp index e4d9cf45..f7d693e7 100644 --- a/src/VideoDecoder.cpp +++ b/src/VideoDecoder.cpp @@ -94,11 +94,11 @@ VideoFrame VideoDecoder::frame() if (d.width <= 0 || d.height <= 0 || !d.codec_ctx) return VideoFrame(0, 0, VideoFormat(VideoFormat::Format_Invalid)); //DO NOT make frame as a memeber, because VideoFrame is explictly shared! - float aspectRatio = ((float)d.frame->width / (float)d.frame->height) * + float displayAspectRatio = ((float)d.frame->width / (float)d.frame->height) * ((float)d.codec_ctx->sample_aspect_ratio.num / (float)d.codec_ctx->sample_aspect_ratio.den); VideoFrame frame(d.frame->width, d.frame->height, VideoFormat((int)d.codec_ctx->pix_fmt)); - frame.setAspectRatio(aspectRatio); + frame.setDisplayAspectRatio(displayAspectRatio); frame.setBits(d.frame->data); frame.setBytesPerLine(d.frame->linesize); return frame; diff --git a/src/VideoFrame.cpp b/src/VideoFrame.cpp index 78bb9c55..1fa23827 100644 --- a/src/VideoFrame.cpp +++ b/src/VideoFrame.cpp @@ -40,19 +40,19 @@ public: : FramePrivate() , width(0) , height(0) + , displayAspectRatio(0) , format(VideoFormat::Format_Invalid) , textures(4, 0) , conv(0) - , aspectRatio(0) {} VideoFramePrivate(int w, int h, const VideoFormat& fmt) : FramePrivate() , width(w) , height(h) + , displayAspectRatio(0) , format(fmt) , textures(4, 0) , conv(0) - , aspectRatio(0) { planes.resize(format.planeCount()); line_sizes.resize(format.planeCount()); @@ -114,7 +114,7 @@ public: } int width, height; - float aspectRatio; + float displayAspectRatio; VideoFormat format; QVector textures; @@ -197,7 +197,7 @@ VideoFrame VideoFrame::clone() const memcpy(dst, bits(i), plane_size); dst += plane_size; } - f.setAspectRatio(d->aspectRatio); + f.setDisplayAspectRatio(d->displayAspectRatio); //f.setImageConverter(d->conv); return f; } @@ -289,11 +289,11 @@ int VideoFrame::planeHeight(int plane) const return d->format.chromaHeight(d->height); } -float VideoFrame::aspectRatio() const +float VideoFrame::displayAspectRatio() const { Q_D(const VideoFrame); - if (d->aspectRatio != 0) - return d->aspectRatio; + if (d->displayAspectRatio != 0) + return d->displayAspectRatio; if (d->width > 0 && d->height > 0) return (float)d->width / (float)d->height; @@ -301,9 +301,9 @@ float VideoFrame::aspectRatio() const return 0; } -void VideoFrame::setAspectRatio(float aspectRatio) +void VideoFrame::setDisplayAspectRatio(float displayAspectRatio) { - d_func()->aspectRatio = aspectRatio; + d_func()->displayAspectRatio = displayAspectRatio; } int VideoFrame::effectiveBytesPerLine(int plane) const diff --git a/src/VideoRenderer.cpp b/src/VideoRenderer.cpp index 10f346a5..4065167e 100644 --- a/src/VideoRenderer.cpp +++ b/src/VideoRenderer.cpp @@ -46,7 +46,7 @@ VideoRenderer::~VideoRenderer() bool VideoRenderer::receive(const VideoFrame &frame) { DPTR_D(VideoRenderer); - d.source_aspect_ratio = frame.aspectRatio(); + d.source_aspect_ratio = frame.displayAspectRatio(); setInSize(frame.width(), frame.height()); return receiveFrame(frame); }