FFmpeg
Loading...
Searching...
No Matches
ffmpeg_enc.c File Reference
#include <math.h>
#include <stdint.h>
#include "ffmpeg.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/avutil.h"
#include "libavutil/dict.h"
#include "libavutil/display.h"
#include "libavutil/eval.h"
#include "libavutil/frame.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/rational.h"
#include "libavutil/time.h"
#include "libavutil/timestamp.h"
#include "libavcodec/avcodec.h"

Go to the source code of this file.

Data Structures

struct  EncoderPriv
 
struct  EncoderThread
 

Functions

static EncoderPrivep_from_enc (Encoder *enc)
 
void enc_free (Encoder **penc)
 
static const char * enc_item_name (void *obj)
 
static int enc_realloc (Encoder *enc, const AVCodec *codec)
 
int enc_alloc (Encoder **penc, const AVCodec *codec, Scheduler *sch, unsigned sch_idx, void *log_parent)
 
static int hw_device_setup_for_encode (Encoder *e, AVCodecContext *enc_ctx, AVBufferRef *frames_ref)
 
static int apply_enc_options (Encoder *e, AVDictionary **opts)
 
static int enc_reopen (void *opaque, const AVFrame *frame, AVDictionary **extra_encoder_opts)
 
int enc_open (void *opaque, const AVFrame *frame)
 
static int check_recording_time (OutputStream *ost, int64_t ts, AVRational tb)
 
static int do_subtitle_out (OutputFile *of, OutputStream *ost, const AVSubtitle *sub, AVPacket *pkt)
 
void enc_stats_write (OutputStream *ost, EncStats *es, const AVFrame *frame, const AVPacket *pkt, uint64_t frame_num)
 
static double psnr (double d)
 
static int update_video_stats (OutputStream *ost, const AVPacket *pkt, int write_vstats)
 
static int encode_frame (OutputFile *of, OutputStream *ost, AVFrame *frame, AVPacket *pkt)
 
static enum AVPictureType forced_kf_apply (void *logctx, KeyframeForceCtx *kf, const AVFrame *frame)
 
static int frame_encode (OutputStream *ost, AVFrame *frame, AVPacket *pkt)
 
static void enc_thread_set_name (const OutputStream *ost)
 
static void enc_thread_uninit (EncoderThread *et)
 
static int enc_thread_init (EncoderThread *et)
 
static int flush_encoder (OutputStream *ost, EncoderThread *et)
 
static int reinit_encoder (OutputStream *ost, EncoderThread *et)
 
int encoder_thread (void *arg)
 
int enc_loopback (Encoder *enc)
 

Variables

static const AVClass enc_class
 

Function Documentation

◆ ep_from_enc()

◆ enc_free()

void enc_free ( Encoder ** penc)

Definition at line 73 of file ffmpeg_enc.c.

Referenced by enc_alloc(), and ost_free().

◆ enc_item_name()

static const char * enc_item_name ( void * obj)
static

Definition at line 88 of file ffmpeg_enc.c.

◆ enc_realloc()

static int enc_realloc ( Encoder * enc,
const AVCodec * codec )
static

Definition at line 102 of file ffmpeg_enc.c.

Referenced by reinit_encoder().

◆ enc_alloc()

int enc_alloc ( Encoder ** penc,
const AVCodec * codec,
Scheduler * sch,
unsigned sch_idx,
void * log_parent )

Definition at line 125 of file ffmpeg_enc.c.

Referenced by ost_add().

◆ hw_device_setup_for_encode()

static int hw_device_setup_for_encode ( Encoder * e,
AVCodecContext * enc_ctx,
AVBufferRef * frames_ref )
static

Definition at line 159 of file ffmpeg_enc.c.

Referenced by enc_reopen().

◆ apply_enc_options()

static int apply_enc_options ( Encoder * e,
AVDictionary ** opts )
static

Definition at line 210 of file ffmpeg_enc.c.

Referenced by enc_reopen().

◆ enc_reopen()

static int enc_reopen ( void * opaque,
const AVFrame * frame,
AVDictionary ** extra_encoder_opts )
static

