You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avfilter/avf_showwaves: cleanup and simplify some draw calls
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include "libavutil/avassert.h"
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/avstring.h"
|
#include "libavutil/avstring.h"
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/parseutils.h"
|
#include "libavutil/parseutils.h"
|
||||||
#include "avfilter.h"
|
#include "avfilter.h"
|
||||||
@@ -241,28 +242,26 @@ static void draw_sample_point_rgba_full(uint8_t *buf, int height, int linesize,
|
|||||||
int16_t *prev_y,
|
int16_t *prev_y,
|
||||||
const uint8_t color[4], int h)
|
const uint8_t color[4], int h)
|
||||||
{
|
{
|
||||||
if (h >= 0 && h < height) {
|
uint32_t clr = AV_RN32(color);
|
||||||
buf[h * linesize + 0] = color[0];
|
if (h >= 0 && h < height)
|
||||||
buf[h * linesize + 1] = color[1];
|
AV_WN32(buf + h * linesize, clr);
|
||||||
buf[h * linesize + 2] = color[2];
|
|
||||||
buf[h * linesize + 3] = color[3];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_sample_line_rgba_scale(uint8_t *buf, int height, int linesize,
|
static void draw_sample_line_rgba_scale(uint8_t *buf, int height, int linesize,
|
||||||
int16_t *prev_y,
|
int16_t *prev_y,
|
||||||
const uint8_t color[4], int h)
|
const uint8_t color[4], int h)
|
||||||
{
|
{
|
||||||
int k;
|
|
||||||
int start = height/2;
|
int start = height/2;
|
||||||
int end = av_clip(h, 0, height-1);
|
int end = av_clip(h, 0, height-1);
|
||||||
|
uint8_t *bufk;
|
||||||
if (start > end)
|
if (start > end)
|
||||||
FFSWAP(int16_t, start, end);
|
FFSWAP(int16_t, start, end);
|
||||||
for (k = start; k < end; k++) {
|
bufk = buf + start * linesize;
|
||||||
buf[k * linesize + 0] += color[0];
|
for (int k = start; k < end; k++, bufk += linesize) {
|
||||||
buf[k * linesize + 1] += color[1];
|
bufk[0] += color[0];
|
||||||
buf[k * linesize + 2] += color[2];
|
bufk[1] += color[1];
|
||||||
buf[k * linesize + 3] += color[3];
|
bufk[2] += color[2];
|
||||||
|
bufk[3] += color[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,24 +269,21 @@ static void draw_sample_line_rgba_full(uint8_t *buf, int height, int linesize,
|
|||||||
int16_t *prev_y,
|
int16_t *prev_y,
|
||||||
const uint8_t color[4], int h)
|
const uint8_t color[4], int h)
|
||||||
{
|
{
|
||||||
int k;
|
|
||||||
int start = height/2;
|
int start = height/2;
|
||||||
int end = av_clip(h, 0, height-1);
|
int end = av_clip(h, 0, height-1);
|
||||||
|
uint32_t clr = AV_RN32(color);
|
||||||
|
uint8_t *bufk;
|
||||||
if (start > end)
|
if (start > end)
|
||||||
FFSWAP(int16_t, start, end);
|
FFSWAP(int16_t, start, end);
|
||||||
for (k = start; k < end; k++) {
|
bufk = buf + start * linesize;
|
||||||
buf[k * linesize + 0] = color[0];
|
for (int k = start; k < end; k++, bufk += linesize)
|
||||||
buf[k * linesize + 1] = color[1];
|
AV_WN32(bufk, clr);
|
||||||
buf[k * linesize + 2] = color[2];
|
|
||||||
buf[k * linesize + 3] = color[3];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_sample_p2p_rgba_scale(uint8_t *buf, int height, int linesize,
|
static void draw_sample_p2p_rgba_scale(uint8_t *buf, int height, int linesize,
|
||||||
int16_t *prev_y,
|
int16_t *prev_y,
|
||||||
const uint8_t color[4], int h)
|
const uint8_t color[4], int h)
|
||||||
{
|
{
|
||||||
int k;
|
|
||||||
if (h >= 0 && h < height) {
|
if (h >= 0 && h < height) {
|
||||||
buf[h * linesize + 0] += color[0];
|
buf[h * linesize + 0] += color[0];
|
||||||
buf[h * linesize + 1] += color[1];
|
buf[h * linesize + 1] += color[1];
|
||||||
@@ -295,14 +291,16 @@ static void draw_sample_p2p_rgba_scale(uint8_t *buf, int height, int linesize,
|
|||||||
buf[h * linesize + 3] += color[3];
|
buf[h * linesize + 3] += color[3];
|
||||||
if (*prev_y && h != *prev_y) {
|
if (*prev_y && h != *prev_y) {
|
||||||
int start = *prev_y;
|
int start = *prev_y;
|
||||||
|
uint8_t *bufk;
|
||||||
int end = av_clip(h, 0, height-1);
|
int end = av_clip(h, 0, height-1);
|
||||||
if (start > end)
|
if (start > end)
|
||||||
FFSWAP(int16_t, start, end);
|
FFSWAP(int16_t, start, end);
|
||||||
for (k = start + 1; k < end; k++) {
|
bufk = buf + (start + 1) * linesize;
|
||||||
buf[k * linesize + 0] += color[0];
|
for (int k = start + 1; k < end; k++, bufk += linesize) {
|
||||||
buf[k * linesize + 1] += color[1];
|
bufk[0] += color[0];
|
||||||
buf[k * linesize + 2] += color[2];
|
bufk[1] += color[1];
|
||||||
buf[k * linesize + 3] += color[3];
|
bufk[2] += color[2];
|
||||||
|
bufk[3] += color[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,23 +311,18 @@ static void draw_sample_p2p_rgba_full(uint8_t *buf, int height, int linesize,
|
|||||||
int16_t *prev_y,
|
int16_t *prev_y,
|
||||||
const uint8_t color[4], int h)
|
const uint8_t color[4], int h)
|
||||||
{
|
{
|
||||||
int k;
|
uint32_t clr = AV_RN32(color);
|
||||||
if (h >= 0 && h < height) {
|
if (h >= 0 && h < height) {
|
||||||
buf[h * linesize + 0] = color[0];
|
AV_WN32(buf + h * linesize, clr);
|
||||||
buf[h * linesize + 1] = color[1];
|
|
||||||
buf[h * linesize + 2] = color[2];
|
|
||||||
buf[h * linesize + 3] = color[3];
|
|
||||||
if (*prev_y && h != *prev_y) {
|
if (*prev_y && h != *prev_y) {
|
||||||
int start = *prev_y;
|
int start = *prev_y;
|
||||||
|
uint8_t *bufk;
|
||||||
int end = av_clip(h, 0, height-1);
|
int end = av_clip(h, 0, height-1);
|
||||||
if (start > end)
|
if (start > end)
|
||||||
FFSWAP(int16_t, start, end);
|
FFSWAP(int16_t, start, end);
|
||||||
for (k = start + 1; k < end; k++) {
|
bufk = buf + (start + 1) * linesize;
|
||||||
buf[k * linesize + 0] = color[0];
|
for (int k = start + 1; k < end; k++, bufk += linesize)
|
||||||
buf[k * linesize + 1] = color[1];
|
AV_WN32(bufk, clr);
|
||||||
buf[k * linesize + 2] = color[2];
|
|
||||||
buf[k * linesize + 3] = color[3];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*prev_y = h;
|
*prev_y = h;
|
||||||
@@ -339,29 +332,27 @@ static void draw_sample_cline_rgba_scale(uint8_t *buf, int height, int linesize,
|
|||||||
int16_t *prev_y,
|
int16_t *prev_y,
|
||||||
const uint8_t color[4], int h)
|
const uint8_t color[4], int h)
|
||||||
{
|
{
|
||||||
int k;
|
|
||||||
const int start = (height - h) / 2;
|
const int start = (height - h) / 2;
|
||||||
const int end = start + h;
|
const int end = start + h;
|
||||||
for (k = start; k < end; k++) {
|
uint8_t *bufk = buf + start * linesize;
|
||||||
buf[k * linesize + 0] += color[0];
|
for (int k = start; k < end; k++, bufk += linesize) {
|
||||||
buf[k * linesize + 1] += color[1];
|
bufk[0] += color[0];
|
||||||
buf[k * linesize + 2] += color[2];
|
bufk[1] += color[1];
|
||||||
buf[k * linesize + 3] += color[3];
|
bufk[2] += color[2];
|
||||||
|
bufk[3] += color[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_sample_cline_rgba_full(uint8_t *buf, int height, int linesize,
|
static void draw_sample_cline_rgba_full(uint8_t *buf, int height, int linesize,
|
||||||
int16_t *prev_y,
|
int16_t *prev_y,
|
||||||
const uint8_t color[4], int h)
|
const uint8_t color[4], int h)
|
||||||
{
|
{
|
||||||
int k;
|
uint32_t clr = AV_RN32(color);
|
||||||
const int start = (height - h) / 2;
|
const int start = (height - h) / 2;
|
||||||
const int end = start + h;
|
const int end = start + h;
|
||||||
for (k = start; k < end; k++) {
|
uint8_t *bufk = buf + start * linesize;
|
||||||
buf[k * linesize + 0] = color[0];
|
for (int k = start; k < end; k++, bufk += linesize)
|
||||||
buf[k * linesize + 1] = color[1];
|
AV_WN32(bufk, clr);
|
||||||
buf[k * linesize + 2] = color[2];
|
|
||||||
buf[k * linesize + 3] = color[3];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_sample_point_gray(uint8_t *buf, int height, int linesize,
|
static void draw_sample_point_gray(uint8_t *buf, int height, int linesize,
|
||||||
|
Reference in New Issue
Block a user