summaryrefslogtreecommitdiff
path: root/gst-libs/gst/codecparsers
Commit message (Collapse)AuthorAgeFilesLines
* gsth264parser: Fix handling of NALs with emulation byte setMarek Vasut2021-09-091-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case a set of NALs with emulation_prevention_three_byte is decoded using hardware decoder like Hantro G1, wrong struct v4l2_ctrl_h264_decode_params .dec_ref_pic_marking_bit_size is passed into the kernel, which results in decoding artifacts. Subtract the number of emulation three bytes from the .dec_ref_pic_m->bit_size to get the correct bit size and avoid having these artifacts. Apply the exact same fix to slice->pic_order_cnt_bit_size as well. The following NALs (7, 8, 6, 5) decode with artifacts, .dec_ref_pic_marking_bit_size is set to 10 without this patch. 00000000 00 00 00 01 27 4d 00 20 89 8b 60 3c 04 bf 2e 02 |....'M. ..`<....| 00000010 d4 18 04 18 c0 c0 01 77 00 00 5d c1 7b df 05 00 |.......w..].{...| 00000020 00 00 01 28 ee 1f 20 00 00 01 06 05 10 b9 ed b9 |...(.. .........| 00000030 30 5d 21 4b 71 83 71 2c 10 a3 14 bb 29 80 00 00 |0]!Kq.q,....)...| 00000040 01 25 b8 00 05 00 00 03 03 7f fa 78 1e e7 fd fe |.%.........x....| ^^^^^^^^^^^^--- emulation 3 byte 00000050 b4 62 7a 31 ff 7d 81 fd 26 d8 62 b6 d6 25 46 ae |.bz1.}..&.b..%F.| The following NALs (7, 8, 6, 5) decode fine, .dec_ref_pic_marking_bit_size is set to 2 without this patch. 00000000 00 00 00 01 27 4d 00 20 89 8b 60 3c 04 bf 2e 02 |....'M. ..`<....| 00000010 d4 18 04 18 c0 c0 01 77 00 00 5d c1 7b df 05 00 |.......w..].{...| 00000020 00 00 01 28 ee 1f 20 00 00 01 06 05 10 b9 ed b9 |...(.. .........| 00000030 30 5d 21 4b 71 83 71 2c 10 a3 14 bb 29 80 00 00 |0]!Kq.q,....)...| 00000040 01 25 b8 00 04 c0 00 03 7f fa 78 1e e7 fd fe b4 |.%........x.....| 00000050 62 7a 31 ff 7d 81 fd 26 d8 62 b6 d6 25 46 ae ce |bz1.}..&.b..%F..| Fixes: d0d65fa875 ("codecparsers: h264: record dec_ref_pic_marking() size") Fixes: 0cc7d6f093 ("codecparsers: h264: record pic_order_cnt elements size") Signed-off-by: Marek Vasut <marex@denx.de> Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2517>
* gsth264parser: reject memory management control op greater than 6Aaron Boxer2021-09-091-1/+1
| | | | | | | | This prevents assertion from being thrown in gst_h264_dpb_perform_memory_management_control_operation if corrupt NAL has a control op greater than 6 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2508>
* gsth264parser: fix typo in debug messageBrad Hards2021-08-271-1/+1
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2493>
* Use g_memdup2() where available and add fallback for older GLib versionsTim-Philipp Müller2021-08-051-1/+1
| | | | | | | g_memdup() is deprecated since GLib 2.68 and we want to avoid deprecation warnings with recent versions of GLib. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2280>
* codecparsers: av1: fix underflow in last_frame_idxDaniel Almeida2021-07-121-1/+1
| | | | | | | | | The spec mandates this field be parsed using unsigned arithmetic. Nevertheless, av1parser will use -1 apparently as an uninitialized value in gst_av1_parse_frame_header. This immediately underflows last_frame_idx though, since its type was defined as guint8. Fix this by converting to gint8. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2401>
* codecparsers: vp9parser: Use macro to define the size of filter_level in ↵He Junyan2021-07-021-1/+1
| | | | | | Segmentation. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2369>
* codecparsers: vp9parser: Delete the verbose redefine of MAX_LOOP_FILTER.He Junyan2021-07-021-1/+0
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2369>
* av1parser: Fix tile size calculationSeungha Yang2021-06-291-1/+1
| | | | | | | Remaining size should exclude already read "tile size bits". And see also "5.11.1. General tile group OBU syntax" Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2365>
* jpeg2000parse, openjpeg: add support for YCrCb 4:1:1 samplingStéphane Cerveau2021-06-142-12/+24
| | | | | | | Add YCrCb 4:1:1 support in openjpeg elements and fix in jpeg2000parse the YCrCb 4:1:0 support Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2321>
* h2645parser: Catch overflows in AVC/HEVC NAL unit length calculationsSebastian Dröge2021-03-242-2/+30
| | | | | | | | | | | | | | | | | | | Offset and size are stored as 32 bit guint and might overflow when adding the nal_length_size, so let's avoid that. For the size this would happen if the AVC/HEVC NAL unit size happens to be stored in 4 bytes and is 4294967292 or higher, which is likely corrupted data anyway. For the offset this is something for the caller of these functions to take care of but is unlikely to happen as it would require parsing on a >4GB buffer. Allowing these overflows causes all kinds of follow-up bugs in the h2645parse elements, ranging from infinite loops and memory leaks to potential memory corruptions. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2103>
* gst: don't use volatile to mean atomicMatthew Waters2021-03-221-1/+1
| | | | | | | | | | | | volatile is not sufficient to provide atomic guarantees and real atomics should be used instead. GCC 11 has started warning about using volatile with atomic operations. https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719 Discovered in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/868 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2098>
* codecparsers: av1: Fix a typo in frame_restoration_type setting.He Junyan2021-01-231-3/+3
| | | | | Fixes: #1500 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1974>
* codecparsers: Exclude the size of obu_size when identify OBU.He Junyan2021-01-191-1/+5
| | | | | | | obu->obu_size does not contain the bytes of obu_size itself, we need to exclude it when doing the saint check. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1614>
* codecparsers: av1: add the set_operating_point() API.He Junyan2020-11-172-2/+35
| | | | | | | | | The av1 can support multi layers when scalability is enabled. We need an API to set the operating point and filter the OBUs just belonging to some layers(the layers are specified by the operating point). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Add an API to reset the annex_b state only.He Junyan2020-11-172-18/+37
| | | | | | | | | | | | | In practice, we encounter streams that have one or more temporal units error. When that kind of error temporal units is in annex b format, the whole temporal unit should be discarded. But the temporal units before it are correct and can be used. More important, because of the error temporal unit, the parser is in a wrong state and all later temporal unit are also parsed uncorrectly. We need to add this API to reset the annex_b state only when we meet some temporal unit error. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: clean the seen_frame_header in parse_tile_group().He Junyan2020-11-171-10/+9
| | | | | | | | The current seen_frame_header is not cleaned correctly. According to the spec, it should be cleaned when tiles are parsed completely. Also delete a verbose seen_frame_header init in reset_state(). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: fix a typo in parse_metadata_scalabilityHe Junyan2020-11-171-1/+1
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Do not assert in identify_one_obu when check annex b size.He Junyan2020-11-171-4/+10
| | | | | | | Some buggy stream just writes the wrong temporal unit and frame size in the stream. We should return failure rather than assert to abort. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Add unknow AV1 profile define for saint check.He Junyan2020-11-171-0/+9
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Improve the parse_tile_info.He Junyan2020-11-172-13/+34
| | | | | | | | | | | | 1. store more tile info when parse tile group. The column, row, tile offset and tile data size are all useful for decoder process, especially for HW kind decoder such as VAAPI dec. Also fix the tile group skip size for each tile data. 2. No min_inner_tile_width requirement in newest spec. 3. Calculate the sbs of each tile for both uniform tile and non-uniformi tile. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Fix a tile info read typo in frame header.He Junyan2020-11-171-1/+1
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Fix a typo when get value of segmentation params.He Junyan2020-11-171-1/+2
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: add valid check for global motion params.He Junyan2020-11-172-0/+162
| | | | | | | | The global motion params and its matrix values need to be verified before we use them. If it is invalid, we should notify the decoder that it should not be used. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: uint8 range is not enough for av1_bitstreamfn_nsHe Junyan2020-11-171-2/+2
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: delete duplicated GST_AV1_GM_ABS_ALPHA_BITS define.He Junyan2020-11-171-1/+0
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Improve the loop filter setting.He Junyan2020-11-172-65/+54
| | | | | | | | | 1. loop_filter_ref_deltas should be int because it needs to compare with 0. 2. Move the loop filter init logic to setup_past_independence() and load_previous(), which make it more precise with the spec. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Fix a error report for metadata obu.He Junyan2020-11-171-1/+7
| | | | | | | | | The metadata OBUs, for example, ITUT_T35 has an undefined payload such as itu_t_t35_payload_bytes field in AV1 spec, which may cause the failure of parsing the trailings bits. We can give a warning and ignore this kind of errors. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: Fix a level index bug in sequence.He Junyan2020-11-171-1/+1
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* codecparsers: av1: all ref idx should be gint8.He Junyan2020-11-172-4/+9
| | | | | | | All the ref index need to compare with 0 in reference index decision algorithm. We also need to init them to -1. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1464>
* h265parser: Fix wrong warning messageNicolas Dufresne2020-11-041-1/+1
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1714>
* h265parse: Add missing const qualifierNicolas Dufresne2020-11-022-11/+13
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1750>
* Meson: Use pkg-config generatorXavier Claessens2020-10-231-0/+10
|
* codecparsers: h264parser: guard against ref_pic_markings overflowAndrew Wesie2020-10-161-3/+7
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1703>
* codecparsers: vp8parser: clear the frame_hdr before parsing.He Junyan2020-09-251-0/+2
| | | | | | | Uninited frame_hdr may have garbage and may contain some wrong results after the parsing process. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1587>
* h265parse: recognize more HEVC extension streamsHaihao Xiang2020-09-162-0/+91
| | | | | | | | | | | | There are streams which have the right general_profile_idc and general_profile_compatibility_flag, but don't have the right extension flags. We may try to use chroma_format_idc and bit_depth to recognize these streams. e.g. https://www.itu.int/wftp3/av-arch/jctvc-site/bitstream_exchange/draft_conformance/SCC/IBF_Disabled_A_MediaTek_2.zip Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1328>
* h265parser: select the right profile for high throughput SCC streamHaihao Xiang2020-09-161-12/+22
| | | | | | | | | | | | | | Currently screen-extended-high-throughput-444 is recognized as screen-extended-main-444, screen-extended-high-throughput-444-10 is recognized as screen-extended-main-444-10 because they have the same extension flags, so without this patch, it is possible that a decoder which supports SCC but doesn't support throughput SCC will try to decode a throughput SCC stream. e.g. https://www.itu.int/wftp3/av-arch/jctvc-site/bitstream_exchange/draft_conformance/SCC/HT_A_SCC_Apple_2.zip Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1328>
* h265parser: Fix possible invalid memory accessSeungha Yang2020-07-142-4/+19
| | | | | | | | | | | ... and do more strict validation for num_tile_columns_minus1 and num_tile_rows_minus1. As per specification Table A.8, allowed maximum number of tile rows and tile columns are 22 and 20, respectively. So we should adjust the size of each array. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1372>
* nalutils: Improve slightly the error traceNicolas Dufresne2020-06-201-18/+22
| | | | | | | | | | | Until now, bound check would simply trace the values and the range. This enhances the trace by also tracing the name of the variable that was to be set or read. This is not magically perfect in all cases, but greatly speed the debugging work. Here's an example before and after this change: Before: gst_h264_parser_parse_slice_hdr: value not in allowed range. value: 819183, range -87-77 After: gst_h264_parser_parse_slice_hdr: value for 'slice->slice_qp_delta' not in allowed range. value: 819183, range -87-77 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1356>
* codecparsers: fix typo in GstH265RegisteredUserData docStéphane Cerveau2020-05-271-1/+1
| | | | Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1303>
* codecparsers: h264: Only set relevant default weight valuesNicolas Dufresne2020-05-191-4/+4
| | | | | | | This is minor optimization to avoid setting values we don't need. It also makes debugging easier since only relevant values a non-zero now. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1238>
* codecparsers: h264: Fix default ref list sizeNicolas Dufresne2020-05-191-2/+11
| | | | | | | | The default in PPS was not applied properly. The default does not apply for I-Slice and l1 default only applies for B-Slice. This fixes the slice values for num_ref_idx_l0_active_minus1 and num_ref_idx_l1_active_minus1. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1238>
* h265parse: Ensure parsing ends on start-code + full headerNicolas Dufresne2020-05-071-0/+9
| | | | | | | | | | | | | | | | | The parser is used all over the place assuming that after calling gst_h265_parser_identify_nalu(), the start-code found is can also be identified. In H264 this works, because scan_for_start_code rely on gst_byte_reader_masked_scan_uint32() that ensures that 1 byte passed the 3 bytes start code is found. But for HEVC, we need two bytes to identify the following NAL. This patch will return NO_NAL_END, even if a start code is found in the case there was not enough bytes. This solution was chosen to maintain backward compatibility, and reduce complexicity. Fixes #1287 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1251>
* h264parser: Removed impossible error caseNicolas Dufresne2020-05-071-6/+0
| | | | | | | | | | Same as done for H264, this error was trying to catch the case where we had a start code without any bytes afterward. This will never happen since the start code scanner only returns a match if there is one byte after start code (pattern 0x00000100 / mask 0xffffff00). In H264, once byte is sufficient to identify the NALU. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1251>
* h264parse: Properly handle 4 bytes start codeNicolas Dufresne2020-05-071-6/+3
| | | | | | | | | | | This will stop stripping four bytes start code. This was fixed and broken again as it was causing the a timestamp shift. We now call gst_base_parse_set_ts_at_offset() with the offset of the first NAL to ensure that fixing a moderatly broken input stream won't affect the timestamps. We also fixes the unit test, removing a comment about the stripping behaviour not being correct. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1251>
* h265parser: Fix NAL size check for identificationNicolas Dufresne2020-05-071-0/+7
| | | | | | | | | | Unlike H264, H265 requires 2 bytes after the start code to allow NAL identification. This would otherwise report a broken NAL and skip important data. Fixes #1287 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1251>
* h265parser: Removed impossible error caseNicolas Dufresne2020-05-071-6/+0
| | | | | | | | | This error was trying to catch the case where we had a start code without any bytes afterward. This will never happen since the start code scanner only returns a match if there is one byte adter start code (pattern 0x00000100 / mask 0xffffff00). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1251>
* libs: parser: h265: Add SCC extension support.He Junyan2020-05-052-6/+259
| | | | | | Add support for screen content coding extensions profiles. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1146>
* libs: parser: Adds AV1 parser.Georg Ottinger2020-05-013-0/+6310
| | | | | | | | | | | | | | | | This is the first version of AV1 parser implementation in GStreamer. A test file is also provied with several test cases. It contains a test sequence taken from the aom testdata set, with one key and one inter-frame. The same test sequence has been reencoded to annexb. testdata is taken from aom testdata (and reencoded for annexb) as well as handcrafted testcases. Once reference testdata is available, the testing could be imporved aswell. Co-author: He Junyan <junyan.he@hotmail.com> Co-author: Víctor Manuel Jáquez Leal <vjaquez@igalia.com> Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/785>
* libs: h265parser: Add High throughput scc extensions profiles' IDC.He Junyan2020-04-282-1/+6
| | | | | | It is compitable with scc and we use scc's function to identify it. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1121>
* libs: h265parser: select extension profile by profile idc.He Junyan2020-04-281-132/+185
| | | | | | | | | | | | | the old manner does not consider the profile idc. The profile idc should play an more important role in recognizing the profile than the other information. And there is no need to mix profiles of different extensions together to find the closest profile when the bits stream is not standard, different extensions support different features and should not be mixed. The correct way should be recognize the extension category by profile idc firstly, and then find the closest profile. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1121>