19void scale_frame(
char *dst,
char *src,
25 assert(block_size > 0);
26 int blocks_per_line = src_line_len / block_size / f;
29 for(
int y = 0; y + f <= src_h; y += f){
31 for(
int x = 0; x + f * block_size <= src_line_len; x += f * block_size){
32 memcpy(dst + out_lines * dst_line_len + written, src + y*src_line_len + x, block_size);
33 written += block_size;
44 unsigned scale_factor)
60 if(scale_factor != 0){
62 int block_count = (dst->
header.
width + block_size_px - 1) / block_size_px;
63 dst->
header.
width = (block_count / scale_factor) * block_size_px;
73 char *scale_src =
nullptr;
74 std::vector<unsigned char> rgb_frame;
80 unsigned char *dec_dst =
nullptr;
81 if(scale_factor != 0){
82 rgb_frame.resize(rgb_line_len * src->
tiles[0].
height);
83 scale_src = (
char *) rgb_frame.data();
84 dec_dst = (
unsigned char *) scale_src;
86 dec_dst = (
unsigned char *) dst->
data;
90 dec(dec_dst + rgb_line_len * i,
100 scale_frame(dst->
data, scale_src,
102 scale_factor,
codec);
110 unsigned scale_factor)
130 int dst_frame_to_allocate = 0;
132 if(scale_factor != 0){
134 int block_count = (dst->
header.
width + block_size_px - 1) / block_size_px;
135 dst->
header.
width = (block_count / scale_factor) * block_size_px;
145 dst_frame_to_allocate += dst_frame_size;
152 char *scale_dst = dst->
data;
153 unsigned char *dec_dst = (
unsigned char *) dst->
data;
154 unsigned char *dec_src = (
unsigned char *) src->
tiles[0].
data;
156 if(scale_factor != 0){
158 scale_dst = dst->
data + dst_frame_size;
160 dec_src = (
unsigned char *) scale_dst;
162 scale_frame(scale_dst, src->
tiles[0].
data,
169 if(dec_src == dec_dst){
177 dec(dec_dst + dst_line_len * i,
178 dec_src + src_line_len * i,
187 if(target_w== -1 || target_h== -1)
190 float scale = std::sqrt((
static_cast<float>(src_w) * src_h)
191 / (
static_cast<float>(target_w) * target_h));
196 return std::round(scale);
int vc_get_linesize(unsigned int width, codec_t codec)
bool ipc_frame_reserve(Ipc_frame *frame, size_t size)
bool ipc_frame_from_ug_frame_hq(struct Ipc_frame *dst, const struct video_frame *src, codec_t codec, unsigned scale_factor)
Same as ipc_frame_from_ug_frame, but convert pixfmt first and scale later.
bool ipc_frame_from_ug_frame(struct Ipc_frame *dst, const struct video_frame *src, codec_t codec, unsigned scale_factor)
Make an ipc frame from ultragrid frame.
int ipc_frame_get_scale_factor(int src_w, int src_h, int target_w, int target_h)
decoder_t get_decoder_from_to(codec_t in, codec_t out)
decoder_func_t * decoder_t
decoder_func_t vc_memcpy
dummy conversion - ptr to it returned if no conversion needed
char * data
Raw tile data. Pointer must be at least 4B aligned.
Struct video_frame represents a video frame and contains video description.
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
@ RGB
RGB 8-bit (packed into 24-bit word)
@ VIDEO_CODEC_NONE
dummy color spec
int get_pf_block_bytes(codec_t codec)
returns codec_info_t::block_size_bytes
double get_bpp(codec_t codec)
int get_pf_block_pixels(codec_t codec)
returns codec_info_t::block_size_pixels