RetroArch
Classes | Macros | Functions | Variables
ffmpeg_core.c File Reference
#include <retro_common_api.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
#include <libavutil/time.h>
#include <libavutil/opt.h>
#include <libavdevice/avdevice.h>
#include <rthreads/rthreads.h>
#include <queues/fifo_queue.h>
#include <string/stdstring.h>
#include <libretro.h>
Include dependency graph for ffmpeg_core.c:

Classes

struct  attachment
 
struct  frame
 

Macros

#define CORE_PREFIX(s)   s
 
#define PIX_FMT_RGB32   AV_PIX_FMT_RGB32
 
#define LOG_ERR(msg)
 
#define MAX_STREAMS   8
 

Functions

static void fallback_log (enum retro_log_level level, const char *fmt,...)
 
static retro_video_refresh_t CORE_PREFIX (video_cb)
 
static retro_audio_sample_t CORE_PREFIX (audio_cb)
 
static retro_audio_sample_batch_t CORE_PREFIX (audio_batch_cb)
 
static retro_environment_t CORE_PREFIX (environ_cb)
 
static retro_input_poll_t CORE_PREFIX (input_poll_cb)
 
static retro_input_state_t CORE_PREFIX (input_state_cb)
 
static void append_attachment (const uint8_t *data, size_t size)
 
void CORE_PREFIX() retro_init (void)
 
void CORE_PREFIX() retro_deinit (void)
 
unsigned CORE_PREFIX() retro_api_version (void)
 
void CORE_PREFIX() retro_set_controller_port_device (unsigned port, unsigned device)
 
void CORE_PREFIX() retro_get_system_info (struct retro_system_info *info)
 
void CORE_PREFIX() retro_get_system_av_info (struct retro_system_av_info *info)
 
void CORE_PREFIX() retro_set_environment (retro_environment_t cb)
 
void CORE_PREFIX() retro_set_audio_sample (retro_audio_sample_t cb)
 
void CORE_PREFIX() retro_set_audio_sample_batch (retro_audio_sample_batch_t cb)
 
void CORE_PREFIX() retro_set_input_poll (retro_input_poll_t cb)
 
void CORE_PREFIX() retro_set_input_state (retro_input_state_t cb)
 
void CORE_PREFIX() retro_set_video_refresh (retro_video_refresh_t cb)
 
void CORE_PREFIX() retro_reset (void)
 
static void check_variables (void)
 
static void seek_frame (int seek_frames)
 
void CORE_PREFIX() retro_run (void)
 
static bool open_codec (AVCodecContext **ctx, unsigned index)
 
static bool codec_is_image (enum AVCodecID id)
 
static bool codec_id_is_ttf (enum AVCodecID id)
 
static bool open_codecs (void)
 
static bool init_media_info (void)
 
static void set_colorspace (struct SwsContext *sws, unsigned width, unsigned height, enum AVColorSpace default_color, int in_range)
 
static bool decode_video (AVPacket *pkt, AVFrame *frame, AVFrame *conv, struct SwsContext *sws)
 
static int16_tdecode_audio (AVCodecContext *ctx, AVPacket *pkt, AVFrame *frame, int16_t *buffer, size_t *buffer_cap, SwrContext *swr)
 
static void decode_thread_seek (double time)
 
static void decode_thread (void *data)
 
void CORE_PREFIX() retro_unload_game (void)
 
bool CORE_PREFIX() retro_load_game (const struct retro_game_info *info)
 
unsigned CORE_PREFIX() retro_get_region (void)
 
bool CORE_PREFIX() retro_load_game_special (unsigned type, const struct retro_game_info *info, size_t num)
 
size_t CORE_PREFIX() retro_serialize_size (void)
 
bool CORE_PREFIX() retro_serialize (void *data, size_t size)
 
bool CORE_PREFIX() retro_unserialize (const void *data, size_t size)
 
void *CORE_PREFIX() retro_get_memory_data (unsigned id)
 
size_t CORE_PREFIX() retro_get_memory_size (unsigned id)
 
void CORE_PREFIX() retro_cheat_reset (void)
 
void CORE_PREFIX() retro_cheat_set (unsigned index, bool enabled, const char *code)
 

Variables

static bool reset_triggered
 
retro_log_printf_t log_cb
 
static AVFormatContext * fctx
 
static AVCodecContext * vctx
 
static int video_stream
 
static enum AVColorSpace colorspace
 
static AVCodecContext * actx [MAX_STREAMS]
 
static AVCodecContext * sctx [MAX_STREAMS]
 
static int audio_streams [MAX_STREAMS]
 
static int audio_streams_num
 
static int audio_streams_ptr
 
static int subtitle_streams [MAX_STREAMS]
 
static int subtitle_streams_num
 
static int subtitle_streams_ptr
 
static struct attachmentattachments
 
static size_t attachments_size
 
static uint64_t frame_cnt
 
