23 #include "libavutil/fifo.h"
24 #include "libavutil/avassert.h"
25 #include "libavutil/imgutils.h"
38 #define MAX_THREADS 64
39 #define BUFFER_SIZE (2*MAX_THREADS)
163 *thread_avctx = *avctx;
233 new->pts = frame->
pts;
242 task.
indata = (
void*)frame;
int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
unsigned finished_task_index
This structure describes decoded (raw) audio or video data.
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
os2threads to pthreads wrapper
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVCodecContext * parent_avctx
int av_dup_packet(AVPacket *pkt)
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
#define CODEC_FLAG_INPUT_PRESERVED
The parent program guarantees that the input for B-frames containing streams is not written to for at...
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int av_fifo_size(AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
#define CODEC_CAP_INTRA_ONLY
Codec is intra only.
static av_cold int end(AVCodecContext *avctx)
Multithreading support functions.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
Task finished_tasks[BUFFER_SIZE]
void * frame_thread_encoder
struct AVCodecInternal * internal
Private context used for internal data.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
const OptionDef options[]
pthread_mutex_t buffer_mutex
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int active_thread_type
Which multithreading methods are in use by the codec.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int capabilities
Codec capabilities.
pthread_cond_t finished_task_cond
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Libavcodec external API header.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options)
enum AVPictureType pict_type
Picture type of the frame.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int width
picture width / height.
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
pthread_mutex_t task_fifo_mutex
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
#define attribute_align_arg
static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
main external API structure.
#define FF_THREAD_FRAME
Decode more than one frame at once.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
pthread_t worker[MAX_THREADS]
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
common internal api header.
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
pthread_mutex_t finished_task_mutex
static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond)
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
w32threads to pthreads wrapper
void ff_frame_thread_encoder_free(AVCodecContext *avctx)
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void *attribute_align_arg worker(void *v)
pthread_cond_t task_fifo_cond
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int thread_type
Which multithreading methods to use.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...