History

avfilter/yadif: simplify the code for better readability

Limin Wang committed 6 years ago

Commit 2a9b9341 parent 9bb47076 files · +23 −18Browse files

Unified · Split

6 files
  1. libavfilter/vf_bwdif.c +6 −7
  2. libavfilter/vf_yadif.c +10 −6
  3. libavfilter/x86/vf_bwdif_init.c +1 −1
  4. libavfilter/x86/vf_yadif_init.c +1 −2
  5. libavfilter/yadif.h +4 −1
  6. libavfilter/yadif_common.c +1 −1
libavfilter/vf_bwdif.c+6−7
@@ -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->csp->comp[td->plane].depth)) - 1;
223− int df = (yadif->csp->comp[td->plane].depth + 7) / 8;
222+ int clip_max = (1 << (yadif->depth)) - 1;
223+ int df = (yadif->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->csp->nb_components; i++) {
270+ for (i = 0; i < yadif->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->csp->log2_chroma_w);
276− h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
275+ w = AV_CEIL_RSHIFT(w, yadif->hsub);
276+ h = AV_CEIL_RSHIFT(h, yadif->vsub);
277277 }
278278
279279 td.w = w;
@@ -348,9 +348,8 @@ 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);
352351 yadif->filter = filter;
353− if (yadif->csp->comp[0].depth > 8) {
352+ if (yadif->depth > 8) {
354353 s->filter_intra = filter_intra_16bit;
355354 s->filter_line = filter_line_c_16bit;
356355 s->filter_edge = filter_edge_16bit;
libavfilter/vf_yadif.c+10−6
@@ -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->csp->comp[td->plane].depth + 7) / 8;
195+ int df = (s->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->csp->nb_components; i++) {
236+ for (i = 0; i < yadif->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->csp->log2_chroma_w);
242− h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
241+ w = AV_CEIL_RSHIFT(w, yadif->hsub);
242+ h = AV_CEIL_RSHIFT(h, yadif->vsub);
243243 }
244244
245245
@@ -292,6 +292,7 @@ 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);
295296
296297 outlink->time_base.num = ctx->inputs[0]->time_base.num;
297298 outlink->time_base.den = ctx->inputs[0]->time_base.den * 2;
@@ -307,9 +308,12 @@ static int config_output(AVFilterLink *outlink) · 9 unmodified lines
307308 return AVERROR(EINVAL);
308309 }
309310
310− s->csp = av_pix_fmt_desc_get(outlink->format);
311311 s->filter = filter;
312− if (s->csp->comp[0].depth > 8) {
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) {
313317 s->filter_line = filter_line_c_16bit;
314318 s->filter_edges = filter_edges_16bit;
315319 } 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->csp) ? 8 : yadif->csp->comp[0].depth;
58+ int bit_depth = yadif->depth;
5959
6060 if (bit_depth <= 8) {
6161 #if ARCH_X86_32
libavfilter/x86/vf_yadif_init.c+1−2
@@ -60,8 +60,7 @@ 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->csp) ? 8
64− : yadif->csp->comp[0].depth;
63+ int bit_depth = yadif->depth;
6564
6665 if (bit_depth >= 15) {
6766 #if ARCH_X86_32
libavfilter/yadif.h+4−1
@@ -72,7 +72,10 @@ 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− const AVPixFmtDescriptor *csp;
75+ int nb_components;
76+ int depth;
77+ int hsub;
78+ int vsub;
7679 int eof;
7780 uint8_t *temp_line;
7881 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->csp->nb_components; i++)
72+ for (i = 0; i < yadif->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