mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 22:40:18 +00:00
video_codec: moved pixfmt convs to a separate file
Just the conversions grew to a significant amount so it is better to split the file to two to keep the general video codec utility functions in one file and the conversions in the another.
This commit is contained in:
@@ -155,6 +155,7 @@ COMMON_OBJS = \
|
||||
src/ihdtv/ihdtv.o \
|
||||
src/lib_common.o \
|
||||
src/module.o \
|
||||
src/pixfmt_conv.o \
|
||||
src/rtsp/rtsp_utils.o \
|
||||
src/ug_runtime_error.o \
|
||||
tools/ipc_frame_ug.o \
|
||||
|
||||
2683
src/pixfmt_conv.c
Normal file
2683
src/pixfmt_conv.c
Normal file
File diff suppressed because it is too large
Load Diff
106
src/pixfmt_conv.h
Normal file
106
src/pixfmt_conv.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @file pixfmt_conv.h
|
||||
* @author Martin Benes <martinbenesh@gmail.com>
|
||||
* @author Lukas Hejtmanek <xhejtman@ics.muni.cz>
|
||||
* @author Petr Holub <hopet@ics.muni.cz>
|
||||
* @author Milos Liska <xliska@fi.muni.cz>
|
||||
* @author Jiri Matela <matela@ics.muni.cz>
|
||||
* @author Dalibor Matura <255899@mail.muni.cz>
|
||||
* @author Ian Wesley-Smith <iwsmith@cct.lsu.edu>
|
||||
*/
|
||||
/* Copyright (c) 2005-2023 CESNET z.s.p.o.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by CESNET z.s.p.o.
|
||||
*
|
||||
* 4. Neither the name of the 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 PIXFMT_CONV_H_8C5FFAF7_CE36_4885_943F_527153D90865
|
||||
#define PIXFMT_CONV_H_8C5FFAF7_CE36_4885_943F_527153D90865
|
||||
|
||||
#include "types.h" // codec_t
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif // !defined __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DEFAULT_R_SHIFT 0
|
||||
#define DEFAULT_G_SHIFT 8
|
||||
#define DEFAULT_B_SHIFT 16
|
||||
#define DEFAULT_RGB_SHIFT_INIT { DEFAULT_R_SHIFT, DEFAULT_G_SHIFT, DEFAULT_B_SHIFT }
|
||||
|
||||
/**
|
||||
* @brief Defines type for pixelformat conversions
|
||||
*
|
||||
* dst and src must not overlap.
|
||||
*
|
||||
* src should have allocated MAX_PADDING bytes more to accomodate some pixel
|
||||
* block conversions requirements (Already done by vf_alloc_desc_data() and by
|
||||
* RTP stack.)
|
||||
*
|
||||
* @param[out] dst destination buffer
|
||||
* @param[in] src source buffer
|
||||
* @param[in] dst_len expected number of bytes to be written
|
||||
* @param[in] rshift offset of red field inside a word (in bits)
|
||||
* @param[in] gshift offset of green field inside a word (in bits)
|
||||
* @param[in] bshift offset of blue field inside a word (in bits)
|
||||
*
|
||||
* @note
|
||||
* {r,g,b}shift are usually applicable only for output RGBA. If decoder
|
||||
* doesn't output RGBA, values are ignored.
|
||||
*/
|
||||
typedef void decoder_func_t(unsigned char * __restrict dst, const unsigned char * __restrict src, int dst_len, int rshift, int gshift, int bshift);
|
||||
typedef decoder_func_t *decoder_t;
|
||||
|
||||
decoder_t get_decoder_from_to(codec_t in, codec_t out) ATTRIBUTE(const);
|
||||
decoder_t get_best_decoder_from(codec_t in, const codec_t *out_candidates, codec_t *out);
|
||||
|
||||
decoder_func_t vc_copylineRGBA;
|
||||
decoder_func_t vc_copylineToRGBA_inplace;
|
||||
decoder_func_t vc_copylineABGRtoRGB;
|
||||
decoder_func_t vc_copylineRGBtoRGBA;
|
||||
decoder_func_t vc_copylineRGBtoUYVY_SSE;
|
||||
decoder_func_t vc_copylineRGBtoGrayscale_SSE;
|
||||
decoder_func_t vc_copylineUYVYtoRGB_SSE;
|
||||
decoder_func_t vc_copylineUYVYtoGrayscale;
|
||||
decoder_func_t vc_memcpy;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // defined PIXFMT_CONV_H_8C5FFAF7_CE36_4885_943F_527153D90865
|
||||
|
||||
2614
src/video_codec.c
2614
src/video_codec.c
File diff suppressed because it is too large
Load Diff
@@ -53,42 +53,17 @@
|
||||
#include <stdbool.h>
|
||||
#endif // !defined __cplusplus
|
||||
|
||||
#include "pixfmt_conv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DEFAULT_R_SHIFT 0
|
||||
#define DEFAULT_G_SHIFT 8
|
||||
#define DEFAULT_B_SHIFT 16
|
||||
#define DEFAULT_RGB_SHIFT_INIT { DEFAULT_R_SHIFT, DEFAULT_G_SHIFT, DEFAULT_B_SHIFT }
|
||||
#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
|
||||
*
|
||||
* dst and src must not overlap.
|
||||
*
|
||||
* src should have allocated MAX_PADDING bytes more to accomodate some pixel
|
||||
* block conversions requirements (Already done by vf_alloc_desc_data() and by
|
||||
* RTP stack.)
|
||||
*
|
||||
* @param[out] dst destination buffer
|
||||
* @param[in] src source buffer
|
||||
* @param[in] dst_len expected number of bytes to be written
|
||||
* @param[in] rshift offset of red field inside a word (in bits)
|
||||
* @param[in] gshift offset of green field inside a word (in bits)
|
||||
* @param[in] bshift offset of blue field inside a word (in bits)
|
||||
*
|
||||
* @note
|
||||
* {r,g,b}shift are usually applicable only for output RGBA. If decoder
|
||||
* doesn't output RGBA, values are ignored.
|
||||
*/
|
||||
typedef void decoder_func_t(unsigned char * __restrict dst, const unsigned char * __restrict src, int dst_len, int rshift, int gshift, int bshift);
|
||||
typedef decoder_func_t *decoder_t;
|
||||
|
||||
/// Prints list of suppored codecs for video module
|
||||
void show_codec_help(const char *module, const codec_t *codecs8, const codec_t *codecs10, const codec_t *codecs_ge12);
|
||||
/// @returns number of bits per color component
|
||||
@@ -105,8 +80,6 @@ codec_t get_codec_from_fcc(uint32_t fourcc) ATTRIBUTE(const);
|
||||
codec_t get_codec_from_name(const char *name) ATTRIBUTE(const);
|
||||
const char *get_codec_file_extension(codec_t codec) ATTRIBUTE(const);
|
||||
codec_t get_codec_from_file_extension(const char *ext) ATTRIBUTE(const);
|
||||
decoder_t get_decoder_from_to(codec_t in, codec_t out) ATTRIBUTE(const);
|
||||
decoder_t get_best_decoder_from(codec_t in, const codec_t *out_candidates, codec_t *out);
|
||||
|
||||
struct pixfmt_desc get_pixfmt_desc(codec_t pixfmt);
|
||||
int compare_pixdesc(const struct pixfmt_desc *desc_a, const struct pixfmt_desc *desc_b, const struct pixfmt_desc *src_desc);
|
||||
@@ -130,16 +103,6 @@ bool codec_is_planar(codec_t codec) ATTRIBUTE(const);
|
||||
void vc_deinterlace(unsigned char *src, long src_linesize, int lines);
|
||||
bool vc_deinterlace_ex(codec_t codec, unsigned char *src, size_t src_linesize, unsigned char *dst, size_t dst_pitch, size_t lines);
|
||||
|
||||
decoder_func_t vc_copylineRGBA;
|
||||
decoder_func_t vc_copylineToRGBA_inplace;
|
||||
decoder_func_t vc_copylineABGRtoRGB;
|
||||
decoder_func_t vc_copylineRGBtoRGBA;
|
||||
decoder_func_t vc_copylineRGBtoUYVY_SSE;
|
||||
decoder_func_t vc_copylineRGBtoGrayscale_SSE;
|
||||
decoder_func_t vc_copylineUYVYtoRGB_SSE;
|
||||
decoder_func_t vc_copylineUYVYtoGrayscale;
|
||||
decoder_func_t vc_memcpy;
|
||||
|
||||
bool clear_video_buffer(unsigned char *data, size_t linesize, size_t pitch, size_t height, codec_t color_spec);
|
||||
|
||||
void uyvy_to_i422(int width, int height, const char *in, char *out);
|
||||
|
||||
@@ -21,7 +21,7 @@ astat_lib: astat.a
|
||||
astat.a: astat.o src/compat/platform_pipe.o
|
||||
ar rcs astat.a $^
|
||||
|
||||
convert: src/video_codec.o src/compat/platform_time.o convert.o src/debug.o src/utils/color_out.o src/utils/misc.o
|
||||
convert: src/pixfmt_conv.o src/video_codec.o src/compat/platform_time.o convert.o src/debug.o src/utils/color_out.o src/utils/misc.o
|
||||
$(CXX) $^ -o convert
|
||||
|
||||
decklink_temperature: decklink_temperature.cpp ext-deps/DeckLink/Linux/DeckLinkAPIDispatch.o
|
||||
|
||||
Reference in New Issue
Block a user