def test_fragment_slices_not_contiguous(): e = exceptions.FragmentSlicesNotContiguous( initial_fragment_offset=(10, 6), this_fragment_offset=(20, 6), fragment_x_offset=10, fragment_y_offset=11, expected_fragment_x_offset=12, expected_fragment_y_offset=13, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ The current picture fragment's slices are non-contiguous (14.2). The fragmented picture starting at bit offset 81 contains a fragment at bit offset 161 with an unexpected start offset: * fragment_x_offset = 10 (should be 12) * fragment_y_offset = 11 (should be 13) Fragmented pictures must include picture slices in raster-scan order starting with sx=0, sy=0 and without leaving any gaps. """ ) assert dedent(e.bitstream_viewer_hint()) == dedent( """ To view the offending part of the bitstream: {cmd} {file} --from-offset 81 --to_offset {offset} --show fragment_parse --hide slice """ )
def test_inconsistent_next_parse_offset(): e = exceptions.InconsistentNextParseOffset( 100, 15, 20, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ Incorrect next_parse_offset value in parse info: got 15 bytes, expected 20 bytes (10.5.1). The erroneous parse info block begins at bit offset 800 and is followed by the next parse info block at bit offset 960. Does the next_parse_offset include the 13 bytes of the parse info header? Is next_parse_offset given in bits, not bytes? """ ) assert dedent(e.bitstream_viewer_hint()) == dedent( """ To view the erroneous parse info block: {cmd} {file} --offset 800 --after-context 144 To view the following parse info block: {cmd} {file} --offset {offset} --after-context 144 """ ) assert e.offending_offset() == 800
def test_too_many_slices_in_fragmented_picture(): e = exceptions.TooManySlicesInFragmentedPicture( initial_fragment_offset=(10, 6), this_fragment_offset=(20, 6), fragment_slices_received=10, fragment_slices_remaining=5, fragment_slice_count=6, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ The current fragmented picture contains too many picture slices (14.2). This fragmented picture (starting at bit offset 81) consists of a total of 15 picture slices. 10 slices have already been received but the current fragment (at bit offset 161) contains 6 slices while only 5 more are expected. """ ) assert dedent(e.bitstream_viewer_hint()) == dedent( """ To view the offending part of the bitstream: {cmd} {file} --from-offset 81 --to_offset {offset} --show fragment_parse --hide slice """ )
def test_picture_number_changed_mid_fragmented_picture(): e = exceptions.PictureNumberChangedMidFragmentedPicture( last_picture_number_offset=(10, 6), last_picture_number=100, picture_number_offset=(20, 6), picture_number=101, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ The picture number changed from 100 to 101 within the same fragmented picture (14.2). The previous fragment in this fragmented picture defined its picture number at bit offset 81. The current fragment provided a different picture number at bit offset 161. Was the picture number incremented for every fragment rather than for every complete picture in the stream? """ ) assert dedent(e.bitstream_viewer_hint()) == dedent( """ To view the offending part of the bitstream: {cmd} {file} --from-offset 81 --to_offset {offset} --show fragment_parse --hide slice """ )
def test_picture_interleaved_with_fragmented_picture(): e = exceptions.PictureInterleavedWithFragmentedPicture( initial_fragment_offset=(10, 6), this_offset=(20, 6), fragment_slices_received=10, fragment_slices_remaining=5, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ A non-fragmented picture was encountered while 5 slices are still outstanding in a fragmented picture (14.2). The fragmented picture started at bit offset 81 and 10 of 15 expected slices were received before the non-fragmented picture was encountered at bit offset 161. Were some picture fragments omitted when copying a fragmented picture from another sequence? """ ) assert dedent(e.bitstream_viewer_hint()) == dedent( """ To view the offending part of the bitstream: {cmd} {file} --from-offset 81 --to_offset {offset} --show parse_info --show fragment_parse --show picture_parse --hide slice """ )
def test_level_invalid_sequence(): e = exceptions.LevelInvalidSequence( tables.ParseCodes.high_quality_picture_fragment, [ tables.ParseCodes.end_of_sequence, tables.ParseCodes.padding_data, tables.ParseCodes.auxiliary_data, tables.ParseCodes.high_quality_picture, tables.ParseCodes.low_delay_picture, ], False, tables.Levels.sub_sd, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ The current sequence does not match the structure required by the current level, 1, (SMPTE ST 2042-2:2017). Either pictures or picture fragments may be used in a stream, but not both. The parse code high quality picture fragment (0xEC) was encountered but end of sequence (0x10) or padding data (0x30) or auxiliary data (0x20) or high quality picture (0xE8) or low delay picture (0xC8) expected. """ )
def test_incompatible_level_and_video_format_error(codec_features): assert wrap_paragraphs( IncompatibleLevelAndVideoFormatError( codec_features).explain()) == wrap_paragraphs(""" Level unconstrained (0) specified for minimal but the video format requested is not permitted by this level. """)
def test_invalid_slice_y_length(): e = exceptions.InvalidSliceYLength( slice_y_length=100, slice_bytes=10, sx=1, sy=2, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ Low-delay slice_y_length value, 100, is out of range, expected a value no greater than 66 (13.5.3.1). * The current slice (sx=1, sy=2) is 10 bytes (80 bits) long (see slice_bytes() (13.5.3.2)). * 7 bits are reserved for the qindex field. * intlog2(73) = 7 bits are reserved for the slice_y_length field. * This leaves 66 bits to split between the luminance and color difference components. Was the size of this slice correctly computed? Were the size of the qindex and slice_y_length fields accounted for? """ )
def test_fragmented_picture_restarted(): e = exceptions.FragmentedPictureRestarted( initial_fragment_offset=(10, 6), this_fragment_offset=(20, 6), fragment_slices_received=10, fragment_slices_remaining=5, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ A picture fragment with fragment_slice_count=0 was encountered while 5 slices are still outstanding (14.2). The previous fragmented picture started at bit offset 81 and 10 of 15 expected slices were received before the current picture fragment with fragment_slice_count=0 arrived at bit offset 161. Was a picture fragment with fragment_slice_count=0 incorrectly used as padding while waiting for some picture slices to be ready? Were some picture fragments omitted when copying a fragmented picture from another sequence? """ ) assert dedent(e.bitstream_viewer_hint()) == dedent( """ To view the offending part of the bitstream: {cmd} {file} --from-offset 81 --to_offset {offset} --show fragment_parse --hide slice """ )
def test_all_zeros(self): e = exceptions.PictureDimensionsNotMultipleOfFrameDimensions( luma_width=0, luma_height=0, color_diff_width=0, color_diff_height=0, frame_width=2000, frame_height=1000, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ The frame dimensions cannot be evenly divided by the current color difference sampling format and picture coding mode (11.6.2) Frame dimensions: * frame_width: 2000 * frame_height: 1000 The dimensions computed by picture_dimensions were: * luma_width: 0 (not a factor of 2000) * luma_height: 0 (not a factor of 1000) * color_diff_width: 0 (not a factor of 2000) * color_diff_height: 0 (not a factor of 1000) Was a frame size with an odd width or height used along with a non-4:4:4 color difference sampling mode or when pictures are fields? Was the source sampling mode (11.4.5) used instead of the picture coding mode (11.5) to determine the picture size? """ )
def test_non_conseuctive_picture_numbers(): e = exceptions.NonConsecutivePictureNumbers( last_picture_number_offset=(10, 6), last_picture_number=100, picture_number_offset=(20, 6), picture_number=200, ) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ Non-consecutive picture number, got 200 after 100 (12.2) and (14.2). Picture numbers must have consecutive, ascending integer values, wrapping at (2**32)-1 back to 0. * Previous picture number defined at bit offset 81 * Current picture number defined at bit offset 161 Was this picture taken from another sequence without being assigned a new picture number? """ ) assert dedent(e.bitstream_viewer_hint()) == dedent( """ To view the erroneous picture number definition: {cmd} {file} --offset 161 To view the previous picture number definition: {cmd} {file} --offset 81 """ )
def test_zero_pixel_frame_size(): e = exceptions.ZeroPixelFrameSize(10, 0) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid custom frame size, 10x0 was provided containing zero pixels (11.4.3). """ )
def test_picture_bytes_specified_for_lossless_mode_error(codec_features): codec_features["lossless"] = True codec_features["picture_bytes"] = 123 assert wrap_paragraphs( PictureBytesSpecifiedForLosslessModeError( codec_features).explain()) == wrap_paragraphs(""" The codec configuration minimal specifies a lossless format but did not omit picture_bytes (it is set to 123). """)
def test_bad_preset_transfer_function(): e = exceptions.BadPresetTransferFunction(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid transfer function index, 999, was provided (11.4.10.4). See (Table 11.9) for an enumeration of allowed values. """ )
def test_bad_preset_color_matrix(): e = exceptions.BadPresetColorMatrix(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid color matrix index, 999, was provided (11.4.10.3). See (Table 11.8) for an enumeration of allowed values. """ )
def test_bad_preset_color_spec(): e = exceptions.BadPresetColorSpec(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid preset color spec index, 999, was provided (11.4.10.1). See (Table 11.6) for an enumeration of allowed values. """ )
def test_bad_preset_signal_range(): e = exceptions.BadPresetSignalRange(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid preset signal range index, 999, was provided (11.4.9). See (Table 11.5) for an enumeration of allowed values. """ )
def test_pixel_aspect_ratio_contains_zeros(): e = exceptions.PixelAspectRatioContainsZeros(2, 0) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid pixel aspect ratio, 2:0, was provided (11.4.7). Pixel aspect ratios must be valid ratios (i.e. not contain zeros). """ )
def test_frame_rate_has_zero_denominator(): e = exceptions.FrameRateHasZeroDenominator(10) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid frame rate, 10/0 fps, was provided (11.4.6). The frame rate specification contains a division by zero. """ )
def test_frame_rate_has_zero_numerator(): e = exceptions.FrameRateHasZeroNumerator(10) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid frame rate, 0/10 fps, was provided (11.4.6). Frame rates must not be zero. """ )
def test_bad_preset_frame_rate_index(): e = exceptions.BadPresetFrameRateIndex(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid preset frame rate index, 999, was provided (11.4.6). See (Table 11.3) for an enumeration of allowed values. """ )
def test_bad_source_sampling_mode(): e = exceptions.BadSourceSamplingMode(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid source sampling mode, 999, was provided (11.4.5). See (11.4.5) for an enumeration of allowed values. """ )
def test_bad_preset_color_primaries(): e = exceptions.BadPresetColorPrimaries(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid color primaries index, 999, was provided (11.4.10.2). See (Table 11.7) for an enumeration of allowed values. """ )
def test_bad_preset_pixel_aspect_ratio(): e = exceptions.BadPresetPixelAspectRatio(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid preset pixel aspect ratio index, 999, was provided (11.4.7). See (Table 11.4) for an enumeration of allowed values. """ )
def test_slice_bytes_has_zero_denom(): e = exceptions.SliceBytesHasZeroDenominator(10) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ Invalid slice bytes count, 10/0, in slice parameters (12.4.5.2). Division by zero. """ )
def test_zero_slices_in_coded_picture(): e = exceptions.ZeroSlicesInCodedPicture(10, 0) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ Invalid slice count, 10x0, specified in slice parameters (12.4.5.2). There must be at least one slice in either dimension. """ )
def test_bad_picture_coding_mode(): e = exceptions.BadPictureCodingMode(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid picture coding mode, 999, was provided in a sequence header (11.5). See (11.5) for an enumeration of allowed values. """ )
def test_bad_color_difference_sampling_format(): e = exceptions.BadColorDifferenceSamplingFormat(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid color difference sampling format, 999, was provided (11.4.4). See (Table 11.2) for an enumeration of allowed values. """ )
def test_slice_bytes_is_less_than_one(): e = exceptions.SliceBytesIsLessThanOne(10, 11) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ Slice bytes count, 10/11, in slice parameters is less than one (12.4.5.2). Slices must be at least 1 byte. """ )
def test_bad_ho_wavelet_index(): e = exceptions.BadHOWaveletIndex(999) assert wrap_paragraphs(e.explain()) == wrap_paragraphs( """ An invalid horizontal only wavelet index, 999, was provided in the extended transform parameters (12.4.4.2). See (Table 12.1) for an enumeration of allowed values. """ )