FFmpeg
Data Structures | Macros | Functions
frame_thread_encoder.c File Reference
#include <stdatomic.h>
#include "frame_thread_encoder.h"
#include "libavutil/avassert.h"
#include "libavutil/cpu.h"
#include "libavutil/opt.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "avcodec_internal.h"
#include "codec_par.h"
#include "encode.h"
#include "internal.h"
#include "pthread_internal.h"

Go to the source code of this file.

Data Structures

struct  Task
 
struct  ThreadContext
 

Macros

#define MAX_THREADS   64
 
#define BUFFER_SIZE   (MAX_THREADS + 2)
 
#define OFF(member)   offsetof(ThreadContext, member)
 
#define DUP_MATRIX(m)
 

Functions

 DEFINE_OFFSET_ARRAY (ThreadContext, thread_ctx, pthread_init_cnt,(OFF(task_fifo_mutex), OFF(finished_task_mutex)),(OFF(task_fifo_cond), OFF(finished_task_cond)))
 
static void *attribute_align_arg worker (void *v)
 
av_cold int ff_frame_thread_encoder_init (AVCodecContext *avctx)
 Initialize frame thread encoder. More...
 
av_cold void ff_frame_thread_encoder_free (AVCodecContext *avctx)
 
int ff_thread_video_encode_frame (AVCodecContext *avctx, AVPacket *pkt, AVFrame *frame, int *got_packet_ptr)
 

Macro Definition Documentation

◆ MAX_THREADS

#define MAX_THREADS   64

Definition at line 36 of file frame_thread_encoder.c.

◆ BUFFER_SIZE

#define BUFFER_SIZE   (MAX_THREADS + 2)

Definition at line 41 of file frame_thread_encoder.c.

◆ OFF

#define OFF (   member)    offsetof(ThreadContext, member)

Definition at line 71 of file frame_thread_encoder.c.

◆ DUP_MATRIX

#define DUP_MATRIX (   m)
Value:
if (avctx->m) { \
thread_avctx->m = av_memdup(avctx->m, 64 * sizeof(*avctx->m)); \
if (!thread_avctx->m) { \
ret = AVERROR(ENOMEM); \
goto fail; \
} \
}

Function Documentation

◆ DEFINE_OFFSET_ARRAY()

DEFINE_OFFSET_ARRAY ( ThreadContext  ,
thread_ctx  ,
pthread_init_cnt  ,
(OFF(task_fifo_mutex), OFF(finished_task_mutex))  ,
(OFF(task_fifo_cond), OFF(finished_task_cond))   
)

◆ worker()

static void* attribute_align_arg worker ( void *  v)
static

Definition at line 77 of file frame_thread_encoder.c.

Referenced by ff_frame_thread_encoder_init().

◆ ff_frame_thread_encoder_init()

av_cold int ff_frame_thread_encoder_init ( AVCodecContext avctx)

Initialize frame thread encoder.

Note
hardware encoders are not supported

Definition at line 119 of file frame_thread_encoder.c.

Referenced by ff_encode_preinit().

◆ ff_frame_thread_encoder_free()

av_cold void ff_frame_thread_encoder_free ( AVCodecContext avctx)

Definition at line 274 of file frame_thread_encoder.c.

Referenced by ff_codec_close(), and ff_frame_thread_encoder_init().

◆ ff_thread_video_encode_frame()

int ff_thread_video_encode_frame ( AVCodecContext avctx,
AVPacket pkt,
AVFrame frame,
int got_packet_ptr 
)

Definition at line 300 of file frame_thread_encoder.c.

Referenced by encode_simple_internal().

AVERROR
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
av_memdup
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
Definition: mem.c:302
fail
#define fail()
Definition: checkasm.h:179