UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
i420.c
Go to the documentation of this file.
1
12/*
13 * Copyright (c) 2024 CESNET z.s.p.o.
14 * All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, is permitted provided that the following conditions
18 * are met:
19 *
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 *
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 *
27 * 3. Neither the name of CESNET nor the names of its contributors may be
28 * used to endorse or promote products derived from this software without
29 * specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
33 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
34 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
35 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
41 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 */
44
45#include <assert.h>
46#include <stdbool.h>
47#include <stdlib.h>
48
49#include "lib_common.h"
50#include "types.h"
51#include "video_codec.h"
52#include "video_decompress.h"
53
57
58static void *
60{
61 return malloc(sizeof(struct i420_decompress_state));
62}
63
64static int
66 int gshift, int bshift, int pitch,
67 codec_t out_codec)
68{
69 (void) rshift, (void) gshift, (void) bshift;
70 assert(out_codec == UYVY);
71 assert(pitch == (int) desc.width * 2); // implement other ir needed
72 struct i420_decompress_state *s = state;
73 s->desc = desc;
74 return true;
75}
76
78i420_decompress(void *state, unsigned char *dst, unsigned char *buffer,
79 unsigned int src_len, int frame_seq,
80 struct video_frame_callbacks *callbacks,
81 struct pixfmt_desc *internal_prop)
82{
83 (void) src_len, (void) frame_seq, (void) callbacks,
84 (void) internal_prop;
85 struct i420_decompress_state *s = state;
86 i420_8_to_uyvy((int) s->desc.width, (int) s->desc.height, buffer, dst);
87 return DECODER_GOT_FRAME;
88}
89
90static int
92{
93 (void) state;
94
96 assert(*len >= sizeof(int));
97 *(int *) val = true;
98 *len = sizeof(int);
99 return true;
100 }
101 return false;
102}
103
104static void
106{
107 free(state);
108}
109
110static int
112 codec_t ugc)
113{
114 (void) internal;
115 enum {
116 PRIO_NA = -1,
117 PRIO_NORMAL = 500,
118 };
119 // probing (ugc==VC_NONE) is skipped (optional, not necessary)
120 return compression == I420 && ugc == UYVY ? PRIO_NORMAL : PRIO_NA;
121}
122
128
void ** state
int void * val
struct video_desc desc
int void size_t * len
int property
decompress_status
#define DECOMPRESS_PROPERTY_ACCEPTS_CORRUPTED_FRAME
@ DECODER_GOT_FRAME
static void i420_decompress_done(void *state)
Definition i420.c:105
static decompress_status i420_decompress(void *state, unsigned char *dst, unsigned char *buffer, unsigned int src_len, int frame_seq, struct video_frame_callbacks *callbacks, struct pixfmt_desc *internal_prop)
Definition i420.c:78
static const struct video_decompress_info i420_info
Definition i420.c:123
static int i420_decompress_reconfigure(void *state, struct video_desc desc, int rshift, int gshift, int bshift, int pitch, codec_t out_codec)
Definition i420.c:65
static int i420_decompress_get_property(void *state, int property, void *val, size_t *len)
Definition i420.c:91
static int i420_decompress_get_priority(codec_t compression, struct pixfmt_desc internal, codec_t ugc)
Definition i420.c:111
static void * i420_decompress_init(void)
Definition i420.c:59
@ LIBRARY_CLASS_VIDEO_DECOMPRESS
Definition lib_common.h:81
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
Definition lib_common.h:144
struct video_desc desc
Definition i420.c:55
unsigned int width
width of every tile (!)
Definition types.h:179
unsigned int height
height of every tile (!)
Definition types.h:180
Struct containing callbacks of a video_frame.
Definition types.h:230
codec_t
Definition types.h:65
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
Definition types.h:71
@ I420
planar YCbCr 4:2:0
Definition types.h:97
void i420_8_to_uyvy(int width, int height, const unsigned char *in, unsigned char *out)
API for video decompress drivers.
#define VIDEO_DECOMPRESS_ABI_VERSION