The video color properties should always be in sync with the user- requested values, since we forward them to the filter graph.

Definition at line 228 of file ffmpeg_enc.c.

Referenced by enc_open(), and reinit_encoder().

◆ enc_open()

int enc_open ( void * opaque,
const AVFrame * frame )

Definition at line 424 of file ffmpeg_enc.c.

Referenced by encoder_thread(), and ost_add().

◆ check_recording_time()

static int check_recording_time ( OutputStream * ost,
int64_t ts,
AVRational tb )
static

Definition at line 451 of file ffmpeg_enc.c.

Referenced by do_subtitle_out(), and frame_encode().

◆ do_subtitle_out()

static int do_subtitle_out ( OutputFile * of,
OutputStream * ost,
const AVSubtitle * sub,
AVPacket * pkt )
static

Definition at line 462 of file ffmpeg_enc.c.

Referenced by frame_encode().

◆ enc_stats_write()

void enc_stats_write ( OutputStream * ost,
EncStats * es,
const AVFrame * frame,
const AVPacket * pkt,
uint64_t frame_num )

Definition at line 550 of file ffmpeg_enc.c.

Referenced by encode_frame(), and write_packet().

◆ psnr()

static double psnr ( double d)
inlinestatic

Definition at line 624 of file ffmpeg_enc.c.

Referenced by FRAMESYNC_DEFINE_CLASS(), main(), run_psnr(), uninit(), and update_video_stats().

◆ update_video_stats()

static int update_video_stats ( OutputStream * ost,
const AVPacket * pkt,
int write_vstats )
static

Definition at line 629 of file ffmpeg_enc.c.

Referenced by encode_frame().

◆ encode_frame()

static int encode_frame ( OutputFile * of,
OutputStream * ost,
AVFrame * frame,
AVPacket * pkt )
static

Definition at line 694 of file ffmpeg_enc.c.

Referenced by ac3_fixed_encode_init(), ff_ac3_float_encode_init(), and frame_encode().

◆ forced_kf_apply()

static enum AVPictureType forced_kf_apply ( void * logctx,
KeyframeForceCtx * kf,
const AVFrame * frame )
static

Definition at line 829 of file ffmpeg_enc.c.

Referenced by frame_encode().

◆ frame_encode()

static int frame_encode ( OutputStream * ost,
AVFrame * frame,
AVPacket * pkt )
static

Definition at line 878 of file ffmpeg_enc.c.

Referenced by encoder_thread(), and flush_encoder().

◆ enc_thread_set_name()

static void enc_thread_set_name ( const OutputStream * ost)
static

Definition at line 913 of file ffmpeg_enc.c.

Referenced by encoder_thread().

◆ enc_thread_uninit()

static void enc_thread_uninit ( EncoderThread * et)
static

Definition at line 921 of file ffmpeg_enc.c.

Referenced by enc_thread_init(), and encoder_thread().

◆ enc_thread_init()

static int enc_thread_init ( EncoderThread * et)
static

Definition at line 929 of file ffmpeg_enc.c.

Referenced by encoder_thread().

◆ flush_encoder()

static int flush_encoder ( OutputStream * ost,
EncoderThread * et )
static

Definition at line 948 of file ffmpeg_enc.c.

Referenced by encoder_thread(), and reinit_encoder().

◆ reinit_encoder()

static int reinit_encoder ( OutputStream * ost,
EncoderThread * et )
static

Definition at line 961 of file ffmpeg_enc.c.

Referenced by encoder_thread().

◆ encoder_thread()

int encoder_thread ( void * arg)

Definition at line 1009 of file ffmpeg_enc.c.

Referenced by ost_add().

◆ enc_loopback()

int enc_loopback ( Encoder * enc)

Definition at line 1098 of file ffmpeg_enc.c.

Referenced by dec_create().

Variable Documentation

◆ enc_class

const AVClass enc_class
static
Initial value:
= {
.class_name = "Encoder",
.parent_log_context_offset = 0x42 ,
.item_name = enc_item_name,
}
static const char * enc_item_name(void *obj)
Definition ffmpeg_enc.c:88
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 95 of file ffmpeg_enc.c.

Referenced by enc_alloc().