diff --git a/src/transmit.cpp b/src/transmit.cpp index fd913da30..1d27fbaaf 100644 --- a/src/transmit.cpp +++ b/src/transmit.cpp @@ -80,7 +80,6 @@ #include "tv.h" #include "transmit.h" #include "utils/jpeg_reader.h" -#include "utils/math.h" #include "video.h" #include "video_codec.h" @@ -534,8 +533,7 @@ static vector get_packet_sizes(struct video_frame *frame, int substream, in } int fec_symbol_offset = 0; - int pf_block_size = is_codec_opaque(frame->color_spec) ? 1 : lcm(get_pf_block_size(frame->color_spec), 48); // 6/8 -> RGB/A convertible to UYVY (multiple of 2 pixs) - // 48 -> RG48 to R12L; @todo figure out better solution + int pf_block_size = is_codec_opaque(frame->color_spec) ? 1 : round(PIX_BLOCK_LCM * get_bpp(frame->color_spec)); unsigned pos = 0; do { int len = get_video_pkt_len(frame->fec_params.type != FEC_NONE, mtu, diff --git a/src/utils/math.h b/src/utils/math.h deleted file mode 100644 index 7c60e08d1..000000000 --- a/src/utils/math.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file utils/math.h - * @author Martin Pulec - */ -/* - * Copyright (c) 2022 CESNET, z. s. p. o. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, is permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of CESNET nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef UTILS_MATH_H_7D3DA851_76A8_4022_B14B_8CCEFEF580B4 -#define UTILS_MATH_H_7D3DA851_76A8_4022_B14B_8CCEFEF580B4 - -static inline int gcd(int a, int b) -{ - // Everything divides 0 - if (a == 0) { - return b; - } - if (b == 0) { - return a; - } - - // base case - if (a == b) { - return a; - } - - // a is greater - if (a > b) { - return gcd(a-b, b); - } - return gcd(a, b-a); -} - -static inline int lcm(int a, int b) { - return a * b / gcd(a, b); -} - -#endif // ! defined UTILS_MATH_H_7D3DA851_76A8_4022_B14B_8CCEFEF580B4 - diff --git a/src/video_codec.h b/src/video_codec.h index ff2aade0a..9858d926b 100644 --- a/src/video_codec.h +++ b/src/video_codec.h @@ -60,6 +60,7 @@ extern "C" { #define MAX_BPS 8 /* for Y416 */ ///< maximal (average) number of pixels per know pixel formats (up-round if needed) #define MAX_PADDING 64 ///< maximal padding in bytes that may be needed to align to pixfmt block size for Y416->R12L: ///< 64 = vc_linesize(8 /*maximal block pix count (R12L)*/, Y416 /*codec with maximal lenght of 1st arg-sized block*/) +#define PIX_BLOCK_LCM 24 ///< least common multiple of all pixfmt block sizes in pixels (codec_info_t::block_size/codec_info_t::bpp). "contributors:" 8 R12L, 6 v210 /** * @brief Defines type for pixelformat conversions