| OLD | NEW |
| 1 /* | 1 /* |
| 2 * copyright (c) 2008 vmrsss | 2 * copyright (c) 2008 vmrsss |
| 3 * copyright (c) 2009 Stefano Sabatini | 3 * copyright (c) 2009 Stefano Sabatini |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 ColorContext *color = ctx->priv; | 400 ColorContext *color = ctx->priv; |
| 401 uint8_t rgba_color[4]; | 401 uint8_t rgba_color[4]; |
| 402 int is_packed_rgba; | 402 int is_packed_rgba; |
| 403 const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format]
; | 403 const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format]
; |
| 404 | 404 |
| 405 color->hsub = pix_desc->log2_chroma_w; | 405 color->hsub = pix_desc->log2_chroma_w; |
| 406 color->vsub = pix_desc->log2_chroma_h; | 406 color->vsub = pix_desc->log2_chroma_h; |
| 407 | 407 |
| 408 color->w &= ~((1 << color->hsub) - 1); | 408 color->w &= ~((1 << color->hsub) - 1); |
| 409 color->h &= ~((1 << color->vsub) - 1); | 409 color->h &= ~((1 << color->vsub) - 1); |
| 410 if (av_check_image_size(color->w, color->h, 0, ctx) < 0) | 410 if (av_image_check_size(color->w, color->h, 0, ctx) < 0) |
| 411 return AVERROR(EINVAL); | 411 return AVERROR(EINVAL); |
| 412 | 412 |
| 413 memcpy(rgba_color, color->color, sizeof(rgba_color)); | 413 memcpy(rgba_color, color->color, sizeof(rgba_color)); |
| 414 fill_line_with_color(color->line, color->line_step, color->w, color->color, | 414 fill_line_with_color(color->line, color->line_step, color->w, color->color, |
| 415 inlink->format, rgba_color, &is_packed_rgba); | 415 inlink->format, rgba_color, &is_packed_rgba); |
| 416 | 416 |
| 417 av_log(ctx, AV_LOG_INFO, "w:%d h:%d r:%d/%d color:0x%02x%02x%02x%02x[%s]\n", | 417 av_log(ctx, AV_LOG_INFO, "w:%d h:%d r:%d/%d color:0x%02x%02x%02x%02x[%s]\n", |
| 418 color->w, color->h, color->time_base.den, color->time_base.num, | 418 color->w, color->h, color->time_base.den, color->time_base.num, |
| 419 color->color[0], color->color[1], color->color[2], color->color[3], | 419 color->color[0], color->color[1], color->color[2], color->color[3], |
| 420 is_packed_rgba ? "rgba" : "yuva"); | 420 is_packed_rgba ? "rgba" : "yuva"); |
| 421 inlink->w = color->w; | 421 inlink->w = color->w; |
| 422 inlink->h = color->h; | 422 inlink->h = color->h; |
| 423 | 423 |
| 424 return 0; | 424 return 0; |
| 425 } | 425 } |
| 426 | 426 |
| 427 static int color_request_frame(AVFilterLink *link) | 427 static int color_request_frame(AVFilterLink *link) |
| 428 { | 428 { |
| 429 ColorContext *color = link->src->priv; | 429 ColorContext *color = link->src->priv; |
| 430 AVFilterBufferRef *picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, c
olor->w, color->h); | 430 AVFilterBufferRef *picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, c
olor->w, color->h); |
| 431 picref->pixel_aspect = (AVRational) {1, 1}; | 431 picref->video->pixel_aspect = (AVRational) {1, 1}; |
| 432 picref->pts = av_rescale_q(color->pts++, color->time_base, AV_TIME_
BASE_Q); | 432 picref->pts = av_rescale_q(color->pts++, color->time_base, A
V_TIME_BASE_Q); |
| 433 picref->pos = 0; | 433 picref->pos = 0; |
| 434 | 434 |
| 435 avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0)); | 435 avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0)); |
| 436 draw_rectangle(picref, | 436 draw_rectangle(picref, |
| 437 color->line, color->line_step, color->hsub, color->vsub, | 437 color->line, color->line_step, color->hsub, color->vsub, |
| 438 0, 0, color->w, color->h); | 438 0, 0, color->w, color->h); |
| 439 avfilter_draw_slice(link, 0, color->h, 1); | 439 avfilter_draw_slice(link, 0, color->h, 1); |
| 440 avfilter_end_frame(link); | 440 avfilter_end_frame(link); |
| 441 avfilter_unref_buffer(picref); | 441 avfilter_unref_buffer(picref); |
| 442 | 442 |
| 443 return 0; | 443 return 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 456 .inputs = (AVFilterPad[]) {{ .name = NULL}}, | 456 .inputs = (AVFilterPad[]) {{ .name = NULL}}, |
| 457 | 457 |
| 458 .outputs = (AVFilterPad[]) {{ .name = "default", | 458 .outputs = (AVFilterPad[]) {{ .name = "default", |
| 459 .type = CODEC_TYPE_VIDEO, | 459 .type = CODEC_TYPE_VIDEO, |
| 460 .request_frame = color_request_frame, | 460 .request_frame = color_request_frame, |
| 461 .config_props = color_config_props }, | 461 .config_props = color_config_props }, |
| 462 { .name = NULL}}, | 462 { .name = NULL}}, |
| 463 }; | 463 }; |
| 464 | 464 |
| 465 #endif /* CONFIG_COLOR_FILTER */ | 465 #endif /* CONFIG_COLOR_FILTER */ |
| OLD | NEW |