| @@ -262,6 +262,8 @@ typedef struct DrawTextContext { · 261 unmodified lines |
| 262 | 262 | int bb_right; ///< the size of the right box border |
| 263 | 263 | int bb_bottom; ///< the size of the bottom box border |
| 264 | 264 | int bb_left; ///< the size of the left box border |
| 265 | + int box_width; ///< the width of box |
| 266 | + int box_height; ///< the height of box |
| 265 | 267 | int tabsize; ///< tab size |
| 266 | 268 | int fix_bounds; ///< do we let it go out of frame bounds - t/f |
| 267 | 269 | |
| @@ -297,6 +299,9 @@ typedef struct DrawTextContext { · 29 unmodified lines |
| 297 | 299 | #endif |
| 298 | 300 | AVDictionary *metadata; |
| 299 | 301 | |
| 302 | + int boxw; ///< the value of the boxw parameter |
| 303 | + int boxh; ///< the value of the boxh parameter |
| 304 | + |
| 300 | 305 | TextLine *lines; ///< computed information about text lines |
| 301 | 306 | int line_count; ///< the number of text lines |
| 302 | 307 | uint32_t *tab_clusters; ///< the position of tab characters in the text |
| @@ -322,6 +327,8 @@ static const AVOption drawtext_options[]= { · 19 unmodified lines |
| 322 | 327 | {"fontsize", "set font size", OFFSET(fontsize_expr), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS}, |
| 323 | 328 | {"x", "set x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS}, |
| 324 | 329 | {"y", "set y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS}, |
| 330 | + {"boxw", "set box width", OFFSET(boxw), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS}, |
| 331 | + {"boxh", "set box height", OFFSET(boxh), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS}, |
| 325 | 332 | {"shadowx", "set shadow x offset", OFFSET(shadowx), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGS}, |
| 326 | 333 | {"shadowy", "set shadow y offset", OFFSET(shadowy), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGS}, |
| 327 | 334 | {"borderw", "set border width", OFFSET(borderw), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGS}, |
| @@ -1473,8 +1480,8 @@ static int draw_glyphs(DrawTextContext *s, AVFrame *frame, · 1145 unmodified lines |
| 1473 | 1480 | FT_BitmapGlyph b_glyph; |
| 1474 | 1481 | int clip_x = 0, clip_y = 0; |
| 1475 | 1482 | |
| 1476 | | − clip_x = FFMIN(metrics->rect_x + metrics->width + s->bb_right, frame->width); |
| 1477 | | − clip_y = FFMIN(metrics->rect_y + metrics->height + s->bb_bottom, frame->height); |
| 1483 | + clip_x = FFMIN(metrics->rect_x + s->box_width + s->bb_right, frame->width); |
| 1484 | + clip_y = FFMIN(metrics->rect_y + s->box_height + s->bb_bottom, frame->height); |
| 1478 | 1485 | |
| 1479 | 1486 | for (l = 0; l < s->line_count; ++l) { |
| 1480 | 1487 | TextLine *line = &s->lines[l]; |
| @@ -1907,6 +1914,9 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame) · 426 unmodified lines |
| 1907 | 1914 | metrics.rect_x = s->x; |
| 1908 | 1915 | metrics.rect_y = s->y; |
| 1909 | 1916 | |
| 1917 | + s->box_width = s->boxw == 0 ? metrics.width : s->boxw; |
| 1918 | + s->box_height = s->boxh == 0 ? metrics.height : s->boxh; |
| 1919 | + |
| 1910 | 1920 | if (!s->draw_box) { |
| 1911 | 1921 | // Create a border for the clipping region to take into account subpixel |
| 1912 | 1922 | // errors in text measurement and effects. |
| @@ -1920,16 +1930,16 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame) · 7 unmodified lines |
| 1920 | 1930 | /* Check if the whole box is out of the frame */ |
| 1921 | 1931 | is_outside = metrics.rect_x - s->bb_left >= width || |
| 1922 | 1932 | metrics.rect_y - s->bb_top >= height || |
| 1923 | | − metrics.rect_x + metrics.width + s->bb_right <= 0 || |
| 1924 | | − metrics.rect_y + metrics.height + s->bb_bottom <= 0; |
| 1933 | + metrics.rect_x + s->box_width + s->bb_right <= 0 || |
| 1934 | + metrics.rect_y + s->box_height + s->bb_bottom <= 0; |
| 1925 | 1935 | |
| 1926 | 1936 | if (!is_outside) { |
| 1927 | 1937 | /* draw box */ |
| 1928 | 1938 | if (s->draw_box) { |
| 1929 | 1939 | rec_x = metrics.rect_x - s->bb_left; |
| 1930 | 1940 | rec_y = metrics.rect_y - s->bb_top; |
| 1931 | | − rec_width = metrics.width + s->bb_right + s->bb_left; |
| 1932 | | − rec_height = metrics.height + s->bb_bottom + s->bb_top; |
| 1941 | + rec_width = s->box_width + s->bb_right + s->bb_left; |
| 1942 | + rec_height = s->box_height + s->bb_bottom + s->bb_top; |
| 1933 | 1943 | ff_blend_rectangle(&s->dc, &boxcolor, |
| 1934 | 1944 | frame->data, frame->linesize, width, height, |
| 1935 | 1945 | rec_x, rec_y, rec_width, rec_height); |