mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-08-01 15:07:49 +00:00
ffmpeg: v4l2-request-api: set HEVC SPS control at format selection
This commit is contained in:
parent
6c085648ed
commit
57cc627ea3
@ -0,0 +1,121 @@
|
|||||||
|
From 2756ad266f18d546551a3eab0650c95ddb62e0ff Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||||
|
Date: Sat, 14 Mar 2020 22:21:42 +0000
|
||||||
|
Subject: [PATCH] v4l2 request hevc: Set SPS control at initialization
|
||||||
|
|
||||||
|
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||||
|
---
|
||||||
|
libavcodec/v4l2_request_hevc.c | 61 ++++++++++++++++++++++------------
|
||||||
|
1 file changed, 40 insertions(+), 21 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c
|
||||||
|
index 94977c5d0e..0ab1c201b0 100644
|
||||||
|
--- a/libavcodec/v4l2_request_hevc.c
|
||||||
|
+++ b/libavcodec/v4l2_request_hevc.c
|
||||||
|
@@ -231,21 +231,12 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h,
|
||||||
|
slice_params->entry_point_offset_minus1[i] = sh->entry_point_offset[i] - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int v4l2_request_hevc_start_frame(AVCodecContext *avctx,
|
||||||
|
- av_unused const uint8_t *buffer,
|
||||||
|
- av_unused uint32_t size)
|
||||||
|
+static void fill_sps(struct v4l2_ctrl_hevc_sps *ctrl, const HEVCContext *h)
|
||||||
|
{
|
||||||
|
- const HEVCContext *h = avctx->priv_data;
|
||||||
|
const HEVCSPS *sps = h->ps.sps;
|
||||||
|
- const HEVCPPS *pps = h->ps.pps;
|
||||||
|
- const ScalingList *sl = pps->scaling_list_data_present_flag ?
|
||||||
|
- &pps->scaling_list :
|
||||||
|
- sps->scaling_list_enable_flag ?
|
||||||
|
- &sps->scaling_list : NULL;
|
||||||
|
- V4L2RequestControlsHEVC *controls = h->ref->hwaccel_picture_private;
|
||||||
|
|
||||||
|
/* ISO/IEC 23008-2, ITU-T Rec. H.265: Sequence parameter set */
|
||||||
|
- controls->sps = (struct v4l2_ctrl_hevc_sps) {
|
||||||
|
+ *ctrl = (struct v4l2_ctrl_hevc_sps) {
|
||||||
|
.chroma_format_idc = sps->chroma_format_idc,
|
||||||
|
.pic_width_in_luma_samples = sps->width,
|
||||||
|
.pic_height_in_luma_samples = sps->height,
|
||||||
|
@@ -270,31 +261,47 @@ static int v4l2_request_hevc_start_frame(AVCodecContext *avctx,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (sps->separate_colour_plane_flag)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_SEPARATE_COLOUR_PLANE;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_SEPARATE_COLOUR_PLANE;
|
||||||
|
|
||||||
|
if (sps->scaling_list_enable_flag)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED;
|
||||||
|
|
||||||
|
if (sps->amp_enabled_flag)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_AMP_ENABLED;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_AMP_ENABLED;
|
||||||
|
|
||||||
|
if (sps->sao_enabled)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_SAMPLE_ADAPTIVE_OFFSET;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_SAMPLE_ADAPTIVE_OFFSET;
|
||||||
|
|
||||||
|
if (sps->pcm_enabled_flag)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_PCM_ENABLED;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_PCM_ENABLED;
|
||||||
|
|
||||||
|
if (sps->pcm.loop_filter_disable_flag)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_PCM_LOOP_FILTER_DISABLED;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_PCM_LOOP_FILTER_DISABLED;
|
||||||
|
|
||||||
|
if (sps->long_term_ref_pics_present_flag)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_LONG_TERM_REF_PICS_PRESENT;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_LONG_TERM_REF_PICS_PRESENT;
|
||||||
|
|
||||||
|
if (sps->sps_temporal_mvp_enabled_flag)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_SPS_TEMPORAL_MVP_ENABLED;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_SPS_TEMPORAL_MVP_ENABLED;
|
||||||
|
|
||||||
|
if (sps->sps_strong_intra_smoothing_enable_flag)
|
||||||
|
- controls->sps.flags |= V4L2_HEVC_SPS_FLAG_STRONG_INTRA_SMOOTHING_ENABLED;
|
||||||
|
+ ctrl->flags |= V4L2_HEVC_SPS_FLAG_STRONG_INTRA_SMOOTHING_ENABLED;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int v4l2_request_hevc_start_frame(AVCodecContext *avctx,
|
||||||
|
+ av_unused const uint8_t *buffer,
|
||||||
|
+ av_unused uint32_t size)
|
||||||
|
+{
|
||||||
|
+ const HEVCContext *h = avctx->priv_data;
|
||||||
|
+ const HEVCSPS *sps = h->ps.sps;
|
||||||
|
+ const HEVCPPS *pps = h->ps.pps;
|
||||||
|
+ const ScalingList *sl = pps->scaling_list_data_present_flag ?
|
||||||
|
+ &pps->scaling_list :
|
||||||
|
+ sps->scaling_list_enable_flag ?
|
||||||
|
+ &sps->scaling_list : NULL;
|
||||||
|
+ V4L2RequestControlsHEVC *controls = h->ref->hwaccel_picture_private;
|
||||||
|
+
|
||||||
|
+ fill_sps(&controls->sps, h);
|
||||||
|
|
||||||
|
if (sl) {
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
@@ -502,9 +509,21 @@ static int v4l2_request_hevc_set_controls(AVCodecContext *avctx)
|
||||||
|
|
||||||
|
static int v4l2_request_hevc_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
+ const HEVCContext *h = avctx->priv_data;
|
||||||
|
+ struct v4l2_ctrl_hevc_sps sps;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = ff_v4l2_request_init(avctx, V4L2_PIX_FMT_HEVC_SLICE, 3 * 1024 * 1024, NULL, 0);
|
||||||
|
+ struct v4l2_ext_control control[] = {
|
||||||
|
+ {
|
||||||
|
+ .id = V4L2_CID_MPEG_VIDEO_HEVC_SPS,
|
||||||
|
+ .ptr = &sps,
|
||||||
|
+ .size = sizeof(sps),
|
||||||
|
+ }
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ fill_sps(&sps, h);
|
||||||
|
+
|
||||||
|
+ ret = ff_v4l2_request_init(avctx, V4L2_PIX_FMT_HEVC_SLICE, 3 * 1024 * 1024, control, FF_ARRAY_ELEMS(control));
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user