Until now, the MPEG-2 V4L2 API was not exported as a public API, and only defined in a private media header (media/mpeg2-ctrls.h). After reviewing the MPEG-2 specification in detail, and reworking the controls so they match the MPEG-2 semantics properly, we can consider it ready.
Showing the changes to include/uapi (2 of 14 files). Show all
Unified · Split
| @@ -1862,6 +1862,118 @@ struct v4l2_ctrl_vp8_frame { · 1861 unmodified lines | ||
| 1862 | 1862 | __u64 flags; |
| 1863 | 1863 | }; |
| 1864 | 1864 | |
| 1865 | +/* Stateless MPEG-2 controls */ | |
| 1866 | + | |
| 1867 | +#define V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE 0x01 | |
| 1868 | + | |
| 1869 | +#define V4L2_CID_STATELESS_MPEG2_SEQUENCE (V4L2_CID_CODEC_STATELESS_BASE+220) | |
| 1870 | +/** | |
| 1871 | + * struct v4l2_ctrl_mpeg2_sequence - MPEG-2 sequence header | |
| 1872 | + * | |
| 1873 | + * All the members on this structure match the sequence header and sequence | |
| 1874 | + * extension syntaxes as specified by the MPEG-2 specification. | |
| 1875 | + * | |
| 1876 | + * Fields horizontal_size, vertical_size and vbv_buffer_size are a | |
| 1877 | + * combination of respective _value and extension syntax elements, | |
| 1878 | + * as described in section 6.3.3 "Sequence header". | |
| 1879 | + * | |
| 1880 | + * @horizontal_size: combination of elements horizontal_size_value and | |
| 1881 | + * horizontal_size_extension. | |
| 1882 | + * @vertical_size: combination of elements vertical_size_value and | |
| 1883 | + * vertical_size_extension. | |
| 1884 | + * @vbv_buffer_size: combination of elements vbv_buffer_size_value and | |
| 1885 | + * vbv_buffer_size_extension. | |
| 1886 | + * @profile_and_level_indication: see MPEG-2 specification. | |
| 1887 | + * @chroma_format: see MPEG-2 specification. | |
| 1888 | + * @flags: see V4L2_MPEG2_SEQ_FLAG_{}. | |
| 1889 | + */ | |
| 1890 | +struct v4l2_ctrl_mpeg2_sequence { | |
| 1891 | + __u16 horizontal_size; | |
| 1892 | + __u16 vertical_size; | |
| 1893 | + __u32 vbv_buffer_size; | |
| 1894 | + __u16 profile_and_level_indication; | |
| 1895 | + __u8 chroma_format; | |
| 1896 | + __u8 flags; | |
| 1897 | +}; | |
| 1898 | + | |
| 1899 | +#define V4L2_MPEG2_PIC_CODING_TYPE_I 1 | |
| 1900 | +#define V4L2_MPEG2_PIC_CODING_TYPE_P 2 | |
| 1901 | +#define V4L2_MPEG2_PIC_CODING_TYPE_B 3 | |
| 1902 | +#define V4L2_MPEG2_PIC_CODING_TYPE_D 4 | |
| 1903 | + | |
| 1904 | +#define V4L2_MPEG2_PIC_TOP_FIELD 0x1 | |
| 1905 | +#define V4L2_MPEG2_PIC_BOTTOM_FIELD 0x2 | |
| 1906 | +#define V4L2_MPEG2_PIC_FRAME 0x3 | |
| 1907 | + | |
| 1908 | +#define V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST 0x0001 | |
| 1909 | +#define V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT 0x0002 | |
| 1910 | +#define V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV 0x0004 | |
| 1911 | +#define V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE 0x0008 | |
| 1912 | +#define V4L2_MPEG2_PIC_FLAG_INTRA_VLC 0x0010 | |
| 1913 | +#define V4L2_MPEG2_PIC_FLAG_ALT_SCAN 0x0020 | |
| 1914 | +#define V4L2_MPEG2_PIC_FLAG_REPEAT_FIRST 0x0040 | |
| 1915 | +#define V4L2_MPEG2_PIC_FLAG_PROGRESSIVE 0x0080 | |
| 1916 | + | |
| 1917 | +#define V4L2_CID_STATELESS_MPEG2_PICTURE (V4L2_CID_CODEC_STATELESS_BASE+221) | |
| 1918 | +/** | |
| 1919 | + * struct v4l2_ctrl_mpeg2_picture - MPEG-2 picture header | |
| 1920 | + * | |
| 1921 | + * All the members on this structure match the picture header and picture | |
| 1922 | + * coding extension syntaxes as specified by the MPEG-2 specification. | |
| 1923 | + * | |
| 1924 | + * @backward_ref_ts: timestamp of the V4L2 capture buffer to use as | |
| 1925 | + * reference for backward prediction. | |
| 1926 | + * @forward_ref_ts: timestamp of the V4L2 capture buffer to use as | |
| 1927 | + * reference for forward prediction. These timestamp refers to the | |
| 1928 | + * timestamp field in struct v4l2_buffer. Use v4l2_timeval_to_ns() | |
| 1929 | + * to convert the struct timeval to a __u64. | |
| 1930 | + * @flags: see V4L2_MPEG2_PIC_FLAG_{}. | |
| 1931 | + * @f_code: see MPEG-2 specification. | |
| 1932 | + * @picture_coding_type: see MPEG-2 specification. | |
| 1933 | + * @picture_structure: see V4L2_MPEG2_PIC_{}_FIELD. | |
| 1934 | + * @intra_dc_precision: see MPEG-2 specification. | |
| 1935 | + * @reserved: padding field. Should be zeroed by applications. | |
| 1936 | + */ | |
| 1937 | +struct v4l2_ctrl_mpeg2_picture { | |
| 1938 | + __u64 backward_ref_ts; | |
| 1939 | + __u64 forward_ref_ts; | |
| 1940 | + __u32 flags; | |
| 1941 | + __u8 f_code[2][2]; | |
| 1942 | + __u8 picture_coding_type; | |
| 1943 | + __u8 picture_structure; | |
| 1944 | + __u8 intra_dc_precision; | |
| 1945 | + __u8 reserved[5]; | |
| 1946 | +}; | |
| 1947 | + | |
| 1948 | +#define V4L2_CID_STATELESS_MPEG2_QUANTISATION (V4L2_CID_CODEC_STATELESS_BASE+222) | |
| 1949 | +/** | |
| 1950 | + * struct v4l2_ctrl_mpeg2_quantisation - MPEG-2 quantisation | |
| 1951 | + * | |
| 1952 | + * Quantisation matrices as specified by section 6.3.7 | |
| 1953 | + * "Quant matrix extension". | |
| 1954 | + * | |
| 1955 | + * @intra_quantiser_matrix: The quantisation matrix coefficients | |
| 1956 | + * for intra-coded frames, in zigzag scanning order. It is relevant | |
| 1957 | + * for both luma and chroma components, although it can be superseded | |
| 1958 | + * by the chroma-specific matrix for non-4:2:0 YUV formats. | |
| 1959 | + * @non_intra_quantiser_matrix: The quantisation matrix coefficients | |
| 1960 | + * for non-intra-coded frames, in zigzag scanning order. It is relevant | |
| 1961 | + * for both luma and chroma components, although it can be superseded | |
| 1962 | + * by the chroma-specific matrix for non-4:2:0 YUV formats. | |
| 1963 | + * @chroma_intra_quantiser_matrix: The quantisation matrix coefficients | |
| 1964 | + * for the chominance component of intra-coded frames, in zigzag scanning | |
| 1965 | + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. | |
| 1966 | + * @chroma_non_intra_quantiser_matrix: The quantisation matrix coefficients | |
| 1967 | + * for the chrominance component of non-intra-coded frames, in zigzag scanning | |
| 1968 | + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. | |
| 1969 | + */ | |
| 1970 | +struct v4l2_ctrl_mpeg2_quantisation { | |
| 1971 | + __u8 intra_quantiser_matrix[64]; | |
| 1972 | + __u8 non_intra_quantiser_matrix[64]; | |
| 1973 | + __u8 chroma_intra_quantiser_matrix[64]; | |
| 1974 | + __u8 chroma_non_intra_quantiser_matrix[64]; | |
| 1975 | +}; | |
| 1976 | + | |
| 1865 | 1977 | #define V4L2_CID_COLORIMETRY_CLASS_BASE (V4L2_CTRL_CLASS_COLORIMETRY | 0x900) |
| 1866 | 1978 | #define V4L2_CID_COLORIMETRY_CLASS (V4L2_CTRL_CLASS_COLORIMETRY | 1) |
| 1867 | 1979 | |
| @@ -1747,6 +1747,9 @@ struct v4l2_ext_control { · 1746 unmodified lines | ||
| 1747 | 1747 | struct v4l2_ctrl_h264_decode_params __user *p_h264_decode_params; |
| 1748 | 1748 | struct v4l2_ctrl_fwht_params __user *p_fwht_params; |
| 1749 | 1749 | struct v4l2_ctrl_vp8_frame __user *p_vp8_frame; |
| 1750 | + struct v4l2_ctrl_mpeg2_sequence __user *p_mpeg2_sequence; | |
| 1751 | + struct v4l2_ctrl_mpeg2_picture __user *p_mpeg2_picture; | |
| 1752 | + struct v4l2_ctrl_mpeg2_quantisation __user *p_mpeg2_quantisation; | |
| 1750 | 1753 | void __user *ptr; |
| 1751 | 1754 | }; |
| 1752 | 1755 | } __attribute__ ((packed)); |