mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-22 10:40:25 +00:00
Postprocess decoder updates
Some semantic fixes (processing multiple tiles and non-/tiling-changing postprocessors handling). TODO: Rewrite to a more understandable way.
This commit is contained in:
@@ -262,7 +262,7 @@ void decoder_register_video_display(struct state_decoder *decoder, struct displa
|
||||
|
||||
if(decoder->postprocess) {
|
||||
codec_t postprocess_supported_codecs[20];
|
||||
int len = sizeof(postprocess_supported_codecs);
|
||||
size_t len = sizeof(postprocess_supported_codecs);
|
||||
bool ret = vo_postprocess_get_property(decoder->postprocess, VO_PP_PROPERTY_CODECS,
|
||||
(void *) postprocess_supported_codecs, &len);
|
||||
|
||||
@@ -505,12 +505,47 @@ static struct video_frame * reconfigure_decoder(struct state_decoder * const dec
|
||||
return NULL;
|
||||
struct video_desc display_desc = desc;
|
||||
|
||||
int display_mode;
|
||||
size_t len = sizeof(int);
|
||||
int ret;
|
||||
|
||||
ret = display_get_property(decoder->display, DISPLAY_PROPERTY_VIDEO_MODE,
|
||||
&display_mode, &len);
|
||||
if(!ret) {
|
||||
debug_msg("Failed to get video display mode.");
|
||||
display_mode = DISPLAY_PROPERTY_VIDEO_MERGED;
|
||||
}
|
||||
|
||||
bool pp_does_change_tiling_mode = false;
|
||||
|
||||
if (decoder->postprocess) {
|
||||
size_t len = sizeof(pp_does_change_tiling_mode);
|
||||
if(vo_postprocess_get_property(decoder->postprocess, VO_PP_DOES_CHANGE_TILING_MODE,
|
||||
&pp_does_change_tiling_mode, &len)) {
|
||||
if(len == 0) {
|
||||
// just for sake of completness since it shouldn't be a case
|
||||
fprintf(stderr, "[Decoder] Warning: unable to get pp tiling mode!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(decoder->postprocess) {
|
||||
struct video_desc pp_desc = desc;
|
||||
pp_desc.color_spec = out_codec;
|
||||
if(!pp_does_change_tiling_mode) {
|
||||
pp_desc.width *= get_video_mode_tiles_x(decoder->video_mode);
|
||||
pp_desc.height *= get_video_mode_tiles_y(decoder->video_mode);
|
||||
pp_desc.tile_count = 1;
|
||||
}
|
||||
vo_postprocess_reconfigure(decoder->postprocess, pp_desc);
|
||||
decoder->pp_frame = vo_postprocess_getf(decoder->postprocess);
|
||||
vo_postprocess_get_out_desc(decoder->postprocess, &display_desc, &render_mode, &decoder->pp_output_frames_count);
|
||||
} else {
|
||||
if(display_mode == DISPLAY_PROPERTY_VIDEO_MERGED) {
|
||||
display_desc.width *= get_video_mode_tiles_x(decoder->video_mode);
|
||||
display_desc.height *= get_video_mode_tiles_y(decoder->video_mode);
|
||||
display_desc.tile_count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_codec_opaque(out_codec)) {
|
||||
@@ -519,29 +554,12 @@ static struct video_frame * reconfigure_decoder(struct state_decoder * const dec
|
||||
decoder->change_il = NULL;
|
||||
}
|
||||
|
||||
|
||||
size_t len = sizeof(int);
|
||||
int ret;
|
||||
|
||||
int display_mode;
|
||||
ret = display_get_property(decoder->display, DISPLAY_PROPERTY_VIDEO_MODE,
|
||||
&display_mode, &len);
|
||||
if(!ret) {
|
||||
debug_msg("Failed to get video display mode.");
|
||||
display_mode = DISPLAY_PROPERTY_VIDEO_MERGED;
|
||||
}
|
||||
|
||||
if (!decoder->postprocess) { /* otherwise we need postprocessor mode, which we obtained before */
|
||||
if (!decoder->postprocess || !pp_does_change_tiling_mode) { /* otherwise we need postprocessor mode, which we obtained before */
|
||||
render_mode = display_mode;
|
||||
}
|
||||
|
||||
display_desc.color_spec = out_codec;
|
||||
display_desc.interlacing = display_il;
|
||||
if(!decoder->postprocess && display_mode == DISPLAY_PROPERTY_VIDEO_MERGED) {
|
||||
display_desc.width *= get_video_mode_tiles_x(decoder->video_mode);
|
||||
display_desc.height *= get_video_mode_tiles_y(decoder->video_mode);
|
||||
display_desc.tile_count = 1;
|
||||
}
|
||||
|
||||
if(!video_desc_eq(decoder->display_desc, display_desc))
|
||||
{
|
||||
@@ -600,7 +618,6 @@ static struct video_frame * reconfigure_decoder(struct state_decoder * const dec
|
||||
linewidth = desc.width * get_video_mode_tiles_x(decoder->video_mode);
|
||||
}
|
||||
|
||||
|
||||
if(!decoder->postprocess) {
|
||||
if(decoder->requested_pitch == PITCH_DEFAULT)
|
||||
decoder->pitch = vc_get_linesize(linewidth, out_codec);
|
||||
@@ -1139,8 +1156,6 @@ int decode_frame(struct coded_data *cdata, void *decode_data)
|
||||
|
||||
if(!pp_ret) {
|
||||
ret = FALSE;
|
||||
|
||||
assert(decoder->pp_output_frames_count == 1);
|
||||
decoder->pp_frame = vo_postprocess_getf(decoder->postprocess);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -1148,10 +1163,15 @@ int decode_frame(struct coded_data *cdata, void *decode_data)
|
||||
for (i = 1; i < decoder->pp_output_frames_count; ++i) {
|
||||
display_put_frame(decoder->display, (char *) frame);
|
||||
frame = display_get_frame(decoder->display);
|
||||
vo_postprocess(decoder->postprocess,
|
||||
pp_ret = vo_postprocess(decoder->postprocess,
|
||||
NULL,
|
||||
frame,
|
||||
decoder->display_pitch);
|
||||
if(!pp_ret) {
|
||||
ret = FALSE;
|
||||
decoder->pp_frame = vo_postprocess_getf(decoder->postprocess);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
/* get new postprocess frame */
|
||||
|
||||
@@ -74,7 +74,19 @@ typedef void *(*vo_postprocess_init_t)(char *cfg);
|
||||
*/
|
||||
typedef int (*vo_postprocess_reconfigure_t)(void *state, struct video_desc desc);
|
||||
typedef struct video_frame * (*vo_postprocess_getf_t)(void *state);
|
||||
typedef void (*vo_postprocess_get_out_desc_t)(void *, struct video_desc *out, int *display_mode, int *out_frame_count);
|
||||
/*
|
||||
* Returns various information about postprocessor format not only output (legacy name).
|
||||
*
|
||||
* @param s postprocessor state
|
||||
* @param out output video description according to input parameters
|
||||
* @param in_display_mode some postprocessors change tiling mode (this is queryied by get_property
|
||||
* function). If postprocessor does not report that it changes tiling mode,
|
||||
* this parameter should be ignored.
|
||||
* @param out_frame_count Because the postprocess function is called synchronously, in case that
|
||||
* from one input frame is generated more, this sets how many can be generated
|
||||
* at maximum.
|
||||
*/
|
||||
typedef void (*vo_postprocess_get_out_desc_t)(void *s, struct video_desc *out, int *in_tile_mode, int *out_frame_count);
|
||||
|
||||
/**
|
||||
* Returns supported codecs
|
||||
@@ -97,7 +109,9 @@ typedef bool (*vo_postprocess_get_property_t)(void *state, int property, void *v
|
||||
*
|
||||
* @param state postprocessor state
|
||||
* @param input frame
|
||||
* @return flag if output video frame is filled with valid data
|
||||
*
|
||||
* @return flag If output video frame is filled with valid data.
|
||||
*
|
||||
*/
|
||||
typedef bool (*vo_postprocess_t)(void *state, struct video_frame *in, struct video_frame *out, int req_out_pitch);
|
||||
|
||||
|
||||
@@ -172,13 +172,14 @@ void interlace_get_out_desc(void *state, struct video_desc *out, int *in_display
|
||||
{
|
||||
struct state_interlace *s = (struct state_interlace *) state;
|
||||
|
||||
out->width = vf_get_tile(s->odd, 0)->width * 2;
|
||||
out->height = vf_get_tile(s->odd, 0)->height * 2;
|
||||
out->width = vf_get_tile(s->odd, 0)->width;
|
||||
out->height = vf_get_tile(s->odd, 0)->height;
|
||||
out->color_spec = s->odd->color_spec;
|
||||
out->interlacing = INTERLACED_MERGED;
|
||||
out->fps = s->odd->fps / 2.0;
|
||||
out->tile_count =1; s->odd->tile_count;
|
||||
out->tile_count = s->odd->tile_count;
|
||||
|
||||
*in_display_mode = DISPLAY_PROPERTY_VIDEO_MERGED;
|
||||
UNUSED(in_display_mode);
|
||||
//*in_display_mode = DISPLAY_PROPERTY_VIDEO_MERGED;
|
||||
*out_frames = 1;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
#include "video_codec.h"
|
||||
#include "video_display.h" /* DISPLAY_PROPERTY_VIDEO_SEPARATE_FILES */
|
||||
#include "vo_postprocess.h" /* VO_PP_DOES_CHANGE_TILING_MODE */
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include "vo_postprocess/split.h"
|
||||
@@ -72,8 +73,8 @@ bool split_get_property(void *state, int property, void *val, size_t *len)
|
||||
|
||||
switch(property) {
|
||||
case VO_PP_DOES_CHANGE_TILING_MODE:
|
||||
if(len >= sizeof(bool)) {
|
||||
*val = true;
|
||||
if(*len >= sizeof(bool)) {
|
||||
*(bool *) val = true;
|
||||
*len = sizeof(bool);
|
||||
} else {
|
||||
*len = 0;
|
||||
|
||||
Reference in New Issue
Block a user