h264: populate AVCodecContext with SPS values during codec init
This allows user code to properly detect HW decoding compat before decoding actually starts.
This commit is contained in:
parent
d9bf16e077
commit
84cc0ee78f
|
@ -909,6 +909,11 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
|
|||
return ff_get_format(h->avctx, pix_fmts);
|
||||
}
|
||||
|
||||
enum AVPixelFormat ff_h264_get_pixel_format(H264Context *h)
|
||||
{
|
||||
return get_pixel_format(h, 1);
|
||||
}
|
||||
|
||||
/* export coded and cropped frame dimensions to AVCodecContext */
|
||||
static void init_dimensions(H264Context *h)
|
||||
{
|
||||
|
|
|
@ -419,6 +419,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||
}
|
||||
}
|
||||
|
||||
if (h->ps.sps) {
|
||||
h->avctx->colorspace = h->ps.sps->vui.matrix_coeffs;
|
||||
h->avctx->pix_fmt = ff_h264_get_pixel_format(h);
|
||||
if (h->avctx->pix_fmt < 0)
|
||||
h->avctx->pix_fmt = AV_PIX_FMT_NONE;
|
||||
|
||||
h->avctx->profile = ff_h264_get_profile(h->ps.sps);
|
||||
h->avctx->level = h->ps.sps->level_idc;
|
||||
h->avctx->refs = h->ps.sps->ref_frame_count;
|
||||
}
|
||||
|
||||
if (h->ps.sps && h->ps.sps->bitstream_restriction_flag &&
|
||||
h->avctx->has_b_frames < h->ps.sps->num_reorder_frames) {
|
||||
h->avctx->has_b_frames = h->ps.sps->num_reorder_frames;
|
||||
|
|
|
@ -699,4 +699,6 @@ void ff_h264_free_tables(H264Context *h);
|
|||
|
||||
void ff_h264_set_erpic(ERPicture *dst, const H264Picture *src);
|
||||
|
||||
enum AVPixelFormat ff_h264_get_pixel_format(H264Context *h);
|
||||
|
||||
#endif /* AVCODEC_H264DEC_H */
|
||||
|
|
Loading…
Reference in New Issue