Skip to content

Commit 41549fe

Browse files
authored
Merge pull request #4 from svt/10-bit-alt-2
10 bit support
2 parents ecb086b + bdc82e6 commit 41549fe

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ filter doesn't need any specific configuration.
2727

2828
Only `AV_PIX_FMT_BGRA` is used right now since that's what we need.
2929

30+
It is possible though, to preserve 10 bit colors using the `clear` param in combination with FFmpegs split and overlay filters:
31+
32+
`-filter_complex "split=2[main][over1];[over1]proxy=clear=1:<other proxy params>[over2];[main][over2]overlay=format=yuv420p10`
33+
3034
## License
3135

3236
Copyright 2020 Sveriges Television AB.

vf_proxy.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "libavutil/avassert.h"
1414
#include "libavutil/avstring.h"
1515
#include "libavutil/imgutils.h"
16+
#include "libavutil/intreadwrite.h"
1617
#include "libavutil/opt.h"
1718
#include "libavutil/parseutils.h"
1819
#include "video.h"
@@ -21,6 +22,7 @@ typedef struct {
2122
const AVClass* class;
2223
char* filter_path;
2324
char* config;
25+
int clear;
2426
void* handle;
2527
void* user_data;
2628
int (*filter_init)(const char*, void**);
@@ -109,6 +111,14 @@ static int query_formats(AVFilterContext* ctx) {
109111
return ff_set_common_formats(ctx, fmts_list);
110112
}
111113

114+
static void clear_image(AVFrame* out) {
115+
for (int i = 0; i < out->height; i++) {
116+
for (int j = 0; j < out->width; j++) {
117+
AV_WN32(out->data[0] + i * out->linesize[0] + j * 4, 0);
118+
}
119+
}
120+
}
121+
112122
static int filter_frame(AVFilterLink* inlink, AVFrame* in) {
113123
AVFilterContext* ctx = inlink->dst;
114124
AVFilterLink* outlink = ctx->outputs[0];
@@ -139,6 +149,10 @@ static int filter_frame(AVFilterLink* inlink, AVFrame* in) {
139149
return data_size;
140150
}
141151

152+
if (pc->clear) {
153+
clear_image(out);
154+
}
155+
142156
double time_ms = in->pts * av_q2d(inlink->time_base) * 1000;
143157

144158
int rc = pc->filter_frame(out->data[0], data_size, in->width, in->height,
@@ -192,6 +206,14 @@ static const AVOption proxy_options[] = {
192206
CHAR_MIN,
193207
CHAR_MAX,
194208
FLAGS},
209+
{"clear",
210+
"clear frame before filtering",
211+
OFFSET(clear),
212+
AV_OPT_TYPE_BOOL,
213+
{.i64 = 0},
214+
0,
215+
1,
216+
FLAGS},
195217
{NULL},
196218
};
197219

0 commit comments

Comments
 (0)