| @@ -193,6 +193,7 @@ typedef struct LibplaceboContext { · 192 unmodified lines |
| 193 | 193 | int color_range; |
| 194 | 194 | int color_primaries; |
| 195 | 195 | int color_trc; |
| 196 | + int rotation; |
| 196 | 197 | AVDictionary *extra_opts; |
| 197 | 198 | |
| 198 | 199 | int have_hwdevice; |
| @@ -802,6 +803,13 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, · 603 unmodified lines |
| 802 | 803 | image->crop.y0 = av_expr_eval(s->crop_y_pexpr, s->var_values, NULL); |
| 803 | 804 | image->crop.x1 = image->crop.x0 + s->var_values[VAR_CROP_W]; |
| 804 | 805 | image->crop.y1 = image->crop.y0 + s->var_values[VAR_CROP_H]; |
| 806 | + image->rotation = s->rotation; |
| 807 | + if (s->rotation % PL_ROTATION_180 == PL_ROTATION_90) { |
| 808 | + /* Libplacebo expects the input crop relative to the actual frame |
| 809 | + * dimensions, so un-transpose them here */ |
| 810 | + FFSWAP(float, image->crop.x0, image->crop.y0); |
| 811 | + FFSWAP(float, image->crop.x1, image->crop.y1); |
| 812 | + } |
| 805 | 813 | |
| 806 | 814 | if (src == ref) { |
| 807 | 815 | /* Only update the target crop once, for the 'reference' frame */ |
| @@ -1198,6 +1206,14 @@ static int libplacebo_config_input(AVFilterLink *inlink) · 390 unmodified lines |
| 1198 | 1206 | AVFilterContext *avctx = inlink->dst; |
| 1199 | 1207 | LibplaceboContext *s = avctx->priv; |
| 1200 | 1208 | |
| 1209 | + if (s->rotation % PL_ROTATION_180 == PL_ROTATION_90) { |
| 1210 | + /* Swap width and height for 90 degree rotations to make the size and |
| 1211 | + * scaling calculations work out correctly */ |
| 1212 | + FFSWAP(int, inlink->w, inlink->h); |
| 1213 | + if (inlink->sample_aspect_ratio.num) |
| 1214 | + inlink->sample_aspect_ratio = av_inv_q(inlink->sample_aspect_ratio); |
| 1215 | + } |
| 1216 | + |
| 1201 | 1217 | if (inlink->format == AV_PIX_FMT_VULKAN) |
| 1202 | 1218 | return ff_vk_filter_config_input(inlink); |
| 1203 | 1219 | |
| @@ -1386,6 +1402,13 @@ static const AVOption libplacebo_options[] = { · 182 unmodified lines |
| 1386 | 1402 | {"smpte2084", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE2084}, INT_MIN, INT_MAX, STATIC, .unit = "color_trc"}, |
| 1387 | 1403 | {"arib-std-b67", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_ARIB_STD_B67}, INT_MIN, INT_MAX, STATIC, .unit = "color_trc"}, |
| 1388 | 1404 | |
| 1405 | + {"rotate", "rotate the input clockwise", OFFSET(rotation), AV_OPT_TYPE_INT, {.i64=PL_ROTATION_0}, PL_ROTATION_0, PL_ROTATION_360, DYNAMIC, .unit = "rotation"}, |
| 1406 | + {"0", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PL_ROTATION_0}, .flags = STATIC, .unit = "rotation"}, |
| 1407 | + {"90", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PL_ROTATION_90}, .flags = STATIC, .unit = "rotation"}, |
| 1408 | + {"180", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PL_ROTATION_180}, .flags = STATIC, .unit = "rotation"}, |
| 1409 | + {"270", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PL_ROTATION_270}, .flags = STATIC, .unit = "rotation"}, |
| 1410 | + {"360", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PL_ROTATION_360}, .flags = STATIC, .unit = "rotation"}, |
| 1411 | + |
| 1389 | 1412 | { "upscaler", "Upscaler function", OFFSET(upscaler), AV_OPT_TYPE_STRING, {.str = "spline36"}, .flags = DYNAMIC }, |
| 1390 | 1413 | { "downscaler", "Downscaler function", OFFSET(downscaler), AV_OPT_TYPE_STRING, {.str = "mitchell"}, .flags = DYNAMIC }, |
| 1391 | 1414 | { "frame_mixer", "Frame mixing function", OFFSET(frame_mixer), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = DYNAMIC }, |