v4l2codecs: h264: Update to the new uAPI

Starting from Linux v5.11, the V4L2 stateless H.264 uAPI
is updated and stable.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1624>
This commit is contained in:
Ezequiel Garcia 2020-09-30 10:40:51 -03:00 committed by GStreamer Merge Bot
parent 56ecc19067
commit 7d6b06ca1b
8 changed files with 904 additions and 590 deletions

View file

@ -24,7 +24,7 @@
#include "gstv4l2codecallocator.h" #include "gstv4l2codecallocator.h"
#include "gstv4l2codech264dec.h" #include "gstv4l2codech264dec.h"
#include "gstv4l2codecpool.h" #include "gstv4l2codecpool.h"
#include "linux/h264-ctrls.h" #include "linux/v4l2-controls.h"
GST_DEBUG_CATEGORY_STATIC (v4l2_h264dec_debug); GST_DEBUG_CATEGORY_STATIC (v4l2_h264dec_debug);
#define GST_CAT_DEFAULT v4l2_h264dec_debug #define GST_CAT_DEFAULT v4l2_h264dec_debug
@ -60,6 +60,7 @@ struct _GstV4l2CodecH264Dec
gint coded_height; gint coded_height;
guint bitdepth; guint bitdepth;
guint chroma_format_idc; guint chroma_format_idc;
guint num_slices;
GstV4l2CodecAllocator *sink_allocator; GstV4l2CodecAllocator *sink_allocator;
GstV4l2CodecAllocator *src_allocator; GstV4l2CodecAllocator *src_allocator;
@ -73,10 +74,11 @@ struct _GstV4l2CodecH264Dec
struct v4l2_ctrl_h264_pps pps; struct v4l2_ctrl_h264_pps pps;
struct v4l2_ctrl_h264_scaling_matrix scaling_matrix; struct v4l2_ctrl_h264_scaling_matrix scaling_matrix;
struct v4l2_ctrl_h264_decode_params decode_params; struct v4l2_ctrl_h264_decode_params decode_params;
struct v4l2_ctrl_h264_pred_weights pred_weight;
GArray *slice_params; GArray *slice_params;
enum v4l2_mpeg_video_h264_decode_mode decode_mode; enum v4l2_stateless_h264_decode_mode decode_mode;
enum v4l2_mpeg_video_h264_start_code start_code; enum v4l2_stateless_h264_start_code start_code;
GstMemory *bitstream; GstMemory *bitstream;
GstMapInfo bitstream_map; GstMapInfo bitstream_map;
@ -91,19 +93,19 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstV4l2CodecH264Dec,
static gboolean static gboolean
is_frame_based (GstV4l2CodecH264Dec * self) is_frame_based (GstV4l2CodecH264Dec * self)
{ {
return self->decode_mode == V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED; return self->decode_mode == V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED;
} }
static gboolean static gboolean
is_slice_based (GstV4l2CodecH264Dec * self) is_slice_based (GstV4l2CodecH264Dec * self)
{ {
return self->decode_mode == V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED; return self->decode_mode == V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED;
} }
static gboolean static gboolean
needs_start_codes (GstV4l2CodecH264Dec * self) needs_start_codes (GstV4l2CodecH264Dec * self)
{ {
return self->start_code == V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B; return self->start_code == V4L2_STATELESS_H264_START_CODE_ANNEX_B;
} }
@ -114,10 +116,10 @@ gst_v4l2_codec_h264_dec_open (GstVideoDecoder * decoder)
/* *INDENT-OFF* */ /* *INDENT-OFF* */
struct v4l2_ext_control control[] = { struct v4l2_ext_control control[] = {
{ {
.id = V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE, .id = V4L2_CID_STATELESS_H264_DECODE_MODE,
}, },
{ {
.id = V4L2_CID_MPEG_VIDEO_H264_START_CODE, .id = V4L2_CID_STATELESS_H264_START_CODE,
}, },
}; };
/* *INDENT-ON* */ /* *INDENT-ON* */
@ -229,7 +231,7 @@ gst_v4l2_codec_h264_dec_negotiate (GstVideoDecoder * decoder)
/* *INDENT-OFF* */ /* *INDENT-OFF* */
struct v4l2_ext_control control[] = { struct v4l2_ext_control control[] = {
{ {
.id = V4L2_CID_MPEG_VIDEO_H264_SPS, .id = V4L2_CID_STATELESS_H264_SPS,
.ptr = &self->sps, .ptr = &self->sps,
.size = sizeof (self->sps), .size = sizeof (self->sps),
}, },
@ -416,7 +418,7 @@ gst_v4l2_codec_h264_dec_fill_pps (GstV4l2CodecH264Dec * self, GstH264PPS * pps)
| (pps->constrained_intra_pred_flag ? V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED : 0) | (pps->constrained_intra_pred_flag ? V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED : 0)
| (pps->redundant_pic_cnt_present_flag ? V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT : 0) | (pps->redundant_pic_cnt_present_flag ? V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT : 0)
| (pps->transform_8x8_mode_flag ? V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE : 0) | (pps->transform_8x8_mode_flag ? V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE : 0)
| V4L2_H264_PPS_FLAG_PIC_SCALING_MATRIX_PRESENT, | V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT,
}; };
/* *INDENT-ON* */ /* *INDENT-ON* */
} }
@ -453,21 +455,44 @@ gst_v4l2_codec_h264_dec_fill_decoder_params (GstV4l2CodecH264Dec * self,
/* *INDENT-OFF* */ /* *INDENT-OFF* */
self->decode_params = (struct v4l2_ctrl_h264_decode_params) { self->decode_params = (struct v4l2_ctrl_h264_decode_params) {
.num_slices = 0, /* will be incremented as we receive slices */
.nal_ref_idc = picture->nal_ref_idc, .nal_ref_idc = picture->nal_ref_idc,
.top_field_order_cnt = picture->top_field_order_cnt, .top_field_order_cnt = picture->top_field_order_cnt,
.bottom_field_order_cnt = picture->bottom_field_order_cnt, .bottom_field_order_cnt = picture->bottom_field_order_cnt,
.flags = picture->idr ? V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC : 0, .frame_num = slice_hdr->frame_num,
.idr_pic_id = slice_hdr->idr_pic_id,
.pic_order_cnt_lsb = slice_hdr->pic_order_cnt_lsb,
.delta_pic_order_cnt_bottom = slice_hdr->delta_pic_order_cnt_bottom,
.delta_pic_order_cnt0 = slice_hdr->delta_pic_order_cnt[0],
.delta_pic_order_cnt1 = slice_hdr->delta_pic_order_cnt[1],
.dec_ref_pic_marking_bit_size = slice_hdr->dec_ref_pic_marking.bit_size,
.pic_order_cnt_bit_size = slice_hdr->pic_order_cnt_bit_size,
.slice_group_change_cycle = slice_hdr->slice_group_change_cycle,
.flags = (picture->idr ? V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC : 0) |
(slice_hdr->field_pic_flag ? V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC : 0) |
(slice_hdr->bottom_field_flag ? V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD : 0),
}; };
for (i = 0; i < refs->len; i++) { for (i = 0; i < refs->len; i++) {
GstH264Picture *ref_pic = g_array_index (refs, GstH264Picture *, i); GstH264Picture *ref_pic = g_array_index (refs, GstH264Picture *, i);
gint pic_num = ref_pic->pic_num; gint pic_num = ref_pic->pic_num;
guchar dpb_ref = 0;
/* Unwrap pic_num */ /* Unwrap pic_num */
if (pic_num < 0) if (pic_num < 0)
pic_num += slice_hdr->max_pic_num; pic_num += slice_hdr->max_pic_num;
switch (ref_pic->field) {
case GST_H264_PICTURE_FIELD_FRAME:
dpb_ref = V4L2_H264_FRAME_REF;
break;
case GST_H264_PICTURE_FIELD_TOP_FIELD:
dpb_ref = V4L2_H264_TOP_FIELD_REF;
break;
case GST_H264_PICTURE_FIELD_BOTTOM_FIELD:
dpb_ref = V4L2_H264_BOTTOM_FIELD_REF;
break;
}
self->decode_params.dpb[i] = (struct v4l2_h264_dpb_entry) { self->decode_params.dpb[i] = (struct v4l2_h264_dpb_entry) {
/* /*
* The reference is multiplied by 1000 because it's wassed as micro * The reference is multiplied by 1000 because it's wassed as micro
@ -483,6 +508,7 @@ gst_v4l2_codec_h264_dec_fill_decoder_params (GstV4l2CodecH264Dec * self,
V4L2_H264_DPB_ENTRY_FLAG_ACTIVE : 0) V4L2_H264_DPB_ENTRY_FLAG_ACTIVE : 0)
| (GST_H264_PICTURE_IS_LONG_TERM_REF (ref_pic) ? | (GST_H264_PICTURE_IS_LONG_TERM_REF (ref_pic) ?
V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM : 0), V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM : 0),
.fields = dpb_ref,
}; };
} }
/* *INDENT-ON* */ /* *INDENT-ON* */
@ -490,6 +516,60 @@ gst_v4l2_codec_h264_dec_fill_decoder_params (GstV4l2CodecH264Dec * self,
g_array_unref (refs); g_array_unref (refs);
} }
static void
gst_v4l2_codec_h264_dec_fill_pred_weight (GstV4l2CodecH264Dec * self,
GstH264SliceHdr * slice_hdr)
{
gint i, j;
/* *INDENT-OFF* */
self->pred_weight = (struct v4l2_ctrl_h264_pred_weights) {
.luma_log2_weight_denom = slice_hdr->pred_weight_table.luma_log2_weight_denom,
.chroma_log2_weight_denom = slice_hdr->pred_weight_table.chroma_log2_weight_denom,
};
/* *INDENT-ON* */
for (i = 0; i <= slice_hdr->num_ref_idx_l0_active_minus1; i++) {
self->pred_weight.weight_factors[0].luma_weight[i] =
slice_hdr->pred_weight_table.luma_weight_l0[i];
self->pred_weight.weight_factors[0].luma_offset[i] =
slice_hdr->pred_weight_table.luma_offset_l0[i];
}
if (slice_hdr->pps->sequence->chroma_array_type != 0) {
for (i = 0; i <= slice_hdr->num_ref_idx_l0_active_minus1; i++) {
for (j = 0; j < 2; j++) {
self->pred_weight.weight_factors[0].chroma_weight[i][j] =
slice_hdr->pred_weight_table.chroma_weight_l0[i][j];
self->pred_weight.weight_factors[0].chroma_offset[i][j] =
slice_hdr->pred_weight_table.chroma_offset_l0[i][j];
}
}
}
/* Skip l1 if this is not a B-Frames. */
if (slice_hdr->type % 5 != GST_H264_B_SLICE)
return;
for (i = 0; i <= slice_hdr->num_ref_idx_l1_active_minus1; i++) {
self->pred_weight.weight_factors[0].luma_weight[i] =
slice_hdr->pred_weight_table.luma_weight_l1[i];
self->pred_weight.weight_factors[0].luma_offset[i] =
slice_hdr->pred_weight_table.luma_offset_l1[i];
}
if (slice_hdr->pps->sequence->chroma_array_type != 0) {
for (i = 0; i <= slice_hdr->num_ref_idx_l1_active_minus1; i++) {
for (j = 0; j < 2; j++) {
self->pred_weight.weight_factors[1].chroma_weight[i][j] =
slice_hdr->pred_weight_table.chroma_weight_l1[i][j];
self->pred_weight.weight_factors[1].chroma_offset[i][j] =
slice_hdr->pred_weight_table.chroma_offset_l1[i][j];
}
}
}
}
static guint static guint
get_slice_header_bit_size (GstH264Slice * slice) get_slice_header_bit_size (GstH264Slice * slice)
{ {
@ -501,13 +581,12 @@ static void
gst_v4l2_codec_h264_dec_fill_slice_params (GstV4l2CodecH264Dec * self, gst_v4l2_codec_h264_dec_fill_slice_params (GstV4l2CodecH264Dec * self,
GstH264Slice * slice) GstH264Slice * slice)
{ {
gint n = self->decode_params.num_slices++; gint n = self->num_slices++;
gsize slice_size = slice->nalu.size; gsize slice_size = slice->nalu.size;
struct v4l2_ctrl_h264_slice_params *params; struct v4l2_ctrl_h264_slice_params *params;
gint i, j;
/* Ensure array is large enough */ /* Ensure array is large enough */
if (self->slice_params->len < self->decode_params.num_slices) if (self->slice_params->len < self->num_slices)
g_array_set_size (self->slice_params, self->slice_params->len * 2); g_array_set_size (self->slice_params, self->slice_params->len * 2);
if (needs_start_codes (self)) if (needs_start_codes (self))
@ -516,26 +595,11 @@ gst_v4l2_codec_h264_dec_fill_slice_params (GstV4l2CodecH264Dec * self,
/* *INDENT-OFF* */ /* *INDENT-OFF* */
params = &g_array_index (self->slice_params, struct v4l2_ctrl_h264_slice_params, n); params = &g_array_index (self->slice_params, struct v4l2_ctrl_h264_slice_params, n);
*params = (struct v4l2_ctrl_h264_slice_params) { *params = (struct v4l2_ctrl_h264_slice_params) {
.size = slice_size,
.start_byte_offset = self->bitstream_map.size,
.header_bit_size = get_slice_header_bit_size (slice), .header_bit_size = get_slice_header_bit_size (slice),
.first_mb_in_slice = slice->header.first_mb_in_slice, .first_mb_in_slice = slice->header.first_mb_in_slice,
.slice_type = slice->header.type % 5, .slice_type = slice->header.type % 5,
.pic_parameter_set_id = slice->header.pps->id,
.colour_plane_id = slice->header.colour_plane_id, .colour_plane_id = slice->header.colour_plane_id,
.redundant_pic_cnt = slice->header.redundant_pic_cnt, .redundant_pic_cnt = slice->header.redundant_pic_cnt,
.frame_num = slice->header.frame_num,
.idr_pic_id = slice->header.idr_pic_id,
.pic_order_cnt_lsb = slice->header.pic_order_cnt_lsb,
.delta_pic_order_cnt_bottom = slice->header.delta_pic_order_cnt_bottom,
.delta_pic_order_cnt0 = slice->header.delta_pic_order_cnt[0],
.delta_pic_order_cnt1 = slice->header.delta_pic_order_cnt[1],
.pred_weight_table = (struct v4l2_h264_pred_weight_table) {
.luma_log2_weight_denom = slice->header.pred_weight_table.luma_log2_weight_denom,
.chroma_log2_weight_denom = slice->header.pred_weight_table.chroma_log2_weight_denom,
},
.dec_ref_pic_marking_bit_size = slice->header.dec_ref_pic_marking.bit_size,
.pic_order_cnt_bit_size = slice->header.pic_order_cnt_bit_size,
.cabac_init_idc = slice->header.cabac_init_idc, .cabac_init_idc = slice->header.cabac_init_idc,
.slice_qp_delta = slice->header.slice_qp_delta, .slice_qp_delta = slice->header.slice_qp_delta,
.slice_qs_delta = slice->header.slice_qs_delta, .slice_qs_delta = slice->header.slice_qs_delta,
@ -544,54 +608,10 @@ gst_v4l2_codec_h264_dec_fill_slice_params (GstV4l2CodecH264Dec * self,
.slice_beta_offset_div2 = slice->header.slice_beta_offset_div2, .slice_beta_offset_div2 = slice->header.slice_beta_offset_div2,
.num_ref_idx_l0_active_minus1 = slice->header.num_ref_idx_l0_active_minus1, .num_ref_idx_l0_active_minus1 = slice->header.num_ref_idx_l0_active_minus1,
.num_ref_idx_l1_active_minus1 = slice->header.num_ref_idx_l1_active_minus1, .num_ref_idx_l1_active_minus1 = slice->header.num_ref_idx_l1_active_minus1,
.slice_group_change_cycle = slice->header.slice_group_change_cycle, .flags = (slice->header.direct_spatial_mv_pred_flag ? V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED : 0) |
.flags = (slice->header.field_pic_flag ? V4L2_H264_SLICE_FLAG_FIELD_PIC : 0) |
(slice->header.bottom_field_flag ? V4L2_H264_SLICE_FLAG_BOTTOM_FIELD : 0) |
(slice->header.direct_spatial_mv_pred_flag ? V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED : 0) |
(slice->header.sp_for_switch_flag ? V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH : 0), (slice->header.sp_for_switch_flag ? V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH : 0),
}; };
/* *INDENT-ON* */ /* *INDENT-ON* */
for (i = 0; i <= slice->header.num_ref_idx_l0_active_minus1; i++) {
params->pred_weight_table.weight_factors[0].luma_weight[i] =
slice->header.pred_weight_table.luma_weight_l0[i];
params->pred_weight_table.weight_factors[0].luma_offset[i] =
slice->header.pred_weight_table.luma_offset_l0[i];
}
if (slice->header.pps->sequence->chroma_array_type != 0) {
for (i = 0; i <= slice->header.num_ref_idx_l0_active_minus1; i++) {
for (j = 0; j < 2; j++) {
params->pred_weight_table.weight_factors[0].chroma_weight[i][j] =
slice->header.pred_weight_table.chroma_weight_l0[i][j];
params->pred_weight_table.weight_factors[0].chroma_offset[i][j] =
slice->header.pred_weight_table.chroma_offset_l0[i][j];
}
}
}
/* Skip l1 if this is not a B-Frame. */
if (slice->header.type % 5 != GST_H264_B_SLICE)
return;
for (i = 0; i <= slice->header.num_ref_idx_l1_active_minus1; i++) {
params->pred_weight_table.weight_factors[1].luma_weight[i] =
slice->header.pred_weight_table.luma_weight_l1[i];
params->pred_weight_table.weight_factors[1].luma_offset[i] =
slice->header.pred_weight_table.luma_offset_l1[i];
}
if (slice->header.pps->sequence->chroma_array_type != 0) {
for (i = 0; i <= slice->header.num_ref_idx_l1_active_minus1; i++) {
for (j = 0; j < 2; j++) {
params->pred_weight_table.weight_factors[1].chroma_weight[i][j] =
slice->header.pred_weight_table.chroma_weight_l1[i][j];
params->pred_weight_table.weight_factors[1].chroma_offset[i][j] =
slice->header.pred_weight_table.chroma_offset_l1[i][j];
}
}
}
} }
static guint8 static guint8
@ -633,15 +653,17 @@ gst_v4l2_codec_h264_dec_fill_references (GstV4l2CodecH264Dec * self,
for (i = 0; i < ref_pic_list0->len; i++) { for (i = 0; i < ref_pic_list0->len; i++) {
GstH264Picture *ref_pic = GstH264Picture *ref_pic =
g_array_index (ref_pic_list0, GstH264Picture *, i); g_array_index (ref_pic_list0, GstH264Picture *, i);
slice_params->ref_pic_list0[i] = slice_params->ref_pic_list0[i].index =
lookup_dpb_index (self->decode_params.dpb, ref_pic); lookup_dpb_index (self->decode_params.dpb, ref_pic);
slice_params->ref_pic_list0[i].fields = 0;
} }
for (i = 0; i < ref_pic_list1->len; i++) { for (i = 0; i < ref_pic_list1->len; i++) {
GstH264Picture *ref_pic = GstH264Picture *ref_pic =
g_array_index (ref_pic_list1, GstH264Picture *, i); g_array_index (ref_pic_list1, GstH264Picture *, i);
slice_params->ref_pic_list1[i] = slice_params->ref_pic_list1[i].index =
lookup_dpb_index (self->decode_params.dpb, ref_pic); lookup_dpb_index (self->decode_params.dpb, ref_pic);
slice_params->ref_pic_list1[i].fields = 0;
} }
} }
@ -774,9 +796,6 @@ gst_v4l2_codec_h264_dec_start_picture (GstH264Decoder * decoder,
gst_v4l2_codec_h264_dec_fill_decoder_params (self, &slice->header, picture, gst_v4l2_codec_h264_dec_fill_decoder_params (self, &slice->header, picture,
dpb); dpb);
if (is_frame_based (self))
gst_v4l2_codec_h264_dec_fill_slice_params (self, slice);
return TRUE; return TRUE;
} }
@ -886,7 +905,7 @@ gst_v4l2_codec_h264_dec_reset_picture (GstV4l2CodecH264Dec * self)
self->bitstream_map = (GstMapInfo) GST_MAP_INFO_INIT; self->bitstream_map = (GstMapInfo) GST_MAP_INFO_INIT;
} }
self->decode_params.num_slices = 0; self->num_slices = 0;
} }
static gboolean static gboolean
@ -925,28 +944,33 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self,
/* *INDENT-OFF* */ /* *INDENT-OFF* */
struct v4l2_ext_control control[] = { struct v4l2_ext_control control[] = {
{ {
.id = V4L2_CID_MPEG_VIDEO_H264_SPS, .id = V4L2_CID_STATELESS_H264_SPS,
.ptr = &self->sps, .ptr = &self->sps,
.size = sizeof (self->sps), .size = sizeof (self->sps),
}, },
{ {
.id = V4L2_CID_MPEG_VIDEO_H264_PPS, .id = V4L2_CID_STATELESS_H264_PPS,
.ptr = &self->pps, .ptr = &self->pps,
.size = sizeof (self->pps), .size = sizeof (self->pps),
}, },
{ {
.id = V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX, .id = V4L2_CID_STATELESS_H264_SCALING_MATRIX,
.ptr = &self->scaling_matrix, .ptr = &self->scaling_matrix,
.size = sizeof (self->scaling_matrix), .size = sizeof (self->scaling_matrix),
}, },
{ {
.id = V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS, .id = V4L2_CID_STATELESS_H264_SLICE_PARAMS,
.ptr = self->slice_params->data, .ptr = self->slice_params->data,
.size = g_array_get_element_size (self->slice_params) .size = g_array_get_element_size (self->slice_params)
* self->decode_params.num_slices, * self->num_slices,
}, },
{ {
.id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS, .id = V4L2_CID_STATELESS_H264_PRED_WEIGHTS,
.ptr = &self->pred_weight,
.size = sizeof (self->pred_weight),
},
{
.id = V4L2_CID_STATELESS_H264_DECODE_PARAMS,
.ptr = &self->decode_params, .ptr = &self->decode_params,
.size = sizeof (self->decode_params), .size = sizeof (self->decode_params),
}, },
@ -1032,6 +1056,7 @@ gst_v4l2_codec_h264_dec_decode_slice (GstH264Decoder * decoder,
} }
gst_v4l2_codec_h264_dec_fill_slice_params (self, slice); gst_v4l2_codec_h264_dec_fill_slice_params (self, slice);
gst_v4l2_codec_h264_dec_fill_pred_weight (self, &slice->header);
gst_v4l2_codec_h264_dec_fill_references (self, ref_pic_list0, gst_v4l2_codec_h264_dec_fill_references (self, ref_pic_list0,
ref_pic_list1); ref_pic_list1);
} }

View file

@ -1,212 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* These are the H.264 state controls for use with stateless H.264
* codec drivers.
*
* It turns out that these structs are not stable yet and will undergo
* more changes. So keep them private until they are stable and ready to
* become part of the official public API.
*/
#ifndef _H264_CTRLS_H_
#define _H264_CTRLS_H_
#include "linux/videodev2.h"
/* Our pixel format isn't stable at the moment */
#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */
/*
* This is put insanely high to avoid conflicting with controls that
* would be added during the phase where those controls are not
* stable. It should be fixed eventually.
*/
#define V4L2_CID_MPEG_VIDEO_H264_SPS (V4L2_CID_MPEG_BASE+1000)
#define V4L2_CID_MPEG_VIDEO_H264_PPS (V4L2_CID_MPEG_BASE+1001)
#define V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX (V4L2_CID_MPEG_BASE+1002)
#define V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS (V4L2_CID_MPEG_BASE+1003)
#define V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (V4L2_CID_MPEG_BASE+1004)
#define V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (V4L2_CID_MPEG_BASE+1005)
#define V4L2_CID_MPEG_VIDEO_H264_START_CODE (V4L2_CID_MPEG_BASE+1006)
/* enum v4l2_ctrl_type type values */
#define V4L2_CTRL_TYPE_H264_SPS 0x0110
#define V4L2_CTRL_TYPE_H264_PPS 0x0111
#define V4L2_CTRL_TYPE_H264_SCALING_MATRIX 0x0112
#define V4L2_CTRL_TYPE_H264_SLICE_PARAMS 0x0113
#define V4L2_CTRL_TYPE_H264_DECODE_PARAMS 0x0114
enum v4l2_mpeg_video_h264_decode_mode {
V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED,
V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED,
};
enum v4l2_mpeg_video_h264_start_code {
V4L2_MPEG_VIDEO_H264_START_CODE_NONE,
V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B,
};
#define V4L2_H264_SPS_CONSTRAINT_SET0_FLAG 0x01
#define V4L2_H264_SPS_CONSTRAINT_SET1_FLAG 0x02
#define V4L2_H264_SPS_CONSTRAINT_SET2_FLAG 0x04
#define V4L2_H264_SPS_CONSTRAINT_SET3_FLAG 0x08
#define V4L2_H264_SPS_CONSTRAINT_SET4_FLAG 0x10
#define V4L2_H264_SPS_CONSTRAINT_SET5_FLAG 0x20
#define V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE 0x01
#define V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS 0x02
#define V4L2_H264_SPS_FLAG_DELTA_PIC_ORDER_ALWAYS_ZERO 0x04
#define V4L2_H264_SPS_FLAG_GAPS_IN_FRAME_NUM_VALUE_ALLOWED 0x08
#define V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY 0x10
#define V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD 0x20
#define V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE 0x40
struct v4l2_ctrl_h264_sps {
__u8 profile_idc;
__u8 constraint_set_flags;
__u8 level_idc;
__u8 seq_parameter_set_id;
__u8 chroma_format_idc;
__u8 bit_depth_luma_minus8;
__u8 bit_depth_chroma_minus8;
__u8 log2_max_frame_num_minus4;
__u8 pic_order_cnt_type;
__u8 log2_max_pic_order_cnt_lsb_minus4;
__u8 max_num_ref_frames;
__u8 num_ref_frames_in_pic_order_cnt_cycle;
__s32 offset_for_ref_frame[255];
__s32 offset_for_non_ref_pic;
__s32 offset_for_top_to_bottom_field;
__u16 pic_width_in_mbs_minus1;
__u16 pic_height_in_map_units_minus1;
__u32 flags;
};
#define V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE 0x0001
#define V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT 0x0002
#define V4L2_H264_PPS_FLAG_WEIGHTED_PRED 0x0004
#define V4L2_H264_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT 0x0008
#define V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED 0x0010
#define V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT 0x0020
#define V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE 0x0040
#define V4L2_H264_PPS_FLAG_PIC_SCALING_MATRIX_PRESENT 0x0080
struct v4l2_ctrl_h264_pps {
__u8 pic_parameter_set_id;
__u8 seq_parameter_set_id;
__u8 num_slice_groups_minus1;
__u8 num_ref_idx_l0_default_active_minus1;
__u8 num_ref_idx_l1_default_active_minus1;
__u8 weighted_bipred_idc;
__s8 pic_init_qp_minus26;
__s8 pic_init_qs_minus26;
__s8 chroma_qp_index_offset;
__s8 second_chroma_qp_index_offset;
__u16 flags;
};
struct v4l2_ctrl_h264_scaling_matrix {
__u8 scaling_list_4x4[6][16];
__u8 scaling_list_8x8[6][64];
};
struct v4l2_h264_weight_factors {
__s16 luma_weight[32];
__s16 luma_offset[32];
__s16 chroma_weight[32][2];
__s16 chroma_offset[32][2];
};
struct v4l2_h264_pred_weight_table {
__u16 luma_log2_weight_denom;
__u16 chroma_log2_weight_denom;
struct v4l2_h264_weight_factors weight_factors[2];
};
#define V4L2_H264_SLICE_TYPE_P 0
#define V4L2_H264_SLICE_TYPE_B 1
#define V4L2_H264_SLICE_TYPE_I 2
#define V4L2_H264_SLICE_TYPE_SP 3
#define V4L2_H264_SLICE_TYPE_SI 4
#define V4L2_H264_SLICE_FLAG_FIELD_PIC 0x01
#define V4L2_H264_SLICE_FLAG_BOTTOM_FIELD 0x02
#define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED 0x04
#define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH 0x08
struct v4l2_ctrl_h264_slice_params {
/* Size in bytes, including header */
__u32 size;
/* Offset in bytes to the start of slice in the OUTPUT buffer. */
__u32 start_byte_offset;
/* Offset in bits to slice_data() from the beginning of this slice. */
__u32 header_bit_size;
__u16 first_mb_in_slice;
__u8 slice_type;
__u8 pic_parameter_set_id;
__u8 colour_plane_id;
__u8 redundant_pic_cnt;
__u16 frame_num;
__u16 idr_pic_id;
__u16 pic_order_cnt_lsb;
__s32 delta_pic_order_cnt_bottom;
__s32 delta_pic_order_cnt0;
__s32 delta_pic_order_cnt1;
struct v4l2_h264_pred_weight_table pred_weight_table;
/* Size in bits of dec_ref_pic_marking() syntax element. */
__u32 dec_ref_pic_marking_bit_size;
/* Size in bits of pic order count syntax. */
__u32 pic_order_cnt_bit_size;
__u8 cabac_init_idc;
__s8 slice_qp_delta;
__s8 slice_qs_delta;
__u8 disable_deblocking_filter_idc;
__s8 slice_alpha_c0_offset_div2;
__s8 slice_beta_offset_div2;
__u8 num_ref_idx_l0_active_minus1;
__u8 num_ref_idx_l1_active_minus1;
__u32 slice_group_change_cycle;
/*
* Entries on each list are indices into
* v4l2_ctrl_h264_decode_params.dpb[].
*/
__u8 ref_pic_list0[32];
__u8 ref_pic_list1[32];
__u32 flags;
};
#define V4L2_H264_DPB_ENTRY_FLAG_VALID 0x01
#define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x02
#define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x04
#define V4L2_H264_DPB_ENTRY_FLAG_FIELD 0x08
#define V4L2_H264_DPB_ENTRY_FLAG_BOTTOM_FIELD 0x10
struct v4l2_h264_dpb_entry {
__u64 reference_ts;
__u16 frame_num;
__u16 pic_num;
/* Note that field is indicated by v4l2_buffer.field */
__s32 top_field_order_cnt;
__s32 bottom_field_order_cnt;
__u32 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */
};
#define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC 0x01
struct v4l2_ctrl_h264_decode_params {
struct v4l2_h264_dpb_entry dpb[16];
__u16 num_slices;
__u16 nal_ref_idc;
__s32 top_field_order_cnt;
__s32 bottom_field_order_cnt;
__u32 flags; /* V4L2_H264_DECODE_PARAM_FLAG_* */
};
#endif

View file

@ -20,10 +20,7 @@
#ifndef __LINUX_MEDIA_H #ifndef __LINUX_MEDIA_H
#define __LINUX_MEDIA_H #define __LINUX_MEDIA_H
#ifndef __KERNEL__
#include <stdint.h> #include <stdint.h>
#define __user
#endif
#include "linux/types-compat.h" #include "linux/types-compat.h"
struct media_device_info { struct media_device_info {
@ -127,6 +124,7 @@ struct media_device_info {
#define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006) #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006)
#define MEDIA_ENT_F_PROC_VIDEO_ENCODER (MEDIA_ENT_F_BASE + 0x4007) #define MEDIA_ENT_F_PROC_VIDEO_ENCODER (MEDIA_ENT_F_BASE + 0x4007)
#define MEDIA_ENT_F_PROC_VIDEO_DECODER (MEDIA_ENT_F_BASE + 0x4008) #define MEDIA_ENT_F_PROC_VIDEO_DECODER (MEDIA_ENT_F_BASE + 0x4008)
#define MEDIA_ENT_F_PROC_VIDEO_ISP (MEDIA_ENT_F_BASE + 0x4009)
/* /*
* Switch and bridge entity functions * Switch and bridge entity functions
@ -167,7 +165,6 @@ struct media_entity_desc {
__u32 minor; __u32 minor;
} dev; } dev;
#if !defined(__KERNEL__)
/* /*
* TODO: this shouldn't have been added without * TODO: this shouldn't have been added without
* actual drivers that use this. When the first real driver * actual drivers that use this. When the first real driver
@ -199,7 +196,6 @@ struct media_entity_desc {
__u32 minor; __u32 minor;
} fb; } fb;
int dvb; int dvb;
#endif
/* Sub-device specifications */ /* Sub-device specifications */
/* Nothing needed yet */ /* Nothing needed yet */
@ -236,9 +232,9 @@ struct media_link_desc {
struct media_links_enum { struct media_links_enum {
__u32 entity; __u32 entity;
/* Should have enough room for pads elements */ /* Should have enough room for pads elements */
struct media_pad_desc __user *pads; struct media_pad_desc *pads;
/* Should have enough room for links elements */ /* Should have enough room for links elements */
struct media_link_desc __user *links; struct media_link_desc *links;
__u32 reserved[4]; __u32 reserved[4];
}; };
@ -267,21 +263,6 @@ struct media_links_enum {
#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1) #define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) #define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2)
#if defined(__KERNEL__)
/*
* Connector functions
*
* For now these should not be used in userspace, as some definitions may
* change.
*
* It is the responsibility of the entity drivers to add connectors and links.
*/
#define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 0x30001)
#define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 0x30002)
#define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 0x30003)
#endif
/* /*
* MC next gen API definitions * MC next gen API definitions
@ -383,7 +364,6 @@ struct media_v2_topology {
#define MEDIA_REQUEST_IOC_QUEUE _IO('|', 0x80) #define MEDIA_REQUEST_IOC_QUEUE _IO('|', 0x80)
#define MEDIA_REQUEST_IOC_REINIT _IO('|', 0x81) #define MEDIA_REQUEST_IOC_REINIT _IO('|', 0x81)
#ifndef __KERNEL__
/* /*
* Legacy symbols used to avoid userspace compilation breakages. * Legacy symbols used to avoid userspace compilation breakages.
@ -435,6 +415,5 @@ struct media_v2_topology {
/* Obsolete symbol for media_version, no longer used in the kernel */ /* Obsolete symbol for media_version, no longer used in the kernel */
#define MEDIA_API_VERSION ((0 << 16) | (1 << 8) | 0) #define MEDIA_API_VERSION ((0 << 16) | (1 << 8) | 0)
#endif
#endif /* __LINUX_MEDIA_H */ #endif /* __LINUX_MEDIA_H */

View file

@ -24,7 +24,7 @@
#ifndef __TYPES_COMPAT_H__ #ifndef __TYPES_COMPAT_H__
#define __TYPES_COMPAT_H__ #define __TYPES_COMPAT_H__
#define __user #define __inline__ inline
#ifdef __linux__ #ifdef __linux__
#include <linux/types.h> #include <linux/types.h>

View file

@ -92,7 +92,6 @@ struct v4l2_edid {
__u8 *edid; __u8 *edid;
}; };
#ifndef __KERNEL__
/* Backward compatibility target definitions --- to be removed. */ /* Backward compatibility target definitions --- to be removed. */
#define V4L2_SEL_TGT_CROP_ACTIVE V4L2_SEL_TGT_CROP #define V4L2_SEL_TGT_CROP_ACTIVE V4L2_SEL_TGT_CROP
#define V4L2_SEL_TGT_COMPOSE_ACTIVE V4L2_SEL_TGT_COMPOSE #define V4L2_SEL_TGT_COMPOSE_ACTIVE V4L2_SEL_TGT_COMPOSE
@ -105,6 +104,5 @@ struct v4l2_edid {
#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE V4L2_SEL_FLAG_GE #define V4L2_SUBDEV_SEL_FLAG_SIZE_GE V4L2_SEL_FLAG_GE
#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE #define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE
#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG #define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG
#endif
#endif /* __V4L2_COMMON__ */ #endif /* __V4L2_COMMON__ */

File diff suppressed because it is too large Load diff

View file

@ -169,6 +169,8 @@ enum v4l2_buf_type {
|| (type) == V4L2_BUF_TYPE_SDR_OUTPUT \ || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \
|| (type) == V4L2_BUF_TYPE_META_OUTPUT) || (type) == V4L2_BUF_TYPE_META_OUTPUT)
#define V4L2_TYPE_IS_CAPTURE(type) (!V4L2_TYPE_IS_OUTPUT(type))
enum v4l2_tuner_type { enum v4l2_tuner_type {
V4L2_TUNER_RADIO = 1, V4L2_TUNER_RADIO = 1,
V4L2_TUNER_ANALOG_TV = 2, V4L2_TUNER_ANALOG_TV = 2,
@ -217,9 +219,7 @@ enum v4l2_colorspace {
V4L2_COLORSPACE_470_SYSTEM_M = 5, V4L2_COLORSPACE_470_SYSTEM_M = 5,
/* /*
* EBU Tech 3213 PAL/SECAM colorspace. This only makes sense when * EBU Tech 3213 PAL/SECAM colorspace.
* dealing with really old PAL/SECAM recordings. Superseded by
* SMPTE 170M.
*/ */
V4L2_COLORSPACE_470_SYSTEM_BG = 6, V4L2_COLORSPACE_470_SYSTEM_BG = 6,
@ -324,14 +324,12 @@ enum v4l2_ycbcr_encoding {
/* Rec. 709/EN 61966-2-4 Extended Gamut -- HDTV */ /* Rec. 709/EN 61966-2-4 Extended Gamut -- HDTV */
V4L2_YCBCR_ENC_XV709 = 4, V4L2_YCBCR_ENC_XV709 = 4,
#ifndef __KERNEL__
/* /*
* sYCC (Y'CbCr encoding of sRGB), identical to ENC_601. It was added * sYCC (Y'CbCr encoding of sRGB), identical to ENC_601. It was added
* originally due to a misunderstanding of the sYCC standard. It should * originally due to a misunderstanding of the sYCC standard. It should
* not be used, instead use V4L2_YCBCR_ENC_601. * not be used, instead use V4L2_YCBCR_ENC_601.
*/ */
V4L2_YCBCR_ENC_SYCC = 5, V4L2_YCBCR_ENC_SYCC = 5,
#endif
/* BT.2020 Non-constant Luminance Y'CbCr */ /* BT.2020 Non-constant Luminance Y'CbCr */
V4L2_YCBCR_ENC_BT2020 = 6, V4L2_YCBCR_ENC_BT2020 = 6,
@ -369,9 +367,9 @@ enum v4l2_hsv_encoding {
enum v4l2_quantization { enum v4l2_quantization {
/* /*
* The default for R'G'B' quantization is always full range, except * The default for R'G'B' quantization is always full range.
* for the BT2020 colorspace. For Y'CbCr the quantization is always * For Y'CbCr the quantization is always limited range, except
* limited range, except for COLORSPACE_JPEG: this is full range. * for COLORSPACE_JPEG: this is full range.
*/ */
V4L2_QUANTIZATION_DEFAULT = 0, V4L2_QUANTIZATION_DEFAULT = 0,
V4L2_QUANTIZATION_FULL_RANGE = 1, V4L2_QUANTIZATION_FULL_RANGE = 1,
@ -380,14 +378,13 @@ enum v4l2_quantization {
/* /*
* Determine how QUANTIZATION_DEFAULT should map to a proper quantization. * Determine how QUANTIZATION_DEFAULT should map to a proper quantization.
* This depends on whether the image is RGB or not, the colorspace and the * This depends on whether the image is RGB or not, the colorspace.
* Y'CbCr encoding. * The Y'CbCr encoding is not used anymore, but is still there for backwards
* compatibility.
*/ */
#define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb_or_hsv, colsp, ycbcr_enc) \ #define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb_or_hsv, colsp, ycbcr_enc) \
(((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \ (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \
V4L2_QUANTIZATION_LIM_RANGE : \ V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)
(((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \
V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE))
/* /*
* Deprecated names for opRGB colorspace (IEC 61966-2-5) * Deprecated names for opRGB colorspace (IEC 61966-2-5)
@ -395,10 +392,8 @@ enum v4l2_quantization {
* WARNING: Please don't use these deprecated defines in your code, as * WARNING: Please don't use these deprecated defines in your code, as
* there is a chance we have to remove them in the future. * there is a chance we have to remove them in the future.
*/ */
#ifndef __KERNEL__
#define V4L2_COLORSPACE_ADOBERGB V4L2_COLORSPACE_OPRGB #define V4L2_COLORSPACE_ADOBERGB V4L2_COLORSPACE_OPRGB
#define V4L2_XFER_FUNC_ADOBERGB V4L2_XFER_FUNC_OPRGB #define V4L2_XFER_FUNC_ADOBERGB V4L2_XFER_FUNC_OPRGB
#endif
enum v4l2_priority { enum v4l2_priority {
V4L2_PRIORITY_UNSET = 0, /* not initialized */ V4L2_PRIORITY_UNSET = 0, /* not initialized */
@ -485,6 +480,8 @@ struct v4l2_capability {
#define V4L2_CAP_TOUCH 0x10000000 /* Is a touch device */ #define V4L2_CAP_TOUCH 0x10000000 /* Is a touch device */
#define V4L2_CAP_IO_MC 0x20000000 /* Is input/output controlled by the media controller */
#define V4L2_CAP_DEVICE_CAPS 0x80000000 /* sets device capabilities field */ #define V4L2_CAP_DEVICE_CAPS 0x80000000 /* sets device capabilities field */
/* /*
@ -592,8 +589,6 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_XYUV32 v4l2_fourcc('X', 'Y', 'U', 'V') /* 32 XYUV-8-8-8-8 */ #define V4L2_PIX_FMT_XYUV32 v4l2_fourcc('X', 'Y', 'U', 'V') /* 32 XYUV-8-8-8-8 */
#define V4L2_PIX_FMT_VUYA32 v4l2_fourcc('V', 'U', 'Y', 'A') /* 32 VUYA-8-8-8-8 */ #define V4L2_PIX_FMT_VUYA32 v4l2_fourcc('V', 'U', 'Y', 'A') /* 32 VUYA-8-8-8-8 */
#define V4L2_PIX_FMT_VUYX32 v4l2_fourcc('V', 'U', 'Y', 'X') /* 32 VUYX-8-8-8-8 */ #define V4L2_PIX_FMT_VUYX32 v4l2_fourcc('V', 'U', 'Y', 'X') /* 32 VUYX-8-8-8-8 */
#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */
/* two planes -- one Y, one Cr + Cb interleaved */ /* two planes -- one Y, one Cr + Cb interleaved */
@ -603,6 +598,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
#define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */ #define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */
#define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */ #define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */
#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
/* two non contiguous planes - one Y, one Cr + Cb interleaved */ /* two non contiguous planes - one Y, one Cr + Cb interleaved */
#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */ #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */
@ -700,6 +696,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC aka H.265 */ #define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC aka H.265 */
#define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T') /* Fast Walsh Hadamard Transform (vicodec) */ #define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T') /* Fast Walsh Hadamard Transform (vicodec) */
#define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H') /* Stateless FWHT (vicodec) */ #define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H') /* Stateless FWHT (vicodec) */
#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */
/* Vendor-specific formats */ /* Vendor-specific formats */
#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
@ -735,6 +732,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */ #define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */
#define V4L2_PIX_FMT_SUNXI_TILED_NV12 v4l2_fourcc('S', 'T', '1', '2') /* Sunxi Tiled NV12 Format */ #define V4L2_PIX_FMT_SUNXI_TILED_NV12 v4l2_fourcc('S', 'T', '1', '2') /* Sunxi Tiled NV12 Format */
#define V4L2_PIX_FMT_CNF4 v4l2_fourcc('C', 'N', 'F', '4') /* Intel 4-bit packed depth confidence information */ #define V4L2_PIX_FMT_CNF4 v4l2_fourcc('C', 'N', 'F', '4') /* Intel 4-bit packed depth confidence information */
#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* BTTV 8-bit dithered RGB */
/* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */ /* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */
#define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */ #define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */
@ -765,11 +763,16 @@ struct v4l2_pix_format {
#define V4L2_META_FMT_D4XX v4l2_fourcc('D', '4', 'X', 'X') /* D4XX Payload Header metadata */ #define V4L2_META_FMT_D4XX v4l2_fourcc('D', '4', 'X', 'X') /* D4XX Payload Header metadata */
#define V4L2_META_FMT_VIVID v4l2_fourcc('V', 'I', 'V', 'D') /* Vivid Metadata */ #define V4L2_META_FMT_VIVID v4l2_fourcc('V', 'I', 'V', 'D') /* Vivid Metadata */
/* Vendor specific - used for RK_ISP1 camera sub-system */
#define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */
#define V4L2_META_FMT_RK_ISP1_STAT_3A v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A Statistics */
/* priv field value to indicates that subsequent fields are valid. */ /* priv field value to indicates that subsequent fields are valid. */
#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe #define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
/* Flags */ /* Flags */
#define V4L2_PIX_FMT_FLAG_PREMUL_ALPHA 0x00000001 #define V4L2_PIX_FMT_FLAG_PREMUL_ALPHA 0x00000001
#define V4L2_PIX_FMT_FLAG_SET_CSC 0x00000002
/* /*
* F O R M A T E N U M E R A T I O N * F O R M A T E N U M E R A T I O N
@ -780,13 +783,20 @@ struct v4l2_fmtdesc {
__u32 flags; __u32 flags;
__u8 description[32]; /* Description string */ __u8 description[32]; /* Description string */
__u32 pixelformat; /* Format fourcc */ __u32 pixelformat; /* Format fourcc */
__u32 reserved[4]; __u32 mbus_code; /* Media bus code */
__u32 reserved[3];
}; };
#define V4L2_FMT_FLAG_COMPRESSED 0x0001 #define V4L2_FMT_FLAG_COMPRESSED 0x0001
#define V4L2_FMT_FLAG_EMULATED 0x0002 #define V4L2_FMT_FLAG_EMULATED 0x0002
#define V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM 0x0004 #define V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM 0x0004
#define V4L2_FMT_FLAG_DYN_RESOLUTION 0x0008 #define V4L2_FMT_FLAG_DYN_RESOLUTION 0x0008
#define V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL 0x0010
#define V4L2_FMT_FLAG_CSC_COLORSPACE 0x0020
#define V4L2_FMT_FLAG_CSC_XFER_FUNC 0x0040
#define V4L2_FMT_FLAG_CSC_YCBCR_ENC 0x0080
#define V4L2_FMT_FLAG_CSC_HSV_ENC V4L2_FMT_FLAG_CSC_YCBCR_ENC
#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100
/* Frame Size and frame rate enumeration */ /* Frame Size and frame rate enumeration */
/* /*
@ -916,23 +926,6 @@ struct v4l2_jpegcompression {
* M E M O R Y - M A P P I N G B U F F E R S * M E M O R Y - M A P P I N G B U F F E R S
*/ */
#ifdef __KERNEL__
/*
* This corresponds to the user space version of timeval
* for 64-bit time_t. sparc64 is different from everyone
* else, using the microseconds in the wrong half of the
* second 64-bit word.
*/
struct __kernel_v4l2_timeval {
long long tv_sec;
#if defined(__sparc__) && defined(__arch64__)
int tv_usec;
int __pad;
#else
long long tv_usec;
#endif
};
#endif
struct v4l2_requestbuffers { struct v4l2_requestbuffers {
__u32 count; __u32 count;
@ -943,12 +936,13 @@ struct v4l2_requestbuffers {
}; };
/* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */ /* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */
#define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0) #define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0)
#define V4L2_BUF_CAP_SUPPORTS_USERPTR (1 << 1) #define V4L2_BUF_CAP_SUPPORTS_USERPTR (1 << 1)
#define V4L2_BUF_CAP_SUPPORTS_DMABUF (1 << 2) #define V4L2_BUF_CAP_SUPPORTS_DMABUF (1 << 2)
#define V4L2_BUF_CAP_SUPPORTS_REQUESTS (1 << 3) #define V4L2_BUF_CAP_SUPPORTS_REQUESTS (1 << 3)
#define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4)
#define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5)
#define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6)
/** /**
* struct v4l2_plane - plane info for multi-planar buffers * struct v4l2_plane - plane info for multi-planar buffers
@ -1019,11 +1013,7 @@ struct v4l2_buffer {
__u32 bytesused; __u32 bytesused;
__u32 flags; __u32 flags;
__u32 field; __u32 field;
#ifdef __KERNEL__
struct __kernel_v4l2_timeval timestamp;
#else
struct timeval timestamp; struct timeval timestamp;
#endif
struct v4l2_timecode timecode; struct v4l2_timecode timecode;
__u32 sequence; __u32 sequence;
@ -1043,7 +1033,6 @@ struct v4l2_buffer {
}; };
}; };
#ifndef __KERNEL__
/** /**
* v4l2_timeval_to_ns - Convert timeval to nanoseconds * v4l2_timeval_to_ns - Convert timeval to nanoseconds
* @ts: pointer to the timeval variable to be converted * @ts: pointer to the timeval variable to be converted
@ -1051,11 +1040,10 @@ struct v4l2_buffer {
* Returns the scalar nanosecond representation of the timeval * Returns the scalar nanosecond representation of the timeval
* parameter. * parameter.
*/ */
static inline __u64 v4l2_timeval_to_ns(const struct timeval *tv) static __inline__ __u64 v4l2_timeval_to_ns(const struct timeval *tv)
{ {
return (__u64)tv->tv_sec * 1000000000ULL + tv->tv_usec * 1000; return (__u64)tv->tv_sec * 1000000000ULL + tv->tv_usec * 1000;
} }
#endif
/* Flags for 'flags' field */ /* Flags for 'flags' field */
/* Buffer is mapped (flag) */ /* Buffer is mapped (flag) */
@ -1164,16 +1152,16 @@ struct v4l2_framebuffer {
struct v4l2_clip { struct v4l2_clip {
struct v4l2_rect c; struct v4l2_rect c;
struct v4l2_clip __user *next; struct v4l2_clip *next;
}; };
struct v4l2_window { struct v4l2_window {
struct v4l2_rect w; struct v4l2_rect w;
__u32 field; /* enum v4l2_field */ __u32 field; /* enum v4l2_field */
__u32 chromakey; __u32 chromakey;
struct v4l2_clip __user *clips; struct v4l2_clip *clips;
__u32 clipcount; __u32 clipcount;
void __user *bitmap; void *bitmap;
__u8 global_alpha; __u8 global_alpha;
}; };
@ -1712,20 +1700,25 @@ struct v4l2_ext_control {
union { union {
__s32 value; __s32 value;
__s64 value64; __s64 value64;
char __user *string; char *string;
__u8 __user *p_u8; __u8 *p_u8;
__u16 __user *p_u16; __u16 *p_u16;
__u32 __user *p_u32; __u32 *p_u32;
struct v4l2_area __user *p_area; struct v4l2_area *p_area;
void __user *ptr; struct v4l2_ctrl_h264_sps *p_h264_sps;
struct v4l2_ctrl_h264_pps *p_h264_pps;
struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix;
struct v4l2_ctrl_h264_pred_weights *p_h264_pred_weights;
struct v4l2_ctrl_h264_slice_params *p_h264_slice_params;
struct v4l2_ctrl_h264_decode_params *p_h264_decode_params;
struct v4l2_ctrl_fwht_params *p_fwht_params;
void *ptr;
}; };
} __attribute__ ((packed)); } __attribute__ ((packed));
struct v4l2_ext_controls { struct v4l2_ext_controls {
union { union {
#ifndef __KERNEL__
__u32 ctrl_class; __u32 ctrl_class;
#endif
__u32 which; __u32 which;
}; };
__u32 count; __u32 count;
@ -1736,9 +1729,7 @@ struct v4l2_ext_controls {
}; };
#define V4L2_CTRL_ID_MASK (0x0fffffff) #define V4L2_CTRL_ID_MASK (0x0fffffff)
#ifndef __KERNEL__
#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
#endif
#define V4L2_CTRL_ID2WHICH(id) ((id) & 0x0fff0000UL) #define V4L2_CTRL_ID2WHICH(id) ((id) & 0x0fff0000UL)
#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) #define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
#define V4L2_CTRL_MAX_DIMS (4) #define V4L2_CTRL_MAX_DIMS (4)
@ -1763,6 +1754,15 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_U16 = 0x0101, V4L2_CTRL_TYPE_U16 = 0x0101,
V4L2_CTRL_TYPE_U32 = 0x0102, V4L2_CTRL_TYPE_U32 = 0x0102,
V4L2_CTRL_TYPE_AREA = 0x0106, V4L2_CTRL_TYPE_AREA = 0x0106,
V4L2_CTRL_TYPE_H264_SPS = 0x0200,
V4L2_CTRL_TYPE_H264_PPS = 0x0201,
V4L2_CTRL_TYPE_H264_SCALING_MATRIX = 0x0202,
V4L2_CTRL_TYPE_H264_SLICE_PARAMS = 0x0203,
V4L2_CTRL_TYPE_H264_DECODE_PARAMS = 0x0204,
V4L2_CTRL_TYPE_H264_PRED_WEIGHTS = 0x0205,
V4L2_CTRL_TYPE_FWHT_PARAMS = 0x0220,
}; };
/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
@ -2371,11 +2371,7 @@ struct v4l2_event {
} u; } u;
__u32 pending; __u32 pending;
__u32 sequence; __u32 sequence;
#ifdef __KERNEL__
struct __kernel_timespec timestamp;
#else
struct timespec timestamp; struct timespec timestamp;
#endif
__u32 id; __u32 id;
__u32 reserved[8]; __u32 reserved[8];
}; };

View file

@ -26,7 +26,7 @@
#include "gstv4l2codech264dec.h" #include "gstv4l2codech264dec.h"
#include "gstv4l2codecvp8dec.h" #include "gstv4l2codecvp8dec.h"
#include "gstv4l2decoder.h" #include "gstv4l2decoder.h"
#include "linux/h264-ctrls.h" #include "linux/v4l2-controls.h"
#include "linux/vp8-ctrls.h" #include "linux/vp8-ctrls.h"
#include "linux/media.h" #include "linux/media.h"