Fix colorspace conversion and sbs2 frame rate issues

This commit is contained in:
spicyjpeg 2023-05-16 10:30:59 +02:00
parent 4419132326
commit 67746af7b4
No known key found for this signature in database
GPG Key ID: 5CC87404C01DF393
3 changed files with 12 additions and 7 deletions

View File

@ -69,7 +69,6 @@ typedef struct {
} vid_encoder_state_t;
typedef struct {
int video_frame_src_size;
int video_frame_dst_size;
int audio_stream_index;
int video_stream_index;

View File

@ -48,7 +48,6 @@ bool open_av_data(const char *filename, settings_t *settings, bool use_audio, bo
av_decoder_state_t* av = &(settings->decoder_state_av);
av->video_next_pts = 0.0;
av->frame = NULL;
av->video_frame_src_size = 0;
av->video_frame_dst_size = 0;
av->audio_stream_index = -1;
av->video_stream_index = -1;
@ -202,8 +201,13 @@ bool open_av_data(const char *filename, settings_t *settings, bool use_audio, bo
NULL,
NULL
);
// Is this even necessary? -- spicyjpeg
sws_setColorspaceDetails(
if (av->scaler == NULL) {
return false;
}
#if 0
// FIXME: if this is uncommented libswscale may produce completely black
// frames for whatever reason...
if (sws_setColorspaceDetails(
av->scaler,
sws_getCoefficients(av->video_codec_context->colorspace),
(av->video_codec_context->color_range == AVCOL_RANGE_JPEG),
@ -212,14 +216,16 @@ bool open_av_data(const char *filename, settings_t *settings, bool use_audio, bo
0,
0,
0
);
) < 0) {
return false;
}
#endif
if (settings->swscale_options) {
if (av_opt_set_from_string(av->scaler, settings->swscale_options, NULL, "=", ":,") < 0) {
return false;
}
}
av->video_frame_src_size = 4*av->video_codec_context->width*av->video_codec_context->height;
av->video_frame_dst_size = 3*settings->video_width*settings->video_height/2;
}

View File

@ -363,7 +363,7 @@ void encode_file_sbs(settings_t *settings, FILE *output) {
settings->state_vid.frame_max_size = settings->alignment;
settings->state_vid.quant_scale_sum = 0;
for (int j = 0; ensure_av_data(settings, 0, 1); j++) {
for (int j = 0; ensure_av_data(settings, 0, 2); j++) {
encode_frame_bs(settings->video_frames, settings);
fwrite(settings->state_vid.frame_output, settings->alignment, 1, output);