53 #define MAGIC 0xdeadc0de 131 for (i = 0; i < rd->
workload; i++) {
134 "discarding %d message(s)\n", rd->
id,
161 return maxv == minv ? maxv : rand() % (maxv - minv) + minv;
168 int nb_senders, sender_min_load, sender_max_load;
169 int nb_receivers, receiver_min_load, receiver_max_load;
176 "<nb_senders> <sender_min_send> <sender_max_send> " 177 "<nb_receivers> <receiver_min_recv> <receiver_max_recv>\n", av[0]);
181 max_queue_size = atoi(av[1]);
182 nb_senders = atoi(av[2]);
183 sender_min_load = atoi(av[3]);
184 sender_max_load = atoi(av[4]);
185 nb_receivers = atoi(av[5]);
186 receiver_min_load = atoi(av[6]);
187 receiver_max_load = atoi(av[7]);
189 if (max_queue_size <= 0 ||
190 nb_senders <= 0 || sender_min_load <= 0 || sender_max_load <= 0 ||
191 nb_receivers <= 0 || receiver_min_load <= 0 || receiver_max_load <= 0) {
197 "%d receivers receiving [%d-%d]\n", max_queue_size,
198 nb_senders, sender_min_load, sender_max_load,
199 nb_receivers, receiver_min_load, receiver_max_load);
203 if (!senders || !receivers) {
214 #define SPAWN_THREADS(type) do { \ 215 for (i = 0; i < nb_##type##s; i++) { \ 216 struct type##_data *td = &type##s[i]; \ 220 td->workload = get_workload(type##_min_load, type##_max_load); \ 222 ret = pthread_create(&td->tid, NULL, type##_thread, td); \ 224 const int err = AVERROR(ret); \ 225 av_log(NULL, AV_LOG_ERROR, "Unable to start " AV_STRINGIFY(type) \ 226 " thread: %s\n", av_err2str(err)); \ 232 #define WAIT_THREADS(type) do { \ 233 for (i = 0; i < nb_##type##s; i++) { \ 234 struct type##_data *td = &type##s[i]; \ 236 ret = pthread_join(td->tid, NULL); \ 238 const int err = AVERROR(ret); \ 239 av_log(NULL, AV_LOG_ERROR, "Unable to join " AV_STRINGIFY(type) \ 240 " thread: %s\n", av_err2str(err)); \
This structure describes decoded (raw) audio or video data.
void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err)
Set the receiving error code.
static int get_workload(int minv, int maxv)
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...
AVThreadMessageQueue * queue
#define SPAWN_THREADS(type)
int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq)
Return the current number of messages in the queue.
static void * sender_thread(void *arg)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_thread_message_queue_recv(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Receive a message from the queue.
static av_cold int end(AVCodecContext *avctx)
int av_thread_message_queue_send(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Send a message on the queue.
static void * receiver_thread(void *arg)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AVERROR_EOF
End of file.
AVDictionary * metadata
metadata.
AVThreadMessageQueue * queue
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_thread_message_flush(AVThreadMessageQueue *mq)
Flush the message queue.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
simple assert() macros that are a bit more flexible than ISO C assert().
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
reference-counted frame API
char * av_asprintf(const char *fmt,...)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
#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.
void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, int err)
Set the sending error code.
int main(int ac, char **av)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, unsigned nelem, unsigned elsize)
Allocate a new message queue.
#define WAIT_THREADS(type)
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_thread_message_queue_free(AVThreadMessageQueue **mq)
Free a message queue.
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
static double val(void *priv, double ch)
static void free_frame(void *arg)
void * av_mallocz_array(size_t nmemb, size_t size)