![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
This file contains video codec-related functions. More...
#include "config_unix.h"#include "config_win32.h"#include <assert.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "color.h"#include "compat/qsort_s.h"#include "debug.h"#include "host.h"#include "hwaccel_vdpau.h"#include "hwaccel_drm.h"#include "utils/macros.h"#include "video_codec.h"
Go to the source code of this file.
Classes | |
| struct | alternative_codec_name |
| struct | alternative_fourcc |
| struct | codec_info_t |
| struct | pixfmt_plane_info_t |
| for planar pixel formats More... | |
Macros | |
| #define | __STDC_WANT_LIB_EXT1__ 1 |
| #define | BYTE_SWAP(x) |
| #define | HW_VDPAU_FRAME_SZ 0 |
Functions | |
| bool | clear_video_buffer (unsigned char *data, size_t linesize, size_t pitch, size_t height, codec_t color_spec) |
| void | codec_get_planes_subsampling (codec_t pix_fmt, int *sub) |
| bool | codec_is_420 (codec_t pix_fmt) |
| bool | codec_is_a_rgb (codec_t codec) |
| Returns TRUE if specified pixelformat is some form of RGB (not YUV). | |
| bool | codec_is_const_size (codec_t codec) |
| Returns TRUE if specified pixelformat has constant size regardles of resolution. If so the block_size value represents the size. | |
| bool | codec_is_hw_accelerated (codec_t codec) |
| bool | codec_is_in_set (codec_t codec, const codec_t *set) |
| bool | codec_is_planar (codec_t codec) |
| int | compare_pixdesc (const struct pixfmt_desc *desc_a, const struct pixfmt_desc *desc_b, const struct pixfmt_desc *src_desc) |
| int | get_bits_per_component (codec_t codec) |
| double | get_bpp (codec_t codec) |
| const char * | get_codec_file_extension (codec_t codec) |
| codec_t | get_codec_from_fcc (uint32_t fourcc) |
| codec_t | get_codec_from_file_extension (const char *ext) |
| codec_t | get_codec_from_name (const char *name) |
| static codec_t | get_codec_from_name_wo_alias (const char *name) |
| const char * | get_codec_name (codec_t codec) |
| const char * | get_codec_name_long (codec_t codec) |
| uint32_t | get_fourcc (codec_t codec) |
| int | get_pf_block_bytes (codec_t codec) |
| returns codec_info_t::block_size_bytes | |
| int | get_pf_block_pixels (codec_t codec) |
| returns codec_info_t::block_size_pixels | |
| const char * | get_pixdesc_desc (struct pixfmt_desc desc) |
| struct pixfmt_desc | get_pixfmt_desc (codec_t pixfmt) |
| int | get_subsampling (codec_t codec) |
| void | i420_16_to_y416 (int width, int height, const unsigned char *in, unsigned char *out, int in_depth) |
| void | i420_8_to_uyvy (int width, int height, const unsigned char *in, unsigned char *out) |
| void | i422_16_to_y416 (int width, int height, const unsigned char *in, unsigned char *out, int in_depth) |
| void | i422_8_to_uyvy (int width, int height, const unsigned char *in, unsigned char *out) |
| void | i444_16_to_y416 (int width, int height, const unsigned char *in, unsigned char *out, int in_depth) |
| void | i444_8_to_uyvy (int width, int height, const unsigned char *in, unsigned char *out) |
| bool | is_codec_interframe (codec_t codec) |
| bool | is_codec_opaque (codec_t codec) |
| bool | pixdesc_equals (struct pixfmt_desc desc_a, struct pixfmt_desc desc_b) |
| void | show_codec_help (const char *module, const codec_t *codecs8, const codec_t *codecs10, const codec_t *codecs_ge12) |
| Prints list of suppored codecs for video module. | |
| void | uyvy_to_i422 (int width, int height, const unsigned char *in, unsigned char *out) |
| void | vc_deinterlace (unsigned char *src, long src_linesize, int lines) |
| Deinterlaces framebuffer. | |
| bool | vc_deinterlace_ex (codec_t codec, unsigned char *src, size_t src_linesize, unsigned char *dst, size_t dst_pitch, size_t lines) |
| size_t | vc_get_datalen (unsigned int width, unsigned int height, codec_t codec) |
| int | vc_get_linesize (unsigned int width, codec_t codec) |
| int | vc_get_size (unsigned int width, codec_t codec) |
| void | watch_pixfmt_degrade (const char *mod_name, struct pixfmt_desc desc_src, struct pixfmt_desc desc_dst) |
| void | y416_to_i444 (int width, int height, const unsigned char *in, unsigned char *out, int depth) |
Variables | |
| static const struct codec_info_t | codec_info [] |
| static const struct alternative_codec_name | codec_name_aliases [] |
| static const struct alternative_fourcc | fourcc_aliases [] |
| char | pixfmt_conv_pref [] = "dsc" |
| bitdepth, subsampling, color space | |
| static const struct pixfmt_plane_info_t | pixfmt_plane_info [] |
This file contains video codec-related functions.
This file contains video codecs' metadata and helper functions as well as pixelformat converting functions.
Definition in file video_codec.c.
| #define __STDC_WANT_LIB_EXT1__ 1 |
Definition at line 53 of file video_codec.c.
| #define BYTE_SWAP | ( | x | ) |
Definition at line 85 of file video_codec.c.
| #define HW_VDPAU_FRAME_SZ 0 |
Definition at line 118 of file video_codec.c.
| bool clear_video_buffer | ( | unsigned char * | data, |
| size_t | linesize, | ||
| size_t | pitch, | ||
| size_t | height, | ||
| codec_t | color_spec ) |
Definition at line 862 of file video_codec.c.
References BGR, HW_VDPAU, RGB, RGBA, UYVY, and v210.
Referenced by vf_clear().
| void codec_get_planes_subsampling | ( | codec_t | pix_fmt, |
| int * | sub ) |
Returns subsampling of individual planes of planar pixel format
Undefined if pix_fmt is not a planar pixel format
| [out] | sub | subsampling, allocated array must be able to hold 8 members |
Definition at line 924 of file video_codec.c.
References pixfmt_plane_info, and pixfmt_plane_info_t::plane_info.
Referenced by buf_get_linesizes(), buf_get_planes(), same_linesizes(), to_lavc_vid_conv(), and vc_get_datalen().
| bool codec_is_420 | ( | codec_t | pix_fmt | ) |
Definition at line 930 of file video_codec.c.
References pixfmt_plane_info, and pixfmt_plane_info_t::plane_info.
| bool codec_is_a_rgb | ( | codec_t | codec | ) |
Returns TRUE if specified pixelformat is some form of RGB (not YUV).
Unspecified for compressed codecs.
| TRUE | if pixelformat is RGB |
| FALSE | if pixelformat is not a RGB |
Definition at line 463 of file video_codec.c.
References codec_info, and codec_info_t::rgb.
Referenced by check_duration(), cleanup_screen(), compute_dst_rect(), configure_with(), display_decklink_reconfigure(), display_frame(), display_sdl_reconfigure_real(), gpujpeg_decompress_get_priority(), j2k_decompress_get_priority(), libavcodec_decompress_get_priority(), print_pixel_formats(), and save_video_frame().
| bool codec_is_const_size | ( | codec_t | codec | ) |
Returns TRUE if specified pixelformat has constant size regardles of resolution. If so the block_size value represents the size.
Unspecified for compressed codecs.
| TRUE | if pixelformat is const size |
| FALSE | if pixelformat is not const size |
Definition at line 479 of file video_codec.c.
References codec_info, and codec_info_t::const_size.
Referenced by av_to_uv_convert(), vf_alloc_desc(), and vf_alloc_desc_data().
| bool codec_is_hw_accelerated | ( | codec_t | codec | ) |
Definition at line 489 of file video_codec.c.
References HW_VDPAU.
Referenced by video_decoder_order_output_codecs().
Tries to find specified codec in set of video codecs. The set must by ended by VIDEO_CODEC_NONE.
Definition at line 851 of file video_codec.c.
References VIDEO_CODEC_NONE.
Referenced by check_for_slave_format_change(), get_best_decoder_from(), load_texture(), reconfigure_if_needed(), and select_display_codec().
| bool codec_is_planar | ( | codec_t | codec | ) |
Definition at line 912 of file video_codec.c.
References pixfmt_plane_info, and pixfmt_plane_info_t::plane_info.
Referenced by avg_lines(), display_sdl2_get_property(), get_av_to_uv_conversion(), same_linesizes(), to_lavc_vid_conv(), vc_deinterlace_ex(), vc_get_datalen(), vidcap_dshow_probe_internal(), vidcap_testcard_init(), and write_mode().
| int compare_pixdesc | ( | const struct pixfmt_desc * | desc_a, |
| const struct pixfmt_desc * | desc_b, | ||
| const struct pixfmt_desc * | src_desc ) |
qsort(_s)-compatible comparator
Definition at line 1138 of file video_codec.c.
References pixfmt_desc::depth, pixfmt_conv_pref, pixfmt_desc::rgb, and pixfmt_desc::subsampling.
Referenced by lavc_compare_convs_inner(), QSORT_S_COMP_DEFINE(), QSORT_S_COMP_DEFINE(), QSORT_S_COMP_DEFINE(), QSORT_S_COMP_DEFINE(), and set_convertible_formats().
| int get_bits_per_component | ( | codec_t | codec | ) |
Definition at line 280 of file video_codec.c.
References codec_info_t::bits_per_channel, and codec_info.
Referenced by avg_lines(), display_gl_get_property(), display_gl_reconfigure(), filter(), get_16_bit_pnm_data(), get_out_cv_data_type(), j2k_decompress_reconfigure(), print_pixel_formats(), reconfigure_if_needed(), resize_frame_dimensions(), same_linesizes(), save_video_frame(), save_video_frame_as_pnm(), save_video_frame_as_y4m(), testcard_show_codec_help(), to_lavc_vid_conv(), vc_deinterlace_ex(), vc_get_datalen(), vidcap_decklink_init(), vidcap_testcard_init(), and video_pattern_generator_create().
| double get_bpp | ( | codec_t | codec | ) |
Definition at line 301 of file video_codec.c.
References codec_info.
Referenced by border_postprocess(), crop_postprocess(), crop_postprocess_reconfigure(), display_frame(), filter(), ipc_frame_from_ug_frame(), ipc_frame_from_ug_frame_hq(), j2k_decompress_reconfigure(), reconfigure(), vf_split(), vidcap_dvs_init(), and vidcap_testcard2_thread().
| const char * get_codec_file_extension | ( | codec_t | codec | ) |
Definition at line 406 of file video_codec.c.
References codec_info, and codec_info_t::file_extension.
Referenced by get_tile_count(), save_video_frame(), video_export(), and video_reading_thread().
| codec_t get_codec_from_fcc | ( | uint32_t | fourcc | ) |
Definition at line 350 of file video_codec.c.
References alternative_fourcc::alias, codec_info, codec_info_t::fcc, fourcc_aliases, and VIDEO_CODEC_NONE.
Referenced by display_sage_init(), parse_video_desc_info(), and parse_video_hdr().
| codec_t get_codec_from_file_extension | ( | const char * | ext | ) |
Definition at line 417 of file video_codec.c.
References codec_info, codec_info_t::file_extension, and VIDEO_CODEC_NONE.
Referenced by testcard_load_from_file(), and write_to_container().
| codec_t get_codec_from_name | ( | const char * | name | ) |
Definition at line 387 of file video_codec.c.
References alternative_codec_name::alias, codec_name_aliases, get_codec_from_name_wo_alias(), name, alternative_codec_name::primary_name, and VIDEO_CODEC_NONE.

|
static |
Helper codec finding function
Iterates through codec list and finds appropriate codec.
Definition at line 376 of file video_codec.c.
References codec_info, name, and VIDEO_CODEC_NONE.
Referenced by get_codec_from_name().
| const char * get_codec_name | ( | codec_t | codec | ) |
Definition at line 326 of file video_codec.c.
References codec_info, codec_info_t::name, and name.
| const char * get_codec_name_long | ( | codec_t | codec | ) |
Definition at line 338 of file video_codec.c.
References codec_info, and codec_info_t::name_long.
Referenced by print_pixel_formats(), print_video_codecs(), and testcard_show_codec_help().
| uint32_t get_fourcc | ( | codec_t | codec | ) |
Definition at line 314 of file video_codec.c.
References codec_info, and codec_info_t::fcc.
Referenced by configure_with(), format_video_header(), and output_summary().
| int get_pf_block_bytes | ( | codec_t | codec | ) |
returns codec_info_t::block_size_bytes
Definition at line 556 of file video_codec.c.
References codec_info_t::block_size_bytes, and codec_info.
Referenced by crop_postprocess(), crop_postprocess_reconfigure(), display_dummy_putf(), filter(), filter(), get_packet_sizes(), reconfigure_decoder(), upload_to_cuda_buf(), vf_alloc_desc(), and vf_alloc_desc_data().
| int get_pf_block_pixels | ( | codec_t | codec | ) |
returns codec_info_t::block_size_pixels
Definition at line 568 of file video_codec.c.
References codec_info_t::block_size_pixels, and codec_info.
Referenced by get_packet_sizes(), ipc_frame_from_ug_frame(), ipc_frame_from_ug_frame_hq(), and reconfigure_decoder().
| const char * get_pixdesc_desc | ( | struct pixfmt_desc | desc | ) |
Definition at line 1203 of file video_codec.c.
References desc.
Referenced by choose_codec_and_decoder(), decompress_thread(), j2k_probe_internal_codec(), and video_decoder_order_output_codecs().
| struct pixfmt_desc get_pixfmt_desc | ( | codec_t | pixfmt | ) |
Definition at line 1125 of file video_codec.c.
References codec_info_t::bits_per_channel, codec_info, pixfmt_desc::depth, codec_info_t::rgb, pixfmt_desc::rgb, codec_info_t::subsampling, pixfmt_desc::subsampling, VIDEO_CODEC_END, and VIDEO_CODEC_FIRST.
Referenced by get_av_to_uv_conversion(), get_available_pix_fmts(), get_best_decoder_from(), get_decoder_from_uv_to_uv(), pick_av_convertible_to_ug(), probe_internal(), probe_internal_cineform(), QSORT_S_COMP_DEFINE(), QSORT_S_COMP_DEFINE(), QSORT_S_COMP_DEFINE(), QSORT_S_COMP_DEFINE(), set_convertible_formats(), to_lavc_vid_conv_init(), and video_decoder_order_output_codecs().
| int get_subsampling | ( | codec_t | codec | ) |
Definition at line 291 of file video_codec.c.
References codec_info, and codec_info_t::subsampling.
| void i420_16_to_y416 | ( | int | width, |
| int | height, | ||
| const unsigned char * | in, | ||
| unsigned char * | out, | ||
| int | in_depth ) |
Definition at line 1022 of file video_codec.c.
References DEPTH16, vc_get_linesize(), and Y416.
Referenced by testcard_load_from_file_y4m().

| void i420_8_to_uyvy | ( | int | width, |
| int | height, | ||
| const unsigned char * | in, | ||
| unsigned char * | out ) |
Definition at line 1064 of file video_codec.c.
References OPTIMIZED_FOR, UYVY, and vc_get_linesize().
Referenced by i420_decompress(), and testcard_load_from_file_y4m().

| void i422_16_to_y416 | ( | int | width, |
| int | height, | ||
| const unsigned char * | in, | ||
| unsigned char * | out, | ||
| int | in_depth ) |
Definition at line 999 of file video_codec.c.
References DEPTH16.
Referenced by testcard_load_from_file_y4m().
| void i422_8_to_uyvy | ( | int | width, |
| int | height, | ||
| const unsigned char * | in, | ||
| unsigned char * | out ) |
Definition at line 1088 of file video_codec.c.
Referenced by testcard_load_from_file_y4m().
| void i444_16_to_y416 | ( | int | width, |
| int | height, | ||
| const unsigned char * | in, | ||
| unsigned char * | out, | ||
| int | in_depth ) |
Definition at line 981 of file video_codec.c.
Referenced by testcard_load_from_file_y4m().
| void i444_8_to_uyvy | ( | int | width, |
| int | height, | ||
| const unsigned char * | in, | ||
| unsigned char * | out ) |
Definition at line 1106 of file video_codec.c.
Referenced by testcard_load_from_file_y4m().
| bool is_codec_interframe | ( | codec_t | codec | ) |
Returns whether specified codec is an interframe compression. Not defined for pixelformats
| TRUE | if compression is interframe |
| FALSE | if compression is not interframe |
Definition at line 448 of file video_codec.c.
References codec_info, and codec_info_t::interframe.
Referenced by print_video_codecs().
| bool is_codec_opaque | ( | codec_t | codec | ) |
| TRUE | if codec is compressed |
| FALSE | if codec is pixelformat |
Definition at line 432 of file video_codec.c.
References codec_info, and codec_info_t::opaque.
Referenced by avg_lines(), display_dump_getf(), display_dump_reconfigure(), get_codecs(), get_packet_sizes(), print_pixel_formats(), print_video_codecs(), probe_cuda_ug_to_av(), save_video_frame(), h264_sdp_video_rxtx::send_frame(), testcard_show_codec_help(), vc_deinterlace_ex(), vidcap_dshow_grab(), vidcap_dshow_init(), vidcap_dshow_probe_internal(), vidcap_ndi_grab(), and write_mode().
| bool pixdesc_equals | ( | struct pixfmt_desc | desc_a, |
| struct pixfmt_desc | desc_b ) |
Definition at line 1217 of file video_codec.c.
References pixfmt_desc::depth, pixfmt_desc::rgb, and pixfmt_desc::subsampling.
Referenced by reconfigure_if_needed(), and video_decoder_order_output_codecs().
| void show_codec_help | ( | const char * | module, |
| const codec_t * | codecs8, | ||
| const codec_t * | codecs10, | ||
| const codec_t * | codecs_ge12 ) |
Prints list of suppored codecs for video module.
Definition at line 250 of file video_codec.c.
References codec_info, name, and VIDEO_CODEC_NONE.
Referenced by show_help().
| void uyvy_to_i422 | ( | int | width, |
| int | height, | ||
| const unsigned char * | in, | ||
| unsigned char * | out ) |
Definition at line 941 of file video_codec.c.
Referenced by save_video_frame_as_y4m().
| void vc_deinterlace | ( | unsigned char * | src, |
| long | src_linesize, | ||
| int | lines ) |
Deinterlaces framebuffer.
vc_deinterlace performs linear blend deinterlace on a framebuffer.
| [in,out] | src | framebuffer to be deinterlaced |
| [in] | src_linesize | length of a line (bytes) |
| [in] | lines | number of lines |
Definition at line 588 of file video_codec.c.
References val.
Referenced by display_frame(), display_sage_run(), and slave_worker().
| bool vc_deinterlace_ex | ( | codec_t | codec, |
| unsigned char * | src, | ||
| size_t | src_linesize, | ||
| unsigned char * | dst, | ||
| size_t | dst_pitch, | ||
| size_t | lines ) |
Extended version of vc_deinterlace(). The former version was in-place only. This allows to output to a different buffer while it can still be used in-place.
Definition at line 713 of file video_codec.c.
References codec_is_planar(), DEBUG_TIMER_START, DEBUG_TIMER_STOP, get_bits_per_component(), is_codec_opaque(), R10k, R12L, v210, val, and vc_deinterlace_ex().
Referenced by deinterlace_postprocess(), display_frame(), perform_df(), and vc_deinterlace_ex().

| size_t vc_get_datalen | ( | unsigned int | width, |
| unsigned int | height, | ||
| codec_t | codec ) |
Returns storage requirements for given parameters
Definition at line 534 of file video_codec.c.
References codec_get_planes_subsampling(), codec_is_planar(), get_bits_per_component(), and vc_get_linesize().
Referenced by still_image_video_pattern_generator::still_image_video_pattern_generator(), SampleGrabberCallback::BufferCB(), codec_conversion_test_testcard_uyvy_to_i420(), do_av_to_uv_convert(), get_16_bit_pnm_data(), j2k_compress_push(), main(), r12l_postprocessor_get_sz(), save_video_frame_as_y4m(), testcard_load_from_file(), testcard_load_from_file_pam(), testcard_load_from_file_y4m(), vf_alloc_desc(), vidcap_dshow_grab(), vidcap_testcard2_init(), and vidcap_testcard2_thread().

| int vc_get_linesize | ( | unsigned int | width, |
| codec_t | codec ) |
Definition at line 498 of file video_codec.c.
References codec_info_t::block_size_bytes, codec_info_t::block_size_pixels, codec_info, and codec_info_t::h_align.
Referenced by i420_16_to_y416(), i420_8_to_uyvy(), and vc_get_datalen().
| int vc_get_size | ( | unsigned int | width, |
| codec_t | codec ) |
This differs from vc_get_linesize for v210, eg. for width=1 that function returns 128, while this function 16. Also for R10k, lines are aligned to 256 B (64 pixels), while single pixel is only 4 B.
Definition at line 521 of file video_codec.c.
References codec_info_t::block_size_bytes, codec_info_t::block_size_pixels, and codec_info.
Referenced by do_av_to_uv_convert(), draw_frame(), testcard_convert_buffer(), and to_lavc_memcpy_data().
| void watch_pixfmt_degrade | ( | const char * | mod_name, |
| struct pixfmt_desc | desc_src, | ||
| struct pixfmt_desc | desc_dst ) |
Definition at line 1184 of file video_codec.c.
References pixfmt_desc::depth, LOG_LEVEL_WARNING, log_msg(), and pixfmt_desc::subsampling.
Referenced by get_av_to_uv_conversion(), and to_lavc_vid_conv_init().

| void y416_to_i444 | ( | int | width, |
| int | height, | ||
| const unsigned char * | in, | ||
| unsigned char * | out, | ||
| int | depth ) |
Definition at line 963 of file video_codec.c.
Referenced by save_video_frame_as_y4m().
|
static |
Definition at line 121 of file video_codec.c.
Referenced by codec_is_a_rgb(), codec_is_const_size(), get_bits_per_component(), get_bpp(), get_cineform_module_info(), get_cmpto_j2k_module_info(), get_codec_file_extension(), get_codec_from_fcc(), get_codec_from_file_extension(), get_codec_from_name_wo_alias(), get_codec_name(), get_codec_name_long(), get_fourcc(), get_pf_block_bytes(), get_pf_block_pixels(), get_pixfmt_desc(), get_subsampling(), is_codec_interframe(), is_codec_opaque(), show_codec_help(), vc_get_linesize(), and vc_get_size().
|
static |
Definition at line 243 of file video_codec.c.
Referenced by get_codec_from_name().
|
static |
This array contains FourCC aliases mapping
Definition at line 223 of file video_codec.c.
Referenced by get_codec_from_fcc().
| char pixfmt_conv_pref[] = "dsc" |
bitdepth, subsampling, color space
Definition at line 80 of file video_codec.c.
Referenced by compare_pixdesc(), and set_pixfmt_conv_policy().
|
static |
Definition at line 207 of file video_codec.c.
Referenced by codec_get_planes_subsampling(), codec_is_420(), and codec_is_planar().