Go to the documentation of this file.
91 #define PROMPEG_RTP_PT 0x60
92 #define PROMPEG_FEC_COL 0x0
93 #define PROMPEG_FEC_ROW 0x1
119 #define OFFSET(x) offsetof(PrompegContext, x)
120 #define E AV_OPT_FLAG_ENCODING_PARAM
123 {
"ttl",
"Time to live (in milliseconds, multicast only)",
OFFSET(ttl),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags =
E },
136 static void xor_fast(
const uint8_t *in1,
const uint8_t *in2, uint8_t *
out,
int size) {
142 n =
size /
sizeof (uint64_t);
143 s = n *
sizeof (uint64_t);
145 for (
i = 0;
i < n;
i++) {
156 n =
size /
sizeof (uint32_t);
157 s = n *
sizeof (uint32_t);
159 for (
i = 0;
i < n;
i++) {
171 for (
i = 0;
i < n;
i++) {
177 uint8_t **bitstring) {
181 if (
size < 12 || (buf[0] & 0xc0) != 0x80 || (buf[1] & 0x7f) != 0x21) {
185 if (
size !=
s->packet_size) {
198 b[0] = buf[0] & 0x3f;
212 memcpy(
b + 8, buf + 12,
s->length_recovery);
220 uint8_t *buf =
s->rtp_buf;
228 buf[0] = 0x80 | (
b[0] & 0x3f);
243 buf[16] = 0x80 |
b[1];
262 memcpy(buf + 28,
b + 8,
s->length_recovery);
276 s->fec_col_hd =
NULL;
277 s->fec_row_hd =
NULL;
279 if (
s->l *
s->d > 100) {
287 if (rtp_port < 1 || rtp_port > UINT16_MAX - 4) {
298 &udp_opts,
h->protocol_whitelist,
h->protocol_blacklist,
h) < 0)
302 &udp_opts,
h->protocol_whitelist,
h->protocol_blacklist,
h) < 0)
305 h->max_packet_size =
s->fec_col_hd->max_packet_size;
327 if (size < 12 || size > UINT16_MAX + 12) {
333 s->packet_idx_max =
s->l *
s->d;
334 s->packet_size =
size;
335 s->length_recovery =
size - 12;
336 s->rtp_buf_size = 28 +
s->length_recovery;
337 s->bitstring_size = 8 +
s->length_recovery;
338 s->fec_arr_len = 1 + 2 *
s->l;
345 s->rtp_col_sn =
seed & 0x0fff;
346 s->rtp_row_sn = (
seed >> 16) & 0x0fff;
353 for (
i = 0;
i <
s->fec_arr_len;
i++) {
355 if (!
s->fec_arr[
i]) {
359 if (!
s->fec_arr[
i]->bitstring) {
364 s->fec_row = *
s->fec_arr;
365 s->fec_col =
s->fec_arr + 1;
366 s->fec_col_tmp =
s->fec_arr + 1 +
s->l;
372 memset(
s->rtp_buf, 0,
s->rtp_buf_size);
387 uint8_t *bitstring =
NULL;
388 int col_idx, col_out_idx, row_idx;
397 col_idx =
s->packet_idx %
s->l;
398 row_idx =
s->packet_idx /
s->l %
s->d;
402 if (!
s->first ||
s->packet_idx > 0) {
406 memcpy(
s->fec_row->bitstring, bitstring,
s->bitstring_size);
410 xor_fast(
s->fec_row->bitstring, bitstring,
s->fec_row->bitstring,
418 fec_tmp =
s->fec_col[col_idx];
419 s->fec_col[col_idx] =
s->fec_col_tmp[col_idx];
420 s->fec_col_tmp[col_idx] = fec_tmp;
422 memcpy(
s->fec_col_tmp[col_idx]->bitstring, bitstring,
s->bitstring_size);
423 s->fec_col_tmp[col_idx]->sn =
AV_RB16(buf + 2);
424 s->fec_col_tmp[col_idx]->ts =
AV_RB32(buf + 4);
426 xor_fast(
s->fec_col_tmp[col_idx]->bitstring, bitstring,
427 s->fec_col_tmp[col_idx]->bitstring,
s->bitstring_size);
431 if (!
s->first &&
s->packet_idx %
s->d == 0) {
432 col_out_idx =
s->packet_idx /
s->d;
437 if (++
s->packet_idx >=
s->packet_idx_max) {
458 for (
i = 0;
i <
s->fec_arr_len;
i++) {
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define URL_PROTOCOL_FLAG_NETWORK
static int prompeg_open(URLContext *h, const char *uri, int flags)
static int ffurl_write(URLContext *h, const uint8_t *buf, int size)
Write size bytes from buf to the resource accessed by h.
static const AVClass prompeg_class
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it.
static int prompeg_init(URLContext *h, const uint8_t *buf, int size)
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
const URLProtocol ff_prompeg_protocol
static const AVOption options[]
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static int prompeg_create_bitstring(URLContext *h, const uint8_t *buf, int size, uint8_t **bitstring)
#define AV_LOG_INFO
Standard information.
static int prompeg_close(URLContext *h)
#define i(width, name, range_min, range_max)
#define av_malloc_array(a, b)
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
static int prompeg_write_fec(URLContext *h, PrompegFec *fec, uint8_t type)
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static void xor_fast(const uint8_t *in1, const uint8_t *in2, uint8_t *out, int size)
PrompegFec ** fec_col_tmp
@ AV_OPT_TYPE_INT
Underlying C type is int.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
static int prompeg_write(URLContext *h, const uint8_t *buf, int size)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16