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

Showing the changes to libavfilter (6 of 6 files). Show all

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
219219 YADIFContext *yadif = &s->yadif;
220220 ThreadData *td = arg;
221221 int linesize = yadif->cur->linesize[td->plane];
222− int clip_max = (1 << (yadif->depth)) - 1;
223− int df = (yadif->depth + 7) / 8;
222+ int clip_max = (1 << (yadif->csp->comp[td->plane].depth)) - 1;
223+ int df = (yadif->csp->comp[td->plane].depth + 7) / 8;
224224 int refs = linesize / df;
225225 int slice_start = (td->h * jobnr ) / nb_jobs;
226226 int slice_end = (td->h * (jobnr+1)) / nb_jobs;
@@ -267,13 +267,13 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, · 40 unmodified lines
267267 ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };
268268 int i;
269269
270− for (i = 0; i < yadif->nb_components; i++) {
270+ for (i = 0; i < yadif->csp->nb_components; i++) {
271271 int w = dstpic->width;
272272 int h = dstpic->height;
273273
274274 if (i == 1 || i == 2) {
275− w = AV_CEIL_RSHIFT(w, yadif->hsub);
276− h = AV_CEIL_RSHIFT(h, yadif->vsub);
275+ w = AV_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w);
276+ h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
277277 }
278278
279279 td.w = w;
@@ -348,8 +348,9 @@ static int config_props(AVFilterLink *link) · 68 unmodified lines
348348 return AVERROR(EINVAL);
349349 }
350350
351+ yadif->csp = av_pix_fmt_desc_get(link->format);
351352 yadif->filter = filter;
352− if (yadif->depth > 8) {
353+ if (yadif->csp->comp[0].depth > 8) {
353354 s->filter_intra = filter_intra_16bit;
354355 s->filter_line = filter_line_c_16bit;
355356 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
192192 YADIFContext *s = ctx->priv;
193193 ThreadData *td = arg;
194194 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;
196196 int pix_3 = 3 * df;
197197 int slice_start = (td->h * jobnr ) / nb_jobs;
198198 int slice_end = (td->h * (jobnr+1)) / nb_jobs;
@@ -233,13 +233,13 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, · 34 unmodified lines
233233 ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };
234234 int i;
235235
236− for (i = 0; i < yadif->nb_components; i++) {
236+ for (i = 0; i < yadif->csp->nb_components; i++) {
237237 int w = dstpic->width;
238238 int h = dstpic->height;
239239
240240 if (i == 1 || i == 2) {
241− w = AV_CEIL_RSHIFT(w, yadif->hsub);
242− h = AV_CEIL_RSHIFT(h, yadif->vsub);
241+ w = AV_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w);
242+ h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
243243 }
244244
245245
@@ -292,7 +292,6 @@ static int config_output(AVFilterLink *outlink) · 46 unmodified lines
292292 {
293293 AVFilterContext *ctx = outlink->src;
294294 YADIFContext *s = ctx->priv;
295− const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
296295
297296 outlink->time_base.num = ctx->inputs[0]->time_base.num;
298297 outlink->time_base.den = ctx->inputs[0]->time_base.den * 2;
@@ -308,12 +307,9 @@ static int config_output(AVFilterLink *outlink) · 9 unmodified lines
308307 return AVERROR(EINVAL);
309308 }
310309
310+ s->csp = av_pix_fmt_desc_get(outlink->format);
311311 s->filter = filter;
312− s->depth = desc->comp[0].depth;
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) {
312+ if (s->csp->comp[0].depth > 8) {
317313 s->filter_line = filter_line_c_16bit;
318314 s->filter_edges = filter_edges_16bit;
319315 } 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
5555 {
5656 YADIFContext *yadif = &bwdif->yadif;
5757 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;
5959
6060 if (bit_depth <= 8) {
6161 #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
6060 av_cold void ff_yadif_init_x86(YADIFContext *yadif)
6161 {
6262 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;
6465
6566 if (bit_depth >= 15) {
6667 #if ARCH_X86_32
libavfilter/yadif.h+1−4
@@ -72,10 +72,7 @@ typedef struct YADIFContext { · 71 unmodified lines
7272 void (*filter_edges)(void *dst, void *prev, void *cur, void *next,
7373 int w, int prefs, int mrefs, int parity, int mode);
7474
75− int nb_components;
76− int depth;
77− int hsub;
78− int vsub;
75+ const AVPixFmtDescriptor *csp;
7976 int eof;
8077 uint8_t *temp_line;
8178 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
6969 static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
7070 {
7171 int i;
72− for (i = 0; i < yadif->nb_components; i++)
72+ for (i = 0; i < yadif->csp->nb_components; i++)
7373 if (a->linesize[i] != b->linesize[i])
7474 return 1;
7575 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