mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 13:14:04 +00:00
Update API usage of FFmpeg. Use 2 threads for encoding :)
This commit is contained in:
parent
c4d6b0b7c1
commit
ff7843cbe9
@ -79,14 +79,13 @@ static bool init_audio(struct audio_info *audio, struct ffemu_params *param)
|
||||
if (!codec)
|
||||
return false;
|
||||
|
||||
audio->codec = avcodec_alloc_context();
|
||||
avcodec_get_context_defaults(audio->codec);
|
||||
audio->codec = avcodec_alloc_context3(codec);
|
||||
|
||||
audio->codec->sample_rate = param->samplerate;
|
||||
audio->codec->time_base = (AVRational) { 1, param->samplerate };
|
||||
audio->codec->channels = param->channels;
|
||||
audio->codec->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
if (avcodec_open(audio->codec, codec) != 0)
|
||||
if (avcodec_open2(audio->codec, codec, NULL) != 0)
|
||||
return false;
|
||||
|
||||
audio->buffer = av_malloc(audio->codec->frame_size * param->channels * sizeof(int16_t));
|
||||
@ -119,14 +118,15 @@ static bool init_video(struct video_info *video, struct ffemu_params *param)
|
||||
video->pix_size = sizeof(uint32_t);
|
||||
}
|
||||
|
||||
video->codec = avcodec_alloc_context();
|
||||
video->codec = avcodec_alloc_context3(codec);
|
||||
video->codec->width = param->out_width;
|
||||
video->codec->height = param->out_height;
|
||||
video->codec->time_base = (AVRational) {param->fps.den, param->fps.num};
|
||||
video->codec->pix_fmt = PIX_FMT_RGB32;
|
||||
video->codec->sample_aspect_ratio = av_d2q(param->aspect_ratio * param->out_height / param->out_width, 255);
|
||||
video->codec->thread_count = 2;
|
||||
|
||||
if (avcodec_open(video->codec, codec) != 0)
|
||||
if (avcodec_open2(video->codec, codec, NULL) != 0)
|
||||
return false;
|
||||
|
||||
// Allocate a big buffer :p ffmpeg API doesn't seem to give us some clues how big this buffer should be.
|
||||
@ -173,7 +173,7 @@ static bool init_muxer(ffemu_t *handle)
|
||||
handle->audio.codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||
handle->muxer.astream = stream;
|
||||
|
||||
if (av_write_header(ctx) < 0)
|
||||
if (avformat_write_header(ctx, NULL) < 0)
|
||||
return false;
|
||||
|
||||
handle->muxer.ctx = ctx;
|
||||
@ -244,7 +244,6 @@ static void deinit_thread_buf(ffemu_t *handle)
|
||||
|
||||
ffemu_t *ffemu_new(const struct ffemu_params *params)
|
||||
{
|
||||
avcodec_init();
|
||||
av_register_all();
|
||||
|
||||
ffemu_t *handle = calloc(1, sizeof(*handle));
|
||||
|
Loading…
x
Reference in New Issue
Block a user