mirror of
https://github.com/libretro/RetroArch
synced 2025-04-25 09:02:44 +00:00
Some fixes to FFmpeg. Conserves RAM better.
This commit is contained in:
parent
08ca1a54d3
commit
d2bc4096de
@ -163,11 +163,10 @@ static bool init_video(struct video_info *video, struct ffemu_params *param)
|
|||||||
video->outbuf_size = 1 << 23;
|
video->outbuf_size = 1 << 23;
|
||||||
video->outbuf = av_malloc(video->outbuf_size);
|
video->outbuf = av_malloc(video->outbuf_size);
|
||||||
|
|
||||||
// Just to make sure we can handle the biggest frames.
|
size_t size = avpicture_get_size(PIX_FMT_RGB32, param->out_width, param->out_height);
|
||||||
int size = avpicture_get_size(PIX_FMT_RGB32, param->fb_width, param->fb_height);
|
|
||||||
video->conv_frame_buf = av_malloc(size);
|
video->conv_frame_buf = av_malloc(size);
|
||||||
video->conv_frame = avcodec_alloc_frame();
|
video->conv_frame = avcodec_alloc_frame();
|
||||||
avpicture_fill((AVPicture*)video->conv_frame, video->conv_frame_buf, PIX_FMT_RGB32, param->fb_width, param->fb_height);
|
avpicture_fill((AVPicture*)video->conv_frame, video->conv_frame_buf, PIX_FMT_RGB32, param->out_width, param->out_height);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -382,8 +381,16 @@ int ffemu_push_video(ffemu_t *handle, const struct ffemu_video_data *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
slock_lock(handle->lock);
|
slock_lock(handle->lock);
|
||||||
fifo_write(handle->attr_fifo, data, sizeof(*data));
|
|
||||||
fifo_write(handle->video_fifo, data->data, data->pitch * data->height);
|
// Tightly pack our frame to conserve memory. libsnes tends to use a very large pitch.
|
||||||
|
struct ffemu_video_data attr_data = *data;
|
||||||
|
attr_data.pitch = attr_data.width * handle->video.pix_size;
|
||||||
|
fifo_write(handle->attr_fifo, &attr_data, sizeof(attr_data));
|
||||||
|
|
||||||
|
unsigned offset = 0;
|
||||||
|
for (unsigned y = 0; y < data->height; y++, offset += data->pitch)
|
||||||
|
fifo_write(handle->video_fifo, (const uint8_t*)data->data + offset, attr_data.pitch);
|
||||||
|
|
||||||
slock_unlock(handle->lock);
|
slock_unlock(handle->lock);
|
||||||
scond_signal(handle->cond);
|
scond_signal(handle->cond);
|
||||||
|
|
||||||
@ -434,7 +441,7 @@ static int ffemu_push_video_thread(ffemu_t *handle, const struct ffemu_video_dat
|
|||||||
int linesize = data->pitch;
|
int linesize = data->pitch;
|
||||||
|
|
||||||
sws_scale(handle->video.sws_ctx, (const uint8_t* const*)&data->data, &linesize, 0,
|
sws_scale(handle->video.sws_ctx, (const uint8_t* const*)&data->data, &linesize, 0,
|
||||||
handle->video.codec->height, handle->video.conv_frame->data, handle->video.conv_frame->linesize);
|
data->height, handle->video.conv_frame->data, handle->video.conv_frame->linesize);
|
||||||
|
|
||||||
handle->video.conv_frame->pts = handle->video.frame_cnt;
|
handle->video.conv_frame->pts = handle->video.frame_cnt;
|
||||||
handle->video.conv_frame->display_picture_number = handle->video.frame_cnt;
|
handle->video.conv_frame->display_picture_number = handle->video.frame_cnt;
|
||||||
|
8
ssnes.c
8
ssnes.c
@ -404,7 +404,7 @@ static void print_help(void)
|
|||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
puts("\t-r/--record: Path to record video file.\n\t\tUsing .mkv extension is recommended, and codecs used are FFV1/FLAC.");
|
puts("\t-r/--record: Path to record video file.\n\t\tUsing .mkv extension is recommended, and codecs used are FFV1/FLAC.");
|
||||||
puts("\t--size: Overrides output video size when recording with FFmpeg (format: width:height).");
|
puts("\t--size: Overrides output video size when recording with FFmpeg (format: widthxheight).");
|
||||||
#endif
|
#endif
|
||||||
puts("\t-v/--verbose: Verbose logging.");
|
puts("\t-v/--verbose: Verbose logging.");
|
||||||
puts("\t-U/--ups: Specifies path for UPS patch that will be applied to ROM.");
|
puts("\t-U/--ups: Specifies path for UPS patch that will be applied to ROM.");
|
||||||
@ -720,7 +720,7 @@ static void parse_input(int argc, char *argv[])
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
g_extern.record_width = strtoul(optarg, &ptr, 0);
|
g_extern.record_width = strtoul(optarg, &ptr, 0);
|
||||||
if ((*ptr != ':') || errno)
|
if ((*ptr != 'x') || errno)
|
||||||
{
|
{
|
||||||
SSNES_ERR("Wrong format for --size.\n");
|
SSNES_ERR("Wrong format for --size.\n");
|
||||||
print_help();
|
print_help();
|
||||||
@ -879,7 +879,7 @@ static void init_recording(void)
|
|||||||
struct ffemu_params params = {
|
struct ffemu_params params = {
|
||||||
.out_width = 256,
|
.out_width = 256,
|
||||||
.out_height = 224,
|
.out_height = 224,
|
||||||
.fb_width = 1024,
|
.fb_width = 512,
|
||||||
.fb_height = 512,
|
.fb_height = 512,
|
||||||
.channels = 2,
|
.channels = 2,
|
||||||
.samplerate = 32000,
|
.samplerate = 32000,
|
||||||
@ -908,7 +908,7 @@ static void init_recording(void)
|
|||||||
unsigned max_width = 512;
|
unsigned max_width = 512;
|
||||||
unsigned max_height = 512;
|
unsigned max_height = 512;
|
||||||
g_extern.filter.psize(&max_width, &max_height);
|
g_extern.filter.psize(&max_width, &max_height);
|
||||||
params.fb_width = g_extern.filter.pitch >> 2;
|
params.fb_width = next_pow2(max_width);
|
||||||
params.fb_height = next_pow2(max_height);
|
params.fb_height = next_pow2(max_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user