Go to the documentation of this file.
   54 #define MAGIC 0xdeadc0de 
  135                    "discarding %d message(s)\n", rd->
id,
 
  162     return maxv == minv ? maxv : rand() % (maxv - minv) + minv;
 
  169     int nb_senders, sender_min_load, sender_max_load;
 
  170     int nb_receivers, receiver_min_load, receiver_max_load;
 
  177                "<nb_senders> <sender_min_send> <sender_max_send> " 
  178                "<nb_receivers> <receiver_min_recv> <receiver_max_recv>\n", av[0]);
 
  182     max_queue_size    = atoi(av[1]);
 
  183     nb_senders        = atoi(av[2]);
 
  184     sender_min_load   = atoi(av[3]);
 
  185     sender_max_load   = atoi(av[4]);
 
  186     nb_receivers      = atoi(av[5]);
 
  187     receiver_min_load = atoi(av[6]);
 
  188     receiver_max_load = atoi(av[7]);
 
  190     if (max_queue_size <= 0 ||
 
  191         nb_senders <= 0 || sender_min_load <= 0 || sender_max_load <= 0 ||
 
  192         nb_receivers <= 0 || receiver_min_load <= 0 || receiver_max_load <= 0) {
 
  198            "%d receivers receiving [%d-%d]\n", max_queue_size,
 
  199            nb_senders, sender_min_load, sender_max_load,
 
  200            nb_receivers, receiver_min_load, receiver_max_load);
 
  202     senders   = 
av_calloc(nb_senders,   
sizeof(*senders));
 
  203     receivers = 
av_calloc(nb_receivers, 
sizeof(*receivers));
 
  204     if (!senders || !receivers) {
 
  215 #define SPAWN_THREADS(type) do {                                                \ 
  216     for (i = 0; i < nb_##type##s; i++) {                                        \ 
  217         struct type##_data *td = &type##s[i];                                   \ 
  221         td->workload = get_workload(type##_min_load, type##_max_load);          \ 
  223         ret = pthread_create(&td->tid, NULL, type##_thread, td);                \ 
  225             const int err = AVERROR(ret);                                       \ 
  226             av_log(NULL, AV_LOG_ERROR, "Unable to start " AV_STRINGIFY(type)    \ 
  227                    " thread: %s\n", av_err2str(err));                           \ 
  233 #define WAIT_THREADS(type) do {                                                 \ 
  234     for (i = 0; i < nb_##type##s; i++) {                                        \ 
  235         struct type##_data *td = &type##s[i];                                   \ 
  237         ret = pthread_join(td->tid, NULL);                                      \ 
  239             const int err = AVERROR(ret);                                       \ 
  240             av_log(NULL, AV_LOG_ERROR, "Unable to join " AV_STRINGIFY(type)     \ 
  241                    " thread: %s\n", av_err2str(err));                           \ 
  
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
int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq)
Return the current number of messages in the queue.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
#define AVERROR_EOF
End of file.
char * av_asprintf(const char *fmt,...)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
#define WAIT_THREADS(type)
static double val(void *priv, double ch)
int av_thread_message_queue_recv(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Receive a message from the queue.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_thread_message_queue_send(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Send a message on the queue.
void av_thread_message_flush(AVThreadMessageQueue *mq)
Flush the message queue.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static void free_frame(void *arg)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static void * receiver_thread(void *arg)
#define SPAWN_THREADS(type)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
#define AV_LOG_INFO
Standard information.
int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, unsigned nelem, unsigned elsize)
Allocate a new message queue.
static int get_workload(int minv, int maxv)
#define i(width, name, range_min, range_max)
void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, int err)
Set the sending error code.
void * av_calloc(size_t nmemb, size_t size)
AVThreadMessageQueue * queue
int main(int ac, char **av)
AVDictionary * metadata
metadata.
AVThreadMessageQueue * queue
static void * sender_thread(void *arg)
void av_thread_message_queue_free(AVThreadMessageQueue **mq)
Free a message queue.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err)
Set the receiving error code.
void av_thread_message_queue_set_free_func(AVThreadMessageQueue *mq, void(*free_func)(void *msg))
Set the optional free message callback function which will be called if an operation is removing mess...