double-framerate: small fixes

- fixed taking codec from input frame (that may be NULL)
- set drop policy only if option nodelay is used - after the previous
  changes, the second frame is correctly output and the filter delays
  it output automatically (until "nodelay" is used)
This commit is contained in:
Martin Pulec
2023-01-11 10:27:30 +01:00
parent 5439cbcc9e
commit 694b226ec1
2 changed files with 9 additions and 8 deletions

View File

@@ -155,7 +155,7 @@ struct video_display_info {
void (*run) (void *state); ///< may be NULL
void (*done) (void *state);
struct video_frame *(*getf) (void *state);
/// @param timeout_ns display is supposed immplement the PUTF_* macros, numerical timeout is seldom used (but double-framerate postprocess requires that)
/// @param timeout_ns display is supposed immplement the PUTF_* macros, numerical timeout is seldom used (but double-framerate postprocess can use that)
int (*putf) (void *state, struct video_frame *frame, long long timeout_ns);
int (*reconfigure_video)(void *state, struct video_desc desc);
int (*ctl_property)(void *state, int property, void *val, size_t *len);

View File

@@ -96,8 +96,9 @@ static void * df_init(const char *config) {
s->buffer_current = 0;
s->deinterlace = deinterlace;
s->nodelay = nodelay;
if (commandline_params.find("decoder-drop-policy") == commandline_params.end()) {
log_msg(LOG_LEVEL_NOTICE, MOD_NAME "Setting drop policy to %s timeout.\n", TIMEOUT);
if (s->nodelay && commandline_params.find("decoder-drop-policy") == commandline_params.end()) {
log_msg(LOG_LEVEL_NOTICE, MOD_NAME "nodelay option used, setting drop policy to %s timeout.\n", TIMEOUT);
commandline_params["decoder-drop-policy"] = TIMEOUT;
}
@@ -154,22 +155,22 @@ static struct video_frame * df_getf(void *state)
return s->in;
}
/// @param in may be NULL
static bool df_postprocess(void *state, struct video_frame *in, struct video_frame *out, int req_pitch)
{
struct state_df *s = (struct state_df *) state;
unsigned int y;
if(in != NULL) {
char *src = s->buffers[(s->buffer_current + 1) % 2] + vc_get_linesize(s->in->tiles[0].width, s->in->color_spec);
char *dst = out->tiles[0].data + req_pitch;
for (y = 0; y < out->tiles[0].height; y += 2) {
for (unsigned y = 0; y < out->tiles[0].height; y += 2) {
memcpy(dst, src, vc_get_linesize(s->in->tiles[0].width, s->in->color_spec));
dst += 2 * req_pitch;
src += 2 * vc_get_linesize(s->in->tiles[0].width, s->in->color_spec);
}
src = s->buffers[s->buffer_current];
dst = out->tiles[0].data;
for (y = 1; y < out->tiles[0].height; y += 2) {
for (unsigned y = 1; y < out->tiles[0].height; y += 2) {
memcpy(dst, src, vc_get_linesize(s->in->tiles[0].width, s->in->color_spec));
dst += 2 * req_pitch;
src += 2 * vc_get_linesize(s->in->tiles[0].width, s->in->color_spec);
@@ -177,7 +178,7 @@ static bool df_postprocess(void *state, struct video_frame *in, struct video_fra
} else {
char *src = s->buffers[s->buffer_current];
char *dst = out->tiles[0].data;
for (y = 0; y < out->tiles[0].height; ++y) {
for (unsigned y = 0; y < out->tiles[0].height; ++y) {
memcpy(dst, src, vc_get_linesize(s->in->tiles[0].width, s->in->color_spec));
dst += req_pitch;
src += vc_get_linesize(s->in->tiles[0].width, s->in->color_spec);
@@ -185,7 +186,7 @@ static bool df_postprocess(void *state, struct video_frame *in, struct video_fra
}
if (s->deinterlace) {
if (!vc_deinterlace_ex(in->color_spec,
if (!vc_deinterlace_ex(out->color_spec,
(unsigned char *) out->tiles[0].data, vc_get_linesize(out->tiles[0].width, out->color_spec),
(unsigned char *) out->tiles[0].data, vc_get_linesize(out->tiles[0].width, out->color_spec),
out->tiles[0].height)) {