mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
avviddec,avcodemap: Use new helper function for map color space information
... between GStreamer and FFmpeg. Note that FFmpeg follows ISO/IEC 23001-8 defined color{matrix,transfer,primaries} values.
This commit is contained in:
parent
f4859ff73d
commit
40f5953828
2 changed files with 12 additions and 172 deletions
|
@ -2938,92 +2938,12 @@ gst_ffmpeg_videoinfo_to_context (GstVideoInfo * info, AVCodecContext * context)
|
|||
break;
|
||||
}
|
||||
|
||||
switch (info->colorimetry.primaries) {
|
||||
case GST_VIDEO_COLOR_PRIMARIES_BT709:
|
||||
context->color_primaries = AVCOL_PRI_BT709;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_PRIMARIES_BT470M:
|
||||
context->color_primaries = AVCOL_PRI_BT470M;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_PRIMARIES_BT470BG:
|
||||
context->color_primaries = AVCOL_PRI_BT470BG;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_PRIMARIES_SMPTE170M:
|
||||
context->color_primaries = AVCOL_PRI_SMPTE170M;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_PRIMARIES_SMPTE240M:
|
||||
context->color_primaries = AVCOL_PRI_SMPTE240M;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_PRIMARIES_FILM:
|
||||
context->color_primaries = AVCOL_PRI_FILM;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_PRIMARIES_BT2020:
|
||||
context->color_primaries = AVCOL_PRI_BT2020;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (info->colorimetry.transfer) {
|
||||
case GST_VIDEO_TRANSFER_BT709:
|
||||
context->color_trc = AVCOL_TRC_BT709;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_GAMMA22:
|
||||
context->color_trc = AVCOL_TRC_GAMMA22;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_GAMMA28:
|
||||
context->color_trc = AVCOL_TRC_GAMMA28;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_SMPTE240M:
|
||||
context->color_trc = AVCOL_TRC_SMPTE240M;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_GAMMA10:
|
||||
context->color_trc = AVCOL_TRC_LINEAR;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_LOG100:
|
||||
context->color_trc = AVCOL_TRC_LOG;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_LOG316:
|
||||
context->color_trc = AVCOL_TRC_LOG_SQRT;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_BT2020_10:
|
||||
context->color_trc = AVCOL_TRC_BT2020_10;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_BT2020_12:
|
||||
context->color_trc = AVCOL_TRC_BT2020_12;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_SMPTE2084:
|
||||
context->color_trc = AVCOL_TRC_SMPTE2084;
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_ARIB_STD_B67:
|
||||
context->color_trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (info->colorimetry.matrix) {
|
||||
case GST_VIDEO_COLOR_MATRIX_RGB:
|
||||
context->colorspace = AVCOL_SPC_RGB;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_MATRIX_BT709:
|
||||
context->colorspace = AVCOL_SPC_BT709;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_MATRIX_FCC:
|
||||
context->colorspace = AVCOL_SPC_FCC;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_MATRIX_BT601:
|
||||
context->colorspace = AVCOL_SPC_BT470BG;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_MATRIX_SMPTE240M:
|
||||
context->colorspace = AVCOL_SPC_SMPTE240M;
|
||||
break;
|
||||
case GST_VIDEO_COLOR_MATRIX_BT2020:
|
||||
context->colorspace = AVCOL_SPC_BT2020_NCL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
context->color_primaries =
|
||||
gst_video_color_primaries_to_iso (info->colorimetry.primaries);
|
||||
context->color_trc =
|
||||
gst_video_color_transfer_to_iso (info->colorimetry.transfer);
|
||||
context->colorspace =
|
||||
gst_video_color_matrix_to_iso (info->colorimetry.matrix);
|
||||
|
||||
if (info->colorimetry.range == GST_VIDEO_COLOR_RANGE_0_255) {
|
||||
context->color_range = AVCOL_RANGE_JPEG;
|
||||
|
|
|
@ -1237,100 +1237,20 @@ gst_ffmpegviddec_negotiate (GstFFMpegVidDec * ffmpegdec,
|
|||
|
||||
if (!gst_structure_has_field (in_s, "colorimetry")
|
||||
|| in_info->colorimetry.primaries == GST_VIDEO_COLOR_PRIMARIES_UNKNOWN) {
|
||||
switch (context->color_primaries) {
|
||||
case AVCOL_PRI_BT709:
|
||||
out_info->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||
break;
|
||||
case AVCOL_PRI_BT470M:
|
||||
out_info->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT470M;
|
||||
break;
|
||||
case AVCOL_PRI_BT470BG:
|
||||
out_info->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT470BG;
|
||||
break;
|
||||
case AVCOL_PRI_SMPTE170M:
|
||||
out_info->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE170M;
|
||||
break;
|
||||
case AVCOL_PRI_SMPTE240M:
|
||||
out_info->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE240M;
|
||||
break;
|
||||
case AVCOL_PRI_FILM:
|
||||
out_info->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_FILM;
|
||||
break;
|
||||
case AVCOL_PRI_BT2020:
|
||||
out_info->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
out_info->colorimetry.primaries =
|
||||
gst_video_color_primaries_from_iso (context->color_primaries);
|
||||
}
|
||||
|
||||
if (!gst_structure_has_field (in_s, "colorimetry")
|
||||
|| in_info->colorimetry.transfer == GST_VIDEO_TRANSFER_UNKNOWN) {
|
||||
switch (context->color_trc) {
|
||||
case AVCOL_TRC_BT709:
|
||||
case AVCOL_TRC_SMPTE170M:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
|
||||
break;
|
||||
case AVCOL_TRC_GAMMA22:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_GAMMA22;
|
||||
break;
|
||||
case AVCOL_TRC_GAMMA28:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_GAMMA28;
|
||||
break;
|
||||
case AVCOL_TRC_SMPTE240M:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_SMPTE240M;
|
||||
break;
|
||||
case AVCOL_TRC_LINEAR:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_GAMMA10;
|
||||
break;
|
||||
case AVCOL_TRC_LOG:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_LOG100;
|
||||
break;
|
||||
case AVCOL_TRC_LOG_SQRT:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_LOG316;
|
||||
break;
|
||||
case AVCOL_TRC_BT2020_10:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_BT2020_10;
|
||||
break;
|
||||
case AVCOL_TRC_BT2020_12:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_BT2020_12;
|
||||
break;
|
||||
case AVCOL_TRC_SMPTE2084:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_SMPTE2084;
|
||||
break;
|
||||
case AVCOL_TRC_ARIB_STD_B67:
|
||||
out_info->colorimetry.transfer = GST_VIDEO_TRANSFER_ARIB_STD_B67;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
out_info->colorimetry.transfer =
|
||||
gst_video_color_transfer_from_iso (context->color_trc);
|
||||
}
|
||||
|
||||
if (!gst_structure_has_field (in_s, "colorimetry")
|
||||
|| in_info->colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_UNKNOWN) {
|
||||
switch (context->colorspace) {
|
||||
case AVCOL_SPC_RGB:
|
||||
out_info->colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||
break;
|
||||
case AVCOL_SPC_BT709:
|
||||
out_info->colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT709;
|
||||
break;
|
||||
case AVCOL_SPC_FCC:
|
||||
out_info->colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_FCC;
|
||||
break;
|
||||
case AVCOL_SPC_BT470BG:
|
||||
case AVCOL_SPC_SMPTE170M:
|
||||
out_info->colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
|
||||
break;
|
||||
case AVCOL_SPC_SMPTE240M:
|
||||
out_info->colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_SMPTE240M;
|
||||
break;
|
||||
case AVCOL_SPC_BT2020_NCL:
|
||||
out_info->colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT2020;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
out_info->colorimetry.matrix =
|
||||
gst_video_color_matrix_from_iso (context->colorspace);
|
||||
}
|
||||
|
||||
if (!gst_structure_has_field (in_s, "colorimetry")
|
||||
|
|
Loading…
Reference in a new issue