Unified · Split
| @@ -85,6 +85,85 @@ · 84 unmodified lines | |||
| 85 | #define OUTPUT_DEQUEUE_TIMEOUT_US 8000 | 85 | #define OUTPUT_DEQUEUE_TIMEOUT_US 8000 |
| 86 | #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 1000000 | 86 | #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 1000000 |
| 87 | 87 | ||
| 88 | enum { | ||
| 89 | COLOR_RANGE_FULL = 0x1, | ||
| 90 | COLOR_RANGE_LIMITED = 0x2, | ||
| 91 | }; | ||
| 92 | |||
| 93 | static enum AVColorRange mcdec_get_color_range(int color_range) | ||
| 94 | { | ||
| 95 | switch (color_range) { | ||
| 96 | case COLOR_RANGE_FULL: | ||
| 97 | return AVCOL_RANGE_JPEG; | ||
| 98 | case COLOR_RANGE_LIMITED: | ||
| 99 | return AVCOL_RANGE_MPEG; | ||
| 100 | default: | ||
| 101 | return AVCOL_RANGE_UNSPECIFIED; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | enum { | ||
| 106 | COLOR_STANDARD_BT709 = 0x1, | ||
| 107 | COLOR_STANDARD_BT601_PAL = 0x2, | ||
| 108 | COLOR_STANDARD_BT601_NTSC = 0x4, | ||
| 109 | COLOR_STANDARD_BT2020 = 0x6, | ||
| 110 | }; | ||
| 111 | |||
| 112 | static enum AVColorSpace mcdec_get_color_space(int color_standard) | ||
| 113 | { | ||
| 114 | switch (color_standard) { | ||
| 115 | case COLOR_STANDARD_BT709: | ||
| 116 | return AVCOL_SPC_BT709; | ||
| 117 | case COLOR_STANDARD_BT601_PAL: | ||
| 118 | return AVCOL_SPC_BT470BG; | ||
| 119 | case COLOR_STANDARD_BT601_NTSC: | ||
| 120 | return AVCOL_SPC_SMPTE170M; | ||
| 121 | case COLOR_STANDARD_BT2020: | ||
| 122 | return AVCOL_SPC_BT2020_NCL; | ||
| 123 | default: | ||
| 124 | return AVCOL_SPC_UNSPECIFIED; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | static enum AVColorPrimaries mcdec_get_color_pri(int color_standard) | ||
| 129 | { | ||
| 130 | switch (color_standard) { | ||
| 131 | case COLOR_STANDARD_BT709: | ||
| 132 | return AVCOL_PRI_BT709; | ||
| 133 | case COLOR_STANDARD_BT601_PAL: | ||
| 134 | return AVCOL_PRI_BT470BG; | ||
| 135 | case COLOR_STANDARD_BT601_NTSC: | ||
| 136 | return AVCOL_PRI_SMPTE170M; | ||
| 137 | case COLOR_STANDARD_BT2020: | ||
| 138 | return AVCOL_PRI_BT2020; | ||
| 139 | default: | ||
| 140 | return AVCOL_PRI_UNSPECIFIED; | ||
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 144 | enum { | ||
| 145 | COLOR_TRANSFER_LINEAR = 0x1, | ||
| 146 | COLOR_TRANSFER_SDR_VIDEO = 0x3, | ||
| 147 | COLOR_TRANSFER_ST2084 = 0x6, | ||
| 148 | COLOR_TRANSFER_HLG = 0x7, | ||
| 149 | }; | ||
| 150 | |||
| 151 | static enum AVColorTransferCharacteristic mcdec_get_color_trc(int color_transfer) | ||
| 152 | { | ||
| 153 | switch (color_transfer) { | ||
| 154 | case COLOR_TRANSFER_LINEAR: | ||
| 155 | return AVCOL_TRC_LINEAR; | ||
| 156 | case COLOR_TRANSFER_SDR_VIDEO: | ||
| 157 | return AVCOL_TRC_SMPTE170M; | ||
| 158 | case COLOR_TRANSFER_ST2084: | ||
| 159 | return AVCOL_TRC_SMPTEST2084; | ||
| 160 | case COLOR_TRANSFER_HLG: | ||
| 161 | return AVCOL_TRC_ARIB_STD_B67; | ||
| 162 | default: | ||
| 163 | return AVCOL_TRC_UNSPECIFIED; | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 88 | enum { | 167 | enum { |
| 89 | COLOR_FormatYUV420Planar = 0x13, | 168 | COLOR_FormatYUV420Planar = 0x13, |
| 90 | COLOR_FormatYUV420SemiPlanar = 0x15, | 169 | COLOR_FormatYUV420SemiPlanar = 0x15, |
| @@ -220,6 +299,10 @@ FF_DISABLE_DEPRECATION_WARNINGS · 129 unmodified lines | |||
| 220 | FF_ENABLE_DEPRECATION_WARNINGS | 299 | FF_ENABLE_DEPRECATION_WARNINGS |
| 221 | #endif | 300 | #endif |
| 222 | frame->pkt_dts = AV_NOPTS_VALUE; | 301 | frame->pkt_dts = AV_NOPTS_VALUE; |
| 302 | frame->color_range = avctx->color_range; | ||
| 303 | frame->color_primaries = avctx->color_primaries; | ||
| 304 | frame->color_trc = avctx->color_trc; | ||
| 305 | frame->colorspace = avctx->colorspace; | ||
| 223 | 306 | ||
| 224 | buffer = av_mallocz(sizeof(AVMediaCodecBuffer)); | 307 | buffer = av_mallocz(sizeof(AVMediaCodecBuffer)); |
| 225 | if (!buffer) { | 308 | if (!buffer) { |
| @@ -368,6 +451,9 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte · 142 unmodified lines | |||
| 368 | int ret = 0; | 451 | int ret = 0; |
| 369 | int width = 0; | 452 | int width = 0; |
| 370 | int height = 0; | 453 | int height = 0; |
| 454 | int color_range = 0; | ||
| 455 | int color_standard = 0; | ||
| 456 | int color_transfer = 0; | ||
| 371 | char *format = NULL; | 457 | char *format = NULL; |
| 372 | 458 | ||
| 373 | if (!s->format) { | 459 | if (!s->format) { |
| @@ -426,6 +512,20 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte · 52 unmodified lines | |||
| 426 | ff_set_sar(avctx, sar); | 512 | ff_set_sar(avctx, sar); |
| 427 | } | 513 | } |
| 428 | 514 | ||
| 515 | AMEDIAFORMAT_GET_INT32(color_range, "color-range", 0); | ||
| 516 | if (color_range) | ||
| 517 | avctx->color_range = mcdec_get_color_range(color_range); | ||
| 518 | |||
| 519 | AMEDIAFORMAT_GET_INT32(color_standard, "color-standard", 0); | ||
| 520 | if (color_standard) { | ||
| 521 | avctx->colorspace = mcdec_get_color_space(color_standard); | ||
| 522 | avctx->color_primaries = mcdec_get_color_pri(color_standard); | ||
| 523 | } | ||
| 524 | |||
| 525 | AMEDIAFORMAT_GET_INT32(color_transfer, "color-transfer", 0); | ||
| 526 | if (color_transfer) | ||
| 527 | avctx->color_trc = mcdec_get_color_trc(color_transfer); | ||
| 528 | |||
| 429 | av_log(avctx, AV_LOG_INFO, | 529 | av_log(avctx, AV_LOG_INFO, |
| 430 | "Output crop parameters top=%d bottom=%d left=%d right=%d, " | 530 | "Output crop parameters top=%d bottom=%d left=%d right=%d, " |
| 431 | "resulting dimensions width=%d height=%d\n", | 531 | "resulting dimensions width=%d height=%d\n", |