(record_ffmpeg.c) Move scaler code to gfx/video_frame.h

This commit is contained in:
twinaphex 2016-05-04 17:11:22 +02:00
parent bfcc89f580
commit b8e140d6c4
2 changed files with 47 additions and 20 deletions

View File

@ -64,6 +64,40 @@ static INLINE void video_frame_scale(
scaler_ctx_scale(scaler, output, input);
}
static INLINE void video_frame_record_scale(
struct scaler_ctx *scaler,
void *output,
const void *input,
unsigned scaler_width,
unsigned scaler_height,
unsigned scaler_pitch,
unsigned width,
unsigned height,
unsigned pitch,
bool bilinear)
{
if (
width != (unsigned)scaler->in_width
|| height != (unsigned)scaler->in_height
)
{
scaler->in_width = width;
scaler->in_height = height;
scaler->in_stride = pitch;
scaler->scaler_type = bilinear ?
SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT;
scaler->out_width = scaler_width;
scaler->out_height = scaler_height;
scaler->out_stride = scaler_pitch;
scaler_ctx_gen_filter(scaler);
}
scaler_ctx_scale(scaler, output, input);
}
static INLINE void video_frame_convert_argb8888_to_abgr8888(
struct scaler_ctx *scaler,
void *output, const void *input,

View File

@ -66,6 +66,8 @@ extern "C" {
#include "../../audio/audio_utils.h"
#include "../record_driver.h"
#include "../../gfx/video_frame.h"
#ifndef PIX_FMT_RGB32
#define PIX_FMT_RGB32 AV_PIX_FMT_RGB32
#endif
@ -978,26 +980,17 @@ static void ffmpeg_scale_input(ffmpeg_t *handle,
}
else
{
if ((int)vid->width != handle->video.scaler.in_width
|| (int)vid->height != handle->video.scaler.in_height)
{
handle->video.scaler.in_width = vid->width;
handle->video.scaler.in_height = vid->height;
handle->video.scaler.in_stride = vid->pitch;
handle->video.scaler.scaler_type = shrunk ?
SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT;
handle->video.scaler.out_width = handle->params.out_width;
handle->video.scaler.out_height = handle->params.out_height;
handle->video.scaler.out_stride =
handle->video.conv_frame->linesize[0];
scaler_ctx_gen_filter(&handle->video.scaler);
}
scaler_ctx_scale(&handle->video.scaler,
handle->video.conv_frame->data[0], vid->data);
video_frame_record_scale(
&handle->video.scaler,
handle->video.conv_frame->data[0],
vid->data,
handle->params.out_width,
handle->params.out_height,
handle->video.conv_frame->linesize[0],
vid->width,
vid->height,
vid->pitch,
shrunk);
}
}