v2: refactored after review
Showing the changes to libavcodec (2 of 2 files). Show all
Unified · Split
| @@ -746,6 +746,8 @@ int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) · 745 unmodified lines | |||
| 746 | AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_INPUT_HDR_METADATA, hdrmeta_buffer); break; | 746 | AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_INPUT_HDR_METADATA, hdrmeta_buffer); break; |
| 747 | case AV_CODEC_ID_HEVC: | 747 | case AV_CODEC_ID_HEVC: |
| 748 | AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INPUT_HDR_METADATA, hdrmeta_buffer); break; | 748 | AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INPUT_HDR_METADATA, hdrmeta_buffer); break; |
| 749 | case AV_CODEC_ID_AV1: | ||
| 750 | AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_INPUT_HDR_METADATA, hdrmeta_buffer); break; | ||
| 749 | } | 751 | } |
| 750 | res = amf_set_property_buffer(surface, L"av_frame_hdrmeta", hdrmeta_buffer); | 752 | res = amf_set_property_buffer(surface, L"av_frame_hdrmeta", hdrmeta_buffer); |
| 751 | AMF_RETURN_IF_FALSE(avctx, res == AMF_OK, AVERROR_UNKNOWN, "SetProperty failed for \"av_frame_hdrmeta\" with error %d\n", res); | 753 | AMF_RETURN_IF_FALSE(avctx, res == AMF_OK, AVERROR_UNKNOWN, "SetProperty failed for \"av_frame_hdrmeta\" with error %d\n", res); |
| @@ -185,7 +185,9 @@ static av_cold int amf_encode_init_av1(AVCodecContext* avctx) · 184 unmodified lines | |||
| 185 | AMFGuid guid; | 185 | AMFGuid guid; |
| 186 | AMFRate framerate; | 186 | AMFRate framerate; |
| 187 | AMFSize framesize = AMFConstructSize(avctx->width, avctx->height); | 187 | AMFSize framesize = AMFConstructSize(avctx->width, avctx->height); |
| 188 | 188 | amf_int64 color_depth; | |
| 189 | amf_int64 color_profile; | ||
| 190 | enum AVPixelFormat pix_fmt; | ||
| 189 | 191 | ||
| 190 | //for av1 alignment and crop | 192 | //for av1 alignment and crop |
| 191 | uint32_t crop_right = 0; | 193 | uint32_t crop_right = 0; |
| @@ -235,6 +237,30 @@ FF_ENABLE_DEPRECATION_WARNINGS · 43 unmodified lines | |||
| 235 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_PROFILE, profile); | 237 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_PROFILE, profile); |
| 236 | } | 238 | } |
| 237 | 239 | ||
| 240 | /// Color profile | ||
| 241 | color_profile = ff_amf_get_color_profile(avctx); | ||
| 242 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PROFILE, color_profile); | ||
| 243 | |||
| 244 | /// Color Depth | ||
| 245 | pix_fmt = avctx->hw_frames_ctx ? ((AVHWFramesContext*)avctx->hw_frames_ctx->data)->sw_format | ||
| 246 | : avctx->pix_fmt; | ||
| 247 | color_depth = AMF_COLOR_BIT_DEPTH_8; | ||
| 248 | if (pix_fmt == AV_PIX_FMT_P010) { | ||
| 249 | color_depth = AMF_COLOR_BIT_DEPTH_10; | ||
| 250 | } | ||
| 251 | |||
| 252 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_COLOR_BIT_DEPTH, color_depth); | ||
| 253 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PROFILE, color_profile); | ||
| 254 | if (color_depth == AMF_COLOR_BIT_DEPTH_8) { | ||
| 255 | /// Color Transfer Characteristics (AMF matches ISO/IEC) | ||
| 256 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_TRANSFER_CHARACTERISTIC, AMF_COLOR_TRANSFER_CHARACTERISTIC_BT709); | ||
| 257 | /// Color Primaries (AMF matches ISO/IEC) | ||
| 258 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PRIMARIES, AMF_COLOR_PRIMARIES_BT709); | ||
| 259 | } else { | ||
| 260 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_TRANSFER_CHARACTERISTIC, AMF_COLOR_TRANSFER_CHARACTERISTIC_SMPTE2084); | ||
| 261 | AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PRIMARIES, AMF_COLOR_PRIMARIES_BT2020); | ||
| 262 | } | ||
| 263 | |||
| 238 | profile_level = avctx->level; | 264 | profile_level = avctx->level; |
| 239 | if (profile_level == AV_LEVEL_UNKNOWN) { | 265 | if (profile_level == AV_LEVEL_UNKNOWN) { |
| 240 | profile_level = ctx->level; | 266 | profile_level = ctx->level; |