History

Revert "avfilter/yadif: simplify the code for better readability"

This reverts commit 2a9b934675b9e2d3850b46f8a618c19b03f02551.

Limin Wang committed 6 years ago

Commit 71ec3e41 parent ca8e5de6 files · +18 −23Browse files

Unified · Split

6 files
  1. libavfilter/vf_bwdif.c +7 −6
  2. libavfilter/vf_yadif.c +6 −10
  3. libavfilter/x86/vf_bwdif_init.c +1 −1
  4. libavfilter/x86/vf_yadif_init.c +2 −1
  5. libavfilter/yadif.h +1 −4
  6. libavfilter/yadif_common.c +1 −1
libavfilter/vf_bwdif.c+7−6
@@ -219,8 +219,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 218 unmodified lines
219 YADIFContext *yadif = &s->yadif;219 YADIFContext *yadif = &s->yadif;
220 ThreadData *td = arg;220 ThreadData *td = arg;
221 int linesize = yadif->cur->linesize[td->plane];221 int linesize = yadif->cur->linesize[td->plane];
222 int clip_max = (1 << (yadif->depth)) - 1;222 int clip_max = (1 << (yadif->csp->comp[td->plane].depth)) - 1;
223 int df = (yadif->depth + 7) / 8;223 int df = (yadif->csp->comp[td->plane].depth + 7) / 8;
224 int refs = linesize / df;224 int refs = linesize / df;
225 int slice_start = (td->h * jobnr ) / nb_jobs;225 int slice_start = (td->h * jobnr ) / nb_jobs;
226 int slice_end = (td->h * (jobnr+1)) / nb_jobs;226 int slice_end = (td->h * (jobnr+1)) / nb_jobs;
@@ -267,13 +267,13 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, · 40 unmodified lines
267 ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };267 ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };
268 int i;268 int i;
269 269
270 for (i = 0; i < yadif->nb_components; i++) {270 for (i = 0; i < yadif->csp->nb_components; i++) {
271 int w = dstpic->width;271 int w = dstpic->width;
272 int h = dstpic->height;272 int h = dstpic->height;
273 273
274 if (i == 1 || i == 2) {274 if (i == 1 || i == 2) {
275 w = AV_CEIL_RSHIFT(w, yadif->hsub);275 w = AV_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w);
276 h = AV_CEIL_RSHIFT(h, yadif->vsub);276 h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
277 }277 }
278 278
279 td.w = w;279 td.w = w;
@@ -348,8 +348,9 @@ static int config_props(AVFilterLink *link) · 68 unmodified lines
348 return AVERROR(EINVAL);348 return AVERROR(EINVAL);
349 }349 }
350 350
351 yadif->csp = av_pix_fmt_desc_get(link->format);
351 yadif->filter = filter;352 yadif->filter = filter;
352 if (yadif->depth > 8) {353 if (yadif->csp->comp[0].depth > 8) {
353 s->filter_intra = filter_intra_16bit;354 s->filter_intra = filter_intra_16bit;
354 s->filter_line = filter_line_c_16bit;355 s->filter_line = filter_line_c_16bit;
355 s->filter_edge = filter_edge_16bit;356 s->filter_edge = filter_edge_16bit;
libavfilter/vf_yadif.c+6−10
@@ -192,7 +192,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 191 unmodified lines
192 YADIFContext *s = ctx->priv;192 YADIFContext *s = ctx->priv;
193 ThreadData *td = arg;193 ThreadData *td = arg;
194 int refs = s->cur->linesize[td->plane];194 int refs = s->cur->linesize[td->plane];
195 int df = (s->depth + 7) / 8;195 int df = (s->csp->comp[td->plane].depth + 7) / 8;
196 int pix_3 = 3 * df;196 int pix_3 = 3 * df;
197 int slice_start = (td->h * jobnr ) / nb_jobs;197 int slice_start = (td->h * jobnr ) / nb_jobs;
198 int slice_end = (td->h * (jobnr+1)) / nb_jobs;198 int slice_end = (td->h * (jobnr+1)) / nb_jobs;
@@ -233,13 +233,13 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, · 34 unmodified lines
233 ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };233 ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };
234 int i;234 int i;
235 235
236 for (i = 0; i < yadif->nb_components; i++) {236 for (i = 0; i < yadif->csp->nb_components; i++) {
237 int w = dstpic->width;237 int w = dstpic->width;
238 int h = dstpic->height;238 int h = dstpic->height;
239 239
240 if (i == 1 || i == 2) {240 if (i == 1 || i == 2) {
241 w = AV_CEIL_RSHIFT(w, yadif->hsub);241 w = AV_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w);
242 h = AV_CEIL_RSHIFT(h, yadif->vsub);242 h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
243 }243 }
244 244
245 245
@@ -292,7 +292,6 @@ static int config_output(AVFilterLink *outlink) · 46 unmodified lines
292{292{
293 AVFilterContext *ctx = outlink->src;293 AVFilterContext *ctx = outlink->src;
294 YADIFContext *s = ctx->priv;294 YADIFContext *s = ctx->priv;
295 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
296 295
297 outlink->time_base.num = ctx->inputs[0]->time_base.num;296 outlink->time_base.num = ctx->inputs[0]->time_base.num;
298 outlink->time_base.den = ctx->inputs[0]->time_base.den * 2;297 outlink->time_base.den = ctx->inputs[0]->time_base.den * 2;
@@ -308,12 +307,9 @@ static int config_output(AVFilterLink *outlink) · 9 unmodified lines
308 return AVERROR(EINVAL);307 return AVERROR(EINVAL);
309 }308 }
310 309
310 s->csp = av_pix_fmt_desc_get(outlink->format);
311 s->filter = filter;311 s->filter = filter;
312 s->depth = desc->comp[0].depth;312 if (s->csp->comp[0].depth > 8) {
313 s->nb_components = desc->nb_components;
314 s->hsub = desc->log2_chroma_w;
315 s->vsub = desc->log2_chroma_h;
316 if (s->depth > 8) {
317 s->filter_line = filter_line_c_16bit;313 s->filter_line = filter_line_c_16bit;
318 s->filter_edges = filter_edges_16bit;314 s->filter_edges = filter_edges_16bit;
319 } else {315 } else {
libavfilter/x86/vf_bwdif_init.c+1−1
@@ -55,7 +55,7 @@ av_cold void ff_bwdif_init_x86(BWDIFContext *bwdif) · 54 unmodified lines
55{55{
56 YADIFContext *yadif = &bwdif->yadif;56 YADIFContext *yadif = &bwdif->yadif;
57 int cpu_flags = av_get_cpu_flags();57 int cpu_flags = av_get_cpu_flags();
58 int bit_depth = yadif->depth;58 int bit_depth = (!yadif->csp) ? 8 : yadif->csp->comp[0].depth;
59 59
60 if (bit_depth <= 8) {60 if (bit_depth <= 8) {
61#if ARCH_X86_3261#if ARCH_X86_32
libavfilter/x86/vf_yadif_init.c+2−1
@@ -60,7 +60,8 @@ void ff_yadif_filter_line_10bit_ssse3(void *dst, void *prev, void *cur, · 59 unmodified lines
60av_cold void ff_yadif_init_x86(YADIFContext *yadif)60av_cold void ff_yadif_init_x86(YADIFContext *yadif)
61{61{
62 int cpu_flags = av_get_cpu_flags();62 int cpu_flags = av_get_cpu_flags();
63 int bit_depth = yadif->depth;63 int bit_depth = (!yadif->csp) ? 8
64 : yadif->csp->comp[0].depth;
64 65
65 if (bit_depth >= 15) {66 if (bit_depth >= 15) {
66#if ARCH_X86_3267#if ARCH_X86_32
libavfilter/yadif.h+1−4
@@ -72,10 +72,7 @@ typedef struct YADIFContext { · 71 unmodified lines
72 void (*filter_edges)(void *dst, void *prev, void *cur, void *next,72 void (*filter_edges)(void *dst, void *prev, void *cur, void *next,
73 int w, int prefs, int mrefs, int parity, int mode);73 int w, int prefs, int mrefs, int parity, int mode);
74 74
75 int nb_components;75 const AVPixFmtDescriptor *csp;
76 int depth;
77 int hsub;
78 int vsub;
79 int eof;76 int eof;
80 uint8_t *temp_line;77 uint8_t *temp_line;
81 int temp_line_size;78 int temp_line_size;
libavfilter/yadif_common.c+1−1
@@ -69,7 +69,7 @@ static int return_frame(AVFilterContext *ctx, int is_second) · 68 unmodified lines
69static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)69static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
70{70{
71 int i;71 int i;
72 for (i = 0; i < yadif->nb_components; i++)72 for (i = 0; i < yadif->csp->nb_components; i++)
73 if (a->linesize[i] != b->linesize[i])73 if (a->linesize[i] != b->linesize[i])
74 return 1;74 return 1;
75 return 0;75 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t