mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-14 02:50:11 +01:00
qsvenc: take only the allocated dimensions from the frames context
Other parameters, like the display size, should still be taken from the codec context.
This commit is contained in:
@@ -355,6 +355,9 @@ static int rc_supported(QSVEncContext *q)
|
|||||||
|
|
||||||
static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
|
static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
|
||||||
{
|
{
|
||||||
|
enum AVPixelFormat sw_format = avctx->pix_fmt == AV_PIX_FMT_QSV ?
|
||||||
|
avctx->sw_pix_fmt : avctx->pix_fmt;
|
||||||
|
const AVPixFmtDescriptor *desc;
|
||||||
float quant;
|
float quant;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -380,15 +383,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
|
|||||||
q->param.mfx.EncodedOrder = 0;
|
q->param.mfx.EncodedOrder = 0;
|
||||||
q->param.mfx.BufferSizeInKB = 0;
|
q->param.mfx.BufferSizeInKB = 0;
|
||||||
|
|
||||||
if (avctx->hw_frames_ctx) {
|
|
||||||
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
|
|
||||||
AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
|
|
||||||
q->param.mfx.FrameInfo = frames_hwctx->surfaces[0].Info;
|
|
||||||
} else {
|
|
||||||
enum AVPixelFormat sw_format = avctx->pix_fmt == AV_PIX_FMT_QSV ?
|
|
||||||
avctx->sw_pix_fmt : avctx->pix_fmt;
|
|
||||||
const AVPixFmtDescriptor *desc;
|
|
||||||
|
|
||||||
desc = av_pix_fmt_desc_get(sw_format);
|
desc = av_pix_fmt_desc_get(sw_format);
|
||||||
if (!desc)
|
if (!desc)
|
||||||
return AVERROR_BUG;
|
return AVERROR_BUG;
|
||||||
@@ -408,6 +402,12 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
|
|||||||
q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth;
|
q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth;
|
||||||
q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
|
q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
|
||||||
q->param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8;
|
q->param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8;
|
||||||
|
|
||||||
|
if (avctx->hw_frames_ctx) {
|
||||||
|
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
|
||||||
|
AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
|
||||||
|
q->param.mfx.FrameInfo.Width = frames_hwctx->surfaces[0].Info.Width;
|
||||||
|
q->param.mfx.FrameInfo.Height = frames_hwctx->surfaces[0].Info.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avctx->framerate.den > 0 && avctx->framerate.num > 0) {
|
if (avctx->framerate.den > 0 && avctx->framerate.num > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user