* Re: [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters
@ 2020-11-10 13:27 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-11-10 13:27 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 17919 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201105205118.178458-4-ezequiel@collabora.com>
References: <20201105205118.178458-4-ezequiel@collabora.com>
TO: Ezequiel Garcia <ezequiel@collabora.com>
TO: linux-media(a)vger.kernel.org
TO: linux-kernel(a)vger.kernel.org
CC: kernel(a)collabora.com
CC: Jonas Karlman <jonas@kwiboo.se>
CC: Hans Verkuil <hverkuil@xs4all.nl>
CC: Nicolas Dufresne <nicolas.dufresne@collabora.com>
CC: Philipp Zabel <p.zabel@pengutronix.de>
CC: Maxime Ripard <mripard@kernel.org>
CC: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
CC: Jernej Skrabec <jernej.skrabec@siol.net>
Hi Ezequiel,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on sunxi/sunxi/for-next linus/master v5.10-rc3 next-20201110]
[cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Ezequiel-Garcia/MPEG-2-stateless-API-cleanup/20201106-045304
base: git://linuxtv.org/media_tree.git master
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago
config: i386-randconfig-m021-20201110 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/media/v4l2-core/v4l2-ctrls.c:1809 std_validate_compound() warn: ignoring unreachable code.
vim +1809 drivers/media/v4l2-core/v4l2-ctrls.c
298c62d3856111e Ezequiel Garcia 2019-07-11 1764
298c62d3856111e Ezequiel Garcia 2019-07-11 1765 #define zero_padding(s) \
298c62d3856111e Ezequiel Garcia 2019-07-11 1766 memset(&(s).padding, 0, sizeof((s).padding))
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1767 #define zero_reserved(s) \
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1768 memset(&(s).reserved, 0, sizeof((s).reserved))
298c62d3856111e Ezequiel Garcia 2019-07-11 1769
1e42d384aa19e06 Paul Kocialkowski 2019-07-25 1770 /*
1e42d384aa19e06 Paul Kocialkowski 2019-07-25 1771 * Compound controls validation requires setting unused fields/flags to zero
1e42d384aa19e06 Paul Kocialkowski 2019-07-25 1772 * in order to properly detect unchanged controls with std_equal's memcmp.
1e42d384aa19e06 Paul Kocialkowski 2019-07-25 1773 */
de8145452eebe55 Ezequiel Garcia 2019-07-11 1774 static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
0176077a813933a Hans Verkuil 2014-04-27 1775 union v4l2_ctrl_ptr ptr)
0176077a813933a Hans Verkuil 2014-04-27 1776 {
0e380411d9f043f Ezequiel Garcia 2020-11-05 1777 struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence;
0e380411d9f043f Ezequiel Garcia 2020-11-05 1778 struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture;
c27bb30e7b6d385 Paul Kocialkowski 2018-09-13 1779 struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
298c62d3856111e Ezequiel Garcia 2019-07-11 1780 struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header;
d9358563179a7f0 Ezequiel Garcia 2020-08-25 1781 struct v4l2_ctrl_h264_slice_params *p_h264_slice_params;
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1782 struct v4l2_ctrl_h264_decode_params *p_h264_dec_params;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1783 struct v4l2_ctrl_hevc_sps *p_hevc_sps;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1784 struct v4l2_ctrl_hevc_pps *p_hevc_pps;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1785 struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
d1dc49370f8371b Ricardo Ribalda 2019-10-07 1786 struct v4l2_area *area;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1787 void *p = ptr.p + idx * ctrl->elem_size;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1788 unsigned int i;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1789
de8145452eebe55 Ezequiel Garcia 2019-07-11 1790 switch ((u32)ctrl->type) {
0e380411d9f043f Ezequiel Garcia 2020-11-05 1791 case V4L2_CTRL_TYPE_MPEG2_SEQUENCE:
0e380411d9f043f Ezequiel Garcia 2020-11-05 1792 p_mpeg2_sequence = p;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1793
0e380411d9f043f Ezequiel Garcia 2020-11-05 1794 switch (p_mpeg2_sequence->chroma_format) {
de8145452eebe55 Ezequiel Garcia 2019-07-11 1795 case 1: /* 4:2:0 */
de8145452eebe55 Ezequiel Garcia 2019-07-11 1796 case 2: /* 4:2:2 */
de8145452eebe55 Ezequiel Garcia 2019-07-11 1797 case 3: /* 4:4:4 */
de8145452eebe55 Ezequiel Garcia 2019-07-11 1798 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1799 default:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1800 return -EINVAL;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1801 }
0e380411d9f043f Ezequiel Garcia 2020-11-05 1802 zero_reserved(*p_mpeg2_sequence);
0e380411d9f043f Ezequiel Garcia 2020-11-05 1803 break;
0e380411d9f043f Ezequiel Garcia 2020-11-05 1804
0e380411d9f043f Ezequiel Garcia 2020-11-05 1805 case V4L2_CTRL_TYPE_MPEG2_PICTURE:
0e380411d9f043f Ezequiel Garcia 2020-11-05 1806 p_mpeg2_picture = p;
0e380411d9f043f Ezequiel Garcia 2020-11-05 1807 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1808
0e380411d9f043f Ezequiel Garcia 2020-11-05 @1809 switch (p_mpeg2_picture->intra_dc_precision) {
de8145452eebe55 Ezequiel Garcia 2019-07-11 1810 case 0: /* 8 bits */
de8145452eebe55 Ezequiel Garcia 2019-07-11 1811 case 1: /* 9 bits */
de8145452eebe55 Ezequiel Garcia 2019-07-11 1812 case 2: /* 10 bits */
de8145452eebe55 Ezequiel Garcia 2019-07-11 1813 case 3: /* 11 bits */
de8145452eebe55 Ezequiel Garcia 2019-07-11 1814 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1815 default:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1816 return -EINVAL;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1817 }
0e380411d9f043f Ezequiel Garcia 2020-11-05 1818 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1819
0e380411d9f043f Ezequiel Garcia 2020-11-05 1820 switch (p_mpeg2_picture->picture_structure) {
033e35dd65bee81 Ezequiel Garcia 2020-11-05 1821 case V4L2_MPEG2_PIC_TOP_FIELD:
033e35dd65bee81 Ezequiel Garcia 2020-11-05 1822 case V4L2_MPEG2_PIC_BOTTOM_FIELD:
033e35dd65bee81 Ezequiel Garcia 2020-11-05 1823 case V4L2_MPEG2_PIC_FRAME:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1824 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1825 default:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1826 return -EINVAL;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1827 }
de8145452eebe55 Ezequiel Garcia 2019-07-11 1828
0e380411d9f043f Ezequiel Garcia 2020-11-05 1829 switch (p_mpeg2_picture->picture_coding_type) {
033e35dd65bee81 Ezequiel Garcia 2020-11-05 1830 case V4L2_MPEG2_PIC_CODING_TYPE_I:
033e35dd65bee81 Ezequiel Garcia 2020-11-05 1831 case V4L2_MPEG2_PIC_CODING_TYPE_P:
033e35dd65bee81 Ezequiel Garcia 2020-11-05 1832 case V4L2_MPEG2_PIC_CODING_TYPE_B:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1833 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1834 default:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1835 return -EINVAL;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1836 }
0e380411d9f043f Ezequiel Garcia 2020-11-05 1837 zero_reserved(*p_mpeg2_picture);
0e380411d9f043f Ezequiel Garcia 2020-11-05 1838 break;
0e380411d9f043f Ezequiel Garcia 2020-11-05 1839
0e380411d9f043f Ezequiel Garcia 2020-11-05 1840 case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS:
0e380411d9f043f Ezequiel Garcia 2020-11-05 1841 p_mpeg2_slice_params = p;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1842
0e380411d9f043f Ezequiel Garcia 2020-11-05 1843 zero_reserved(*p_mpeg2_slice_params);
de8145452eebe55 Ezequiel Garcia 2019-07-11 1844 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1845
de8145452eebe55 Ezequiel Garcia 2019-07-11 1846 case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1847 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1848
de8145452eebe55 Ezequiel Garcia 2019-07-11 1849 case V4L2_CTRL_TYPE_FWHT_PARAMS:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1850 break;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1851
de8145452eebe55 Ezequiel Garcia 2019-07-11 1852 case V4L2_CTRL_TYPE_H264_SPS:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1853 case V4L2_CTRL_TYPE_H264_PPS:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1854 case V4L2_CTRL_TYPE_H264_SCALING_MATRIX:
eb44c6c9c236b15 Ezequiel Garcia 2020-08-25 1855 case V4L2_CTRL_TYPE_H264_PRED_WEIGHTS:
d9358563179a7f0 Ezequiel Garcia 2020-08-25 1856 break;
d9358563179a7f0 Ezequiel Garcia 2020-08-25 1857
de8145452eebe55 Ezequiel Garcia 2019-07-11 1858 case V4L2_CTRL_TYPE_H264_SLICE_PARAMS:
d9358563179a7f0 Ezequiel Garcia 2020-08-25 1859 p_h264_slice_params = p;
d9358563179a7f0 Ezequiel Garcia 2020-08-25 1860
d9358563179a7f0 Ezequiel Garcia 2020-08-25 1861 zero_reserved(*p_h264_slice_params);
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1862 break;
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1863
de8145452eebe55 Ezequiel Garcia 2019-07-11 1864 case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1865 p_h264_dec_params = p;
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1866
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1867 for (i = 0; i < V4L2_H264_NUM_DPB_ENTRIES; i++) {
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1868 struct v4l2_h264_dpb_entry *dpb_entry =
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1869 &p_h264_dec_params->dpb[i];
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1870
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1871 zero_reserved(*dpb_entry);
f9879eb378295e8 Ezequiel Garcia 2020-08-25 1872 }
d9358563179a7f0 Ezequiel Garcia 2020-08-25 1873 zero_reserved(*p_h264_dec_params);
de8145452eebe55 Ezequiel Garcia 2019-07-11 1874 break;
a57d6acaf352d91 Pawel Osciak 2019-07-11 1875
a57d6acaf352d91 Pawel Osciak 2019-07-11 1876 case V4L2_CTRL_TYPE_VP8_FRAME_HEADER:
298c62d3856111e Ezequiel Garcia 2019-07-11 1877 p_vp8_frame_header = p;
298c62d3856111e Ezequiel Garcia 2019-07-11 1878
298c62d3856111e Ezequiel Garcia 2019-07-11 1879 switch (p_vp8_frame_header->num_dct_parts) {
298c62d3856111e Ezequiel Garcia 2019-07-11 1880 case 1:
298c62d3856111e Ezequiel Garcia 2019-07-11 1881 case 2:
298c62d3856111e Ezequiel Garcia 2019-07-11 1882 case 4:
298c62d3856111e Ezequiel Garcia 2019-07-11 1883 case 8:
298c62d3856111e Ezequiel Garcia 2019-07-11 1884 break;
298c62d3856111e Ezequiel Garcia 2019-07-11 1885 default:
298c62d3856111e Ezequiel Garcia 2019-07-11 1886 return -EINVAL;
298c62d3856111e Ezequiel Garcia 2019-07-11 1887 }
298c62d3856111e Ezequiel Garcia 2019-07-11 1888 zero_padding(p_vp8_frame_header->segment_header);
298c62d3856111e Ezequiel Garcia 2019-07-11 1889 zero_padding(p_vp8_frame_header->lf_header);
298c62d3856111e Ezequiel Garcia 2019-07-11 1890 zero_padding(p_vp8_frame_header->quant_header);
298c62d3856111e Ezequiel Garcia 2019-07-11 1891 zero_padding(p_vp8_frame_header->entropy_header);
298c62d3856111e Ezequiel Garcia 2019-07-11 1892 zero_padding(p_vp8_frame_header->coder_state);
a57d6acaf352d91 Pawel Osciak 2019-07-11 1893 break;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1894
256fa3920874b0f Paul Kocialkowski 2019-10-22 1895 case V4L2_CTRL_TYPE_HEVC_SPS:
256fa3920874b0f Paul Kocialkowski 2019-10-22 1896 p_hevc_sps = p;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1897
256fa3920874b0f Paul Kocialkowski 2019-10-22 1898 if (!(p_hevc_sps->flags & V4L2_HEVC_SPS_FLAG_PCM_ENABLED)) {
256fa3920874b0f Paul Kocialkowski 2019-10-22 1899 p_hevc_sps->pcm_sample_bit_depth_luma_minus1 = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1900 p_hevc_sps->pcm_sample_bit_depth_chroma_minus1 = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1901 p_hevc_sps->log2_min_pcm_luma_coding_block_size_minus3 = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1902 p_hevc_sps->log2_diff_max_min_pcm_luma_coding_block_size = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1903 }
256fa3920874b0f Paul Kocialkowski 2019-10-22 1904
256fa3920874b0f Paul Kocialkowski 2019-10-22 1905 if (!(p_hevc_sps->flags &
256fa3920874b0f Paul Kocialkowski 2019-10-22 1906 V4L2_HEVC_SPS_FLAG_LONG_TERM_REF_PICS_PRESENT))
256fa3920874b0f Paul Kocialkowski 2019-10-22 1907 p_hevc_sps->num_long_term_ref_pics_sps = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1908 break;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1909
256fa3920874b0f Paul Kocialkowski 2019-10-22 1910 case V4L2_CTRL_TYPE_HEVC_PPS:
256fa3920874b0f Paul Kocialkowski 2019-10-22 1911 p_hevc_pps = p;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1912
256fa3920874b0f Paul Kocialkowski 2019-10-22 1913 if (!(p_hevc_pps->flags &
256fa3920874b0f Paul Kocialkowski 2019-10-22 1914 V4L2_HEVC_PPS_FLAG_CU_QP_DELTA_ENABLED))
256fa3920874b0f Paul Kocialkowski 2019-10-22 1915 p_hevc_pps->diff_cu_qp_delta_depth = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1916
256fa3920874b0f Paul Kocialkowski 2019-10-22 1917 if (!(p_hevc_pps->flags & V4L2_HEVC_PPS_FLAG_TILES_ENABLED)) {
256fa3920874b0f Paul Kocialkowski 2019-10-22 1918 p_hevc_pps->num_tile_columns_minus1 = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1919 p_hevc_pps->num_tile_rows_minus1 = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1920 memset(&p_hevc_pps->column_width_minus1, 0,
256fa3920874b0f Paul Kocialkowski 2019-10-22 1921 sizeof(p_hevc_pps->column_width_minus1));
256fa3920874b0f Paul Kocialkowski 2019-10-22 1922 memset(&p_hevc_pps->row_height_minus1, 0,
256fa3920874b0f Paul Kocialkowski 2019-10-22 1923 sizeof(p_hevc_pps->row_height_minus1));
256fa3920874b0f Paul Kocialkowski 2019-10-22 1924
256fa3920874b0f Paul Kocialkowski 2019-10-22 1925 p_hevc_pps->flags &=
88441917dc6cd99 Jonas Karlman 2020-05-27 1926 ~V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1927 }
256fa3920874b0f Paul Kocialkowski 2019-10-22 1928
256fa3920874b0f Paul Kocialkowski 2019-10-22 1929 if (p_hevc_pps->flags &
256fa3920874b0f Paul Kocialkowski 2019-10-22 1930 V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER) {
256fa3920874b0f Paul Kocialkowski 2019-10-22 1931 p_hevc_pps->pps_beta_offset_div2 = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1932 p_hevc_pps->pps_tc_offset_div2 = 0;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1933 }
256fa3920874b0f Paul Kocialkowski 2019-10-22 1934
256fa3920874b0f Paul Kocialkowski 2019-10-22 1935 zero_padding(*p_hevc_pps);
256fa3920874b0f Paul Kocialkowski 2019-10-22 1936 break;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1937
256fa3920874b0f Paul Kocialkowski 2019-10-22 1938 case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
256fa3920874b0f Paul Kocialkowski 2019-10-22 1939 p_hevc_slice_params = p;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1940
256fa3920874b0f Paul Kocialkowski 2019-10-22 1941 if (p_hevc_slice_params->num_active_dpb_entries >
256fa3920874b0f Paul Kocialkowski 2019-10-22 1942 V4L2_HEVC_DPB_ENTRIES_NUM_MAX)
256fa3920874b0f Paul Kocialkowski 2019-10-22 1943 return -EINVAL;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1944
256fa3920874b0f Paul Kocialkowski 2019-10-22 1945 zero_padding(p_hevc_slice_params->pred_weight_table);
256fa3920874b0f Paul Kocialkowski 2019-10-22 1946
256fa3920874b0f Paul Kocialkowski 2019-10-22 1947 for (i = 0; i < p_hevc_slice_params->num_active_dpb_entries;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1948 i++) {
256fa3920874b0f Paul Kocialkowski 2019-10-22 1949 struct v4l2_hevc_dpb_entry *dpb_entry =
256fa3920874b0f Paul Kocialkowski 2019-10-22 1950 &p_hevc_slice_params->dpb[i];
256fa3920874b0f Paul Kocialkowski 2019-10-22 1951
256fa3920874b0f Paul Kocialkowski 2019-10-22 1952 zero_padding(*dpb_entry);
256fa3920874b0f Paul Kocialkowski 2019-10-22 1953 }
256fa3920874b0f Paul Kocialkowski 2019-10-22 1954
256fa3920874b0f Paul Kocialkowski 2019-10-22 1955 zero_padding(*p_hevc_slice_params);
256fa3920874b0f Paul Kocialkowski 2019-10-22 1956 break;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1957
d1dc49370f8371b Ricardo Ribalda 2019-10-07 1958 case V4L2_CTRL_TYPE_AREA:
d1dc49370f8371b Ricardo Ribalda 2019-10-07 1959 area = p;
d1dc49370f8371b Ricardo Ribalda 2019-10-07 1960 if (!area->width || !area->height)
d1dc49370f8371b Ricardo Ribalda 2019-10-07 1961 return -EINVAL;
d1dc49370f8371b Ricardo Ribalda 2019-10-07 1962 break;
256fa3920874b0f Paul Kocialkowski 2019-10-22 1963
de8145452eebe55 Ezequiel Garcia 2019-07-11 1964 default:
de8145452eebe55 Ezequiel Garcia 2019-07-11 1965 return -EINVAL;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1966 }
de8145452eebe55 Ezequiel Garcia 2019-07-11 1967
de8145452eebe55 Ezequiel Garcia 2019-07-11 1968 return 0;
de8145452eebe55 Ezequiel Garcia 2019-07-11 1969 }
de8145452eebe55 Ezequiel Garcia 2019-07-11 1970
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 31910 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 0/3] MPEG-2 stateless API cleanup @ 2020-11-05 20:51 Ezequiel Garcia 2020-11-05 20:51 ` [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters Ezequiel Garcia 0 siblings, 1 reply; 7+ messages in thread From: Ezequiel Garcia @ 2020-11-05 20:51 UTC (permalink / raw) To: linux-media, linux-kernel Cc: kernel, Jonas Karlman, Hans Verkuil, Nicolas Dufresne, Philipp Zabel, Maxime Ripard, Paul Kocialkowski, Jernej Skrabec, Ezequiel Garcia Hello everyone, Following the H.264 API cleanup, and with all the lessons learned from it, here's a revisit on the MPEG-2 API. The biggest changes are: * Drop slice size and offset parameters, given the API doesn't seem to be designed to work per-slice. * Convert all the 1-bit syntax elements from structure fields to bits in a bit field flags field, following the other codec APIs. * Split the sequence, picture and slice headers to separate controls. This is build tested only, I haven't yet modified the existing Ffmpeg-based implementation, as I'd like to have some consensus first. Reviews and feedback are appreciated! v2: * Fixed bad use of boolean negation in a flag, which was fortunately reported by 0day bot. Thanks, Ezequiel Ezequiel Garcia (3): media: uapi: mpeg2: Cleanup flags media: uapi: mpeg2: Remove unused slice size and offset media: uapi: mpeg2: Split sequence and picture parameters .../media/v4l/ext-ctrls-codec.rst | 159 +++++++++++------- .../media/v4l/pixfmt-compressed.rst | 5 +- drivers/media/v4l2-core/v4l2-ctrls.c | 59 ++++--- drivers/staging/media/hantro/hantro_drv.c | 10 ++ .../media/hantro/hantro_g1_mpeg2_dec.c | 82 +++++---- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 82 +++++---- drivers/staging/media/sunxi/cedrus/cedrus.c | 14 ++ drivers/staging/media/sunxi/cedrus/cedrus.h | 2 + .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 49 +++--- include/media/mpeg2-ctrls.h | 153 +++++++++++++---- include/media/v4l2-ctrls.h | 4 + 11 files changed, 395 insertions(+), 224 deletions(-) -- 2.27.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters 2020-11-05 20:51 [PATCH v2 0/3] MPEG-2 stateless API cleanup Ezequiel Garcia @ 2020-11-05 20:51 ` Ezequiel Garcia 2020-11-10 18:56 ` Dan Carpenter 2020-11-29 22:59 ` Jonas Karlman 0 siblings, 2 replies; 7+ messages in thread From: Ezequiel Garcia @ 2020-11-05 20:51 UTC (permalink / raw) To: linux-media, linux-kernel Cc: kernel, Jonas Karlman, Hans Verkuil, Nicolas Dufresne, Philipp Zabel, Maxime Ripard, Paul Kocialkowski, Jernej Skrabec, Ezequiel Garcia Typically, bitstreams are composed of one sequence header NAL unit, followed by a number of picture header and picture coding extension NAL units. Each picture can be composed by a number of slices. Let's split the MPEG-2 uAPI to follow these semantics more closely, allowing more usage flexibility. Having these controls splitted allows applications to set a sequence control at the beginning of a sequence, and then set a picture control for each frame. While here add padding fields where needed, and document the uAPI header thoroughly. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> --- .../media/v4l/ext-ctrls-codec.rst | 47 ++++++-- .../media/v4l/pixfmt-compressed.rst | 5 +- drivers/media/v4l2-core/v4l2-ctrls.c | 45 +++++-- drivers/staging/media/hantro/hantro_drv.c | 10 ++ .../media/hantro/hantro_g1_mpeg2_dec.c | 14 ++- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 14 ++- drivers/staging/media/sunxi/cedrus/cedrus.c | 14 +++ drivers/staging/media/sunxi/cedrus/cedrus.h | 2 + .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 8 +- include/media/mpeg2-ctrls.h | 110 +++++++++++++++--- include/media/v4l2-ctrls.h | 4 + 11 files changed, 212 insertions(+), 61 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 4c32b93f41a6..d919cbc119bd 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -2218,14 +2218,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - :stub-columns: 0 :widths: 1 1 2 - * - struct :c:type:`v4l2_mpeg2_sequence` - - ``sequence`` - - Structure with MPEG-2 sequence metadata, merging relevant fields from - the sequence header and sequence extension parts of the bitstream. - * - struct :c:type:`v4l2_mpeg2_picture` - - ``picture`` - - Structure with MPEG-2 picture metadata, merging relevant fields from - the picture header and picture coding extension parts of the bitstream. * - __u64 - ``backward_ref_ts`` - Timestamp of the V4L2 capture buffer to use as backward reference, used @@ -2243,14 +2235,28 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - __u32 - ``quantiser_scale_code`` - Code used to determine the quantization scale to use for the IDCT. + * - __u8 + - ``reserved`` + - Applications and drivers must set this to zero. -.. c:type:: v4l2_mpeg2_sequence +``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (struct)`` + Specifies the sequence parameters (as extracted from the bitstream) for the + associated MPEG-2 slice data. This includes fields matching the syntax + elements from the sequence header and sequence extension parts of the + bitstream as specified by :ref:`mpeg2part2`. + + .. note:: + + This compound control is not yet part of the public kernel API and + it is expected to change. + +.. c:type:: v4l2_ctrl_mpeg2_sequence .. cssclass:: longtable .. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}| -.. flat-table:: struct v4l2_mpeg2_sequence +.. flat-table:: struct v4l2_ctrl_mpeg2_sequence :header-rows: 0 :stub-columns: 0 :widths: 1 1 2 @@ -2272,6 +2278,9 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - __u8 - ``chroma_format`` - The chrominance sub-sampling format (1: 4:2:0, 2: 4:2:2, 3: 4:4:4). + * - __u8 + - ``reserved`` + - Applications and drivers must set this to zero. * - __u32 - ``flags`` - See :ref:`MPEG-2 Sequence Flags <mpeg2_sequence_flags>`. @@ -2292,13 +2301,24 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - Indication that all the frames for the sequence are progressive instead of interlaced. -.. c:type:: v4l2_mpeg2_picture +``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (struct)`` + Specifies the picture parameters (as extracted from the bitstream) for the + associated MPEG-2 slice data. This includes fields matching the syntax + elements from the picture header and picture coding extension parts of the + bitstream as specified by :ref:`mpeg2part2`. + + .. note:: + + This compound control is not yet part of the public kernel API and + it is expected to change. + +.. c:type:: v4l2_ctrl_mpeg2_picture .. cssclass:: longtable .. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}| -.. flat-table:: struct v4l2_mpeg2_picture +.. flat-table:: struct v4l2_ctrl_mpeg2_picture :header-rows: 0 :stub-columns: 0 :widths: 1 1 2 @@ -2319,6 +2339,9 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - ``picture_structure`` - Picture structure (1: interlaced top field, 2: interlaced bottom field, 3: progressive frame). + * - __u8 + - ``reserved`` + - Applications and drivers must set this to zero. * - __u32 - ``flags`` - See :ref:`MPEG-2 Picture Flags <mpeg2_picture_flags>`. diff --git a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst index d585909bc4e2..1da4722bc8f3 100644 --- a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +++ b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst @@ -113,8 +113,9 @@ Compressed Formats This format is adapted for stateless video decoders that implement a MPEG-2 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`). Metadata associated with the frame to decode is required to be passed - through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` control and - quantization matrices can optionally be specified through the + through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE``, + ``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE``, and ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` + controls. Quantization matrices can optionally be specified through the ``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION`` control. See the :ref:`associated Codec Control IDs <v4l2-mpeg-mpeg2>`. Exactly one output and one capture buffer must be provided for use with diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index c24caffc956d..da50fb9edb96 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1620,7 +1620,8 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, union v4l2_ctrl_ptr ptr) { - struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; + struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; + struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; void *p = ptr.p + idx * ctrl->elem_size; if (ctrl->p_def.p_const) @@ -1634,13 +1635,18 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, * v4l2_ctrl_type enum. */ switch ((u32)ctrl->type) { - case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: - p_mpeg2_slice_params = p; + case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: + p_mpeg2_sequence = p; + /* 4:2:0 */ - p_mpeg2_slice_params->sequence.chroma_format = 1; + p_mpeg2_sequence->chroma_format = 1; + break; + case V4L2_CTRL_TYPE_MPEG2_PICTURE: + p_mpeg2_picture = p; + /* interlaced top field */ - p_mpeg2_slice_params->picture.picture_structure = 1; - p_mpeg2_slice_params->picture.picture_coding_type = + p_mpeg2_picture->picture_structure = 1; + p_mpeg2_picture->picture_coding_type = V4L2_MPEG2_PIC_CODING_TYPE_I; break; } @@ -1768,6 +1774,8 @@ static void std_log(const struct v4l2_ctrl *ctrl) static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, union v4l2_ctrl_ptr ptr) { + struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; + struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; @@ -1780,10 +1788,10 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, unsigned int i; switch ((u32)ctrl->type) { - case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: - p_mpeg2_slice_params = p; + case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: + p_mpeg2_sequence = p; - switch (p_mpeg2_slice_params->sequence.chroma_format) { + switch (p_mpeg2_sequence->chroma_format) { case 1: /* 4:2:0 */ case 2: /* 4:2:2 */ case 3: /* 4:4:4 */ @@ -1791,8 +1799,14 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, default: return -EINVAL; } + zero_reserved(*p_mpeg2_sequence); + break; + + case V4L2_CTRL_TYPE_MPEG2_PICTURE: + p_mpeg2_picture = p; + break; - switch (p_mpeg2_slice_params->picture.intra_dc_precision) { + switch (p_mpeg2_picture->intra_dc_precision) { case 0: /* 8 bits */ case 1: /* 9 bits */ case 2: /* 10 bits */ @@ -1801,8 +1815,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, default: return -EINVAL; } + break; - switch (p_mpeg2_slice_params->picture.picture_structure) { + switch (p_mpeg2_picture->picture_structure) { case V4L2_MPEG2_PIC_TOP_FIELD: case V4L2_MPEG2_PIC_BOTTOM_FIELD: case V4L2_MPEG2_PIC_FRAME: @@ -1811,7 +1826,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, return -EINVAL; } - switch (p_mpeg2_slice_params->picture.picture_coding_type) { + switch (p_mpeg2_picture->picture_coding_type) { case V4L2_MPEG2_PIC_CODING_TYPE_I: case V4L2_MPEG2_PIC_CODING_TYPE_P: case V4L2_MPEG2_PIC_CODING_TYPE_B: @@ -1819,7 +1834,13 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, default: return -EINVAL; } + zero_reserved(*p_mpeg2_picture); + break; + + case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: + p_mpeg2_slice_params = p; + zero_reserved(*p_mpeg2_slice_params); break; case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c index 3cd00cc0a364..68543a8836e4 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -286,6 +286,16 @@ static const struct hantro_ctrl controls[] = { .def = 50, .ops = &hantro_jpeg_ctrl_ops, }, + }, { + .codec = HANTRO_MPEG2_DECODER, + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE, + }, + }, { + .codec = HANTRO_MPEG2_DECODER, + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, + }, }, { .codec = HANTRO_MPEG2_DECODER, .cfg = { diff --git a/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c b/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c index b6086474d31f..1a6ca49441f4 100644 --- a/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c @@ -95,8 +95,8 @@ static void hantro_g1_mpeg2_dec_set_buffers(struct hantro_dev *vpu, struct hantro_ctx *ctx, struct vb2_buffer *src_buf, struct vb2_buffer *dst_buf, - const struct v4l2_mpeg2_sequence *seq, - const struct v4l2_mpeg2_picture *pic, + const struct v4l2_ctrl_mpeg2_sequence *seq, + const struct v4l2_ctrl_mpeg2_picture *pic, const struct v4l2_ctrl_mpeg2_slice_params *slice_params) { dma_addr_t forward_addr = 0, backward_addr = 0; @@ -156,8 +156,8 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) struct hantro_dev *vpu = ctx->dev; struct vb2_v4l2_buffer *src_buf, *dst_buf; const struct v4l2_ctrl_mpeg2_slice_params *slice_params; - const struct v4l2_mpeg2_sequence *seq; - const struct v4l2_mpeg2_picture *pic; + const struct v4l2_ctrl_mpeg2_sequence *seq; + const struct v4l2_ctrl_mpeg2_picture *pic; u32 reg; src_buf = hantro_get_src_buf(ctx); @@ -168,8 +168,10 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) slice_params = hantro_get_ctrl(ctx, V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS); - seq = &slice_params->sequence; - pic = &slice_params->picture; + seq = hantro_get_ctrl(ctx, + V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE); + pic = hantro_get_ctrl(ctx, + V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE); reg = G1_REG_DEC_AXI_RD_ID(0) | G1_REG_DEC_TIMEOUT_E(1) | diff --git a/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c b/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c index 28eb77b0569b..45ab5ca32221 100644 --- a/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +++ b/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c @@ -97,8 +97,8 @@ rk3399_vpu_mpeg2_dec_set_buffers(struct hantro_dev *vpu, struct hantro_ctx *ctx, struct vb2_buffer *src_buf, struct vb2_buffer *dst_buf, - const struct v4l2_mpeg2_sequence *seq, - const struct v4l2_mpeg2_picture *pic, + const struct v4l2_ctrl_mpeg2_sequence *seq, + const struct v4l2_ctrl_mpeg2_picture *pic, const struct v4l2_ctrl_mpeg2_slice_params *slice_params) { dma_addr_t forward_addr = 0, backward_addr = 0; @@ -158,8 +158,8 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) struct hantro_dev *vpu = ctx->dev; struct vb2_v4l2_buffer *src_buf, *dst_buf; const struct v4l2_ctrl_mpeg2_slice_params *slice_params; - const struct v4l2_mpeg2_sequence *seq; - const struct v4l2_mpeg2_picture *pic; + const struct v4l2_ctrl_mpeg2_sequence *seq; + const struct v4l2_ctrl_mpeg2_picture *pic; u32 reg; src_buf = hantro_get_src_buf(ctx); @@ -169,8 +169,10 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) slice_params = hantro_get_ctrl(ctx, V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS); - seq = &slice_params->sequence; - pic = &slice_params->picture; + seq = hantro_get_ctrl(ctx, + V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE); + pic = hantro_get_ctrl(ctx, + V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE); reg = VDPU_REG_DEC_ADV_PRE_DIS(0) | VDPU_REG_DEC_SCMD_DIS(0) | diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 9a102b7c1bb9..5b464703cb27 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -29,6 +29,20 @@ #include "cedrus_hw.h" static const struct cedrus_control cedrus_controls[] = { + { + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE, + }, + .codec = CEDRUS_CODEC_MPEG2, + .required = true, + }, + { + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, + }, + .codec = CEDRUS_CODEC_MPEG2, + .required = true, + }, { .cfg = { .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 93c843ae14bb..c27d9b159c26 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -66,6 +66,8 @@ struct cedrus_h264_run { }; struct cedrus_mpeg2_run { + const struct v4l2_ctrl_mpeg2_sequence *sequence; + const struct v4l2_ctrl_mpeg2_picture *picture; const struct v4l2_ctrl_mpeg2_slice_params *slice_params; const struct v4l2_ctrl_mpeg2_quantization *quantization; }; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c index 6a99893cdc77..ea52778b36f9 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c @@ -75,8 +75,8 @@ static void cedrus_mpeg2_irq_disable(struct cedrus_ctx *ctx) static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) { const struct v4l2_ctrl_mpeg2_slice_params *slice_params; - const struct v4l2_mpeg2_sequence *seq; - const struct v4l2_mpeg2_picture *pic; + const struct v4l2_ctrl_mpeg2_sequence *seq; + const struct v4l2_ctrl_mpeg2_picture *pic; const struct v4l2_ctrl_mpeg2_quantization *quantization; dma_addr_t src_buf_addr, dst_luma_addr, dst_chroma_addr; dma_addr_t fwd_luma_addr, fwd_chroma_addr; @@ -90,8 +90,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) u32 reg; slice_params = run->mpeg2.slice_params; - seq = &slice_params->sequence; - pic = &slice_params->picture; + seq = run->mpeg2.sequence; + pic = run->mpeg2.picture; quantization = run->mpeg2.quantization; diff --git a/include/media/mpeg2-ctrls.h b/include/media/mpeg2-ctrls.h index 5b0c916a44dd..cd8f0cea5665 100644 --- a/include/media/mpeg2-ctrls.h +++ b/include/media/mpeg2-ctrls.h @@ -12,24 +12,46 @@ #define _MPEG2_CTRLS_H_ #define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_MPEG_BASE+250) -#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+251) +#define V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (V4L2_CID_MPEG_BASE+251) +#define V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (V4L2_CID_MPEG_BASE+252) +#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+253) /* enum v4l2_ctrl_type type values */ -#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0103 -#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0104 +#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0130 +#define V4L2_CTRL_TYPE_MPEG2_SEQUENCE 0x0131 +#define V4L2_CTRL_TYPE_MPEG2_PICTURE 0x0132 +#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0133 #define V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE 0x0001 -struct v4l2_mpeg2_sequence { - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */ +/** + * struct v4l2_ctrl_mpeg2_sequence - MPEG-2 sequence header + * + * All the members on this structure match the sequence header and sequence + * extension syntaxes as specified by the MPEG-2 specification. + * + * Fields horizontal_size, vertical_size and vbv_buffer_size are a + * combination of respective _value and extension syntax elements, + * as described in section 6.3.3 "Sequence header". + * + * @horizontal_size: combination of elements horizontal_size_value and + * horizontal_size_extension. + * @vertical_size: combination of elements vertical_size_value and + * vertical_size_extension. + * @vbv_buffer_size: combination of elements vbv_buffer_size_value and + * vbv_buffer_size_extension. + * @profile_and_level_indication: see MPEG-2 specification. + * @chroma_format: see MPEG-2 specification. + * @reserved: padding field. Should be zeroed by applications. + * @flags: see V4L2_MPEG2_SEQ_FLAG_{}. + */ +struct v4l2_ctrl_mpeg2_sequence { __u16 horizontal_size; __u16 vertical_size; __u32 vbv_buffer_size; - - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */ __u16 profile_and_level_indication; __u8 chroma_format; - + __u8 reserved; __u32 flags; }; @@ -55,30 +77,80 @@ struct v4l2_mpeg2_sequence { #define V4L2_MPEG2_PIC_FLAG_LOAD_CHROMA_INTRA 0x0400 #define V4L2_MPEG2_PIC_FLAG_LOAD_CHROMA_NON_INTRA 0x0800 -struct v4l2_mpeg2_picture { - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */ +/** + * struct v4l2_ctrl_mpeg2_picture - MPEG-2 picture header + * + * All the members on this structure match the picture header and picture + * coding extension syntaxes as specified by the MPEG-2 specification. + * + * In particular, the set of quantization load flags V4L2_MPEG2_PIC_FLAG_LOAD_{} + * are specified here in order to allow applications to pass non-default + * quantization matrices. In this case, applications are expected to use + * V4L2_CTRL_TYPE_MPEG2_QUANTIZATION to pass the values of non-default + * matrices. + * + * @picture_coding_type: see MPEG-2 specification. + * @f_code[2][2]: see MPEG-2 specification. + * @intra_dc_precision: see MPEG-2 specification. + * @picture_structure: see V4L2_MPEG2_PIC_{}_FIELD. + * @reserved: padding field. Should be zeroed by applications. + * @flags: see V4L2_MPEG2_PIC_FLAG_{}. + */ +struct v4l2_ctrl_mpeg2_picture { __u8 picture_coding_type; - - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture coding extension */ __u8 f_code[2][2]; __u8 intra_dc_precision; __u8 picture_structure; - + __u8 reserved; __u32 flags; }; +/** + * struct v4l2_ctrl_mpeg2_slice_params - MPEG-2 slice header + * + * @backward_ref_ts: timestamp of the V4L2 capture buffer to use as + * reference for backward prediction. + * @forward_ref_ts: timestamp of the V4L2 capture buffer to use as + * reference for forward prediction. These timestamp refers to the + * timestamp field in struct v4l2_buffer. Use v4l2_timeval_to_ns() + * to convert the struct timeval to a __u64. + * @quantiser_scale_code: quantiser scale integer matching an + * homonymous syntax element. + * @reserved: padding field. Should be zeroed by applications. + */ struct v4l2_ctrl_mpeg2_slice_params { __u64 backward_ref_ts; __u64 forward_ref_ts; - - struct v4l2_mpeg2_sequence sequence; - struct v4l2_mpeg2_picture picture; - - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */ __u32 quantiser_scale_code; + __u32 reserved; }; -/* ISO/IEC 13818-2, ITU-T Rec. H.262: Quant matrix extension */ +/** + * struct v4l2_ctrl_mpeg2_quantization - MPEG-2 quantization + * + * Quantization matrices as specified by section 6.3.7 + * "Quant matrix extension". + * + * Applications are expected to set the quantization matrices load + * flags V4L2_MPEG2_PIC_FLAG_LOAD_{} in struct v4l2_ctrl_mpeg2_picture + * to tell the kernel that a non-default matrix shall be used + * to decode the picture. + * + * @intra_quantiser_matrix: The quantization matrix coefficients + * for intra-coded frames, in zigzag scanning order. It is relevant + * for both luma and chroma components, although it can be superseded + * by the chroma-specific matrix for non-4:2:0 YUV formats. + * @non_intra_quantiser_matrix: The quantization matrix coefficients + * for non-intra-coded frames, in zigzag scanning order. It is relevant + * for both luma and chroma components, although it can be superseded + * by the chroma-specific matrix for non-4:2:0 YUV formats. + * @chroma_intra_quantiser_matrix: The quantization matrix coefficients + * for the chominance component of intra-coded frames, in zigzag scanning + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. + * @chroma_non_intra_quantiser_matrix: The quantization matrix coefficients + * for the chrominance component of non-intra-coded frames, in zigzag scanning + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. + */ struct v4l2_ctrl_mpeg2_quantization { __u8 intra_quantiser_matrix[64]; __u8 non_intra_quantiser_matrix[64]; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index cb25f345e9ad..92f4b508f5de 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -43,6 +43,8 @@ struct video_device; * @p_u16: Pointer to a 16-bit unsigned value. * @p_u32: Pointer to a 32-bit unsigned value. * @p_char: Pointer to a string. + * @p_mpeg2_sequence: Pointer to a MPEG2 sequence structure. + * @p_mpeg2_picture: Pointer to a MPEG2 picture structure. * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure. * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure. * @p_fwht_params: Pointer to a FWHT stateless parameters structure. @@ -67,6 +69,8 @@ union v4l2_ctrl_ptr { u16 *p_u16; u32 *p_u32; char *p_char; + struct v4l2_ctrl_mpeg2_sequence *p_sequence; + struct v4l2_ctrl_mpeg2_picture *p_picture; struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization; struct v4l2_ctrl_fwht_params *p_fwht_params; -- 2.27.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters 2020-11-05 20:51 ` [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters Ezequiel Garcia 2020-11-10 18:56 ` Dan Carpenter @ 2020-11-10 18:56 ` Dan Carpenter 1 sibling, 0 replies; 7+ messages in thread From: Dan Carpenter @ 2020-11-10 18:56 UTC (permalink / raw) To: kbuild [-- Attachment #1: Type: text/plain, Size: 4477 bytes --] Hi Ezequiel, url: https://github.com/0day-ci/linux/commits/Ezequiel-Garcia/MPEG-2-stateless-API-cleanup/20201106-045304 base: git://linuxtv.org/media_tree.git master config: i386-randconfig-m021-20201110 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> smatch warnings: drivers/media/v4l2-core/v4l2-ctrls.c:1809 std_validate_compound() warn: ignoring unreachable code. vim +1809 drivers/media/v4l2-core/v4l2-ctrls.c de8145452eebe55 Ezequiel Garcia 2019-07-11 1774 static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, 0176077a813933a Hans Verkuil 2014-04-27 1775 union v4l2_ctrl_ptr ptr) 0176077a813933a Hans Verkuil 2014-04-27 1776 { 0e380411d9f043f Ezequiel Garcia 2020-11-05 1777 struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1778 struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; c27bb30e7b6d385 Paul Kocialkowski 2018-09-13 1779 struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; 298c62d3856111e Ezequiel Garcia 2019-07-11 1780 struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; d9358563179a7f0 Ezequiel Garcia 2020-08-25 1781 struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; f9879eb378295e8 Ezequiel Garcia 2020-08-25 1782 struct v4l2_ctrl_h264_decode_params *p_h264_dec_params; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1783 struct v4l2_ctrl_hevc_sps *p_hevc_sps; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1784 struct v4l2_ctrl_hevc_pps *p_hevc_pps; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1785 struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; d1dc49370f8371b Ricardo Ribalda 2019-10-07 1786 struct v4l2_area *area; de8145452eebe55 Ezequiel Garcia 2019-07-11 1787 void *p = ptr.p + idx * ctrl->elem_size; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1788 unsigned int i; de8145452eebe55 Ezequiel Garcia 2019-07-11 1789 de8145452eebe55 Ezequiel Garcia 2019-07-11 1790 switch ((u32)ctrl->type) { 0e380411d9f043f Ezequiel Garcia 2020-11-05 1791 case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: 0e380411d9f043f Ezequiel Garcia 2020-11-05 1792 p_mpeg2_sequence = p; de8145452eebe55 Ezequiel Garcia 2019-07-11 1793 0e380411d9f043f Ezequiel Garcia 2020-11-05 1794 switch (p_mpeg2_sequence->chroma_format) { de8145452eebe55 Ezequiel Garcia 2019-07-11 1795 case 1: /* 4:2:0 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1796 case 2: /* 4:2:2 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1797 case 3: /* 4:4:4 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1798 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1799 default: de8145452eebe55 Ezequiel Garcia 2019-07-11 1800 return -EINVAL; de8145452eebe55 Ezequiel Garcia 2019-07-11 1801 } 0e380411d9f043f Ezequiel Garcia 2020-11-05 1802 zero_reserved(*p_mpeg2_sequence); 0e380411d9f043f Ezequiel Garcia 2020-11-05 1803 break; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1804 0e380411d9f043f Ezequiel Garcia 2020-11-05 1805 case V4L2_CTRL_TYPE_MPEG2_PICTURE: 0e380411d9f043f Ezequiel Garcia 2020-11-05 1806 p_mpeg2_picture = p; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1807 break; ^^^^^^ de8145452eebe55 Ezequiel Garcia 2019-07-11 1808 0e380411d9f043f Ezequiel Garcia 2020-11-05 @1809 switch (p_mpeg2_picture->intra_dc_precision) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unreachable. de8145452eebe55 Ezequiel Garcia 2019-07-11 1810 case 0: /* 8 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1811 case 1: /* 9 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1812 case 2: /* 10 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1813 case 3: /* 11 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1814 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1815 default: de8145452eebe55 Ezequiel Garcia 2019-07-11 1816 return -EINVAL; de8145452eebe55 Ezequiel Garcia 2019-07-11 1817 } 0e380411d9f043f Ezequiel Garcia 2020-11-05 1818 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1819 [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 31910 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters @ 2020-11-10 18:56 ` Dan Carpenter 0 siblings, 0 replies; 7+ messages in thread From: Dan Carpenter @ 2020-11-10 18:56 UTC (permalink / raw) To: kbuild, Ezequiel Garcia, linux-media, linux-kernel Cc: lkp, kbuild-all, kernel, Jonas Karlman, Hans Verkuil, Nicolas Dufresne, Philipp Zabel, Maxime Ripard, Paul Kocialkowski, Jernej Skrabec [-- Attachment #1: Type: text/plain, Size: 4409 bytes --] Hi Ezequiel, url: https://github.com/0day-ci/linux/commits/Ezequiel-Garcia/MPEG-2-stateless-API-cleanup/20201106-045304 base: git://linuxtv.org/media_tree.git master config: i386-randconfig-m021-20201110 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> smatch warnings: drivers/media/v4l2-core/v4l2-ctrls.c:1809 std_validate_compound() warn: ignoring unreachable code. vim +1809 drivers/media/v4l2-core/v4l2-ctrls.c de8145452eebe55 Ezequiel Garcia 2019-07-11 1774 static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, 0176077a813933a Hans Verkuil 2014-04-27 1775 union v4l2_ctrl_ptr ptr) 0176077a813933a Hans Verkuil 2014-04-27 1776 { 0e380411d9f043f Ezequiel Garcia 2020-11-05 1777 struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1778 struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; c27bb30e7b6d385 Paul Kocialkowski 2018-09-13 1779 struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; 298c62d3856111e Ezequiel Garcia 2019-07-11 1780 struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; d9358563179a7f0 Ezequiel Garcia 2020-08-25 1781 struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; f9879eb378295e8 Ezequiel Garcia 2020-08-25 1782 struct v4l2_ctrl_h264_decode_params *p_h264_dec_params; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1783 struct v4l2_ctrl_hevc_sps *p_hevc_sps; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1784 struct v4l2_ctrl_hevc_pps *p_hevc_pps; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1785 struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; d1dc49370f8371b Ricardo Ribalda 2019-10-07 1786 struct v4l2_area *area; de8145452eebe55 Ezequiel Garcia 2019-07-11 1787 void *p = ptr.p + idx * ctrl->elem_size; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1788 unsigned int i; de8145452eebe55 Ezequiel Garcia 2019-07-11 1789 de8145452eebe55 Ezequiel Garcia 2019-07-11 1790 switch ((u32)ctrl->type) { 0e380411d9f043f Ezequiel Garcia 2020-11-05 1791 case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: 0e380411d9f043f Ezequiel Garcia 2020-11-05 1792 p_mpeg2_sequence = p; de8145452eebe55 Ezequiel Garcia 2019-07-11 1793 0e380411d9f043f Ezequiel Garcia 2020-11-05 1794 switch (p_mpeg2_sequence->chroma_format) { de8145452eebe55 Ezequiel Garcia 2019-07-11 1795 case 1: /* 4:2:0 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1796 case 2: /* 4:2:2 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1797 case 3: /* 4:4:4 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1798 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1799 default: de8145452eebe55 Ezequiel Garcia 2019-07-11 1800 return -EINVAL; de8145452eebe55 Ezequiel Garcia 2019-07-11 1801 } 0e380411d9f043f Ezequiel Garcia 2020-11-05 1802 zero_reserved(*p_mpeg2_sequence); 0e380411d9f043f Ezequiel Garcia 2020-11-05 1803 break; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1804 0e380411d9f043f Ezequiel Garcia 2020-11-05 1805 case V4L2_CTRL_TYPE_MPEG2_PICTURE: 0e380411d9f043f Ezequiel Garcia 2020-11-05 1806 p_mpeg2_picture = p; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1807 break; ^^^^^^ de8145452eebe55 Ezequiel Garcia 2019-07-11 1808 0e380411d9f043f Ezequiel Garcia 2020-11-05 @1809 switch (p_mpeg2_picture->intra_dc_precision) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unreachable. de8145452eebe55 Ezequiel Garcia 2019-07-11 1810 case 0: /* 8 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1811 case 1: /* 9 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1812 case 2: /* 10 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1813 case 3: /* 11 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1814 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1815 default: de8145452eebe55 Ezequiel Garcia 2019-07-11 1816 return -EINVAL; de8145452eebe55 Ezequiel Garcia 2019-07-11 1817 } 0e380411d9f043f Ezequiel Garcia 2020-11-05 1818 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1819 [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 31910 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters @ 2020-11-10 18:56 ` Dan Carpenter 0 siblings, 0 replies; 7+ messages in thread From: Dan Carpenter @ 2020-11-10 18:56 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 4477 bytes --] Hi Ezequiel, url: https://github.com/0day-ci/linux/commits/Ezequiel-Garcia/MPEG-2-stateless-API-cleanup/20201106-045304 base: git://linuxtv.org/media_tree.git master config: i386-randconfig-m021-20201110 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> smatch warnings: drivers/media/v4l2-core/v4l2-ctrls.c:1809 std_validate_compound() warn: ignoring unreachable code. vim +1809 drivers/media/v4l2-core/v4l2-ctrls.c de8145452eebe55 Ezequiel Garcia 2019-07-11 1774 static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, 0176077a813933a Hans Verkuil 2014-04-27 1775 union v4l2_ctrl_ptr ptr) 0176077a813933a Hans Verkuil 2014-04-27 1776 { 0e380411d9f043f Ezequiel Garcia 2020-11-05 1777 struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1778 struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; c27bb30e7b6d385 Paul Kocialkowski 2018-09-13 1779 struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; 298c62d3856111e Ezequiel Garcia 2019-07-11 1780 struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; d9358563179a7f0 Ezequiel Garcia 2020-08-25 1781 struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; f9879eb378295e8 Ezequiel Garcia 2020-08-25 1782 struct v4l2_ctrl_h264_decode_params *p_h264_dec_params; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1783 struct v4l2_ctrl_hevc_sps *p_hevc_sps; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1784 struct v4l2_ctrl_hevc_pps *p_hevc_pps; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1785 struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; d1dc49370f8371b Ricardo Ribalda 2019-10-07 1786 struct v4l2_area *area; de8145452eebe55 Ezequiel Garcia 2019-07-11 1787 void *p = ptr.p + idx * ctrl->elem_size; 256fa3920874b0f Paul Kocialkowski 2019-10-22 1788 unsigned int i; de8145452eebe55 Ezequiel Garcia 2019-07-11 1789 de8145452eebe55 Ezequiel Garcia 2019-07-11 1790 switch ((u32)ctrl->type) { 0e380411d9f043f Ezequiel Garcia 2020-11-05 1791 case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: 0e380411d9f043f Ezequiel Garcia 2020-11-05 1792 p_mpeg2_sequence = p; de8145452eebe55 Ezequiel Garcia 2019-07-11 1793 0e380411d9f043f Ezequiel Garcia 2020-11-05 1794 switch (p_mpeg2_sequence->chroma_format) { de8145452eebe55 Ezequiel Garcia 2019-07-11 1795 case 1: /* 4:2:0 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1796 case 2: /* 4:2:2 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1797 case 3: /* 4:4:4 */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1798 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1799 default: de8145452eebe55 Ezequiel Garcia 2019-07-11 1800 return -EINVAL; de8145452eebe55 Ezequiel Garcia 2019-07-11 1801 } 0e380411d9f043f Ezequiel Garcia 2020-11-05 1802 zero_reserved(*p_mpeg2_sequence); 0e380411d9f043f Ezequiel Garcia 2020-11-05 1803 break; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1804 0e380411d9f043f Ezequiel Garcia 2020-11-05 1805 case V4L2_CTRL_TYPE_MPEG2_PICTURE: 0e380411d9f043f Ezequiel Garcia 2020-11-05 1806 p_mpeg2_picture = p; 0e380411d9f043f Ezequiel Garcia 2020-11-05 1807 break; ^^^^^^ de8145452eebe55 Ezequiel Garcia 2019-07-11 1808 0e380411d9f043f Ezequiel Garcia 2020-11-05 @1809 switch (p_mpeg2_picture->intra_dc_precision) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unreachable. de8145452eebe55 Ezequiel Garcia 2019-07-11 1810 case 0: /* 8 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1811 case 1: /* 9 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1812 case 2: /* 10 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1813 case 3: /* 11 bits */ de8145452eebe55 Ezequiel Garcia 2019-07-11 1814 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1815 default: de8145452eebe55 Ezequiel Garcia 2019-07-11 1816 return -EINVAL; de8145452eebe55 Ezequiel Garcia 2019-07-11 1817 } 0e380411d9f043f Ezequiel Garcia 2020-11-05 1818 break; de8145452eebe55 Ezequiel Garcia 2019-07-11 1819 [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 31910 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters 2020-11-05 20:51 ` [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters Ezequiel Garcia 2020-11-10 18:56 ` Dan Carpenter @ 2020-11-29 22:59 ` Jonas Karlman 2020-11-30 19:12 ` Ezequiel Garcia 1 sibling, 1 reply; 7+ messages in thread From: Jonas Karlman @ 2020-11-29 22:59 UTC (permalink / raw) To: Ezequiel Garcia, linux-media, linux-kernel Cc: kernel, Hans Verkuil, Nicolas Dufresne, Philipp Zabel, Maxime Ripard, Paul Kocialkowski, Jernej Skrabec Hi Ezequiel, On 2020-11-05 21:51, Ezequiel Garcia wrote: > Typically, bitstreams are composed of one sequence header NAL unit, > followed by a number of picture header and picture coding extension > NAL units. Each picture can be composed by a number of slices. > > Let's split the MPEG-2 uAPI to follow these semantics more closely, > allowing more usage flexibility. Having these controls splitted > allows applications to set a sequence control at the beginning > of a sequence, and then set a picture control for each frame. > > While here add padding fields where needed, and document > the uAPI header thoroughly. > > Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> > --- > .../media/v4l/ext-ctrls-codec.rst | 47 ++++++-- > .../media/v4l/pixfmt-compressed.rst | 5 +- > drivers/media/v4l2-core/v4l2-ctrls.c | 45 +++++-- > drivers/staging/media/hantro/hantro_drv.c | 10 ++ > .../media/hantro/hantro_g1_mpeg2_dec.c | 14 ++- > .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 14 ++- > drivers/staging/media/sunxi/cedrus/cedrus.c | 14 +++ > drivers/staging/media/sunxi/cedrus/cedrus.h | 2 + > .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 8 +- > include/media/mpeg2-ctrls.h | 110 +++++++++++++++--- > include/media/v4l2-ctrls.h | 4 + > 11 files changed, 212 insertions(+), 61 deletions(-) > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > index 4c32b93f41a6..d919cbc119bd 100644 > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > @@ -2218,14 +2218,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > :stub-columns: 0 > :widths: 1 1 2 > > - * - struct :c:type:`v4l2_mpeg2_sequence` > - - ``sequence`` > - - Structure with MPEG-2 sequence metadata, merging relevant fields from > - the sequence header and sequence extension parts of the bitstream. > - * - struct :c:type:`v4l2_mpeg2_picture` > - - ``picture`` > - - Structure with MPEG-2 picture metadata, merging relevant fields from > - the picture header and picture coding extension parts of the bitstream. > * - __u64 > - ``backward_ref_ts`` > - Timestamp of the V4L2 capture buffer to use as backward reference, used > @@ -2243,14 +2235,28 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > * - __u32 > - ``quantiser_scale_code`` > - Code used to determine the quantization scale to use for the IDCT. > + * - __u8 > + - ``reserved`` > + - Applications and drivers must set this to zero. > > -.. c:type:: v4l2_mpeg2_sequence > +``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (struct)`` > + Specifies the sequence parameters (as extracted from the bitstream) for the > + associated MPEG-2 slice data. This includes fields matching the syntax > + elements from the sequence header and sequence extension parts of the > + bitstream as specified by :ref:`mpeg2part2`. > + > + .. note:: > + > + This compound control is not yet part of the public kernel API and > + it is expected to change. > + > +.. c:type:: v4l2_ctrl_mpeg2_sequence > > .. cssclass:: longtable > > .. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}| > > -.. flat-table:: struct v4l2_mpeg2_sequence > +.. flat-table:: struct v4l2_ctrl_mpeg2_sequence > :header-rows: 0 > :stub-columns: 0 > :widths: 1 1 2 > @@ -2272,6 +2278,9 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > * - __u8 > - ``chroma_format`` > - The chrominance sub-sampling format (1: 4:2:0, 2: 4:2:2, 3: 4:4:4). > + * - __u8 > + - ``reserved`` > + - Applications and drivers must set this to zero. > * - __u32 > - ``flags`` > - See :ref:`MPEG-2 Sequence Flags <mpeg2_sequence_flags>`. > @@ -2292,13 +2301,24 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > - Indication that all the frames for the sequence are progressive instead > of interlaced. > > -.. c:type:: v4l2_mpeg2_picture > +``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (struct)`` > + Specifies the picture parameters (as extracted from the bitstream) for the > + associated MPEG-2 slice data. This includes fields matching the syntax > + elements from the picture header and picture coding extension parts of the > + bitstream as specified by :ref:`mpeg2part2`. > + > + .. note:: > + > + This compound control is not yet part of the public kernel API and > + it is expected to change. > + > +.. c:type:: v4l2_ctrl_mpeg2_picture > > .. cssclass:: longtable > > .. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}| > > -.. flat-table:: struct v4l2_mpeg2_picture > +.. flat-table:: struct v4l2_ctrl_mpeg2_picture > :header-rows: 0 > :stub-columns: 0 > :widths: 1 1 2 > @@ -2319,6 +2339,9 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > - ``picture_structure`` > - Picture structure (1: interlaced top field, 2: interlaced bottom field, > 3: progressive frame). > + * - __u8 > + - ``reserved`` > + - Applications and drivers must set this to zero. > * - __u32 > - ``flags`` > - See :ref:`MPEG-2 Picture Flags <mpeg2_picture_flags>`. > diff --git a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst > index d585909bc4e2..1da4722bc8f3 100644 > --- a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst > +++ b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst > @@ -113,8 +113,9 @@ Compressed Formats > This format is adapted for stateless video decoders that implement a > MPEG-2 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`). > Metadata associated with the frame to decode is required to be passed > - through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` control and > - quantization matrices can optionally be specified through the > + through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE``, > + ``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE``, and ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` > + controls. Quantization matrices can optionally be specified through the > ``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION`` control. > See the :ref:`associated Codec Control IDs <v4l2-mpeg-mpeg2>`. > Exactly one output and one capture buffer must be provided for use with > diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c > index c24caffc956d..da50fb9edb96 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls.c > @@ -1620,7 +1620,8 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, > static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, > union v4l2_ctrl_ptr ptr) > { > - struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; > + struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; > + struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; > void *p = ptr.p + idx * ctrl->elem_size; > > if (ctrl->p_def.p_const) > @@ -1634,13 +1635,18 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, > * v4l2_ctrl_type enum. > */ > switch ((u32)ctrl->type) { > - case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: > - p_mpeg2_slice_params = p; > + case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: > + p_mpeg2_sequence = p; > + > /* 4:2:0 */ > - p_mpeg2_slice_params->sequence.chroma_format = 1; > + p_mpeg2_sequence->chroma_format = 1; > + break; > + case V4L2_CTRL_TYPE_MPEG2_PICTURE: > + p_mpeg2_picture = p; > + > /* interlaced top field */ > - p_mpeg2_slice_params->picture.picture_structure = 1; > - p_mpeg2_slice_params->picture.picture_coding_type = > + p_mpeg2_picture->picture_structure = 1; > + p_mpeg2_picture->picture_coding_type = > V4L2_MPEG2_PIC_CODING_TYPE_I; > break; > } > @@ -1768,6 +1774,8 @@ static void std_log(const struct v4l2_ctrl *ctrl) > static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > union v4l2_ctrl_ptr ptr) > { > + struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; > + struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; > struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; > struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; > struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; > @@ -1780,10 +1788,10 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > unsigned int i; > > switch ((u32)ctrl->type) { > - case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: > - p_mpeg2_slice_params = p; > + case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: > + p_mpeg2_sequence = p; > > - switch (p_mpeg2_slice_params->sequence.chroma_format) { > + switch (p_mpeg2_sequence->chroma_format) { > case 1: /* 4:2:0 */ > case 2: /* 4:2:2 */ > case 3: /* 4:4:4 */ > @@ -1791,8 +1799,14 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > default: > return -EINVAL; > } > + zero_reserved(*p_mpeg2_sequence); > + break; > + > + case V4L2_CTRL_TYPE_MPEG2_PICTURE: > + p_mpeg2_picture = p; > + break; > > - switch (p_mpeg2_slice_params->picture.intra_dc_precision) { > + switch (p_mpeg2_picture->intra_dc_precision) { > case 0: /* 8 bits */ > case 1: /* 9 bits */ > case 2: /* 10 bits */ > @@ -1801,8 +1815,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > default: > return -EINVAL; > } > + break; > > - switch (p_mpeg2_slice_params->picture.picture_structure) { > + switch (p_mpeg2_picture->picture_structure) { > case V4L2_MPEG2_PIC_TOP_FIELD: > case V4L2_MPEG2_PIC_BOTTOM_FIELD: > case V4L2_MPEG2_PIC_FRAME: > @@ -1811,7 +1826,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > return -EINVAL; > } > > - switch (p_mpeg2_slice_params->picture.picture_coding_type) { > + switch (p_mpeg2_picture->picture_coding_type) { > case V4L2_MPEG2_PIC_CODING_TYPE_I: > case V4L2_MPEG2_PIC_CODING_TYPE_P: > case V4L2_MPEG2_PIC_CODING_TYPE_B: > @@ -1819,7 +1834,13 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > default: > return -EINVAL; > } > + zero_reserved(*p_mpeg2_picture); > + break; > + > + case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: > + p_mpeg2_slice_params = p; > > + zero_reserved(*p_mpeg2_slice_params); > break; > > case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: > diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c > index 3cd00cc0a364..68543a8836e4 100644 > --- a/drivers/staging/media/hantro/hantro_drv.c > +++ b/drivers/staging/media/hantro/hantro_drv.c > @@ -286,6 +286,16 @@ static const struct hantro_ctrl controls[] = { > .def = 50, > .ops = &hantro_jpeg_ctrl_ops, > }, > + }, { > + .codec = HANTRO_MPEG2_DECODER, > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE, > + }, > + }, { > + .codec = HANTRO_MPEG2_DECODER, > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, > + }, > }, { > .codec = HANTRO_MPEG2_DECODER, > .cfg = { > diff --git a/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c b/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c > index b6086474d31f..1a6ca49441f4 100644 > --- a/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c > +++ b/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c > @@ -95,8 +95,8 @@ static void > hantro_g1_mpeg2_dec_set_buffers(struct hantro_dev *vpu, struct hantro_ctx *ctx, > struct vb2_buffer *src_buf, > struct vb2_buffer *dst_buf, > - const struct v4l2_mpeg2_sequence *seq, > - const struct v4l2_mpeg2_picture *pic, > + const struct v4l2_ctrl_mpeg2_sequence *seq, > + const struct v4l2_ctrl_mpeg2_picture *pic, > const struct v4l2_ctrl_mpeg2_slice_params *slice_params) > { > dma_addr_t forward_addr = 0, backward_addr = 0; > @@ -156,8 +156,8 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) > struct hantro_dev *vpu = ctx->dev; > struct vb2_v4l2_buffer *src_buf, *dst_buf; > const struct v4l2_ctrl_mpeg2_slice_params *slice_params; > - const struct v4l2_mpeg2_sequence *seq; > - const struct v4l2_mpeg2_picture *pic; > + const struct v4l2_ctrl_mpeg2_sequence *seq; > + const struct v4l2_ctrl_mpeg2_picture *pic; > u32 reg; > > src_buf = hantro_get_src_buf(ctx); > @@ -168,8 +168,10 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) > > slice_params = hantro_get_ctrl(ctx, > V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS); > - seq = &slice_params->sequence; > - pic = &slice_params->picture; > + seq = hantro_get_ctrl(ctx, > + V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE); > + pic = hantro_get_ctrl(ctx, > + V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE); > > reg = G1_REG_DEC_AXI_RD_ID(0) | > G1_REG_DEC_TIMEOUT_E(1) | > diff --git a/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c b/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c > index 28eb77b0569b..45ab5ca32221 100644 > --- a/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c > +++ b/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c > @@ -97,8 +97,8 @@ rk3399_vpu_mpeg2_dec_set_buffers(struct hantro_dev *vpu, > struct hantro_ctx *ctx, > struct vb2_buffer *src_buf, > struct vb2_buffer *dst_buf, > - const struct v4l2_mpeg2_sequence *seq, > - const struct v4l2_mpeg2_picture *pic, > + const struct v4l2_ctrl_mpeg2_sequence *seq, > + const struct v4l2_ctrl_mpeg2_picture *pic, > const struct v4l2_ctrl_mpeg2_slice_params *slice_params) > { > dma_addr_t forward_addr = 0, backward_addr = 0; > @@ -158,8 +158,8 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) > struct hantro_dev *vpu = ctx->dev; > struct vb2_v4l2_buffer *src_buf, *dst_buf; > const struct v4l2_ctrl_mpeg2_slice_params *slice_params; > - const struct v4l2_mpeg2_sequence *seq; > - const struct v4l2_mpeg2_picture *pic; > + const struct v4l2_ctrl_mpeg2_sequence *seq; > + const struct v4l2_ctrl_mpeg2_picture *pic; > u32 reg; > > src_buf = hantro_get_src_buf(ctx); > @@ -169,8 +169,10 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) > > slice_params = hantro_get_ctrl(ctx, > V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS); > - seq = &slice_params->sequence; > - pic = &slice_params->picture; > + seq = hantro_get_ctrl(ctx, > + V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE); > + pic = hantro_get_ctrl(ctx, > + V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE); > > reg = VDPU_REG_DEC_ADV_PRE_DIS(0) | > VDPU_REG_DEC_SCMD_DIS(0) | > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c > index 9a102b7c1bb9..5b464703cb27 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c > @@ -29,6 +29,20 @@ > #include "cedrus_hw.h" > > static const struct cedrus_control cedrus_controls[] = { > + { > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE, > + }, > + .codec = CEDRUS_CODEC_MPEG2, > + .required = true, > + }, > + { > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, > + }, > + .codec = CEDRUS_CODEC_MPEG2, > + .required = true, > + }, > { > .cfg = { > .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS, > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h > index 93c843ae14bb..c27d9b159c26 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus.h > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h > @@ -66,6 +66,8 @@ struct cedrus_h264_run { > }; > > struct cedrus_mpeg2_run { > + const struct v4l2_ctrl_mpeg2_sequence *sequence; > + const struct v4l2_ctrl_mpeg2_picture *picture; > const struct v4l2_ctrl_mpeg2_slice_params *slice_params; > const struct v4l2_ctrl_mpeg2_quantization *quantization; > }; > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > index 6a99893cdc77..ea52778b36f9 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > @@ -75,8 +75,8 @@ static void cedrus_mpeg2_irq_disable(struct cedrus_ctx *ctx) > static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) > { > const struct v4l2_ctrl_mpeg2_slice_params *slice_params; > - const struct v4l2_mpeg2_sequence *seq; > - const struct v4l2_mpeg2_picture *pic; > + const struct v4l2_ctrl_mpeg2_sequence *seq; > + const struct v4l2_ctrl_mpeg2_picture *pic; > const struct v4l2_ctrl_mpeg2_quantization *quantization; > dma_addr_t src_buf_addr, dst_luma_addr, dst_chroma_addr; > dma_addr_t fwd_luma_addr, fwd_chroma_addr; > @@ -90,8 +90,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) > u32 reg; > > slice_params = run->mpeg2.slice_params; > - seq = &slice_params->sequence; > - pic = &slice_params->picture; > + seq = run->mpeg2.sequence; > + pic = run->mpeg2.picture; > > quantization = run->mpeg2.quantization; > > diff --git a/include/media/mpeg2-ctrls.h b/include/media/mpeg2-ctrls.h > index 5b0c916a44dd..cd8f0cea5665 100644 > --- a/include/media/mpeg2-ctrls.h > +++ b/include/media/mpeg2-ctrls.h > @@ -12,24 +12,46 @@ > #define _MPEG2_CTRLS_H_ > > #define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_MPEG_BASE+250) > -#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+251) > +#define V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (V4L2_CID_MPEG_BASE+251) > +#define V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (V4L2_CID_MPEG_BASE+252) > +#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+253) > > /* enum v4l2_ctrl_type type values */ > -#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0103 > -#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0104 > +#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0130 > +#define V4L2_CTRL_TYPE_MPEG2_SEQUENCE 0x0131 > +#define V4L2_CTRL_TYPE_MPEG2_PICTURE 0x0132 > +#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0133 > > #define V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE 0x0001 > > -struct v4l2_mpeg2_sequence { > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */ > +/** > + * struct v4l2_ctrl_mpeg2_sequence - MPEG-2 sequence header > + * > + * All the members on this structure match the sequence header and sequence > + * extension syntaxes as specified by the MPEG-2 specification. > + * > + * Fields horizontal_size, vertical_size and vbv_buffer_size are a > + * combination of respective _value and extension syntax elements, > + * as described in section 6.3.3 "Sequence header". > + * > + * @horizontal_size: combination of elements horizontal_size_value and > + * horizontal_size_extension. > + * @vertical_size: combination of elements vertical_size_value and > + * vertical_size_extension. > + * @vbv_buffer_size: combination of elements vbv_buffer_size_value and > + * vbv_buffer_size_extension. > + * @profile_and_level_indication: see MPEG-2 specification. > + * @chroma_format: see MPEG-2 specification. > + * @reserved: padding field. Should be zeroed by applications. > + * @flags: see V4L2_MPEG2_SEQ_FLAG_{}. > + */ > +struct v4l2_ctrl_mpeg2_sequence { > __u16 horizontal_size; > __u16 vertical_size; > __u32 vbv_buffer_size; > - > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */ > __u16 profile_and_level_indication; > __u8 chroma_format; > - > + __u8 reserved; > __u32 flags; > }; > > @@ -55,30 +77,80 @@ struct v4l2_mpeg2_sequence { > #define V4L2_MPEG2_PIC_FLAG_LOAD_CHROMA_INTRA 0x0400 > #define V4L2_MPEG2_PIC_FLAG_LOAD_CHROMA_NON_INTRA 0x0800 > > -struct v4l2_mpeg2_picture { > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */ > +/** > + * struct v4l2_ctrl_mpeg2_picture - MPEG-2 picture header > + * > + * All the members on this structure match the picture header and picture > + * coding extension syntaxes as specified by the MPEG-2 specification. > + * > + * In particular, the set of quantization load flags V4L2_MPEG2_PIC_FLAG_LOAD_{} > + * are specified here in order to allow applications to pass non-default > + * quantization matrices. In this case, applications are expected to use > + * V4L2_CTRL_TYPE_MPEG2_QUANTIZATION to pass the values of non-default > + * matrices. > + * > + * @picture_coding_type: see MPEG-2 specification. > + * @f_code[2][2]: see MPEG-2 specification. > + * @intra_dc_precision: see MPEG-2 specification. > + * @picture_structure: see V4L2_MPEG2_PIC_{}_FIELD. > + * @reserved: padding field. Should be zeroed by applications. > + * @flags: see V4L2_MPEG2_PIC_FLAG_{}. > + */ > +struct v4l2_ctrl_mpeg2_picture { > __u8 picture_coding_type; > - > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture coding extension */ > __u8 f_code[2][2]; > __u8 intra_dc_precision; > __u8 picture_structure; > - > + __u8 reserved; > __u32 flags; > }; > > +/** > + * struct v4l2_ctrl_mpeg2_slice_params - MPEG-2 slice header > + * > + * @backward_ref_ts: timestamp of the V4L2 capture buffer to use as > + * reference for backward prediction. > + * @forward_ref_ts: timestamp of the V4L2 capture buffer to use as > + * reference for forward prediction. These timestamp refers to the > + * timestamp field in struct v4l2_buffer. Use v4l2_timeval_to_ns() > + * to convert the struct timeval to a __u64. > + * @quantiser_scale_code: quantiser scale integer matching an > + * homonymous syntax element. > + * @reserved: padding field. Should be zeroed by applications. > + */ > struct v4l2_ctrl_mpeg2_slice_params { > __u64 backward_ref_ts; > __u64 forward_ref_ts; > - > - struct v4l2_mpeg2_sequence sequence; > - struct v4l2_mpeg2_picture picture; > - > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */ > __u32 quantiser_scale_code; > + __u32 reserved; > }; > > -/* ISO/IEC 13818-2, ITU-T Rec. H.262: Quant matrix extension */ > +/** > + * struct v4l2_ctrl_mpeg2_quantization - MPEG-2 quantization > + * > + * Quantization matrices as specified by section 6.3.7 > + * "Quant matrix extension". > + * > + * Applications are expected to set the quantization matrices load > + * flags V4L2_MPEG2_PIC_FLAG_LOAD_{} in struct v4l2_ctrl_mpeg2_picture > + * to tell the kernel that a non-default matrix shall be used > + * to decode the picture. > + * > + * @intra_quantiser_matrix: The quantization matrix coefficients > + * for intra-coded frames, in zigzag scanning order. It is relevant > + * for both luma and chroma components, although it can be superseded > + * by the chroma-specific matrix for non-4:2:0 YUV formats. > + * @non_intra_quantiser_matrix: The quantization matrix coefficients > + * for non-intra-coded frames, in zigzag scanning order. It is relevant > + * for both luma and chroma components, although it can be superseded > + * by the chroma-specific matrix for non-4:2:0 YUV formats. > + * @chroma_intra_quantiser_matrix: The quantization matrix coefficients > + * for the chominance component of intra-coded frames, in zigzag scanning > + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. > + * @chroma_non_intra_quantiser_matrix: The quantization matrix coefficients > + * for the chrominance component of non-intra-coded frames, in zigzag scanning > + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. > + */ > struct v4l2_ctrl_mpeg2_quantization { > __u8 intra_quantiser_matrix[64]; > __u8 non_intra_quantiser_matrix[64]; > diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h > index cb25f345e9ad..92f4b508f5de 100644 > --- a/include/media/v4l2-ctrls.h > +++ b/include/media/v4l2-ctrls.h > @@ -43,6 +43,8 @@ struct video_device; > * @p_u16: Pointer to a 16-bit unsigned value. > * @p_u32: Pointer to a 32-bit unsigned value. > * @p_char: Pointer to a string. > + * @p_mpeg2_sequence: Pointer to a MPEG2 sequence structure. > + * @p_mpeg2_picture: Pointer to a MPEG2 picture structure. > * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure. > * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure. > * @p_fwht_params: Pointer to a FWHT stateless parameters structure. > @@ -67,6 +69,8 @@ union v4l2_ctrl_ptr { > u16 *p_u16; > u32 *p_u32; > char *p_char; > + struct v4l2_ctrl_mpeg2_sequence *p_sequence; > + struct v4l2_ctrl_mpeg2_picture *p_picture; These two should be named p_mpeg2_<name> to match the doc comment. I think this series looks good and aligns MPEG-2 ctrls with other codecs. Together with some fixup at [1] this series is Tested-by: Jonas Karlman <jonas@kwiboo.se> on RK3288 (Hantro G1) with FFmpeg + Kodi. [1] https://github.com/Kwiboo/linux-rockchip/commit/a6942e0a1e5f03078a37a1c575f76d02d7ba775f Best regards, Jonas > struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; > struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization; > struct v4l2_ctrl_fwht_params *p_fwht_params; > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters 2020-11-29 22:59 ` Jonas Karlman @ 2020-11-30 19:12 ` Ezequiel Garcia 0 siblings, 0 replies; 7+ messages in thread From: Ezequiel Garcia @ 2020-11-30 19:12 UTC (permalink / raw) To: Jonas Karlman, linux-media, linux-kernel Cc: kernel, Hans Verkuil, Nicolas Dufresne, Philipp Zabel, Maxime Ripard, Paul Kocialkowski, Jernej Skrabec On Sun, 2020-11-29 at 22:59 +0000, Jonas Karlman wrote: > Hi Ezequiel, > > On 2020-11-05 21:51, Ezequiel Garcia wrote: > > Typically, bitstreams are composed of one sequence header NAL unit, > > followed by a number of picture header and picture coding extension > > NAL units. Each picture can be composed by a number of slices. > > > > Let's split the MPEG-2 uAPI to follow these semantics more closely, > > allowing more usage flexibility. Having these controls splitted > > allows applications to set a sequence control at the beginning > > of a sequence, and then set a picture control for each frame. > > > > While here add padding fields where needed, and document > > the uAPI header thoroughly. > > > > Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> > > --- > > .../media/v4l/ext-ctrls-codec.rst | 47 ++++++-- > > .../media/v4l/pixfmt-compressed.rst | 5 +- > > drivers/media/v4l2-core/v4l2-ctrls.c | 45 +++++-- > > drivers/staging/media/hantro/hantro_drv.c | 10 ++ > > .../media/hantro/hantro_g1_mpeg2_dec.c | 14 ++- > > .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 14 ++- > > drivers/staging/media/sunxi/cedrus/cedrus.c | 14 +++ > > drivers/staging/media/sunxi/cedrus/cedrus.h | 2 + > > .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 8 +- > > include/media/mpeg2-ctrls.h | 110 +++++++++++++++--- > > include/media/v4l2-ctrls.h | 4 + > > 11 files changed, 212 insertions(+), 61 deletions(-) > > > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > > index 4c32b93f41a6..d919cbc119bd 100644 > > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > > @@ -2218,14 +2218,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > > :stub-columns: 0 > > :widths: 1 1 2 > > > > - * - struct :c:type:`v4l2_mpeg2_sequence` > > - - ``sequence`` > > - - Structure with MPEG-2 sequence metadata, merging relevant fields from > > - the sequence header and sequence extension parts of the bitstream. > > - * - struct :c:type:`v4l2_mpeg2_picture` > > - - ``picture`` > > - - Structure with MPEG-2 picture metadata, merging relevant fields from > > - the picture header and picture coding extension parts of the bitstream. > > * - __u64 > > - ``backward_ref_ts`` > > - Timestamp of the V4L2 capture buffer to use as backward reference, used > > @@ -2243,14 +2235,28 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > > * - __u32 > > - ``quantiser_scale_code`` > > - Code used to determine the quantization scale to use for the IDCT. > > + * - __u8 > > + - ``reserved`` > > + - Applications and drivers must set this to zero. > > > > -.. c:type:: v4l2_mpeg2_sequence > > +``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (struct)`` > > + Specifies the sequence parameters (as extracted from the bitstream) for the > > + associated MPEG-2 slice data. This includes fields matching the syntax > > + elements from the sequence header and sequence extension parts of the > > + bitstream as specified by :ref:`mpeg2part2`. > > + > > + .. note:: > > + > > + This compound control is not yet part of the public kernel API and > > + it is expected to change. > > + > > +.. c:type:: v4l2_ctrl_mpeg2_sequence > > > > .. cssclass:: longtable > > > > .. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}| > > > > -.. flat-table:: struct v4l2_mpeg2_sequence > > +.. flat-table:: struct v4l2_ctrl_mpeg2_sequence > > :header-rows: 0 > > :stub-columns: 0 > > :widths: 1 1 2 > > @@ -2272,6 +2278,9 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > > * - __u8 > > - ``chroma_format`` > > - The chrominance sub-sampling format (1: 4:2:0, 2: 4:2:2, 3: 4:4:4). > > + * - __u8 > > + - ``reserved`` > > + - Applications and drivers must set this to zero. > > * - __u32 > > - ``flags`` > > - See :ref:`MPEG-2 Sequence Flags <mpeg2_sequence_flags>`. > > @@ -2292,13 +2301,24 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > > - Indication that all the frames for the sequence are progressive instead > > of interlaced. > > > > -.. c:type:: v4l2_mpeg2_picture > > +``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (struct)`` > > + Specifies the picture parameters (as extracted from the bitstream) for the > > + associated MPEG-2 slice data. This includes fields matching the syntax > > + elements from the picture header and picture coding extension parts of the > > + bitstream as specified by :ref:`mpeg2part2`. > > + > > + .. note:: > > + > > + This compound control is not yet part of the public kernel API and > > + it is expected to change. > > + > > +.. c:type:: v4l2_ctrl_mpeg2_picture > > > > .. cssclass:: longtable > > > > .. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}| > > > > -.. flat-table:: struct v4l2_mpeg2_picture > > +.. flat-table:: struct v4l2_ctrl_mpeg2_picture > > :header-rows: 0 > > :stub-columns: 0 > > :widths: 1 1 2 > > @@ -2319,6 +2339,9 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > > - ``picture_structure`` > > - Picture structure (1: interlaced top field, 2: interlaced bottom field, > > 3: progressive frame). > > + * - __u8 > > + - ``reserved`` > > + - Applications and drivers must set this to zero. > > * - __u32 > > - ``flags`` > > - See :ref:`MPEG-2 Picture Flags <mpeg2_picture_flags>`. > > diff --git a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst > > index d585909bc4e2..1da4722bc8f3 100644 > > --- a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst > > +++ b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst > > @@ -113,8 +113,9 @@ Compressed Formats > > This format is adapted for stateless video decoders that implement a > > MPEG-2 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`). > > Metadata associated with the frame to decode is required to be passed > > - through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` control and > > - quantization matrices can optionally be specified through the > > + through the ``V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE``, > > + ``V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE``, and ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS`` > > + controls. Quantization matrices can optionally be specified through the > > ``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION`` control. > > See the :ref:`associated Codec Control IDs <v4l2-mpeg-mpeg2>`. > > Exactly one output and one capture buffer must be provided for use with > > diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c > > index c24caffc956d..da50fb9edb96 100644 > > --- a/drivers/media/v4l2-core/v4l2-ctrls.c > > +++ b/drivers/media/v4l2-core/v4l2-ctrls.c > > @@ -1620,7 +1620,8 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, > > static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, > > union v4l2_ctrl_ptr ptr) > > { > > - struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; > > + struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; > > + struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; > > void *p = ptr.p + idx * ctrl->elem_size; > > > > if (ctrl->p_def.p_const) > > @@ -1634,13 +1635,18 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, > > * v4l2_ctrl_type enum. > > */ > > switch ((u32)ctrl->type) { > > - case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: > > - p_mpeg2_slice_params = p; > > + case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: > > + p_mpeg2_sequence = p; > > + > > /* 4:2:0 */ > > - p_mpeg2_slice_params->sequence.chroma_format = 1; > > + p_mpeg2_sequence->chroma_format = 1; > > + break; > > + case V4L2_CTRL_TYPE_MPEG2_PICTURE: > > + p_mpeg2_picture = p; > > + > > /* interlaced top field */ > > - p_mpeg2_slice_params->picture.picture_structure = 1; > > - p_mpeg2_slice_params->picture.picture_coding_type = > > + p_mpeg2_picture->picture_structure = 1; > > + p_mpeg2_picture->picture_coding_type = > > V4L2_MPEG2_PIC_CODING_TYPE_I; > > break; > > } > > @@ -1768,6 +1774,8 @@ static void std_log(const struct v4l2_ctrl *ctrl) > > static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > > union v4l2_ctrl_ptr ptr) > > { > > + struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence; > > + struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture; > > struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; > > struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; > > struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; > > @@ -1780,10 +1788,10 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > > unsigned int i; > > > > switch ((u32)ctrl->type) { > > - case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: > > - p_mpeg2_slice_params = p; > > + case V4L2_CTRL_TYPE_MPEG2_SEQUENCE: > > + p_mpeg2_sequence = p; > > > > - switch (p_mpeg2_slice_params->sequence.chroma_format) { > > + switch (p_mpeg2_sequence->chroma_format) { > > case 1: /* 4:2:0 */ > > case 2: /* 4:2:2 */ > > case 3: /* 4:4:4 */ > > @@ -1791,8 +1799,14 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > > default: > > return -EINVAL; > > } > > + zero_reserved(*p_mpeg2_sequence); > > + break; > > + > > + case V4L2_CTRL_TYPE_MPEG2_PICTURE: > > + p_mpeg2_picture = p; > > + break; > > > > - switch (p_mpeg2_slice_params->picture.intra_dc_precision) { > > + switch (p_mpeg2_picture->intra_dc_precision) { > > case 0: /* 8 bits */ > > case 1: /* 9 bits */ > > case 2: /* 10 bits */ > > @@ -1801,8 +1815,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > > default: > > return -EINVAL; > > } > > + break; > > > > - switch (p_mpeg2_slice_params->picture.picture_structure) { > > + switch (p_mpeg2_picture->picture_structure) { > > case V4L2_MPEG2_PIC_TOP_FIELD: > > case V4L2_MPEG2_PIC_BOTTOM_FIELD: > > case V4L2_MPEG2_PIC_FRAME: > > @@ -1811,7 +1826,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > > return -EINVAL; > > } > > > > - switch (p_mpeg2_slice_params->picture.picture_coding_type) { > > + switch (p_mpeg2_picture->picture_coding_type) { > > case V4L2_MPEG2_PIC_CODING_TYPE_I: > > case V4L2_MPEG2_PIC_CODING_TYPE_P: > > case V4L2_MPEG2_PIC_CODING_TYPE_B: > > @@ -1819,7 +1834,13 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, > > default: > > return -EINVAL; > > } > > + zero_reserved(*p_mpeg2_picture); > > + break; > > + > > + case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: > > + p_mpeg2_slice_params = p; > > > > + zero_reserved(*p_mpeg2_slice_params); > > break; > > > > case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: > > diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c > > index 3cd00cc0a364..68543a8836e4 100644 > > --- a/drivers/staging/media/hantro/hantro_drv.c > > +++ b/drivers/staging/media/hantro/hantro_drv.c > > @@ -286,6 +286,16 @@ static const struct hantro_ctrl controls[] = { > > .def = 50, > > .ops = &hantro_jpeg_ctrl_ops, > > }, > > + }, { > > + .codec = HANTRO_MPEG2_DECODER, > > + .cfg = { > > + .id = V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE, > > + }, > > + }, { > > + .codec = HANTRO_MPEG2_DECODER, > > + .cfg = { > > + .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, > > + }, > > }, { > > .codec = HANTRO_MPEG2_DECODER, > > .cfg = { > > diff --git a/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c b/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c > > index b6086474d31f..1a6ca49441f4 100644 > > --- a/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c > > +++ b/drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c > > @@ -95,8 +95,8 @@ static void > > hantro_g1_mpeg2_dec_set_buffers(struct hantro_dev *vpu, struct hantro_ctx *ctx, > > struct vb2_buffer *src_buf, > > struct vb2_buffer *dst_buf, > > - const struct v4l2_mpeg2_sequence *seq, > > - const struct v4l2_mpeg2_picture *pic, > > + const struct v4l2_ctrl_mpeg2_sequence *seq, > > + const struct v4l2_ctrl_mpeg2_picture *pic, > > const struct v4l2_ctrl_mpeg2_slice_params *slice_params) > > { > > dma_addr_t forward_addr = 0, backward_addr = 0; > > @@ -156,8 +156,8 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) > > struct hantro_dev *vpu = ctx->dev; > > struct vb2_v4l2_buffer *src_buf, *dst_buf; > > const struct v4l2_ctrl_mpeg2_slice_params *slice_params; > > - const struct v4l2_mpeg2_sequence *seq; > > - const struct v4l2_mpeg2_picture *pic; > > + const struct v4l2_ctrl_mpeg2_sequence *seq; > > + const struct v4l2_ctrl_mpeg2_picture *pic; > > u32 reg; > > > > src_buf = hantro_get_src_buf(ctx); > > @@ -168,8 +168,10 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) > > > > slice_params = hantro_get_ctrl(ctx, > > V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS); > > - seq = &slice_params->sequence; > > - pic = &slice_params->picture; > > + seq = hantro_get_ctrl(ctx, > > + V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE); > > + pic = hantro_get_ctrl(ctx, > > + V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE); > > > > reg = G1_REG_DEC_AXI_RD_ID(0) | > > G1_REG_DEC_TIMEOUT_E(1) | > > diff --git a/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c b/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c > > index 28eb77b0569b..45ab5ca32221 100644 > > --- a/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c > > +++ b/drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c > > @@ -97,8 +97,8 @@ rk3399_vpu_mpeg2_dec_set_buffers(struct hantro_dev *vpu, > > struct hantro_ctx *ctx, > > struct vb2_buffer *src_buf, > > struct vb2_buffer *dst_buf, > > - const struct v4l2_mpeg2_sequence *seq, > > - const struct v4l2_mpeg2_picture *pic, > > + const struct v4l2_ctrl_mpeg2_sequence *seq, > > + const struct v4l2_ctrl_mpeg2_picture *pic, > > const struct v4l2_ctrl_mpeg2_slice_params *slice_params) > > { > > dma_addr_t forward_addr = 0, backward_addr = 0; > > @@ -158,8 +158,8 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) > > struct hantro_dev *vpu = ctx->dev; > > struct vb2_v4l2_buffer *src_buf, *dst_buf; > > const struct v4l2_ctrl_mpeg2_slice_params *slice_params; > > - const struct v4l2_mpeg2_sequence *seq; > > - const struct v4l2_mpeg2_picture *pic; > > + const struct v4l2_ctrl_mpeg2_sequence *seq; > > + const struct v4l2_ctrl_mpeg2_picture *pic; > > u32 reg; > > > > src_buf = hantro_get_src_buf(ctx); > > @@ -169,8 +169,10 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) > > > > slice_params = hantro_get_ctrl(ctx, > > V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS); > > - seq = &slice_params->sequence; > > - pic = &slice_params->picture; > > + seq = hantro_get_ctrl(ctx, > > + V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE); > > + pic = hantro_get_ctrl(ctx, > > + V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE); > > > > reg = VDPU_REG_DEC_ADV_PRE_DIS(0) | > > VDPU_REG_DEC_SCMD_DIS(0) | > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c > > index 9a102b7c1bb9..5b464703cb27 100644 > > --- a/drivers/staging/media/sunxi/cedrus/cedrus.c > > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c > > @@ -29,6 +29,20 @@ > > #include "cedrus_hw.h" > > > > static const struct cedrus_control cedrus_controls[] = { > > + { > > + .cfg = { > > + .id = V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE, > > + }, > > + .codec = CEDRUS_CODEC_MPEG2, > > + .required = true, > > + }, > > + { > > + .cfg = { > > + .id = V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE, > > + }, > > + .codec = CEDRUS_CODEC_MPEG2, > > + .required = true, > > + }, > > { > > .cfg = { > > .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS, > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h > > index 93c843ae14bb..c27d9b159c26 100644 > > --- a/drivers/staging/media/sunxi/cedrus/cedrus.h > > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h > > @@ -66,6 +66,8 @@ struct cedrus_h264_run { > > }; > > > > struct cedrus_mpeg2_run { > > + const struct v4l2_ctrl_mpeg2_sequence *sequence; > > + const struct v4l2_ctrl_mpeg2_picture *picture; > > const struct v4l2_ctrl_mpeg2_slice_params *slice_params; > > const struct v4l2_ctrl_mpeg2_quantization *quantization; > > }; > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > > index 6a99893cdc77..ea52778b36f9 100644 > > --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > > @@ -75,8 +75,8 @@ static void cedrus_mpeg2_irq_disable(struct cedrus_ctx *ctx) > > static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) > > { > > const struct v4l2_ctrl_mpeg2_slice_params *slice_params; > > - const struct v4l2_mpeg2_sequence *seq; > > - const struct v4l2_mpeg2_picture *pic; > > + const struct v4l2_ctrl_mpeg2_sequence *seq; > > + const struct v4l2_ctrl_mpeg2_picture *pic; > > const struct v4l2_ctrl_mpeg2_quantization *quantization; > > dma_addr_t src_buf_addr, dst_luma_addr, dst_chroma_addr; > > dma_addr_t fwd_luma_addr, fwd_chroma_addr; > > @@ -90,8 +90,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) > > u32 reg; > > > > slice_params = run->mpeg2.slice_params; > > - seq = &slice_params->sequence; > > - pic = &slice_params->picture; > > + seq = run->mpeg2.sequence; > > + pic = run->mpeg2.picture; > > > > quantization = run->mpeg2.quantization; > > > > diff --git a/include/media/mpeg2-ctrls.h b/include/media/mpeg2-ctrls.h > > index 5b0c916a44dd..cd8f0cea5665 100644 > > --- a/include/media/mpeg2-ctrls.h > > +++ b/include/media/mpeg2-ctrls.h > > @@ -12,24 +12,46 @@ > > #define _MPEG2_CTRLS_H_ > > > > #define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_MPEG_BASE+250) > > -#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+251) > > +#define V4L2_CID_MPEG_VIDEO_MPEG2_SEQUENCE (V4L2_CID_MPEG_BASE+251) > > +#define V4L2_CID_MPEG_VIDEO_MPEG2_PICTURE (V4L2_CID_MPEG_BASE+252) > > +#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+253) > > > > /* enum v4l2_ctrl_type type values */ > > -#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0103 > > -#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0104 > > +#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0130 > > +#define V4L2_CTRL_TYPE_MPEG2_SEQUENCE 0x0131 > > +#define V4L2_CTRL_TYPE_MPEG2_PICTURE 0x0132 > > +#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0133 > > > > #define V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE 0x0001 > > > > -struct v4l2_mpeg2_sequence { > > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */ > > +/** > > + * struct v4l2_ctrl_mpeg2_sequence - MPEG-2 sequence header > > + * > > + * All the members on this structure match the sequence header and sequence > > + * extension syntaxes as specified by the MPEG-2 specification. > > + * > > + * Fields horizontal_size, vertical_size and vbv_buffer_size are a > > + * combination of respective _value and extension syntax elements, > > + * as described in section 6.3.3 "Sequence header". > > + * > > + * @horizontal_size: combination of elements horizontal_size_value and > > + * horizontal_size_extension. > > + * @vertical_size: combination of elements vertical_size_value and > > + * vertical_size_extension. > > + * @vbv_buffer_size: combination of elements vbv_buffer_size_value and > > + * vbv_buffer_size_extension. > > + * @profile_and_level_indication: see MPEG-2 specification. > > + * @chroma_format: see MPEG-2 specification. > > + * @reserved: padding field. Should be zeroed by applications. > > + * @flags: see V4L2_MPEG2_SEQ_FLAG_{}. > > + */ > > +struct v4l2_ctrl_mpeg2_sequence { > > __u16 horizontal_size; > > __u16 vertical_size; > > __u32 vbv_buffer_size; > > - > > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */ > > __u16 profile_and_level_indication; > > __u8 chroma_format; > > - > > + __u8 reserved; > > __u32 flags; > > }; > > > > @@ -55,30 +77,80 @@ struct v4l2_mpeg2_sequence { > > #define V4L2_MPEG2_PIC_FLAG_LOAD_CHROMA_INTRA 0x0400 > > #define V4L2_MPEG2_PIC_FLAG_LOAD_CHROMA_NON_INTRA 0x0800 > > > > -struct v4l2_mpeg2_picture { > > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */ > > +/** > > + * struct v4l2_ctrl_mpeg2_picture - MPEG-2 picture header > > + * > > + * All the members on this structure match the picture header and picture > > + * coding extension syntaxes as specified by the MPEG-2 specification. > > + * > > + * In particular, the set of quantization load flags V4L2_MPEG2_PIC_FLAG_LOAD_{} > > + * are specified here in order to allow applications to pass non-default > > + * quantization matrices. In this case, applications are expected to use > > + * V4L2_CTRL_TYPE_MPEG2_QUANTIZATION to pass the values of non-default > > + * matrices. > > + * > > + * @picture_coding_type: see MPEG-2 specification. > > + * @f_code[2][2]: see MPEG-2 specification. > > + * @intra_dc_precision: see MPEG-2 specification. > > + * @picture_structure: see V4L2_MPEG2_PIC_{}_FIELD. > > + * @reserved: padding field. Should be zeroed by applications. > > + * @flags: see V4L2_MPEG2_PIC_FLAG_{}. > > + */ > > +struct v4l2_ctrl_mpeg2_picture { > > __u8 picture_coding_type; > > - > > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture coding extension */ > > __u8 f_code[2][2]; > > __u8 intra_dc_precision; > > __u8 picture_structure; > > - > > + __u8 reserved; > > __u32 flags; > > }; > > > > +/** > > + * struct v4l2_ctrl_mpeg2_slice_params - MPEG-2 slice header > > + * > > + * @backward_ref_ts: timestamp of the V4L2 capture buffer to use as > > + * reference for backward prediction. > > + * @forward_ref_ts: timestamp of the V4L2 capture buffer to use as > > + * reference for forward prediction. These timestamp refers to the > > + * timestamp field in struct v4l2_buffer. Use v4l2_timeval_to_ns() > > + * to convert the struct timeval to a __u64. > > + * @quantiser_scale_code: quantiser scale integer matching an > > + * homonymous syntax element. > > + * @reserved: padding field. Should be zeroed by applications. > > + */ > > struct v4l2_ctrl_mpeg2_slice_params { > > __u64 backward_ref_ts; > > __u64 forward_ref_ts; > > - > > - struct v4l2_mpeg2_sequence sequence; > > - struct v4l2_mpeg2_picture picture; > > - > > - /* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */ > > __u32 quantiser_scale_code; > > + __u32 reserved; > > }; > > > > -/* ISO/IEC 13818-2, ITU-T Rec. H.262: Quant matrix extension */ > > +/** > > + * struct v4l2_ctrl_mpeg2_quantization - MPEG-2 quantization > > + * > > + * Quantization matrices as specified by section 6.3.7 > > + * "Quant matrix extension". > > + * > > + * Applications are expected to set the quantization matrices load > > + * flags V4L2_MPEG2_PIC_FLAG_LOAD_{} in struct v4l2_ctrl_mpeg2_picture > > + * to tell the kernel that a non-default matrix shall be used > > + * to decode the picture. > > + * > > + * @intra_quantiser_matrix: The quantization matrix coefficients > > + * for intra-coded frames, in zigzag scanning order. It is relevant > > + * for both luma and chroma components, although it can be superseded > > + * by the chroma-specific matrix for non-4:2:0 YUV formats. > > + * @non_intra_quantiser_matrix: The quantization matrix coefficients > > + * for non-intra-coded frames, in zigzag scanning order. It is relevant > > + * for both luma and chroma components, although it can be superseded > > + * by the chroma-specific matrix for non-4:2:0 YUV formats. > > + * @chroma_intra_quantiser_matrix: The quantization matrix coefficients > > + * for the chominance component of intra-coded frames, in zigzag scanning > > + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. > > + * @chroma_non_intra_quantiser_matrix: The quantization matrix coefficients > > + * for the chrominance component of non-intra-coded frames, in zigzag scanning > > + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. > > + */ > > struct v4l2_ctrl_mpeg2_quantization { > > __u8 intra_quantiser_matrix[64]; > > __u8 non_intra_quantiser_matrix[64]; > > diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h > > index cb25f345e9ad..92f4b508f5de 100644 > > --- a/include/media/v4l2-ctrls.h > > +++ b/include/media/v4l2-ctrls.h > > @@ -43,6 +43,8 @@ struct video_device; > > * @p_u16: Pointer to a 16-bit unsigned value. > > * @p_u32: Pointer to a 32-bit unsigned value. > > * @p_char: Pointer to a string. > > + * @p_mpeg2_sequence: Pointer to a MPEG2 sequence structure. > > + * @p_mpeg2_picture: Pointer to a MPEG2 picture structure. > > * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure. > > * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure. > > * @p_fwht_params: Pointer to a FWHT stateless parameters structure. > > @@ -67,6 +69,8 @@ union v4l2_ctrl_ptr { > > u16 *p_u16; > > u32 *p_u32; > > char *p_char; > > + struct v4l2_ctrl_mpeg2_sequence *p_sequence; > > + struct v4l2_ctrl_mpeg2_picture *p_picture; > > These two should be named p_mpeg2_<name> to match the doc comment. > > I think this series looks good and aligns MPEG-2 ctrls with other codecs. > Together with some fixup at [1] this series is > > Tested-by: Jonas Karlman <jonas@kwiboo.se> > > on RK3288 (Hantro G1) with FFmpeg + Kodi. > > [1] https://github.com/Kwiboo/linux-rockchip/commit/a6942e0a1e5f03078a37a1c575f76d02d7ba775f > Thanks a lot! Just submitted v3 with your tested-by and the above fixes. Ezequiel ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-11-30 19:13 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-11-10 13:27 [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2020-11-05 20:51 [PATCH v2 0/3] MPEG-2 stateless API cleanup Ezequiel Garcia 2020-11-05 20:51 ` [PATCH v2 3/3] media: uapi: mpeg2: Split sequence and picture parameters Ezequiel Garcia 2020-11-10 18:56 ` Dan Carpenter 2020-11-10 18:56 ` Dan Carpenter 2020-11-10 18:56 ` Dan Carpenter 2020-11-29 22:59 ` Jonas Karlman 2020-11-30 19:12 ` Ezequiel Garcia
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.