static uint64_t audio_frames
 
static double pts_bias
 
static volatile bool decode_thread_dead
 
static fifo_buffer_tvideo_decode_fifo
 
static fifo_buffer_taudio_decode_fifo
 
static scond_tfifo_cond
 
static scond_tfifo_decode_cond
 
static slock_tfifo_lock
 
static slock_tdecode_thread_lock
 
static sthread_tdecode_thread_handle
 
static double decode_last_video_time
 
static double decode_last_audio_time
 
static uint32_tvideo_frame_temp_buffer
 
static bool main_sleeping
 
static bool do_seek
 
static double seek_time
 
static struct frame frames [2]
 
struct {
   unsigned   width
 
   unsigned   height
 
   double   interpolate_fps
 
   unsigned   sample_rate
 
   float   aspect
 
media
 

Macro Definition Documentation

◆ CORE_PREFIX

#define CORE_PREFIX (   s)    s

◆ LOG_ERR

#define LOG_ERR (   msg)
Value:
do { \
log_cb(RETRO_LOG_ERROR, "[FFmpeg]: " msg "\n"); \
} while(0)
static const unsigned char msg[]
Definition: ccm.c:375
Definition: libretro.h:1569

◆ MAX_STREAMS

#define MAX_STREAMS   8

◆ PIX_FMT_RGB32

#define PIX_FMT_RGB32   AV_PIX_FMT_RGB32

Function Documentation

◆ append_attachment()

static void append_attachment ( const uint8_t data,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_variables()

static void check_variables ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ codec_id_is_ttf()

static bool codec_id_is_ttf ( enum AVCodecID  id)
static
Here is the caller graph for this function:

◆ codec_is_image()

static bool codec_is_image ( enum AVCodecID  id)
static
Here is the caller graph for this function:

◆ CORE_PREFIX() [1/6]

static retro_video_refresh_t CORE_PREFIX ( video_cb  )
static

◆ CORE_PREFIX() [2/6]

static retro_audio_sample_t CORE_PREFIX ( audio_cb  )
static

◆ CORE_PREFIX() [3/6]

static retro_audio_sample_batch_t CORE_PREFIX ( audio_batch_cb  )
static

◆ CORE_PREFIX() [4/6]

static retro_environment_t CORE_PREFIX ( environ_cb  )
static

◆ CORE_PREFIX() [5/6]

static retro_input_poll_t CORE_PREFIX ( input_poll_cb  )
static

◆ CORE_PREFIX() [6/6]

static retro_input_state_t CORE_PREFIX ( input_state_cb  )
static

◆ decode_audio()

static int16_t* decode_audio ( AVCodecContext *  ctx,
AVPacket *  pkt,
AVFrame *  frame,
int16_t buffer,
size_t *  buffer_cap,
SwrContext *  swr 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode_thread()

static void decode_thread ( void data)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode_thread_seek()

static void decode_thread_seek ( double  time)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode_video()

static bool decode_video ( AVPacket *  pkt,
AVFrame *  frame,
AVFrame *  conv,
struct SwsContext *  sws 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fallback_log()

static void fallback_log ( enum retro_log_level  level,
const char *  fmt,
  ... 
)
static
Here is the caller graph for this function:

◆ init_media_info()

static bool init_media_info ( void  )
static
Here is the caller graph for this function:

◆ open_codec()

static bool open_codec ( AVCodecContext **  ctx,
unsigned  index 
)
static
Here is the caller graph for this function:

◆ open_codecs()

static bool open_codecs ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ retro_api_version()

unsigned CORE_PREFIX() retro_api_version ( void  )
Here is the caller graph for this function:

◆ retro_cheat_reset()

void CORE_PREFIX() retro_cheat_reset ( void  )
Here is the caller graph for this function:

◆ retro_cheat_set()

void CORE_PREFIX() retro_cheat_set ( unsigned  index,
bool  enabled,
const char *  code 
)
Here is the caller graph for this function:

◆ retro_deinit()

void CORE_PREFIX() retro_deinit ( void  )
Here is the caller graph for this function:

◆ retro_get_memory_data()

void* CORE_PREFIX() retro_get_memory_data ( unsigned  id)
Here is the caller graph for this function:

◆ retro_get_memory_size()

size_t CORE_PREFIX() retro_get_memory_size ( unsigned  id)
Here is the caller graph for this function:

◆ retro_get_region()

unsigned CORE_PREFIX() retro_get_region ( void  )
Here is the caller graph for this function:

◆ retro_get_system_av_info()

void CORE_PREFIX() retro_get_system_av_info ( struct retro_system_av_info info)
Here is the caller graph for this function:

◆ retro_get_system_info()

void CORE_PREFIX() retro_get_system_info ( struct retro_system_info info)
Here is the caller graph for this function:

◆ retro_init()

void CORE_PREFIX() retro_init ( void  )
Here is the caller graph for this function:

◆ retro_load_game()

bool CORE_PREFIX() retro_load_game ( const struct retro_game_info info)
Here is the caller graph for this function:

◆ retro_load_game_special()

bool CORE_PREFIX() retro_load_game_special ( unsigned  type,
const struct retro_game_info info,
size_t  num 
)
Here is the caller graph for this function:

◆ retro_reset()

void CORE_PREFIX() retro_reset ( void  )
Here is the caller graph for this function:

◆ retro_run()

void CORE_PREFIX() retro_run ( void  )
Here is the caller graph for this function:

◆ retro_serialize()

bool CORE_PREFIX() retro_serialize ( void data,
size_t  size 
)
Here is the caller graph for this function:

◆ retro_serialize_size()

size_t CORE_PREFIX() retro_serialize_size ( void  )
Here is the caller graph for this function:

◆ retro_set_audio_sample()

void CORE_PREFIX() retro_set_audio_sample ( retro_audio_sample_t  cb)
Here is the caller graph for this function:

◆ retro_set_audio_sample_batch()

void CORE_PREFIX() retro_set_audio_sample_batch ( retro_audio_sample_batch_t  cb)
Here is the caller graph for this function:

◆ retro_set_controller_port_device()

void CORE_PREFIX() retro_set_controller_port_device ( unsigned  port,
unsigned  device 
)
Here is the caller graph for this function:

◆ retro_set_environment()

void CORE_PREFIX() retro_set_environment ( retro_environment_t  cb)
Here is the caller graph for this function:

◆ retro_set_input_poll()

void CORE_PREFIX() retro_set_input_poll ( retro_input_poll_t  cb)
Here is the caller graph for this function:

◆ retro_set_input_state()

void CORE_PREFIX() retro_set_input_state ( retro_input_state_t  cb)
Here is the caller graph for this function:

◆ retro_set_video_refresh()

void CORE_PREFIX() retro_set_video_refresh ( retro_video_refresh_t  cb)
Here is the caller graph for this function:

◆ retro_unload_game()

void CORE_PREFIX() retro_unload_game ( void  )
Here is the caller graph for this function:

◆ retro_unserialize()

bool CORE_PREFIX() retro_unserialize ( const void data,
size_t  size 
)
Here is the caller graph for this function:

◆ seek_frame()

static void seek_frame ( int  seek_frames)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_colorspace()

static void set_colorspace ( struct SwsContext *  sws,
unsigned  width,
unsigned  height,
enum AVColorSpace  default_color,
int  in_range 
)
static
Here is the caller graph for this function:

Variable Documentation

◆ actx

AVCodecContext* actx[MAX_STREAMS]
static

◆ aspect

float aspect

◆ attachments

struct attachment* attachments
static

◆ attachments_size

size_t attachments_size
static

◆ audio_decode_fifo

fifo_buffer_t* audio_decode_fifo
static

◆ audio_frames

uint64_t audio_frames
static

◆ audio_streams

int audio_streams[MAX_STREAMS]
static

◆ audio_streams_num

int audio_streams_num
static

◆ audio_streams_ptr

int audio_streams_ptr
static

◆ colorspace

enum AVColorSpace colorspace
static

◆ decode_last_audio_time

double decode_last_audio_time
static

◆ decode_last_video_time

double decode_last_video_time
static

◆ decode_thread_dead

volatile bool decode_thread_dead
static

◆ decode_thread_handle

sthread_t* decode_thread_handle
static

◆ decode_thread_lock

slock_t* decode_thread_lock
static

◆ do_seek

bool do_seek
static

◆ fctx

AVFormatContext* fctx
static

◆ fifo_cond

scond_t* fifo_cond
static

◆ fifo_decode_cond

scond_t* fifo_decode_cond
static

◆ fifo_lock

slock_t* fifo_lock
static

◆ frame_cnt

uint64_t frame_cnt
static

◆ frames

struct frame frames[2]
static

◆ height

unsigned height

◆ interpolate_fps

double interpolate_fps

◆ log_cb

◆ main_sleeping

bool main_sleeping
static

◆ media

struct { ... } media

◆ pts_bias

double pts_bias
static

◆ reset_triggered

bool reset_triggered
static

◆ sample_rate

unsigned sample_rate

◆ sctx

AVCodecContext* sctx[MAX_STREAMS]
static

◆ seek_time

double seek_time
static

◆ subtitle_streams

int subtitle_streams[MAX_STREAMS]
static

◆ subtitle_streams_num

int subtitle_streams_num
static

◆ subtitle_streams_ptr

int subtitle_streams_ptr
static

◆ vctx

AVCodecContext* vctx
static

◆ video_decode_fifo

fifo_buffer_t* video_decode_fifo
static

◆ video_frame_temp_buffer

uint32_t* video_frame_temp_buffer
static

◆ video_stream

int video_stream
static

◆ width

unsigned width