+ switch (format->bit_depth_luma_minus8) {
+ case 0: // 8-bit
+ pix_fmts[1] = AV_PIX_FMT_NV12;
+ break;
+ case 2: // 10-bit
+ pix_fmts[1] = AV_PIX_FMT_P010;
+ break;
+ case 4: // 12-bit
+ pix_fmts[1] = AV_PIX_FMT_P016;
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "unsupported bit depth: %d\n",
+ format->bit_depth_luma_minus8 + 8);
+ ctx->internal_error = AVERROR(EINVAL);
+ return 0;
+ }
+ surface_fmt = ff_get_format(avctx, pix_fmts);
+ if (surface_fmt < 0) {
+ av_log(avctx, AV_LOG_ERROR, "ff_get_format failed: %d\n", surface_fmt);
+ ctx->internal_error = AVERROR(EINVAL);
+ return 0;
+ }
+
+ av_log(avctx, AV_LOG_VERBOSE, "Formats: Original: %s | HW: %s | SW: %s\n",
+ av_get_pix_fmt_name(avctx->pix_fmt),
+ av_get_pix_fmt_name(surface_fmt),
+ av_get_pix_fmt_name(avctx->sw_pix_fmt));
+
+ avctx->pix_fmt = surface_fmt;
+