various: allow setting footage aspect ratios
We had support for detecting aspect ratios and respecting them in the render, but this allows people to not only see the aspect ratio in use, but also override it with their own.
This commit is contained in:
@@ -114,8 +114,6 @@ bool FFmpegDecoder::Open()
|
||||
native_pix_fmt_ = GetNativePixelFormat(ideal_pix_fmt_);
|
||||
|
||||
Q_ASSERT(native_pix_fmt_ != PixelFormat::PIX_FMT_INVALID);
|
||||
|
||||
aspect_ratio_ = our_instance->sample_aspect_ratio();
|
||||
}
|
||||
|
||||
time_base_ = our_instance->stream()->time_base;
|
||||
@@ -465,6 +463,7 @@ bool FFmpegDecoder::Probe(Footage *f, const QAtomicInt* cancelled)
|
||||
|
||||
bool image_is_still = false;
|
||||
ImageStream::Interlacing interlacing = ImageStream::kInterlaceNone;
|
||||
rational pixel_aspect_ratio;
|
||||
|
||||
{
|
||||
// Read at least two frames to get more information about this video stream
|
||||
@@ -484,6 +483,10 @@ bool FFmpegDecoder::Probe(Footage *f, const QAtomicInt* cancelled)
|
||||
interlacing = ImageStream::kInterlacedBottomFirst;
|
||||
}
|
||||
}
|
||||
|
||||
pixel_aspect_ratio = av_guess_sample_aspect_ratio(instance.fmt_ctx(),
|
||||
instance.stream(),
|
||||
frame);
|
||||
}
|
||||
|
||||
// Read second frame
|
||||
@@ -527,6 +530,7 @@ bool FFmpegDecoder::Probe(Footage *f, const QAtomicInt* cancelled)
|
||||
image_stream->set_height(avstream->codecpar->height);
|
||||
image_stream->set_format(GetNativePixelFormat(FFmpegCommon::GetCompatiblePixelFormat(static_cast<AVPixelFormat>(avstream->codecpar->format))));
|
||||
image_stream->set_interlacing(interlacing);
|
||||
image_stream->set_pixel_aspect_ratio(pixel_aspect_ratio);
|
||||
|
||||
str = image_stream;
|
||||
|
||||
@@ -825,7 +829,7 @@ FramePtr FFmpegDecoder::BuffersToNativeFrame(int divider, int width, int height,
|
||||
native_pix_fmt_,
|
||||
divider));
|
||||
copy->set_timestamp(Timecode::timestamp_to_time(ts, time_base_));
|
||||
copy->set_sample_aspect_ratio(aspect_ratio_);
|
||||
copy->set_sample_aspect_ratio(std::static_pointer_cast<ImageStream>(stream())->pixel_aspect_ratio());
|
||||
copy->allocate();
|
||||
|
||||
// Convert frame to RGB/A for the rest of the pipeline
|
||||
@@ -1262,16 +1266,6 @@ void FFmpegDecoderInstance::TruncateCacheRangeTo(const qint64 &t)
|
||||
}
|
||||
}
|
||||
|
||||
rational FFmpegDecoderInstance::sample_aspect_ratio() const
|
||||
{
|
||||
return av_guess_sample_aspect_ratio(fmt_ctx_, avstream_, nullptr);
|
||||
}
|
||||
|
||||
AVStream *FFmpegDecoderInstance::stream() const
|
||||
{
|
||||
return avstream_;
|
||||
}
|
||||
|
||||
FFmpegDecoderInstance::FFmpegDecoderInstance(const char *filename, int stream_index) :
|
||||
fmt_ctx_(nullptr),
|
||||
opts_(nullptr),
|
||||
|
||||
Reference in New Issue
Block a user