mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
encoder: jpeg: Fix the sampling factor calculation for ENCODED format.
If the incoming raw video format is GST_VIDEO_FORMAT_ENCODED, use native YUV420 format (which is i420) as default.
This commit is contained in:
parent
0f40843bb3
commit
6b73746ab6
1 changed files with 17 additions and 4 deletions
|
@ -88,9 +88,21 @@ generate_sampling_factors (GstVaapiEncoderJpeg * encoder)
|
||||||
|
|
||||||
vinfo = GST_VAAPI_ENCODER_VIDEO_INFO (encoder);
|
vinfo = GST_VAAPI_ENCODER_VIDEO_INFO (encoder);
|
||||||
|
|
||||||
|
if (GST_VIDEO_INFO_FORMAT (vinfo) == GST_VIDEO_FORMAT_ENCODED) {
|
||||||
|
/* Use native I420 format */
|
||||||
|
encoder->n_components = 3;
|
||||||
|
for (i = 0; i < encoder->n_components; ++i) {
|
||||||
|
if (i == 0)
|
||||||
|
encoder->h_samp[i] = encoder->v_samp[i] = 2;
|
||||||
|
else
|
||||||
|
encoder->h_samp[i] = encoder->v_samp[i] = 1;
|
||||||
|
GST_DEBUG ("sampling factors: %d %d", encoder->h_samp[i],
|
||||||
|
encoder->v_samp[i]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
encoder->n_components = GST_VIDEO_INFO_N_COMPONENTS (vinfo);
|
encoder->n_components = GST_VIDEO_INFO_N_COMPONENTS (vinfo);
|
||||||
if (GST_VIDEO_INFO_IS_GRAY (vinfo))
|
|
||||||
encoder->n_components = 1;
|
|
||||||
|
|
||||||
encoder->h_max_samp = 0;
|
encoder->h_max_samp = 0;
|
||||||
encoder->v_max_samp = 0;
|
encoder->v_max_samp = 0;
|
||||||
|
@ -111,9 +123,10 @@ generate_sampling_factors (GstVaapiEncoderJpeg * encoder)
|
||||||
/* now invert */
|
/* now invert */
|
||||||
/* maximum is invariant, as one of the components should have samp 1 */
|
/* maximum is invariant, as one of the components should have samp 1 */
|
||||||
for (i = 0; i < encoder->n_components; ++i) {
|
for (i = 0; i < encoder->n_components; ++i) {
|
||||||
GST_DEBUG ("%d %d", encoder->h_samp[i], encoder->h_max_samp);
|
|
||||||
encoder->h_samp[i] = encoder->h_max_samp / encoder->h_samp[i];
|
encoder->h_samp[i] = encoder->h_max_samp / encoder->h_samp[i];
|
||||||
encoder->v_samp[i] = encoder->v_max_samp / encoder->v_samp[i];
|
encoder->v_samp[i] = encoder->v_max_samp / encoder->v_samp[i];
|
||||||
|
GST_DEBUG ("sampling factors: %d %d", encoder->h_samp[i],
|
||||||
|
encoder->v_samp[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +229,7 @@ fill_picture (GstVaapiEncoderJpeg * encoder,
|
||||||
pic_param->pic_flags.bits.differential = 0; /* non-Differential Encoding */
|
pic_param->pic_flags.bits.differential = 0; /* non-Differential Encoding */
|
||||||
pic_param->sample_bit_depth = 8;
|
pic_param->sample_bit_depth = 8;
|
||||||
pic_param->num_scan = 1;
|
pic_param->num_scan = 1;
|
||||||
pic_param->num_components = GST_VIDEO_INFO_N_COMPONENTS (vinfo);
|
pic_param->num_components = encoder->n_components;
|
||||||
pic_param->quality = encoder->quality;
|
pic_param->quality = encoder->quality;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue